资源描述
计算机工程学院
Project2(GUI+SQL2005)
实习报告
选题名称: 仓库管理系统
专业: 计算机科学与技术(软件工程方向)
班级: 软件1092
姓名: 王伟剑
学号: 1091305220
指导教师: 冯万利 于长辉 高尚兵 庄军
2011 年 06 月 11 日
Project2(GUI+SQL2005)实习任务书
课题
名称
仓库管理系统
设计
目的
1. 掌握面向对象的程序设计技术和方法;
2. 学习用C#设计GUI程序解决实际问题;
3. 熟悉VS.NET开发平台,能使用.NET平台进行程序设计及程序调试;
4. 能使用ADO.NET进行数据库系统设计与开发。
实验
环境
1. Windows XP 操作系统
2. Visual Studio 开发平台
3. SQL Server2005数据库管理系统
任务
要求
1. 利用C#编程思想进行可视化编程,完成系统的设计。突出体现C#语言与其他语言的不同。
2. 根据课题需要自主创建sql数据库,表内数据关联紧密,数据合理且规范化,避免数据冗余。
3. 能合适的选择高级控件(如:菜单栏,工具栏,dataGridView,treeView等)完成课题内容,窗口布局合理。
4. 每个学生从所给题目中任选一题,必须独立完成,不能相互抄袭。
工作进度计划
序号
起止日期
工 作 内 容
1
2011-4-11 — 2011-6-5
需求分析
2
2011-6-6 — 2011-6-6
系统设计
3
2011-6-7 — 2011-6-9
系统实现
4
2011-6-9 — 2011-6-9
撰写实习报告
5
2011-6-10— 2011-6-10
实习答辩
指导教师(签章):
2011 年 06 月 日
摘要:
随着现代工业的发展,计算机信息管理系统越来越受到企业的重视。本文主要分析介绍了仓库管理系统的一些基本功能和组成情况,包括系统的需求分析、系统结构、功能模块划分以及数据库模式分析等,重点对应用程序的实际开发实现作了介绍。达到了数据的一致性和安全性,且应用程序功能完备,符合了库存管理系统作为典型的信息管理系统(MIS)的要求。同时简单介绍了Visual Studio 2008编程环境和SQL数据库管理系统的功能特点,库存管理系统是企业物流管理中不可或缺的的一部分。本系统利用ASO三层架构,完成系统登录,注销,修改密码的基本功能,仓库入库登记,出库登记,仓库货物预警,仓库内货物盘点的主要功能。本系统并不复杂,主要完成通过GUI开发,利用关键字对数据库进行增删改查等操作。
关键词:仓库管理;数据库;信息管理;Visual Studio 2008
目 录
1 需求分析
1.1 系统概述
仓库存放的货物品种繁多,堆放方式以及处理过程也很复杂。随着业务量的增加,仓库管理者需要处理的信息量会大幅上升,因此往往很难及时准确的掌握整个仓库的运作状态。针对这一情况,本系统在满足仓库的基本管理功能基础上发挥信息系统的智能化,减轻仓库管理人员和操作人员的工作负担。
系统主要实现目标是监控整个仓库的运作情况;提供完整的计划任务功能,由整个操作系统的指令中心来安排进出任务,确认任务的开始,进货管理和出货管理按其指令执行即可;实时监控所有货物的在线运动的情况,实时提供仓库变化的信息。
1.2系统总体需求
根据详细的需求分析,企业在库存中面临的主要问题体现在:库存量大,库存资金周转慢,不能及时统计库存物料;库房人员重复工作多,效率低;不知道库存物资积压时间长短。系统输入繁琐,极易产生输入错误,缺少智能化输入功能,如:产品名称输入过程中,产品名称和产品代码不能够相互协调,易产生不匹配现象。另外,整个系统运行较慢,数据处理能力不够,进行一个查询往往需要等待很长时间。该系统还缺少通用库存管理理功能,货物组成条目都是经过手工计算的,工作量很大,且容易产生错误,有一个小错误,核对都需要花费很大的精力,换句话说,当前没有通用库存管理系统。
本系统从最初的采购到存储和出库,仓库管理将决定企业是否兑现其承诺。从仓库计划到仓库操作和交叉运输,优化的仓库将有助于大幅度减少企业的库存量和和货物成本,因为企业将能保持较低的库存货水平,优化入库,保管和出库活动,并且协调载货量。
1.3可行性分析
技术上可行:该系统所需硬件设备,市场上销售且价格较低,甚至可以使用原有的设备,软件上,操作系统采用Windows系列操作系统,数据库管理系统采用Visual Studio 2008,这些软件在GUI开发中已被大量应用,技术上都比较成熟。因此在技术上是可行的。
2 概要设计
输入账号 密 码 登 录
账号密码符合要求
主要功能
重新输入
退出
2.1E-R图
N
Y
修改密码
注销
主要功能
库存盘点
仓库预警
出库登记
入库登记
显示库内货物详情
输入预警数量
输入货物详情
输入货物详情
显示数量不足货物详情
数据库,信息
栏同步修改
数据库,信息栏同步修改
2.2相关说明
登录系统:账号密码均存储于SQL数据库中。输入账号及账号对应密码,即可 登录系统。
修改密码:需输入一次原密码,输入两次新密码相同即可修改。密码修改同步于 SQL数据库。
注销: 登录账号退出,返回登陆界面。
退出系统: 系统退出。
入库登记:输入产品ID,即可直接获得产品的相关信息,此时输入入库数量就 可以完成货物的入库操作,如果此时产品为新产品,需输入产品的 详细信息,就可以完成货物的入库操作。入库操作同步更新SQL数 据库。
出库登记:输入产品ID,即可直接获得产品的相关信息,此时输入出库数量就 可以完成货物的出库操作,入库操作同步更新SQL数据库。
仓库预警:输入预警数量,点击确定按钮,此时显示数据库中,货物数量小于预 警数量的货物总数和货物详细信息。
商品查询:显示仓库中所有货物的详细信息,可以输入产品ID和产品名称进行 货物查询,支持模糊查找。
3 详细设计
3.1数据库表定义
Users表(用户信息表)
Goods表(货物详情表)
Worehouses表(仓库信息表)
3.2GUI框架设计
1用户系统
2主菜单
3密码修改
4货物入库
5 货物出库
6 库存预警
7 商品查询
4 编码实现
登录系统
public static string pwd;
public static string pid;
private void button1_Click(object sender, EventArgs e)
{
pwd = this.textBox1.Text;
pid = this.textBox2.Text;
Logs l = new Logs();
if (int.Parse (l.isPassword(this.textBox2.Text,this.textBox1.Text).ToString () )== 1)
{
this.Hide();
Management m = new Management();
m.ShowDialog();
}
else
{
DialogResult dr = MessageBox.Show("请检查您的用户名和密码", "登录失败", MessageBoxButtons.YesNo);
if (DialogResult.No==dr)
{
Application.Exit();
}
}
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
主菜单
public partial class Management : Form
{
public Management()
{
InitializeComponent();
}
private void ChangeToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangePassword cp = new ChangePassword();
cp.ShowDialog();
}
private void LogoutToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("您确定要注销吗?","注销", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
Application.Exit();
}
}
private void OutToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void Management_Load(object sender, EventArgs e)
{
this.goodsTableAdapter.Fill(this.wmsDataSet.Goods);
}
private void Management_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void InputF2ToolStripMenuItem_Click(object sender, EventArgs e)
{
InputWHForm iwh = new InputWHForm();
iwh.ShowDialog ();
}
private void Management_Activated(object sender, EventArgs e)
{
this.goodsTableAdapter.Fill(this.wmsDataSet.Goods);
}
private void OutF6ToolStripMenuItem_Click(object sender, EventArgs e)
{
OutWHForm owh = new OutWHForm();
owh.ShowDialog ();
}
private void WarningToolStripMenuItem_Click(object sender, EventArgs e)
{
Warning w = new Warning();
w.ShowDialog();
}
private void GoodsDetailsToolStripMenuItem_Click(object sender, EventArgs e)
{
this.goodsTableAdapter.Fill(this.wmsDataSet.Goods);
}
private void WareHouseDetailsToolStripMenuItem_Click(object sender, EventArgs e)
{
this.warehousesTableAdapter.Fill(this.wmsDataSet1.Warehouses);
}
private void SearchToolStripMenuItem_Click(object sender, EventArgs e)
{
Search s = new Search();
s.Show();
}
private void fillByToolStripButton_Click(object sender, EventArgs e)
{
try
{
this.goodsTableAdapter.FillBy(this.wmsDataSet.Goods);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
}
入库登记
public partial class InputWHForm : Form
{
public InputWHForm()
{
InitializeComponent();
}
private void InputWHForm_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“wmsDataSet4.Goods”中。您可以根据需要移动或移除它。
this.goodsTableAdapter.Fill(this.wmsDataSet4.Goods);
}
private void button6_Click(object sender, EventArgs e)
{
this.Close();
}
public void SendToInput()
{
GoodsDetails s = new GoodsDetails();
s.GID = int.Parse(this.textBox1.Text);
s.GName = boBox1.Text;
s.Gprice = float.Parse(this.textBox3.Text);
s.GProvider1 = boBox1.Text;
s.GProvider2 = boBox4.Text;
s.Wname = int.Parse (boBox2.Text);
s.Count = SqlHelper.DefiniteCount(this.textBox1.Text) + int.Parse(this.textBox2.Text);
SqlHelper.AddGoods(s);
}
private void button5_Click(object sender, EventArgs e)
{
SendToInput();
this.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
GoodsDetails g = SqlHelper.Bind(this.textBox1.Text);
boBox3.Text = g.GName;
this.textBox3.Text = g.Gprice.ToString ();
boBox1.Text = g.GProvider1;
boBox4.Text = g.GProvider2;
boBox2.Text = g.Wname.ToString ();
}
}
出库登记
public partial class OutWHForm : Form
{
public OutWHForm()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
SentToOutput();
this.Close();
}
private void SentToOutput()
{
GoodsDetails s = new GoodsDetails();
s.GID = int.Parse(this.textBox1.Text);
s.GName = boBox1.Text;
s.Gprice = float.Parse(this.textBox3.Text);
s.GProvider1 = boBox1.Text;
s.GProvider2 = boBox4.Text;
s.Count = SqlHelper.DefiniteCount(this.textBox1.Text) - int.Parse(this.textBox2.Text);
SqlHelper.OutGoods(s);
}
private void OutWHForm_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“wmsDataSet2.Goods”中。您可以根据需要移动或移除它。
this.goodsTableAdapter.Fill(this.wmsDataSet2.Goods);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
GoodsDetails g = SqlHelper.Bind(this.textBox1.Text);
boBox3.Text = g.GName;
this.textBox3.Text = g.Gprice.ToString ();
boBox1.Text = g.GProvider1;
boBox4.Text = g.GProvider2;
}
}
库存预警
public partial class Warning : Form
{
public Warning()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
this.listBox1.Items.Clear();
List<GoodsDetails> g = new List<GoodsDetails>();
g = SqlHelper.WarningBind(this.textBox2.Text);
int i = 0;
for ( i=0; i < g.Count();i++ )
{
this.listBox1.Items.Add(g[i].GID.ToString().PadLeft(4) + g[i].GName.PadLeft(20) + g[i].Count.ToString().PadLeft(10) + g[i].GProvider1.PadLeft(20) + g[i].GProvider2.PadLeft(10));
}
this.textBox1.Text = i.ToString();
}
}
货物查询
public partial class Search : Form
{
public Search()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void Search_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“wmsDataSet5.Goods”中。您可以根据需要移动或移除它。
this.goodsTableAdapter.Fill(this.wmsDataSet5.Goods);
}
private void button2_Click(object sender, EventArgs e)
{
GoodsDetails g = SqlHelper.BindVague(boBox3.Text);
this.textBox1.Text = g.GID.ToString();
this.textBox3.Text = g.Gprice.ToString();
boBox1.Text = g.GProvider1;
boBox4.Text = g.GProvider2;
boBox2.Text = g.Wname.ToString();
this.textBox2.Text = g.Count.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
GoodsDetails g = SqlHelper.Bind(this.textBox1.Text);
boBox3.Text = g.GName;
this.textBox3.Text = g.Gprice.ToString();
boBox1.Text = g.GProvider1;
boBox4.Text = g.GProvider2;
boBox2.Text = g.Wname.ToString();
this.textBox2.Text = g.Count.ToString();
}
}
数据库连接
public static void ChangeDBPassword(int p,string p2)
{
SqlConnection co = new SqlConnection(ConnectionString.con);
SqlCommand cmd = new SqlCommand(string.Format("update Users set Upassword='{0}' where UID='{1}'", p,p2), co);
co.Open();
var i = (int)cmd.ExecuteNonQuery ();
MessageBox.Show("密码修改成功");
co.Close();
}
public static void AddGoods(GoodsDetails g)
{
SqlConnection co = new SqlConnection(ConnectionString.con);
SqlCommand cmd3 = new SqlCommand(string.Format("select count(*) from Goods where 产品ID='{0}'", g.GID), co);
co.Open ();
int j=(int)cmd3.ExecuteScalar ();
if(j==0)
{
SqlCommand cmd2 = new SqlCommand(string.Format("insert into Goods values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", g.GID ,g.GName ,g.Gprice,g.Count ,g.GProvider1 ,g.GProvider2 ,g.GDescribe,g.Wname ), co);
int i = (int)cmd2.ExecuteNonQuery();
MessageBox.Show("添加成功");
co.Close();
}
else
{
SqlCommand cmd1 = new SqlCommand(string.Format("update Goods set 产品名称='{1}',产品价格='{2}',仓库所剩数量='{3}',厂商='{4}',厂商='{5}',备注='{6}',收货仓库ID='{7}' where 产品ID='{0}'", g.GID, g.GName, g.Gprice, g.Count , g.GProvider1, g.GProvider2, g.GDescribe,g.Wname ), co);
int i = (int)cmd1.ExecuteNonQuery();
MessageBox.Show("更新成功");
co.Close();
}
}
public static void OutGoods(GoodsDetails g)
{
SqlConnection co = new SqlConnection(ConnectionString.con);
try
{
SqlCommand cmd1 = new SqlCommand(string.Format("update Goods set 产品名称='{1}',产品价格='{2}',仓库所剩数量='{3}',厂商='{4}',厂商='{5}',备注='{6}',收货仓库ID='{7}' where 产品ID='{0}'", g.GID, g.GName, g.Gprice, g.Count, g.GProvider1, g.GProvider2, g.GDescribe,g.Wname ), co);
co.Open();
int i = (int)cmd1.ExecuteNonQuery();
co.Close();
MessageBox.Show("仓库出库记录完成");
}
catch (SqlException)
{
MessageBox.Show("出库失败");
}
}
public static int DefiniteCount(string p)
{
SqlConnection co = new SqlConnection(ConnectionString.con);
SqlCommand cmd = new SqlCommand(string.Format("select 仓库所剩数量from Goods where 产品ID='{0}'", p), co);
SqlCommand cmd1 = new SqlCommand(string.Format("select count(*) from Goods where 产品ID='{0}'", p), co);
co.Open();
int i=0;
if ((int)cmd1.ExecuteScalar() == 1)
i = (int)cmd.ExecuteScalar();
co.Close();
return i;
}
public static GoodsDetails Bind(string p)
{
SqlConnection co = new SqlConnection(ConnectionString.con);
SqlCommand cmd = new SqlCommand(string.Format("select * from Goods where 产品ID='{0}'", p), co);
展开阅读全文