欢迎添加微信互相交流学习哦!
项目源码:https://gitee.com/oklongmm/biye
超市进销存系统
-
- 设计目的
根据所学的数据库原理与程序设计的知识,能够针对一个小型的数据库管理信息系统,进行系统的需求分析,系统设计,数据库设计,编码,测试等,完成题目要求的功能,从而达到掌握开发一个小型数据库管理信息系统的目的。
-
- 设计内容
题目可根据自己熟悉的物品填充,例如图书进销存系统、电脑设备进销存系统、药品进销存系统等等,下面以超市进销存系统为例完成功能:
- 商品信息、供应商信息
- 商品进货、商品查询
以上功能可根据自己对不同物品主要的管理需求进行调整,可以增加或减少相应功能。
【需求分析】
对普通超市来讲,涉及原材料的进货渠道、销售情况及库存等方面的管理,管理的好与坏对超市的持久性至关重要。概括地说,用户对进销存系统的需求具有普遍性。超市进销存销售管理系统适用于超市采购、销售和仓库部门,对超市采购、销售及仓库的业务全过程进行有效控制和跟踪。使用超市进销存销售管理系统可有效减少盲目采购、降低采购成本、合理控制库存、减少资金占用并提高市场灵敏度,提升超市的市场竞争力。
【系统运行环境】
- 系统开发平台:Microsoft Visual Studio 2005
- 系统开发语言:C#
- 数据库管理软件:SQL Server 2005
- 运行平台:Win7
- 运行环境:Microsoft.NET Framework SDK v2.0
【系统设计】
超市进销存销售管理系统功能结构图:
超市进销存管理系统 |
销售管理 |
进货管理 |
库存管理 |
系统维护 |
基本档案 |
员工信息 |
供应商信息 |
商品进货 |
商品查询 |
商品销售 |
商品退货 |
库存警报 |
库存查询 |
数据备份 |
数据还原 |
系统业务流程图:
否 |
是 |
系统登 录 |
是否登录 |
系统主窗体 |
销售管理 |
进货管理 |
库存管理 |
系统维护 |
基本档案 |
【概念结构设计】
供应商信息实体E-R图:
供应商信息表 |
备注 |
地址 |
加入时间 |
传真 |
是否发布 |
供应商编号 |
供应商姓名 |
联系人姓名 |
联系电话 |
员工信息实体E-R图:
员工信息表 |
家庭电话 |
员工职位 |
手机号码 |
员工生日 |
是否发布 |
员工编号 |
员工姓名 |
登录密码 |
员工性别 |
所属部门 |
家庭住址 |
登录ID |
进货信息实体E-R图:
进货信息表 |
应付金额 |
销售单价 |
实付金额 |
商品数量 |
删除标记 |
操作员编号 |
员工姓名 |
库存名称 |
货物名称 |
进货单价 |
备注 |
进货公司名称 |
商品计量单位 |
进货时间 |
【逻辑结构设计】
根据设计好的E-R图在数据库中建立各表,系统数据库中各表的逻辑结构如下:
供应商信息表:
字段名 |
数据类型 |
长度 |
主键 |
描述 |
CompanyID |
varchar |
50 |
否 |
供应商编号 |
CompanyName |
nvarchar |
100 |
否 |
供应商姓名 |
CompanyDirector |
nvarchar |
50 |
否 |
联系人姓名 |
CompanyPhone |
nvarchar |
20 |
否 |
联系电话 |
CompanyFax |
nvarchar |
20 |
否 |
传真 |
CompanyAddress |
nvarchar |
200 |
否 |
地址 |
CompanyRemark |
nvarchar |
400 |
否 |
备注 |
ReDateTime |
datetime |
8 |
否 |
加入日期 |
Falg |
int |
4 |
否 |
是否发布 |
员工信息表:
字段名 |
数据类型 |
长度 |
主键 |
描述 |
EmpID |
nvarchar |
20 |
是 |
员工编号 |
EmpName |
nvarchar |
20 |
否 |
员工姓名 |
EmpLoginName |
nvarchar |
20 |
否 |
登录ID |
EmpLoginPwd |
nvarchar |
20 |
否 |
登录密码 |
EmpSex |
nvarchar |
4 |
否 |
员工性别 |
EmpBirthday |
datetime |
8 |
否 |
员工生日 |
EmpDept |
nvarchar |
20 |
否 |
所属部门 |
EmpPost |
nvarchar |
20 |
否 |
员工职位 |
EmpPhone |
nvarchar |
20 |
否 |
家庭电话 |
EmpPhoneM |
nvarchar |
20 |
否 |
手机号码 |
EmpAddress |
nvarchar |
200 |
否 |
家庭住址 |
EmpFalg |
int |
1 |
否 |
是否发布 |
进货信息表:
字段名 |
数据类型 |
长度 |
主键 |
描述 |
GoodsID |
nvarchar |
20 |
是 |
商品编号 |
EmpId |
nvarchar |
20 |
否 |
操作员编号 |
JhCompName |
nvarchar |
100 |
否 |
进货公司名称 |
DepotName |
nvarchar |
20 |
否 |
仓库名称 |
GoodsName |
nvarchar |
50 |
否 |
货物名称 |
GoodsNum |
int |
4 |
否 |
商品数量 |
GoodsUnit |
nvarchar |
20 |
否 |
商品计量单位 |
GoodsJhPrice |
nvarchar |
8 |
否 |
进货单价 |
GoodsSellPrice |
nvarchar |
8 |
否 |
销售单价 |
GoodsNeedPrice |
nvarchar |
8 |
否 |
应付金额 |
GoodsNoPrice |
nvarchar |
8 |
否 |
实付金额 |
GoodsRemark |
nvarchar |
200 |
否 |
备注 |
GoodTime |
datetime |
8 |
否 |
进货时间 |
Falg |
int |
4 |
否 |
删除标记 |
【窗体设计】
登录窗口:
主窗口:
员工基本信息窗体:
供应商信息窗体:
商品进货窗体:
商品查询窗体:
窗体顶端
【总结】
该系统是用C#完成的,实现的功能比较全面,界面美观。但是需要写太多代码,会遇到许多细节方面的问题(如:数据库的连接、类的使用、函数的使用等等)。还有很多地方有待完善。通过这次的学习设计,对数据库更加了解,还有很多不足的地方。对C#学的还不深,还要多学习,提高自己。
【主要代码设计】
【员工基本信息窗体】
1.通过对员工信息的录入,修改,删除,保存进行操作,在对员工的信息录入时候,员工姓名,登录名称和登录密码的相关操作是必须的 ,因为涉及到了下次登录时候身份的鉴定,相关代码如下:
public int getPan()
{
int intFalg1 = 0;
if (intFalg != 3)
{
if (txtEmpName.Text == "")
{
MessageBox.Show("员工姓名不能为空!", "提示");
txtEmpName.Focus();
return intFalg1;
}
if (txtEmpLoginName.Text == "")
{
MessageBox.Show("登录名称不能为空!", "提示");
return intFalg1;
}
if (intFalg != 2)
{
if (txtEmpLoginPwd.Text == "")
{
MessageBox.Show("登录密码不能为空!", "提示");
return intFalg1;
}
}
2.通过对员工的查询,可以知道员工的信息,查询可根据很多方面的信息而查到所向知道的员工的信息,所一就需要输入查询条件,根据查询条件而知道所向知道的信息,比如员工姓名,性别,所属部门,员工职位,姓名查询是最准确并且速度的方法,性别,所属部门,职位这些查询条件是比较含糊的查询,客户通过自己想要的方式查到员工的信息,相关的代码如下:
private void txtOK_Click(object sender, EventArgs e)
{
string P_Str_selectcondition = this.cbxCondition.Text;
//Items[this.cbxCondition.SelectedIndex].ToString();
if (P_Str_selectcondition == null)
{
MessageBox.Show("请选择查询条件!");
return;
}
if (this.txtKeyWord.Text == "")
{
MessageBox.Show("输入查询条件!");
return;
}
switch (P_Str_selectcondition)
{
case "员工姓名":
tbMenthod.tb_EmpInfoFind(txtKeyWord.Text,1,dataGridView1);
break;
case "员工性别":
tbMenthod.tb_EmpInfoFind(txtKeyWord.Text, 2, dataGridView1);
break;
case "所属部门":
tbMenthod.tb_EmpInfoFind(txtKeyWord.Text, 3, dataGridView1);
break;
case "员工职位":
tbMenthod.tb_EmpInfoFind(txtKeyWord.Text, 4, dataGridView1);
break;
default:
break;
}
}
如果客户 查询到员工的信息之后,想做一些的修改 删除,添加之类的修改,如果添加员工信息的话,则要录入新员工的详细信息,如修改的员工信息的话可根据某方面的信息进行相关的修该,如删除员工信息的话,则要对员工的信息进行全部的删除,并相应的保存到数据库里面,方便下次客户对员工的信息进行相关的操作,具体修改 ,删除,添加的操作代码如下:
private void toolSave_Click(object sender, EventArgs e)
{
if (getPan() == 1)
{
if (intFalg == 1)
{
if (tbMenthod.tb_EmpInfoFind(txtEmpLoginName.Text,"",1) == 1)
{
MessageBox.Show("登录名称已被占用!!");
txtEmpLoginName.Text = "";
txtEmpLoginName.Focus();
return;
}
if (tbMenthod.tb_EmpInfoAdd(EmpClass) == 1)
{
MessageBox.Show("添加成功");
intFalg = 0;
tbMenthod.tb_EmpInfoFind("", 5, dataGridView1);
ClearControls();
ControlStatus();
}
else
{
MessageBox.Show("添加成失败");
intFalg = 0;
//tbMenthod.tb_EmpInfoFind("2",dataGridView1);
ClearControls();
ControlStatus();
}
}
if (intFalg == 2)
{
if (tbMenthod.tb_EmpInfoUpdate(EmpClass)==1)
{
MessageBox.Show("修改成功");
intFalg = 0;
tbMenthod.tb_EmpInfoFind("", 5, dataGridView1);
ClearControls();
ControlStatus();
}
else
{
MessageBox.Show("修改成失败");
intFalg = 0;
//tbMenthod.tb_EmpInfoFind("2",dataGridView1);
ClearControls();
ControlStatus();
}
}
if (intFalg == 3)
{
if (tbMenthod.tb_EmpInfoDelete(EmpClass) == 1)
{
MessageBox.Show("删除成功");
intFalg = 0;
tbMenthod.tb_EmpInfoFind("", 5, dataGridView1);
ClearControls();
ControlStatus();
}
else
{
MessageBox.Show("删除失败");
intFalg = 0;
ClearControls();
ControlStatus();
}
}
}
}
【供应商信息窗体】
2对控件的清零状态,方便进行相关的操作,即信息初始化,代码如下:
private void ClearControls()
{
txtCompanyDirector.Text = "";
txtCompanyAddress.Text = "";
txtCompanyFax.Text = "";
txtCompanyName.Text = "";
txtCompanyPhone.Text = "";
txtCompanyRemark.Text = "";
}
2.1 通过对供应商的信息录入,并保存到数据库里面,此外应注意的是供应商的名称,联系电话,地址是必须的填写的,否则不不可以录入并进行相关操作的,如少填写一项,会弹出相应的对话框,代码如下:
public int GetCount()
{
int intReslult = 0;
if (intFalg == 1 || intFalg == 2)
{
if (txtCompanyName.Text == "")
{
MessageBox.Show("供应商名称不能为空!", "提示");
return intReslult;
}
if (txtCompanyPhone.Text == "")
{
MessageBox.Show("联系电话不能为空!", "提示");
return intReslult;
}
if (txtCompanyDirector.Text == "")
{
MessageBox.Show("地址不能为空!", "提示");
return intReslult;
}
2.2客户对相关的信息进行操作之后,需要保存到数据库,但是应注意的是相关的信息必须是准确的,避免下次信息调出的时候出现差错,因为数据库是共同享有的,所以必须保证供应商资料的准确性,通过保存之前的添加,修改,删除操作并保存到数据库的代码如下:
private void toolSave_Click(object sender, EventArgs e)
{
if (GetCount() == 1)
{
if (intFalg == 1)
{
if (CompanyMenthod.tb_CompanyMenthodAdd(Company) == 1)
{
if (intReturn == 1)
{
frmGonYingShang frmCop= (frmGonYingShang)this.Owner;
jhgood.filltProd(frmCop.treeView1,frmCop.imageList1);
ClearControls();
ControlStatus();
intFalg = 0;
this.Close();
}
MessageBox.Show("添加成功");
intFalg = 0;
CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
ClearControls();
ControlStatus();
}
else
{
MessageBox.Show("添加失败");
intFalg = 0;
CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
ClearControls();
ControlStatus();
}
}
if (intFalg == 2)
{
if (CompanyMenthod.tb_CompanyMenthodUpDate(Company) == 1)
{
MessageBox.Show("修改成功");
intFalg = 0;
CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
ClearControls();
ControlStatus();
}
else
{
MessageBox.Show("修改失败");
intFalg = 0;
CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
ClearControls();
ControlStatus();
}
}
if (intFalg ==3)
{
if (CompanyMenthod.tb_CompanyMenthodDelete(Company) == 1)
{
MessageBox.Show("删除成功");
intFalg = 0;
CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
ClearControls();
ControlStatus();
}
else
{
MessageBox.Show("删除失败");
intFalg = 0;
CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
ClearControls();
ControlStatus();
}
}
}
}
2.3客户对供应商的信息做好相关的操作之后,则方便其他客户对供应商的资料查询,可根据的供应商的名称,负责人姓名而知道所想知道的相关信息,相关的代码如下:
private void txtOK_Click(object sender, EventArgs e)
{
string P_Str_cmdtxt = String.Empty;
string P_Str_selectcondition = this.cbxCondition.Text;
if (P_Str_selectcondition == null)
{
MessageBox.Show("请选择查询条件!");
return;
}
if (this.txtKeyWord.Text == "")
{
MessageBox.Show("输入查询条件!");
return;
}
switch (P_Str_selectcondition)
{
case "供应商名称":
CompanyMenthod.tb_CompanyFind(txtKeyWord.Text,1,dataGridView1);
break;
case "负责人姓名":
CompanyMenthod.tb_CompanyFind(txtKeyWord.Text, 2, dataGridView1);
break;
default:
break;
}
}
【商品进货窗体】
3定义方法getIntCount(),用于获取表单的信息,在具体的实现上,将通过if语句验证各字段的输入的数据不为空,对应放入实现代码如下:
public int getIntCount()
{
int intReslut = 0;
if (intFalg == 1)
{
if (txtGoodsID.Text == "")
{
MessageBox.Show("商品编号不能为空!");
return intReslut;
}
if (txtGoodsName.Text == "")
{
MessageBox.Show("商品名称不能为空!");
return intReslut;
}
if (txtJhCompName.Text == "")
{
MessageBox.Show("供应商名称不能为空!");
return intReslut;
}
if (txtEmpId.Text == "")
{
MessageBox.Show("进货人姓名不能为空!");
return intReslut;
}
if (txtGoodsNum.Text == "")
{
MessageBox.Show("数量不能为空!");
return intReslut;
}
if (txtGoodsName.Text == "")
{
MessageBox.Show("进货单价不能为空!");
return intReslut;
}
}
if (intFalg == 2)
{
if (txtGoodsID.Text == "")
{
MessageBox.Show("商品编号不能为空!,选择要修改记录","提示");
return intReslut;
}
}
if (intFalg == 3)
{
if (txtGoodsID.Text == "")
{
MessageBox.Show("商品编号不能为空!,选择要删除记录", "提示");
return intReslut;
}
}
jhGood.strGoodsID = txtGoodsID.Text;
jhGood.strEmpId = txtEmpId.Text;
jhGood.strJhCompName = txtGoodsName.Text;
jhGood.strDepotName = cmbDepotName.Text;
jhGood.strGoodsNum = Convert.ToInt32(txtGoodsNum.Text);
jhGood.strGoodsName = txtGoodsName.Text;
jhGood.strGoodsUnit = cmbGoodsUnit.Text;
jhGood.deGoodsJhPrice = txtGoodsJhPrice.Text;
jhGood.deGoodsNeedPrice = txtGoodsNeedPrice.Text;
jhGood.deGoodsNoPrice = txtGoodsNoPrice.Text;
jhGood.deGoodsSellPrice = txtGoodsSellPrice.Text;
jhGood.strGoodsRemark = txtGoodsRemark.Text;
jhGood.DaGoodTime = dateTimePicker1.Value;
if (intFalg != 3)
{
jhGood.Falg = 0;
}
else
{
jhGood.Falg = 1;
}
intReslut = 1;
return intReslut;
}
3.1加载时显示所有的商品信息,将结果绑定到DataGirdView控件上,对应的实现代码如下:
private void frmJhGoodsInfo_Load(object sender, EventArgs e)
{
jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
}
3.2在上述代码中,通过调用方法FillControls()显示了单击新机的详细内容,方法FillControls()的具体实现代码如下:
private void FillControls()
{
try
{
SqlDataReader sqldr = jhMenthod.tb_JhGoodsInfoFind(this.dataGridView1[0, this.dataGridView1.CurrentCell.RowIndex].Value.ToString(),1);
sqldr.Read();
if (sqldr.HasRows)
{
txtEmpId.Text=sqldr[1].ToString();
txtGoodsName.Text=sqldr[4].ToString();
cmbDepotName.Text = sqldr[3].ToString();
txtGoodsNum.Text=sqldr[5].ToString();
cmbGoodsUnit.Text=sqldr[6].ToString();
txtGoodsJhPrice.Text=sqldr[7].ToString();
txtGoodsNeedPrice.Text=sqldr[9].ToString();
txtGoodsNoPrice.Text=sqldr[10].ToString();
txtGoodsSellPrice.Text=sqldr[8].ToString();
txtGoodsRemark.Text=sqldr[11].ToString();
txtJhCompName.Text = sqldr[2].ToString();
txtGoodsID.Text = sqldr[0].ToString();
txtGoodsID.Enabled = false;
}
}
catch (Exception ee)
{
MessageBox.Show(ee.ToString());
}
}
3.3单击【添加】按钮可以添加新的进货信息,单击【修改】按钮可以对进货信息进行修改,单击【保存】按钮后可以将修改后的内容进行保存,单击【删除】按钮,可以删除选择的进货信息,对应的实现代码如下:
private void toolSave_Click(object sender, EventArgs e)
{
if (getIntCount() == 1)
{
if (intFalg == 1)
{
if (jhMenthod.tb_JhGoodsInfoMenthodAdd(jhGood)==2)
{
MessageBox.Show("添加成功","提示");
intFalg = 0;
jhMenthod.tb_JhGoodsInfoFind("",5,dataGridView1);
ControlStatus();
ClearContorl();
}
else
{
MessageBox.Show("添加失败", "提示");
intFalg = 0;
jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
ControlStatus();
ClearContorl();
}
}
if (intFalg == 2)
{
if (jhMenthod.tb_JhGoodsInfoMenthodUpdate(jhGood)==1)
{
MessageBox.Show("修改成功", "提示");
intFalg = 0;
jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
ControlStatus();
ClearContorl();
}
else
{
MessageBox.Show("修改失败", "提示");
intFalg = 0;
jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
ControlStatus();
ClearContorl();
}
}
if (intFalg == 3)
{
if (jhMenthod.tb_JhGoodsInfoMenthodDelete(jhGood)==1)
{
MessageBox.Show("删除成功", "提示");
intFalg = 0;
jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
ControlStatus();
ClearContorl();
}
else
{
MessageBox.Show("删除失败", "提示");
intFalg = 0;
jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
ControlStatus();
ClearContorl();
}
}
}
}
3.4DataGirdView控件中的某些信息后,对应的各项信息会在对应的文本框中显示,对应的实现代码如下:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (intFalg == 2 || intFalg == 3)
{
FillControls();
}
}
private void txtGoodsJhPrice_TextChanged(object sender, EventArgs e)
{
if (txtGoodsNum.Text != "")
{
txtGoodsNeedPrice.Text = Convert.ToString(Convert.ToInt32(txtGoodsJhPrice.Text)*Convert.ToInt32(txtGoodsNum.Text));
}
}
private void txtGoodsSellPrice_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar)&&e.KeyChar!='.')
{
MessageBox.Show("请输入数字");
e.Handled = true;
}
}
private void txtGoodsNum_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
{
MessageBox.Show("请输入数字");
e.Handled = true;
}
}
private void txtGoodsJhPrice_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
MessageBox.Show("请输入数字");
e.Handled = true;
}
}
private void txtGoodsNoPrice_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
MessageBox.Show("请输入数字");
e.Handled = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
frmGonYingShang frmgong = new frmGonYingShang();
frmgong.Owner = this;
frmgong.ShowDialog();
}
private void tollDelete_Click(object sender, EventArgs e)
{
ControlStatus();
ClearContorl();
intFalg = 3;
}
}
}
【商品查询窗体】
private void button1_Click(object sender, EventArgs e)
{
if(comboBox1.Text=="")
{
MessageBox.Show("请选择查询条件!");
return;
}
if(comboBox1.Text!=""&&comboBox1.Text!="查询所有信息"&& textBox1.Text=="")
{
MessageBox.Show("请输入查查信息");
return;
}
switch (comboBox1.Text)
{
case "商品编号"://"商品编号":
jhMenthod.tb_JhGoodsInfoFind(textBox1.Text,1,dataGridView1);
comboBox1.SelectedIndex = 0;
break;
case "商品名称"://商品名称"
jhMenthod.tb_JhGoodsInfoFind(textBox1.Text, 2, dataGridView1);
comboBox1.SelectedIndex = 0;
break;
case "查询所有信息"://"所有信息":
jhMenthod.tb_JhGoodsInfoFind(textBox1.Text, 5, dataGridView1);
comboBox1.SelectedIndex = 0;
break;
}
}