家具后台管理系统

来源:互联网 发布:西安手机定位软件 编辑:程序博客网 时间:2024/06/08 11:01

目 录

 

 

 

1.课程设计的题目、系统的总体功能描述

 

 

2.需求分析(概括描述、DFD、DD)

 

 

3. 数据库概念结构设计(局部E-R图、基本E-R图)

 

 

4.数据库逻辑结构设计(关系模式—列表形式、存储过程、触发器、视图、索引)

 

 

5.应用系统功能结构图(模块结构图)

 

 

6.各功能模块程序流程图及其说明

 

 

7. 程序源代码及其说明

 

 

8. 总结(课程设计中遇到的主要问题和解决方法;创新和得意之处;课程设计中存在的不足,需进一步改进的设想;课程设计的感想和心得体会。)

 

 

9. 参考文献

 

 

 

 

一.问题与系统功能描述

 

题目:某家具城进销存管理系统

要求设计出一套家具城的家具管理系统,主要要求如下:

1.实现家具类型、供应商信息的管理;

2.实现客户信息、家具信息的管理;

3.实现家具入库管理;

4.实现家具的销售管理;

5.实现收款管理;

6.创建触发器,实现家具入库和销售时自动修改库存;

7.创建存储过程统计某段时间内各种商品的入库数量和销售数量;

8.建立数据库相关表之间的参照完整性约束。

由题目可以得出我们需要设计的系统至少需要实现家具管理的这些功能:当前家具的信息管理,比如库存量等信息;家具的入库和销售订单要能够保存在数据库中,而且与该货物的库存量相关联;订单保存时要能够给出对应的货款数额;

可以查询给定时间段内的某种货物进出量。在此基础上进行拓展,比如管理员身份验证,用户界面如何实现友好等等方面。

 

二.需求分析

对题目要求进行分析,可以看出设计的主要目标是实现对家具库存、售货进货订单的管理,以及实现查询功能的一个家具管理系统。首先,对于管理系统而言,必须有登录验证功能。然后,基于家具管理,我们需要保存家具库存量等信息。家具的进货与出货记录也需要保存在数据库中。由此可以设计出功能模块图如下:

 

 

 

 

 

 

 

 

 

 

 

 

 


其中身份验证模块包括用户名与密码,家具库存管理模块应该包括家具种类、价格以及库存量,进货与出货订单管理模块应该包括客户姓名、住址、货物种类、日期等订单信息,销量查询功能模块主要是由管理员输入的时间来显示这段时间各种货物种类以及进出量。

 

 

 

 

 

 

 

(3) 数据库概念结构设计(局部E-R图、基本E-R图)

对于家具管理系统,主要涉及的数据表格如下:

1.管理员身份记录表格,E-R图如下:

 

 

 

 

 

 

 

 


           

 

2.家具库存管理表格

 

 

 

 

 

 

 

 

 

 


3.进货订单管理表格

 

 

 

 

 

 

 

 

 

 


    其中客户信息包括客户姓名、住址、电话号码。

 

4.售货订单管理表格

与3类似,只是把进货改为售货,其余属性均一样。

 

基本E-R图如下所示:

 

 

                       

 

 

 

 

 


                                1              1

 


管理员

 

                     N

 

 

 

 


                      1

 

 

 

 

 

 

 


(4) 数据库逻辑结构设计(关系模式—列表形式、存储过程、触发器、视图、索引)

    

 基于上述E-R图,在数据库中建立表,SQL语句如下:

管理员记录表格:CREATE TABLE users  (

name VARCHAR(6)PRIMARY KEY, 

password int(10)N OTNUll

)

  家具库存管理表格:

CREATE TABLE furniture  (

category  VARCHAR(30) PRIMARY KEY, 

price int(3), 

count int(7)

)

CREATE TABLE client  (

cname CHAR(25) PRIMARYKEY, 

cphonenumber int(15) , 

caddress varchar(25), 

category  VARCHAR(30) PRIMARY KEY, 

count int(7),

date date

)

CREATE TABLE provider  (

pname CHAR(25) PRIMARYKEY, 

phonenumber int(15) , 

address varchar(25), 

category  VARCHAR(30) PRIMARY KEY, 

count int(7),

date date

)

在phpMyAdmin中执行完上述语句,可以看到数据库中表格如下:

 

由此可以看出,相关数据表格已经成功建立。

题目要求建立触发器实现有出货和进货订单时库存量自动增加,SQL语句如下:1.createtrigger add1 after insert on provider for each row

begin

declareinumber int(10);

setinumber=new.number ;

updatefurniture set count=count+inumber where category=new.category;

end

2.createtrigger reduce after insert on client for each row

begin

declareinumber int(10);

setinumber=new.number;

updatefurniture set count=count-inumber where category=new.catogory;

end;

执行上述语句成功创建触发器。

最后我需要创建一个存储过程去满足一段时间内进货量与出货量查询的功能要求。语句如下:.create procedure res1

(mintimeTIMESTAMP(6),maxtime TIMESTAMP(6))

BEGIN

 select sum(number) from provider where timebetween mintime and maxtime ;

END

 

createprocedure res2

(mintimeTIMESTAMP(6),maxtime TIMESTAMP(6))

BEGIN

 select category,sum(number) from provider wheredate between mintime and maxtime group by category;

END

存储过程res1与res2分别对应查询的进货量与出货量,执行时需要给它两个时间参数。

综上所述,数据库设计部分已经完成。

 

(5) 应用系统功能结构图(模块结构图)

根据前面的题目要求,我将本次设计的管理系统分为五个模块,如下所示:

                                                       

 

 

 

 

 

 

 

 

 


(6) 各功能模块程序流程图及其说明

模 块       

功    能

与数据库对照关系

家具管理系统

身份认证模块

在用户登录时候对用户输入的身份信息进行验证,决定下一步先是给用户的界面。

主要是与数据库中USERS表格相关联。

家具相关信息模块

在数据库中检索当前家具的相关信息,如库存量、价格,然后在管理员界面显示出来。

主要是与数据库中furniture表格检索信息。

进货订单管理模块

管理员在用户界面输入进货订单的相关信息,如进货商的姓名,住址,等等。然后进行处理,将记录输入到数据库中保存起来。

 

主要是将信息保存在数据库中的provider表格。

售货订单管理模块

管理员在用户界面输入售货订单的相关信息,如客户的姓名,住址,等等。然后进行处理,将记录输入到数据库中保存起来。

 

主要是将信息保存在数据库中的client表格。

家具流动量查询模块

根据管理员输入的时间段,在数据库中查询时间段内家具的进货量与售货量以及对应的类型。

主要是在client与provider表格进行查询。

 

各功能模块说明如下,一共分为5个模块:

 

 

 

程序流程图如下:

 

 

 

 

显示当前家居信息

 

 


                 信息不正确

添加进货订单记录

 

 

 

 


判断信息是否正确

 

管理员输入身份信息

 

                                           正确

 

 

 

 

 

 

 

 

 

 


(7) 程序源代码及其说明

 

首先是Index.html即登录界面,代码如下:

<html>

<head>

 <meta charset="utf-8">

  <title>Login Form</title>

 <link rel="stylesheet" href="css/style.css">

 

</head>

<body>

<formaction="identify.php"method="post">

 <section class="container">

   <div class="login">

     <h1>家具管理系统用户登录</h1>

     <form method="post" action="identify.php">

       <p><input type="text" name="name"value="" placeholder="用户名"></p>

       <p><input type="password" name="password"value="" placeholder="密码"></p>

       <p class="submit"><input type="submit"name="commit" value="登录"></p>

     </form>

   </div>

 

 </section>

<divstyle="text-align:center;">

</div>

</body>

</html>

在这段代码中,当用户输入信息后,调用identify.php脚本进行判断,以下为详细代码

<?php

require_once('allfun.php');//allfun.php包括了连接数据库的函数,故下面可以连接数据库然后进行判断

$name=$_POST['name'];

$password=$_POST['password'];

if(empty($name)||empty($password)){

         echo  iconv('UTF-8','GBK','<script>alert("it can not be empty,please try again after check")</script>');//判断用户输入是否为空,如果为空,则提出警告然后返回登陆界面

                   require_once('index.html');

         exit;//一定要exit不然后面的代码会继续执行

}

else{

         try{

                   $result=login($name,$password);

                   if($result==1){

                   header("location:index4.php");//信息正确则跳转到index4.php这是主界面

                   exit;

                   }

         }catch(Exception$e){

                   echo  iconv('UTF-8','GBK','<script>alert("the name or the  password iswrong,please try again after check ")</script>');//信息不正确时提出警告返回登陆界面

                   require_once('index.html');

                   exit;

         }

}

?>

由代码可以看出,当用户输入信息正确跳转到主界面,以下为主界面详细代码:

 

<!DOCTYPEhtml>

<html lang="en">

   <head>

                   <metacharset="UTF-8" />

       <meta http-equiv="X-UA-Compatible"content="IE=edge,chrome=1">

       <title>家具管理系统</title>

       <meta name="viewport" content="width=device-width,initial-scale=1.0">

       <link rel="stylesheet" type="text/css"href="css/l.css" />//用css来控制页面元素

       <link rel="stylesheet" type="text/css"href="css/style4.css" />

                   <scripttype="text/javascript"src="js/modernizr.custom.04022.js"></script>

                   <!--[iflt IE 9]>

                            <style>

                                     .content{

                                               height:auto;

                                               margin:0;

                                     }

                                     .contentdiv {

                                               position:relative;

                                     }

                            </style>

                   <![endif]-->

   </head>

   <body>

       <div class="container">

                            <header>

                                     <h1>家具管理系统欢迎你!</h1>

                                     <h3>请选择对应的操作</h3>

                                     <?php

                                     $t=date('y-m-dh:i:s',time());

                                     echo"<h3 align='right'>当前时间为:'$t'</h3>";

                                     ?>

                                     <divstyle='text-align:right'><a href='index.html'>退出登录</a></div>

                            </header>

                            <sectionclass="tabs">

                     <input id="tab-1"type="radio" name="radio-set"class="tab-selector-1" checked="checked" />

                           <label for="tab-1"class="tab-label-1">货物信息</label>

                  

                     <input id="tab-2"type="radio" name="radio-set"class="tab-selector-2" />

                           <label for="tab-2"class="tab-label-2">进货订单</label>

                  

                     <input id="tab-3" type="radio"name="radio-set" class="tab-selector-3" />

                           <label for="tab-3"class="tab-label-3">售货订单</label>

                           

                     <input id="tab-4"type="radio" name="radio-set"class="tab-selector-4" />

                           <label for="tab-4"class="tab-label-4">订单查询</label>          

                                <divclass="clear-shadow"></div>

                                    

                           <div class="content">

                                    <div class="content-1">                                      

                                                        <h2>当前货物的相关信息</h2>

                       <?php

                                                  require_once('allfun.php');

                                                  $conn=mq_connect();                                          

                            if(!$conn){

                                    throw newException("can't connect mysql");

                             }

                                                   $conn->query("SET NAMESUTF-8");

                                                   $sql="Select * from`fur`.`furniture`;";

                                                   $result=$conn->query($sql);                                                                                                                                                              

                        echo "<tableborder='5' width='800' height='280'><tr><td align='center'>名称</td><td align='center'>单价</td><td align='center'>库存量</td></tr>";

                        while($row =$result->fetch_array())

                        {

                         echo"<tr>";

                         echo "<tdalign='center'>".$row["category"]."</td>";

                         echo "<tdalign='center'>".$row["price"]."</td>";

                                                         echo "<tdalign='center'>".$row["count"]."</td>";

                        echo"</tr>";

                        }

                        echo"</table>";                                                       

                    ?>                                                

                                         </div>

                                    <div class="content-2">

                                               <formaction="insert1.php"method="post">

                                               <h2>添加进货订单,请输入相关信息</h2>

                                               <inputtype="text" name="name" value=""placeholder="用户名"/>   

                                               <inputtype="text" name="phonenumber" value=""placeholder="电话号码"/>     

                                               <inputtype="text" name="address" value=""placeholder="地址"/>

                                               <selectname="category">

                                               <optionvalue="凳子"/>凳子

                                               <optionvalue="沙发"/>沙发

                                               <optionvalue="床"/>床

                                               <optionvalue="桌子"/>桌子

                                               </select>

                                               <inputtype="text" name="number" value=""placeholder="总数"/>

                                               <inputtype="date" name="date" value="" placeholder="日期"/>

                                               </br></br></br></br></br>

                                               <pclass="submit"><input type="submit"name="buy" value="插入订单记录"></p>

                                               </form>

                                         </div>

                                    <div class="content-3">

                                               <formaction="insert2.php"method="post">

                                               <h2>添加售货订单,输入订单信息</h2>

                    <input type="text"name="name" value="" placeholder="用户名"/> 

                                               <inputtype="text" name="phonenumber" value=""placeholder="电话号码"/>     

                                               <inputtype="text" name="address" value=""placeholder="地址"/>

                                              

                                               <selectname="category">

                                               <optionvalue="凳子"/>凳子

                                               <optionvalue="沙发"/>沙发

                                               <optionvalue="床"/>床

                                               <optionvalue="桌子"/>桌子

                                               </select>

                                               <inputtype="text" name="number" value=""placeholder="总数"/>

                                               <inputtype="date" name="date" value=""placeholder="日期"/>

                                               </br></br></br></br></br>

                                               <pclass="submit"><input type="submit"name="buy" value="插入订单记录"></p>

                                               </form>

                                         </div>

                                         <div class="content-4">

                                               <formaction="res.php"method="post">

                                                        <h2>订单查询</h2>

                                                        <h2>请输入要查询的起始日期和截止日期</h2>

                                                        <inputtype="date" name="date1" value=""placeholder="日期"/>

                                                        <inputtype="date" name="date2" value=""placeholder="日期"/></br></br>

                                                        <pclass="submit"><input type="submit"name="buy" value="查询"></p>

                        </div>

                           </div>

                            </section>

       </div>

   </body>

</html>

在这个界面分为四个模块,分别为货物信息、进货订单、售货订单、订单查询。

当用户点击货物信息标签时,页面会调用脚本从数据库中搜索信息并以表格的形式输出到页面。

当用户点击进货订单标签时,输入相关信息后点击“插入订单记录”按钮,程序会调用insert1..php实现插入进货订单记录的功能,代码如下:

<html>

   <head>

                   <metacharset="UTF-8" />

        <metahttp-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

       <title>家具管理系统</title>

       <meta name="viewport" content="width=device-width,initial-scale=1.0">

       <link rel="stylesheet" type="text/css"href="css/lanrenzhijia.css" />

        <link rel="stylesheet"type="text/css" href="css/style4.css" />                

   </head>

   <body>

 

                            <header>

                                     <h1align='center'>家具管理系统欢迎你!</h1>                               

                            </header>                                                                          

<?php

                   require_once('connet.php');//插入进货记录的脚本

                   $name=$_POST['name'];

                   $phonenumber=$_POST['phonenumber'];

                    $address=$_POST['address'];

                   $category=$_POST['category'];

                    $count=$_POST['number'];

                    $date=$_POST['date'];

                    $conn=mq_connect();

                   if(empty($name)||empty($date)||empty($phonenumber)||empty($address)||empty($category)||empty($count)){

                         echo  iconv('UTF-8','GBK','<script>alert("it can not be empty,please try again after check")</script>');

                       //header("location:index4.php");

                                         echo "<h1 align='center'>一秒后返回主界面</h1>";

                                               header("refresh:1;url=index4.php");

                                               exit;

                    }

                    if(!$conn){

                               throw new Exception("can'tconnect  mysql");

                               }

                    $sql="INSERT INTO`provider`(`pname`, `phonenumber`, `address`, `category`, `number`, `date`)

                    VALUES('$name','$phonenumber','$address','$category','$count','$date')";

                   $result=$conn->query($sql);

                                         $sql1="SELECT price FROM `furniture`WHERE category='$category'";

                                         $price1=$conn->query($sql1);

                                         $price2 = $price1->fetch_array();

                                         $price=$price2[0];

                                         $money=$price*$count;

                    if($result==true){

                         //echo  iconv('UTF-8','GBK','<script>alert("insert successfully!")</script>');

                                         echo "<h1 align='center'>系统提示:本次交易记录成功</h1>";

                                         echo "<h2 align='center'>本次订单总售价为'$money'元</h2></br></br>";

                                         echo "<divstyle='text-align:center'><a href='index4.php'>点击返回主界面</a></div>";

                           }

               ?>                                         

                                               

    </body>

</html>

当用户点击售货订单标签时,输入相关信息后点击“插入订单记录”按钮,程序会调用insert2..php实现插入进货订单记录的功能,代码如下:

<html>

   <head>

                   <metacharset="UTF-8" />

       <meta http-equiv="X-UA-Compatible"content="IE=edge,chrome=1">

       <title>家具管理系统</title>

       <meta name="viewport" content="width=device-width,initial-scale=1.0">

       <link rel="stylesheet" type="text/css"href="css/lanrenzhijia.css" />

       <link rel="stylesheet" type="text/css"href="css/style4.css" />                         

   </head>

   <body>

 

                            <header>

                                     <h1align='center'>家具管理系统欢迎你!</h1>                               

                            </header>                                                                          

                                               <?php

                   require_once('connet.php');//插入售货记录的脚本

                    $name=$_POST['name'];

                   $phonenumber=$_POST['phonenumber'];

                    $address=$_POST['address'];

                   $category=$_POST['category'];

                    $count=$_POST['number'];

                    $date=$_POST['date'];

                    $conn=mq_connect();

                   if(empty($name)||empty($date)||empty($phonenumber)||empty($address)||empty($category)||empty($count)){

                         echo  iconv('UTF-8','GBK','<script>alert("it can not be empty,please try again after check")</script>');

                       //header("location:index4.php");

                                         //require('index4.php');

                                         //exit;

                                               echo"<h1 align='center'>一秒后返回主界面</h1>";

                                               header("refresh:1;url=index4.php");

                                               exit;

                    }

                                               $sqli="selectcount from furniture where category ='$category'";

                                               $count1=$conn->query($sqli);

                                         $count2 = $count1->fetch_array();

                                         $allcount=$count2[0];

                                               if($count>$allcount){

                         echo  iconv('UTF-8','GBK','<script>alert("the  storehouse doesn nothave enough goods")</script>');

                       //header("location:index4.php");

                                         echo "<h1 align='center'>一秒后返回主界面</h1>";

                                               header("refresh:1;url=index4.php");

                                               exit;

                    }

                    if(!$conn){

                               throw new Exception("can'tconnect  mysql");

                               }

                  $sql="INSERT INTO`client`(`cname`, `cphonenumber`, `caddress`, `category`, `cdate`, `count`)

                    VALUES('$name','$phonenumber','$address','$category','$date','$count')";

                 $result=$conn->query($sql);

                                      $sql1="SELECT price FROM `furniture`WHERE category='$category'";

                                      $price1=$conn->query($sql1);

                                      $price2 = $price1->fetch_array();

                                      $price=$price2[0];

                                      $money=$price*$count;

                   if($result==true){                   

                                      echo "<h1 align='center'>系统提示:本次交易记录成功</h1>";

                                      echo "<h2 align='center'>本次订单总价为'$money'元</h2></br></br>";

                                      echo "<divstyle='text-align:center'><a href='index4.php'>点击返回主界面</a></div>";

                           }

               ?>                                         

                                               

   </body>

</html>

     最后一个标签时订单查询,当用户输入查询的起始时间和结束时间时,点击按钮,程序会调用res.php脚本来实现订单查询功能,代码如下:

<html >

   <head>

                   <metacharset="UTF-8" />

       <meta http-equiv="X-UA-Compatible"content="IE=edge,chrome=1">

       <title>家具管理系统</title>

       <meta name="viewport" content="width=device-width,initial-scale=1.0">

       <link rel="stylesheet" type="text/css"href="css/lanrenzhijia.css" />

       <link rel="stylesheet" type="text/css"href="css/style4.css" />                

   </head>

   <body>

 

                            <header>

                                     <h1align='center'>家具管理系统欢迎你!</h1>

                <h2 align='center'>以下为查询结果</h2>                              

                            </header>                                                                          

                                               <?php

                   require_once('connet.php');   //查询的脚本                

                    $mintime=$_POST['date1'];

                    $maxtime=$_POST['date2'];

                    $conn=mq_connect();

                   if(empty($mintime)||empty($maxtime)){

                         echo  iconv('UTF-8','GBK','<script>alert("it can not be empty,please try again after check")</script>');

                         echo "<h1align='center'>一秒后返回主界面</h1>";

                                               header("refresh:1;url=index4.php");

                                               exit;

                    }

                    if(!$conn){

                               throw new Exception("can'tconnect  mysql");

                               }

                     $sql="callres1('$mintime','$maxtime')";

                     $result=$conn->query($sql);

                                          echo "<table border='5'  align='center' width='400'height='100'><tr><td>名称</td><td>进货量</td></tr>";

                        while($row =$result->fetch_array())

                        {

                         echo"<tr>";

                        echo"<td>".$row["category"]."</td>";

                         echo"<td>".$row["sum(number)"]."</td>";                                               

                         echo"</tr>";

                        }

                        echo"</table>";

                     $connl=mq_connect();                                                    

                     $sql1="callres2('$mintime','$maxtime')";    

                    $resultl=$connl->query($sql1);

                                          echo "<table border='5'  align='center' width='400'height='100'><tr><td>名称</td><td>售货量</td></tr>";

                    while($row =$resultl->fetch_array())

                        {

                         echo"<tr>";

                         echo"<td>".$row["category"]."</td>";

                         echo"<td>".$row["sum(count)"]."</td>";                                                  

                        echo"</tr>";

                        }

                        echo"</table></br></br>";

                        echo "<divstyle='text-align:center'><a href='index4.php'>点击返回主界面</a></div>";                                                     

               ?>                                         

                                               

   </body>

</html>

 

完整代码分享:http://pan.baidu.com/s/1ge4JSzD

0 0
原创粉丝点击