资源描述
成 绩
11信计2013-2014(一)
《数据库原理及应用》课程设计
设计题目 仓储物资管理系统
设计时间 2013.12.31---2014.1.4
学生姓名 张政伟
学生学号 20110402124
所在班级 11精算
指导教师 董晓玮
徐州工程学院数学与物理科学学院
目 录
1 可行性研究 3
2 需求分析 3
2.1 任务概述 3
2.1.1 目标 3
2.1.2 运行环境 3
2.2 数据需求 3
2.2.1 数据流条目 3
2.2.2 数据库描述 4
2.3 功能需求 4
2.3.1 功能划分 4
2.3.2 功能描述 4
3 概要设计 4
4 逻辑设计 5
5 界面设计和代码 7
5.1登陆界面设计 7
5.2注册界面与代码 9
5.3修改密码 10
5.4系统主界面设计和代码 11
5.5查询信息管理界面设计 13
5.6添加信息查询界面设计 14
5.7出入库信息表设计 18
5.8删改信息设计 24
6总结 25
参考文献 25
1 可行性研究
仓库管理系统是为了实现企业产品管理的系统化、规范化和自动化,从而提高企业管理效率而设计的。它完全取代了原来一直用人工管理的工作方式,避免了由于管理人员的工作疏忽以及管理质量问题所造成的各种错误,为及时、准确、高效的完成仓库管理提供了强有力的工具和管理手段。仓库管理系统是一个中小型数据库管理系统,它界面美观、操作简单、安全性高,基本满足了仓库管理的要求。本系统的开发语言采用的是C#,开发环境采用的是Visual studio 2008,数据库采用SQL Server 2005,具有一般系统的数据功能,如数据查询,修改和删除等。仓库管理系统在运行阶段,效果好,数据准确性高,提高了工作效率,同时也实现了仓库管理计算机化。
2 需求分析
2.1 任务概述
经过调查,对仓库管理的业务流程进行分析。库存的变化通常是通过入库、出库操作来进行。系统对每个入库操作均要求用户填写入库单,对每个出库操作均要求用户填写出库单。在出入库操作同时可以进行增加、删除和修改等操作。用户可以随时进行各种查询、统计、报表打印、账目核对等工作。另外,也可以用图表形式来反映查询结果。
2.1.1 目标
(1)界面设计要求尽量友好、美观,应提供登录界面,并考虑用户权限问题;
(2)对各种信息应提供录入、修改、删除和查询功能;
(3)具有对商品的基本信息和流动信息进行统计的功能;
(4)具有数据备份与恢复、帮助等功能;
(5)能够新增、修改和删除用户信息;
2.1.2 运行环境
Windows 98/2000/XP/2003操作系统下,安装并配置软件Microsoft SQL Server 2000数据库管理系统。
2.2 数据需求
2.2.1 数据流条目
根据我们的进行的调查和分析,系统中各种功能所需的数据项和数据结构如下:
①商品信息:商品编号,商品名,商品单价;
②职工信息:职工号,职工姓名,性别,电话,住址;
③供货商信息:供应商姓名,地址,电话,单位等;
④入库信息:入库编号,商品编号,商品名称,单价,数量,总价,供应商;
⑧出库信息:出库编号,商品编号,商品名称,单价,数量,总价,经手人;
2.2.2 数据库描述
使用SQL SERVER2000作为后台数据库,就可以行使基于网络连接的用户认证。从而给不同的子系统分配不同的数据库使用角色,让他们彼此之间使用的数据库隔离开来,以达到较高的安全性。
2.3 功能需求
根据对各大超市进行的调查和分析,仓库管理系统应该具有以下功能:
①仓库中的货物信息的录入、修改、删除和查询。
②仓库的信息的的录入、修改、删除、查询和统计。
③管理者的信息的录入、修改、删除和查询。
④供货商的信息的录入、修改、删除、查询和统计。
⑤货物流动信息的录入、修改、删除和查询。
2.3.1 功能划分
仓库管理系统主要实现以下四方面的功能:
A. 登陆
b. 注册
c. 查询
d. 修改
2.3.2 功能描述
仓库管理包括登陆、注册、查询、修改四方面功能。
登陆,分为普通管理员登陆和超级管理员登陆。
查询,分为员工查询,仓库查询和物品查询。
修改,主要实现添加,修改和删除。
3 概要设计
对系统功能分析中的各项功能进行集中、分块,按照结构化程序设计的要求,得到如下图所示的系统功能模块图。
员工查询
仓库查询
商品查询
注册
仓库管理系统
登录
普通管理员
超级管理员
查询
修改
添加
修改
删除
4 逻辑设计
根据数据库需求分析,本系统的数据库逻辑结构设计如下。
①商品信息设计
②入库单信息设计
③ 出库单信息设计
④职工信息设计
⑤仓库信息设计
⑥供货商信息表
5 界面设计和代码
5.1登陆界面设计
public partial class Fmlogin : Form
{ public Fmlogin()
{ InitializeComponent(); }
private void BUT_Y_Click(object sender, EventArgs e)
{ string username = tbuser.Text;
string password = tbpw.Text;
string connstring = @"Data Source=.zhaojuan-PC\SQLEXPRESS;AttachDbFilename=F:\仓库管理系统\仓库管理系统\WMS_DB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlConnection conn = new SqlConnection(connstring);//获取用户名和密码匹配的行的数量的sql语句
string sql = string.Format("select count(*) from [usertable] where username='{0}'and password='{1}'", username, password);
try
{ if (comboBox1.Text == "超级管理员"&&tbuser.Text=="admin")
{conn.Open();
SqlCommand comm = new SqlCommand(sql, conn);
int num = (int)comm.ExecuteScalar();
if (num > 0)
{ this.Hide();
Fmmenu f1 = new Fmmenu();
f1.ShowDialog(); }
else
{ MessageBox.Show("用户名或密码或身份错误,请重新输入!","登录失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
else if (comboBox1.Text =="普通管理员")
{ conn.Open();
SqlCommand comm = new SqlCommand(sql, conn);
int num = (int)comm.ExecuteScalar();
if (num > 0)
{ this.Hide();
Fmmenu f1 = new Fmmenu();
f1.删改信息ToolStripMenuItem.Enabled = false;
f1.ShowDialog(); }
else
{MessageBox.Show("用户名或密码或身份错误,请重新输入!","登录失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);} }
else{
MessageBox.Show("用户名或密码或身份错误,请重新输入!","登录失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
catch (Exception eee)
{ MessageBox.Show(eee.Message, "数据库操作错误!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
finally
{conn.Close(); } }
private void BUT_z_Click(object sender, EventArgs e)
{ Fmregister f2 = new Fmregister(); f2.ShowDialog();} }
5.2注册界面与代码
private void button1_Click(object sender, EventArgs e)
{if (tbpw.Text == tB2_repw.Text)
{ string connstring = @"Data Source=.zhaojuan-PC\SQLEXPRESS;AttachDbFilename=F:\仓库管理系统\仓库管理系统\WMS_DB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlConnection conn = new SqlConnection(connstring); ;
try
{conn.Open();
SqlCommand comm = new SqlCommand("register", conn);
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.AddWithValue("@username", tbuser.Text.Trim());
comm.Parameters.AddWithValue("@password", tbpw.Text.Trim());
comm.Parameters.AddWithValue("@workerID", tB_worker.Text.Trim());
int count = comm.ExecuteNonQuery();//执行命令,返回的行数
if (count > 0) {
MessageBox.Show("注册成功!可以登录!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); }
else
{ MessageBox.Show("注册失败!","错误!",MessageBoxButtons.OK,MessageBoxIcon.Information);} }
catch(Exception )
{ MessageBox.Show("操作数据失败!可能用户名重复或您不是本公司职员!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
finally
{conn.Close();}}
else
MessageBox.Show("注册失败!重复密码错误!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void but_return_Click(object sender, EventArgs e)
{ this.Close();}
5.3修改密码
private void but_Y_Click(object sender, EventArgs e)
{ if (tBsure.Text == tBNpass.Text)
{ string connstring = @"Data Source=zhaojuan-PC\SQLEXPRESS;AttachDbFilename=D:\仓库管理系统\仓库管理系统\WMS_DB.mdf;Integrated Security=True";
SqlConnection conn = new SqlConnection(connstring);
try
{ conn.Open();
SqlCommand comm = new SqlCommand("updatepass", conn);
comm.CommandType=CommandType.StoredProcedure;
comm.Parameters.AddWithValue("@username", tBuser.Text);
comm.Parameters.AddWithValue("@password", tBpass.Text);
comm.Parameters.AddWithValue("@newpass", tBNpass.Text);
int count = comm.ExecuteNonQuery();
if (count > 0)
{MessageBox.Show("修改密码成功");
tBuser.Text = ""; tBpass.Text = ""; tBNpass.Text = "";tBsure.Text = ""; tBuser.Focus(); }
else
{MessageBox.Show("数据库操作失败", "修改密码失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);}}
catch
{ MessageBox.Show("操作数据失败!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
finally
{ conn.Close();} }
else
{ MessageBox.Show("确认密码与新密码不符", "修改密码失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
tBuser.Text = ""; tBpass.Text = ""; tBNpass.Text = ""; tBsure.Text = ""; tBuser.Focus(); } }
private void button1_Click(object sender, EventArgs e)
{this.Close();}
5.4系统主界面设计和代码
public partial class Fmmenu : Form
{public Fmmenu()
{ InitializeComponent();}
private void 职员ToolStripMenuItem_Click(object sender, EventArgs e)
{ putinto_w w = new putinto_w();
w.ShowDialog(); }
private void 查询所有ToolStripMenuItem_Click(object sender, EventArgs e)
{ allinformation s = new allinformation();
s.ShowDialog(); }
private void 按仓库ToolStripMenuItem_Click(object sender, EventArgs e)
{ BY_WHID bw = new BY_WHID();
bw.ShowDialog(); }
private void 供货商ToolStripMenuItem_Click(object sender, EventArgs e)
{ putinto_sup su = new putinto_sup(); su.ShowDialog(); }
private void 仓库信息ToolStripMenuItem_Click(object sender, EventArgs e)
{putinto_WH wh = new putinto_WH(); wh.ShowDialog(); }
private void 商品信息ToolStripMenuItem_Click(object sender, EventArgs e)
{ putin_G g = new putin_G();g.ShowDialog(); }
private void 入库ToolStripMenuItem_Click(object sender, EventArgs e)
{putin pi = new putin(); pi.ShowDialog(); }
private void 出库ToolStripMenuItem_Click(object sender, EventArgs e)
{putout po = new putout(); po.ShowDialog(); }
private void 删改信息ToolStripMenuItem_Click(object sender, EventArgs e)
{updataANDdelete ud = new updataANDdelete(); ud.ShowDialog();}
private void 提醒ToolStripMenuItem_Click(object sender, EventArgs e)
{remind re = new remind(); re.ShowDialog(); }
private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
{ updatapass up = new updatapass(); up.ShowDialog(); }
private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
{ About ab = new About(); ab.ShowDialog(); }
private void 按供货商ToolStripMenuItem_Click(object sender, EventArgs e)
{ BY_SUP bs = new BY_SUP(); bs.ShowDialog(); } }
5.5查询信息管理界面设计
public partial class allinformation : Form
{ public allinformation()
{InitializeComponent(); }
private void allinformation_Load(object sender, EventArgs e)
{ this.view_putoutTableAdapter.Fill(this.wMS_DBDataSet4.View_putout);
this.view_putinTableAdapter.Fill(this.wMS_DBDataSet3.view_putin);
this.supplierTableAdapter.Fill(this.wMS_DBDataSet2.Supplier);
this.workerTableAdapter.Fill(this.wMS_DBDataSet1.Worker);
this.gOODSTableAdapter.Fill(this.wMS_DBDataSet.GOODS);}
private void fillByToolStripButton_Click(object sender, EventArgs e)
{ try
{this.gOODSTableAdapter.FillBy(this.wMS_DBDataSet.GOODS); }
catch (System.Exception ex)
{ System.Windows.Forms.MessageBox.Show(ex.Message);}
try
{ this.workerTableAdapter.FillBy1(this.wMS_DBDataSet1.Worker);}
catch (System.Exception ex)
{ System.Windows.Forms.MessageBox.Show(ex.Message); }
try
{ this.view_putoutTableAdapter.FillBy(this.wMS_DBDataSet4.View_putout); }
catch (System.Exception ex)
{ System.Windows.Forms.MessageBox.Show(ex.Message); }
try
{ this.supplierTableAdapter.FillBy(this.wMS_DBDataSet2.Supplier); }
catch (System.Exception ex)
{ System.Windows.Forms.MessageBox.Show(ex.Message); }
try
{this.view_putinTableAdapter.FillBy(this.wMS_DBDataSet3.view_putin); }
catch (System.Exception ex)
{ System.Windows.Forms.MessageBox.Show(ex.Message); } } }
5.6添加信息查询界面设计
根据上图可知添加信息分为三类,人员信心,仓库信息,和商品信息,此外,人员信息分为职工类和供货商类,因添加界面和代码,格式大抵相同,所以只展示部分界面,进入添加设计如下:
1.添加商品信息
public partial class putin_G : Form
{ public putin_G()
{ InitializeComponent();}
private void but_Y_Click(object sender, EventArgs e)
{string connstring = @"Data Source=.zhaojuan-PC\SQLEXPRESS;AttachDbFilename=F:\仓库管理系统\仓库管理系统\WMS_DB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlConnection conn = new SqlConnection(connstring);
try
{ conn.Open();
SqlCommand comm = new SqlCommand("insertgoods", conn);
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.AddWithValue("@goods_ID", tB1_G_ID.Text.Trim());
comm.Parameters.AddWithValue("@goods_name", tB2_G_name.Text.Trim());
comm.Parameters.AddWithValue("@goods_price", tB3_G_price.Text.Trim());
comm.Parameters.AddWithValue("@minnum", tB5_G_minnum.Text.Trim());
int count = comm.ExecuteNonQuery();//执行命令,返回的行数
if (count > 0)
{MessageBox.Show("添加成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);}
else
{MessageBox.Show("添加失败!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Information);}}
catch (Exception)
{ MessageBox.Show("操作数据失败!可能商品已存在!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Information);}
finally
{conn.Close();}}
private void button1_Click(object sender, EventArgs e)
{ this.Close(); } }
2录入仓库信息
public partial class putinto_WH : Form
{public putinto_WH()
{ InitializeComponent();}
private void but_Y_Click(object sender, EventArgs e)
{string connstring = @"Data Source=.zhaojuan-PC\SQLEXPRESS;AttachDbFilename=F:\仓库管理系统\仓库管理系统\WMS_DB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";SqlConnection conn = new SqlConnection(connstring);
try
{conn.Open();
SqlCommand comm = new SqlCommand("insertWH", conn);
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.AddWithValue("@WH_ID", tB1_WH_ID.Text.Trim());
comm.Parameters.AddWithValue("@WHname", tB2_WHname.Text.Trim());
comm.Parameters.AddWithValue("@workerID", tB3_workerID.Text.Trim());
comm.Parameters.AddWithValue("@WHphone", tB4_WHphone.Text.Trim());
comm.Parameters.AddWithValue("@address", tB5_address.Text.Trim());
int count = comm.ExecuteNonQuery();//执行命令,返回的行数
if (count > 0)
{ MessageBox.Show("添加成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); }
else
{ MessageBox.Show("添加失败!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Information);} }
catch (Exception)
{ MessageBox.Show("操作数据失败!可能仓库已存在!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Information);}
finally
{conn.Close(); } }
private void button1_Click(object sender, EventArgs e)
{this.Close(); }}
3录入职员信息(代码只展示不同部分
Try
{ conn.Open();
SqlCommand comm = new SqlCommand("insertworker", conn);
comm.CommandType=CommandType.StoredProcedure comm.Parameters.AddWithValue("@workerID",tB1_ID.Text.Trim());
comm.Parameters.AddWithValue("@workerName",tB2_name.Text.Trim());
comm.Parameters.AddWithValue("@Sex", tB3_sex.Text.Trim());
comm.Parameters.AddWithValue("@phone", tB4_phone.Text.Trim());
comm.Parameters.AddWithValue("@workerPost",tB5_POST.Text.Trim());
int count = comm.ExecuteNonQuery();//执行命令,返回的行数
5.7出入库信息表设计
1出库表界面设计
public partial class putout : Form
{ public putout()
{ InitializeComponent();}
private void button1_Click(object sender, EventArgs e)
{ this.Close(); }
private void but_Y_Click(ob
展开阅读全文