管理信息系统ERP系统库存子系统设计课设代码(共15页).doc
精选优质文档-倾情为你奉上主界面程序using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using SJZU;namespace SJZU.SWEIMS.GUI.SWEIMS public partial class Frm_Main : Form public Frm_Main() InitializeComponent(); private void Frm_Main_Load(object sender, EventArgs e) toolStripStatusLabel6.Text = DateTime.Now.ToString(); private void 查询分析ToolStripMenuItem3_Click(object sender, EventArgs e) Frm_Warehouse_Query frm_Warehouse_Query = new Frm_Warehouse_Query(); frm_Warehouse_Query.ShowDialog(); private void 添加仓库信息ToolStripMenuItem_Click(object sender, EventArgs e) Frm_Warehouse_Add frm_Warehouse_Add = new Frm_Warehouse_Add(); frm_Warehouse_Add.ShowDialog(); private void 修改仓库信息ToolStripMenuItem_Click(object sender, EventArgs e) Frm_Warehouse_Update frm_Warehouse_Update = new Frm_Warehouse_Update(); frm_Warehouse_Update.ShowDialog(); private void 删除仓库信息ToolStripMenuItem_Click(object sender, EventArgs e) Frm_Warehouse_Delete frm_Warehouse_Delete = new Frm_Warehouse_Delete(); frm_Warehouse_Delete.ShowDialog(); 仓库信息添加界面using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using SJZU.SWEIMS.BusinessModel;using SJZU.SWEIMS.BusinessLogic;namespace SJZU.SWEIMS.GUI.SWEIMS public partial class Frm_Warehouse_Add : Form public Frm_Warehouse_Add() InitializeComponent(); private void Frm_Warehouse_Add_Load(object sender, EventArgs e) /添加按钮事件 private void btnAdd_Click(object sender, EventArgs e) if (string.IsNullOrEmpty(txtWarehouseCode.Text.Trim() MessageBox.Show("请将数据完整输入!", "提示", MessageBoxButtons.OK); else WarehouseManage warehouseManage = new WarehouseManage(); WarehouseTable warehouseTable = new WarehouseTable(); warehouseTable.WarehouseCode = (string)txtWarehouseCode.Text; warehouseTable.WarehouseName = (string)txtWarehouseName.Text; warehouseTable.Property = (string)txtProperty.Text; warehouseTable.Department = (string)txtDepartment.Text; warehouseTable.Address = (string)txtAddress.Text; warehouseTable.Tel = (string)txtTel.Text; warehouseTable.Director = (string)txtDirector.Text; warehouseTable.CreateBy = (string)txtCreateBy.Text; warehouseTable.CreateTime = int.Parse(dtpCreateTime.Value.ToString("yyyyMMdd"); warehouseTable.Summary = (string)txtSummary.Text; int i = warehouseManage.AddWarehouseTable(warehouseTable); if (i > 0) MessageBox.Show("已插入" + i + "条记录!", "提示", MessageBoxButtons.OK); else MessageBox.Show("插入失败!", "提示", MessageBoxButtons.OK); /取消按钮事件 private void btnCanel_Click(object sender, EventArgs e) txtWarehouseCode.Text = null; txtWarehouseName.Text = null; txtProperty.Text = null; txtDepartment.Text = null; txtAddress.Text = null; txtTel.Text = null; txtDirector.Text = null; txtCreateBy.Text = null; txtSummary.Text = null; /退出按钮事件 private void btnExit_Click(object sender, EventArgs e) this.Close(); 仓库信息删除界面using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using SJZU.SWEIMS.BusinessLogic;namespace SJZU.SWEIMS.GUI.SWEIMS public partial class Frm_Warehouse_Delete : Form public Frm_Warehouse_Delete() InitializeComponent(); /点开删除界面时,向下拉菜单中加载可选的仓库编号 private void Frm_Warehouse_Delete_Load(object sender, EventArgs e) AddWarehouseCode(); private void AddWarehouseCode() cboWarehouseCode.DataSource = new WarehouseManage().GetWarehouseCode(); cboWarehouseCode.DisplayMember = "WAREHOUSECODE" /查询选择的仓库信息 private void btnQuery_Click(object sender, EventArgs e) if (string.IsNullOrEmpty(cboWarehouseCode.Text) MessageBox.Show("请选择出库单编号!"); else dgvWarehouseDetails.DataSource = new WarehouseManage().GetWarehouseTable(cboWarehouseCode.Text); /删除选中的仓库 private void btnDelete_Click(object sender, EventArgs e) if (string.IsNullOrEmpty(cboWarehouseCode.Text) MessageBox.Show("请选择出库单编号!"); else int i = new WarehouseManage().DeleteWarehouse(cboWarehouseCode.Text); MessageBox.Show("已经删除"+i+"条记录!"); dgvWarehouseDetails.DataSource = null; AddWarehouseCode(); /点击退出,关闭窗口 private void btnExit_Click(object sender, EventArgs e) this.Close(); 仓库信息更新界面using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using SJZU.SWEIMS.BusinessModel;using SJZU.SWEIMS.BusinessLogic;using System.Data.SqlClient;using SJZU.SWEIMS.DBUtility;namespace SJZU.SWEIMS.GUI.SWEIMS public partial class Frm_Warehouse_Update : Form WarehouseManage warehouseManage = new WarehouseManage(); SqlDataAdapter adapter; DataTable table; public Frm_Warehouse_Update() InitializeComponent(); private void Frm_Warehouse_Update_Load(object sender, EventArgs e) cboWarehouseCode.DataSource = warehouseManage.GetWarehouseCode(); cboWarehouseCode.DisplayMember = "WAREHOUSECODE" /查询仓库信息 private void btnQuery_Click(object sender, EventArgs e) if (string.IsNullOrEmpty(cboWarehouseCode.Text) MessageBox.Show("请选择要查询的仓库编号!"); else string warehouseCode = cboWarehouseCode.Text; string strsql = "select * from WAREHOUSE where WAREHOUSECODE = " + warehouseCode; string connectionString = SQLHelper._connectionString; SqlConnection conn = new SqlConnection(connectionString); adapter = new SqlDataAdapter(strsql, conn); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); adapter.InsertCommand = builder.GetInsertCommand(); adapter.DeleteCommand = builder.GetDeleteCommand(); adapter.UpdateCommand = builder.GetUpdateCommand(); table = new DataTable(); adapter.Fill(table); dgvWarehouseDetails.DataSource = table; private void btnUpdate_Click(object sender, EventArgs e) dgvWarehouseDetails.EndEdit(); try adapter.Update(table); MessageBox.Show("保存成功!"); catch (SqlException err) MessageBox.Show(err.Message, "保存成功!"); private void btnExit_Click(object sender, EventArgs e) this.Close(); 仓库信息查询界面using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using SJZU.SWEIMS.BusinessModel;using SJZU.SWEIMS.BusinessLogic;namespace SJZU.SWEIMS.GUI.SWEIMS public partial class Frm_Warehouse_Query : Form public Frm_Warehouse_Query() InitializeComponent(); private void Frm_Warehouse_Query_Load(object sender, EventArgs e) /按选择的条件查询仓库信息 private void btnQuery_Click(object sender, EventArgs e) int startTime = int.Parse(dtpStart.Value.ToString("yyyyMMdd"); int endTime = int.Parse(dtpEnd.Value.ToString("yyyyMMdd"); if (startTime > endTime) MessageBox.Show("开始时间不能晚于结束时间!"); else /按时间查询,仓库编号和负责人都不是查询条件 if (cbWarehouseCode.Checked = false && cbDirector.Checked = false) dgvWarehouseDetails.DataSource = new WarehouseManage().GetWarehouseTable(startTime, endTime); /按时间和仓库编号查询 else if (cbWarehouseCode.Checked = true && cbDirector.Checked = false) string warehouseCode = txtWarehouseCode.Text; if (string.IsNullOrEmpty(warehouseCode.Trim() MessageBox.Show("请输入仓库编号!"); else dgvWarehouseDetails.DataSource = new WarehouseManage().GetWarehouseTable(startTime, endTime, warehouseCode); /按时间和负责人查询 else if (cbWarehouseCode.Checked = false && cbDirector.Checked = true) string director = txtDirector.Text; if (string.IsNullOrEmpty(director.Trim() MessageBox.Show("请输入负责人!"); else dgvWarehouseDetails.DataSource = new WarehouseManage().GetWarehouseTable(startTime, endTime, director,9); /按时间,仓库编号,负责人查询 else if (cbWarehouseCode.Checked = true && cbDirector.Checked = true) string warehouseCode = txtWarehouseCode.Text; string director = txtDirector.Text; if (string.IsNullOrEmpty(warehouseCode.Trim() | string.IsNullOrEmpty(director.Trim() MessageBox.Show("所选条件不能为空!"); else dgvWarehouseDetails.DataSource = new WarehouseManage().GetWarehouseTable(startTime, endTime, warehouseCode,director); private void btnExit_Click(object sender, EventArgs e) this.Close(); 逻辑层代码using System;using System.Collections.Generic;using System.Text;using System.Data.SqlClient;using SJZU.SWEIMS.DBUtility;using SJZU.SWEIMS.BusinessModel;using System.Data;namespace SJZU.SWEIMS.BusinessLogic public class WarehouseManage /向数据库WAREHOUSE表中添加仓库数据 public int AddWarehouseTable(WarehouseTable warehouseTable) string strsql = "insert into WAREHOUSE(WAREHOUSECODE," + "WAREHOUSENAME," + "PROPERTY," + "DEPARTMENT," + "ADDRESS," + "TEL," + "DIRECTOR," + "CREATEBY," + "CREATETIME," + "SUMMARY)" + "VALUES(WAREHOUSECODE," + "WAREHOUSENAME," + "PROPERTY," + "DEPARTMENT," + "ADDRESS," + "TEL," + "DIRECTOR," + "CREATEBY," + "CREATETIME," + "SUMMARY)" SqlParameter commandParms = new SqlParameter new SqlParameter("WAREHOUSECODE", warehouseTable.WarehouseCode), new SqlParameter("WAREHOUSENAME", warehouseTable.WarehouseName), new SqlParameter("PROPERTY", warehouseTable.Property) , new SqlParameter("DEPARTMENT", warehouseTable.Department), new SqlParameter("ADDRESS",warehouseTable.Address), new SqlParameter("TEL",warehouseTable.Tel), new SqlParameter("DIRECTOR", warehouseTable.Director), new SqlParameter("CREATEBY", warehouseTable.CreateBy), new SqlParameter("CREATETIME",warehouseTable.CreateTime), new SqlParameter("SUMMARY",warehouseTable.Summary); int i = SQLHelper.ExecuteSql(strsql,commandParms); return i; /取得仓库编号 public DataTable GetWarehouseCode() string strSql = "select WAREHOUSECODE from WAREHOUSE" return SQLHelper.Query(strSql).Tables0; /根据仓库编号查询仓库详细信息 public DataTable GetWarehouseTable(string warehouseCode) string strSql = "select * from WAREHOUSE where WAREHOUSECODE = WAREHOUSECODE" SqlParameter commandParms = new SqlParameter new SqlParameter("WAREHOUSECODE", warehouseCode) ; return SQLHelper.Query(strSql, commandParms).Tables0; /根据仓库编号删除仓库信息 public int DeleteWarehouse(string warehouseCode)