本文共 14308 字,大约阅读时间需要 47 分钟。
超市进销存管理系统(C#+SQL Server实现)窗体应用、数据库应用,设计模式
目录
期末大作业纷涌而来,长时间没有更新博客,更新一个SQL server的大作业,使用C#实现超市进销存管理系统,对数据库进行概念设计、逻辑设计、物理设计以及实现,确定需求目标,画出程序结构图,写出数据字典以及数据流程图,分析各实体集的属性及其之间的关系,系统实现。
超市管理系统是一个典型的进销存管理系统,其旨在解决超市商品的采购、销售、仓储等一系列操作流程中的数据信息的处理问题,提供一系列的数据分析 ,帮助经营者合理的调整各个经营运作环节的运作节奏,并对商品流转过程进行了全程跟踪管理、相应款项流通的全程记录管理和票据信息统计的管理。因此超市进销存管理系统的全面应用,规范业务流程、提高了超市的管理水平,提高资金流动的透明度,加快商品资金周转速度,进而全面提高了超市的经营水平、进而全面提升了超市的经济效益。
超市管理系统采用. NET技术和大型数据库SQL Server 2016 开发,主要是处理超市商品的采购、库存和销售各个环节的活动,具有良好的人机界面;考虑到系统的使用对象可能较多,权限管理良好;数据查询方便,支持多条件查询;系统支持良好的数据备份和还原操作,有效保护数据,减少意外损失;在相应的权限下,可方便地删除数据;数据计算自动完成,尽量减少人工干预。
设计环境及开发工具:
操作系统: Windows 10。
数据库管理系统:选用Mircrosoft 公司的Sql Server 2016数据库管理系统。
开发工具:选用visual studio 2019
需求分析
超市管理是多数大型超市日常经营管理中十分重要的一个组成部分,传统的手工管理方式呈现出越来越多的弊端。在手工管理模式下,统计,汇总处理时的工作量极其繁重,处理效率非常低,领导也无法及时了解超市资金占用的实际状况。通过系统管理,企业可以直观分析超市的情况,提高超市的竞争能力。
通过资料与实际调查,要求本系统具有以下功能。
1.具有良好的人机界面。
2.如果系统的使用对象较多, 则要求有良好的权限管理。
3.方便的数据查询,支持多条件查询。
4.系统支持良好的数据备份和还原操作,有效保护数据,减少意外损失。
5.在相应的权限下,可方便地删除数据。
6.数据计算自动完成, 尽量减少人工干预。
7.销售情况打印功能。
8.动态查询
系统设计
超市管理系统主要由基本信息管理、进货管理、销售管理、库存管理、系统维护等模块组成,具体规划如下:
基本信息管理模块。基本信息管理模块主要用于实现系统基本数据的录入。
进货管理模块。 该模块主要用于实现商品的进货数据录入、退货数据录入和进货查询分析。
销售管理模块。该模块主要用于实现商品的销售数据录入、客户退货数据录入和销售信息查询。
库存管理模块。库存管理模块主要用于实现库存调拨、库存商品数量上限报警和库存数据查询。
系统维护模块。系统维护模块用于实现系统用户设置、操作权限设置、密码修改、数据备份和数据恢复。
数据流图及程序结构框图
数据库概念结构设计
本系统后台数据库中的数据表有:
tb_Company(公司基本信息表)
tb_Customer(会员基本信息表)
tb_Department(部门基本信息表)
tb_Depot(仓库类别信息表)
tb_Goods(商品进货信息表)
tb_Popedom(系统权限信息表)
tb_Post(员工职位表)
tb_ReGoods(商品退货信息表)
tb_Sell(商品销售信息表)
tb_Stock(库存信息表)
tb_StockTemp(库存调拨信息表)
tb_Unit(商品信息表)
tb_User(员工基本信息表)
数据库逻辑结构设计
实体集:
商品信息实体、员工信息实体、退货商品实体、商品销售实体、商品库存实体,商品调拨信息实体
实体属性:
商品信息实体:商品进货ID,进货员工ID,进货公司,仓库类别,商品名称,进货数量,进货时间,进货价格,销售价格
员工信息实体:员工姓名,员工性别,系统登陆名,系统登陆密码,所在部门,员工职位,
家庭住址,家庭电话,联系电话
退货商品实体:退货商品ID,商品名称,客户ID,公司名称,仓库名称,退货时间,退货数量,退货原因
商品销售实体:销售ID,商品ID,销售数量,商品规格,销售价格,应付金额,实付金额
商品库存实体:库存ID,商品ID,库存名称,商品名称,库存数量,报警数量,应付金额,实付金额
商品调拨信息实体:调拨ID,操作员ID,商品ID,商品名称,调出仓库,调入仓库,调动数量
数据库物理结构设计
部分表如下:
系统实现(C#语言)
部分窗体及代码如下:
public partial class Login : Form{ SqlBaseClass G_SqlExecute = new SqlBaseClass(); //声明类对象 PropertyClass G_Property = new PropertyClass(); WinOperationClass G_WinFormClass = new WinOperationClass(); private void Login_Load(object sender, EventArgs e){ string cmdtxt = "SELECT DISTINCT SysUserSort FROM tb_Popedom"; this.cbxDegree.BeginUpdate(); this.cbxDegree.DataSource = G_SqlExecute.GetDs(cmdtxt).Tables[0]; this.cbxDegree.DisplayMember = "SysUserSort"; this.cbxDegree.ValueMember = "SysUserSort"; this.cbxDegree.EndUpdate();} private void btnOK_Click_1(object sender, EventArgs e){ if (this.txtUid.Text.Length == 0) {this.errAllInfo.SetError(this.txtUid, "用户名不能为空!");} if (this.txtPwd.Text.Length < 6){this.errAllInfo.SetError(this.txtPwd, "密码不能小于6位!");} string cmdtxt = "SELECT UserID,SysLoginName,Pwd,SysUserSort,PopedomID FROM v_UserView WHERE SysLoginName='" + this.txtUid.Text.Trim() + "'"+ "AND Pwd='" + this.txtPwd.Text.Trim() + "' AND SysUserSort='" + this.cbxDegree.SelectedValue.ToString() + "'"; SqlDataReader P_dr = G_SqlExecute.GetReader(cmdtxt); P_dr.Read(); if (P_dr.HasRows){ AppMain AppForm = new AppMain(); this.Hide(); PropertyClass.SendNameValue = this.txtUid.Text; PropertyClass.SendPopedomValue = P_dr["PopedomID"].ToString(); PropertyClass.SendUserIDValue = P_dr["UserID"].ToString(); PropertyClass.SavePassword = P_dr["Pwd"].ToString(); AppForm.Show();} else{ MessageBox.Show("用户名、密码或身份不正确!", "登录提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); P_dr.Close();} P_dr.Close();} private void btnCancel_Click(object sender, EventArgs e) { this.Close(); }}
public partial class AppMain : Form { SqlBaseClass G_SqlClass = new SqlBaseClass(); // 根据用户权限分配显示菜单 public void MenuIsVisible() { ArrayList arylst = new ArrayList(); ToolStripMenuItem[] menu = new ToolStripMenuItem[] {this.menuEmployee,this.menuCompany,this.menuCustomer,this.menuGoodsIn,this.menuGoodsOut,this.menuSellGoods,this.menuGoodsBack,this.menuDepotChange,this.menuDepotAlarm,this.menuSysUser,this.menuPopedomSet,this.menuDatabak,this.menuReBakData}; DataSet P_ds = G_SqlClass.GetDs("SELECT * FROM v_UserView WHERE SysLoginName = '"+ PropertyClass.SendNameValue+"'"); for (int i = 0; i < 13; i++) { arylst.Add(P_ds.Tables[0].Rows[0][14+i].ToString()); } for (int j = 0; j < arylst.Count; j++) { if (arylst[j].ToString() == "False") { menu[j].Visible = false; } else { menu[j].Visible = true; } } } private void timer1_Tick(object sender, EventArgs e) { this.statusTime.Text = "当前时间:" + DateTime.Now.ToString(); } private void AppMain_Load(object sender, EventArgs e) { this.timer1.Start(); this.statusUser.Text = "系统操作员:"+PropertyClass.SendNameValue; MenuIsVisible(); } private void Menu_Click(object sender, EventArgs e) { WinOperationClass P_Menu = new WinOperationClass(); P_Menu.ShowForm((ToolStripMenuItem)sender, this); } private void AppMain_FormClosed_1(object sender, FormClosedEventArgs e) { if (MessageBox.Show("确定要退出吗?", "提示对话框", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Application.Exit(); this.Dispose(); } else { AppMain app = new AppMain(); app.Show(); } }}
public partial class CompanyInfo : Form { SqlBaseClass G_SqlClass = new SqlBaseClass(); //声明数据库操作类的对象 WinOperationClass G_OperationForm = new WinOperationClass(); int G_Int_status; //保存操作按钮数据 private void ControlStatus() { this.toolSave.Enabled = !this.toolSave.Enabled; this.toolAdd.Enabled = !this.toolAdd.Enabled; this.toolCancel.Enabled = !this.toolCancel.Enabled; this.toolAmend.Enabled = !this.toolAmend.Enabled; this.txtAddress.ReadOnly = !this.txtAddress.ReadOnly; this.txtCompanyName.ReadOnly = !this.txtCompanyName.ReadOnly; this.txtDirector.ReadOnly = !this.txtDirector.ReadOnly; this.txtFax.ReadOnly = !this.txtFax.ReadOnly; this.txtPhone.ReadOnly = !this.txtPhone.ReadOnly; this.txtRemark.ReadOnly = !this.txtRemark.ReadOnly; } private void FillControls() { try { this.txtCompanyName.Text = this.dgvCompanyInfo[1, this.dgvCompanyInfo.CurrentCell.RowIndex].Value.ToString(); this.txtDirector.Text = this.dgvCompanyInfo[2, this.dgvCompanyInfo.CurrentCell.RowIndex].Value.ToString(); this.txtFax.Text = this.dgvCompanyInfo[4, this.dgvCompanyInfo.CurrentCell.RowIndex].Value.ToString(); this.txtPhone.Text = this.dgvCompanyInfo[3, this.dgvCompanyInfo.CurrentCell.RowIndex].Value.ToString(); this.txtRemark.Text = this.dgvCompanyInfo[6, this.dgvCompanyInfo.CurrentCell.RowIndex].Value.ToString(); this.txtAddress.Text = this.dgvCompanyInfo[5, this.dgvCompanyInfo.CurrentCell.RowIndex].Value.ToString(); } catch { } } private void ClearControls() { this.txtAddress.Text = ""; this.txtCompanyName.Text = ""; this.txtDirector.Text = ""; this.txtFax.Text = ""; this.txtPhone.Text = ""; this.txtRemark.Text = ""; } private void CompanyInfo_Load(object sender, EventArgs e) { string cmdtxt = "SELECT CompanyID as 供应商ID,CompanyName as 供应商名称,CompanyDirector as 供应商主管,CompanyPhone as 供应商电话"; cmdtxt += ",CompanyFax as 供应商传真,CompanyAddress as 供应商地址,CompanyRemark as 备注 FROM tb_Company"; this.dgvCompanyInfo.DataSource = G_SqlClass.GetDs(cmdtxt).Tables[0]; this.cbxCondition.SelectedIndex = 0; this.dgvCompanyInfo.Columns[0].Visible = false; } private void toolSave_Click(object sender, EventArgs e) { string P_Str_condition, P_Str_cmdtxt; switch (G_Int_status) { case 1: //下面是要执行的SQL语句 P_Str_cmdtxt = "INSERT INTO tb_Company(CompanyName,CompanyDirector,CompanyPhone,CompanyFax,CompanyAddress,CompanyRemark)"; P_Str_cmdtxt += " VALUES('" + this.txtCompanyName.Text + "','" + this.txtDirector.Text + "','" + this.txtPhone.Text + "'"; P_Str_cmdtxt += ",'" + this.txtFax.Text + "','" + this.txtAddress.Text + "','" + this.txtRemark.Text + "')"; if (this.txtCompanyName.Text == "") { MessageBox.Show("供应商名称不能为空!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { //执行SQL语句并返回执行结果 if (G_SqlClass.GetExecute(P_Str_cmdtxt)) { MessageBox.Show("数据添加成功!"); ControlStatus(); } else { MessageBox.Show("数据添加失败!"); } } break; case 2: P_Str_condition = this.dgvCompanyInfo[0, this.dgvCompanyInfo.CurrentCell.RowIndex].Value.ToString(); P_Str_cmdtxt = "UPDATE tb_Company SET CompanyName='" + this.txtCompanyName.Text + "',CompanyDirector='" + this.txtDirector.Text + "'"; P_Str_cmdtxt += ",CompanyPhone='" + this.txtPhone.Text + "',CompanyFax='" + this.txtFax.Text + "'"; P_Str_cmdtxt += ",CompanyAddress='" + this.txtAddress.Text + "',CompanyRemark='" + this.txtRemark.Text + "'"; P_Str_cmdtxt += " WHERE CompanyID=" + P_Str_condition + ""; if (G_SqlClass.GetExecute(P_Str_cmdtxt)) { MessageBox.Show("数据修改成功!"); ControlStatus(); } else { MessageBox.Show("数据修改失败!"); } break; default: break; //绑定数据显示控件 } string cmdtxt = "SELECT CompanyID as 供应商ID,CompanyName as 供应商名称,CompanyDirector as 供应商主管,CompanyPhone as 供应商电话"; cmdtxt += ",CompanyFax as 供应商传真,CompanyAddress as 供应商地址,CompanyRemark as 备注 FROM tb_Company"; this.dgvCompanyInfo.DataSource = G_SqlClass.GetDs(cmdtxt).Tables[0]; } private void toolCancel_Click(object sender, EventArgs e) { ControlStatus(); ClearControls(); } private void toolAdd_Click(object sender, EventArgs e) { ControlStatus(); ClearControls(); G_Int_status = 1; } private void toolAmend_Click(object sender, EventArgs e) { ControlStatus(); G_Int_status = 2; } private void toolDelete_Click(object sender, EventArgs e) { string P_Str_condition = this.dgvCompanyInfo[0, this.dgvCompanyInfo.CurrentCell.RowIndex].Value.ToString(); string P_Str_cmdtxt = "DELETE FROM tb_Company WHERE CompanyID=" + P_Str_condition + ""; if (G_SqlClass.GetExecute(P_Str_cmdtxt)) { MessageBox.Show("数据删除成功!"); } else { MessageBox.Show("数据删除失败!"); } string cmdtxt = "SELECT CompanyID as 供应商ID,CompanyName as 供应商名称,CompanyDirector as 供应商主管,CompanyPhone as 供应商电话"; cmdtxt += ",CompanyFax as 供应商传真,CompanyAddress as 供应商地址,CompanyRemark as 备注 FROM tb_Company"; this.dgvCompanyInfo.DataSource = G_SqlClass.GetDs(cmdtxt).Tables[0]; } private void toolreflush_Click(object sender, EventArgs e) { string P_Str_cmdtxt = "SELECT CompanyID as 供应商ID,CompanyName as 供应商名称,CompanyDirector as 供应商主管,CompanyPhone as 供应商电话"; P_Str_cmdtxt += ",CompanyFax as 供应商传真,CompanyAddress as 供应商地址,CompanyRemark as 备注 FROM tb_Company"; this.dgvCompanyInfo.DataSource = G_SqlClass.GetDs(P_Str_cmdtxt).Tables[0]; } private void txtOK_Click(object sender, EventArgs e) { string P_Str_cmdtxt = String.Empty; string P_Str_selectcondition = this.cbxCondition.Items[this.cbxCondition.SelectedIndex].ToString(); switch (P_Str_selectcondition) { case "供应商名称": P_Str_cmdtxt = "SELECT CompanyID as 供应商ID,CompanyName as 供应商名称,CompanyDirector as 供应商主管,CompanyPhone as 供应商电话"; P_Str_cmdtxt += ",CompanyFax as 供应商传真,CompanyAddress as 供应商地址,CompanyRemark as 备注 FROM tb_Company "; P_Str_cmdtxt += " WHERE CompanyName LIKE '%" + this.txtKeyWord.Text + "%'"; this.dgvCompanyInfo.DataSource = G_SqlClass.GetDs(P_Str_cmdtxt).Tables[0]; break; case "供应商主管": P_Str_cmdtxt = "SELECT CompanyID as 供应商ID,CompanyName as 供应商名称,CompanyDirector as 供应商主管,CompanyPhone as 供应商电话"; P_Str_cmdtxt += ",CompanyFax as 供应商传真,CompanyAddress as 供应商地址,CompanyRemark as 备注 FROM tb_Company "; P_Str_cmdtxt += " WHERE CompanyDirector LIKE '%" + this.txtKeyWord.Text + "%'"; this.dgvCompanyInfo.DataSource = G_SqlClass.GetDs(P_Str_cmdtxt).Tables[0]; break; default: break; } }
最后生成可执行的安装包程序
从设计之初到完成,看似庞大的任务细分每一项,克服当中的困难,是非常有收获的!
完整程序可私信交流。
转载地址:https://blog.csdn.net/Zzehao11/article/details/107138568 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!