• 小型企业库存管理系统的设计与实现


    双专业毕业论文做了一个小型企业库存管理系统,使用PHP&mysql组合进行开发。头一次开发稍微大一点的东西,php也是自学的。这里想跟大家一起分享一下

    check_login 模块

    View Code
    1 <!--用户登陆检验模块-->
    2  <?php
    3  session_start();
    4 $workid=$_GET['wid'];//获取工作号
    5 if($workid!=$_SESSION['$workid']||$workid==''){
    6 echo "<script language=javascript>alert('您还没有登陆,无法管理!');location.href='login.php';</script>";
    7 }
    8 ?>

    function.inc//主要包括数据库连接模块

    View Code
    1 <?php
    2 function mysql_link($user="admin",$password="admin",$database="systembase"){
    3 $id=mysql_connect("localhost",$user,$password);
    4 if(!$id){
    5 die('Could not connect: ' . mysql_error());
    6 }
    7 if (!mysql_select_db($database,$id)){
    8 die ("Can\'t select_db : " . mysql_error());
    9 }
    10 //改变客户端字符集编码为gb2312
    11 mysql_query("SET NAMES gb2312");
    12 return $id;
    13 }
    14 ?>

    仓库管理界面storage.php

    View Code
    1 <!--仓库管理员管理界面-->
    2 <?php
    3 include "inc/check_login.php";
    4 include "inc/function.inc";
    5 $id=mysql_link("storage","storage");//建立storage连接
    6
    7 $query="select * from admin where admin_id='$workid'";//定位仓库
    8 $result=mysql_query($query,$id);
    9 $info=mysql_fetch_array($result,MYSQL_ASSOC);
    10 $stoid=$info['storage_id'];
    11 ?>
    12 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
    13 <html>
    14 <head>
    15 <LINK href="images/style.css" type=text/css rel=stylesheet>
    16 <META http-equiv=Content-Type content="text/html; charset=gb2312">
    17 <title>仓库管理</title>
    18 <style type="text/css">
    19 body{
    20 font-family:Arial,Helvetica,sans-serif; /*设置字体样式*/
    21 font-size:12px;
    22 margin:0px 240px;
    23 height:auto;
    24 width:800px;
    25 border:1px solid #006633;
    26 background-color:rgb(195,245,200);
    27
    28 }
    29 </style>
    30 </head>
    31 <body>
    32 <div id="header" ></div>
    33 <ul id="nav">
    34 <li><a href="logout.php">注 销</a></li>
    35 <?php
    36 echo "<li><a href=input.php?wid=".$workid.">入 库</a></li>";
    37 echo "<li><a href=output.php?wid=".$workid.">出 库</a></li>";
    38 ?>
    39 </ul>
    40 <div id="content" align=center>
    41 <div id="man_zone" align=center>
    42 <table width="99%" border="1" align="center" cellpadding="3" cellspacing="1">
    43 <?php
    44 $query="select * from storage where storage_id='$stoid'";//定位仓库信息
    45 $result=mysql_query($query,$id);
    46 if(mysql_num_rows($result)<1){
    47 echo "没有仓库".$stoid;
    48 }else{
    49 $info=mysql_fetch_array($result,MYSQL_ASSOC);
    50 echo "仓库号:".$stoid."&nbsp;总容量:".$info['storage_cap']."&nbsp;剩余容量:".$info['storage_lcap']."
    51 &nbsp;仓库地址:".$info['storage_add']."&nbsp;仓库电话:".$info['storage_tele'];
    52 if (!mysql_select_db("basicbase",$id)){
    53 die ("Can\'t select_db : " . mysql_error());
    54 }
    55 //在basicbase中建立对应仓库货物视图,入库视图以及出库视图
    56 //判断是否存在相关视图,没有的话就新建视图
    57 $query="select * from ".$stoid."_inventory";
    58 if(!mysql_query($query,$id)){
    59 //创建inventory视图
    60 $query="create view ".$stoid."_inventory as
    61 select inventory.goods_id,name,number from inventory,systembase.goods where storage_id=".$stoid." and inventory.goods_id=systembase.goods.goods_id";
    62 if(!mysql_query($query,$id)){
    63 die ("Can\'t create_view_inventory : " . mysql_error());
    64 }
    65 //创建input视图
    66 $query="create view ".$stoid."_input as
    67 select input_id,goods_id,number,time from input where admin_id=".$workid;
    68 if(!mysql_query($query,$id)){
    69 die ("Can\'t create_view_input : " . mysql_error());
    70 }
    71 //创建output视图
    72 $query="create view ".$stoid."_output as
    73 select output_id,goods_id,number,time from output where admin_id=".$workid;
    74 if(!mysql_query($query,$id)){
    75 die ("Can\'t create_view_output : " . mysql_error());
    76 }
    77 }
    78 $query="select * from ".$stoid."_inventory";
    79 $result=mysql_query($query,$id);
    80 if(mysql_num_rows($result)<1){
    81 echo "<br>该仓库目前是空的";
    82 }else{
    83 $totalnum=mysql_num_rows($result);
    84 $pagesize=7;
    85 $page=$_GET["page"];
    86 if(""==$page){
    87 $page=1;
    88 }
    89 $begin=($page-1)*$pagesize;
    90 $totalpage=ceil($totalnum/$pagesize);
    91
    92 echo "<tr>仓库中共有".$totalnum."种货物。";
    93 echo "每页".$pagesize."种,共".$totalpage."页。</tr>";
    94 for($j=1;$j<=$totalpage;$j++){
    95 echo "<a href=storage.php?wid=".$workid."&page=".$j.">[".$j."]&nbsp;&nbsp;</a>";
    96 }
    97 echo "<br>";
    98 $query="select *from ".$stoid."_inventory order by goods_id limit $begin,$pagesize";
    99 $result=mysql_query($query,$id);
    100 $datanum=mysql_num_rows($result);
    101 //echo "<tr><td id=table_title >货物id</td><td id=table_title >货物名称</td><td id=table_title >货物数量</td></tr>";
    102 echo "<tr><td >货物id</td><td >货物名称</td><td >货物数量</td></tr>";
    103 for($i=1;$i<=$datanum;$i++){
    104 $info=mysql_fetch_array($result,MYSQL_ASSOC);
    105 //echo "<tr><td id=table_title >".$info['goods_id']."</td><td id=table_title >".$info['name']."</td><td id=table_title >".$info['number']."</td></tr>";
    106 echo "<tr><td >".$info['goods_id']."</td><td >".$info['name']."</td><td >".$info['number']."</td></tr>";
    107 }
    108
    109 }
    110 }
    111 mysql_close($id);
    112 ?>
    113 </table>
    114 </div>
    115 </div>
    116 <div id="footer">版权所有:Freeze&zhaoL <br>E-mail:zhoujiebin15@qq.com</div>
    117 </body>
    118 </html>
    119
    120
    121

    代码太多不一一贴了,第一次写碰到很多问题,但不管怎么说程序还是运行起来了

  • 相关阅读:
    div相对屏幕居中
    Webstorm快捷键
    VIM快捷键
    美食 pizza 家常菜
    ln -s 软链接
    解决Linux服务器执行出现-bash: ./xxx.sh: /bin/sh^M: bad interpreter: No such file or directory
    PHP Apache 搭建FastCGI环境
    VS Code 添加php.validate.executablePath 路径
    git push 时报错 remote: The project you were looking for could not be found.
    PHP类中私有静态成员初始化
  • 原文地址:https://www.cnblogs.com/2010Freeze/p/2047986.html
Copyright © 2020-2023  润新知