已阅读5页,还剩45页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
仓储管理系统代码【李彩享、字朝龙】一、窗体(frmLogin)登录的代码程序using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WMS public partial class frmLogin : Form public static string M_str_name; /记录登录用户名字 public static string M_str_pwd; /记录登录用户密码 public static string M_str_right; /记录登录用户的权限 public frmLogin() InitializeComponent(); private void frmLogin_Load(object sender, EventArgs e) /启动窗口时加载用户名 DbOperator db = new DbOperator(); SqlConnection cnn = db.GetCon(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = select UserName from tbUserInfo ; / cmd.Connection = cnn; cnn.Open(); SqlDataReader dr; dr = cmd.ExecuteReader(); if (dr.HasRows) while (dr.Read() cmbUserList.Items.Add(drUserName.ToString().Trim();/在控件中显示用户名 cmbUserList.Sorted=true; else MessageBox.Show(表中无记录!, 提示?, MessageBoxButtons.YesNo, MessageBoxIcon.Information); dr.Close(); cnn.Close(); private void btnCancel_Click(object sender, EventArgs e) if (MessageBox.Show(你确定要退出吗?, 提示?, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK) this.Close(); else cmbUserList.Focus(); return; private void btnLoad_Click(object sender, EventArgs e)/用存储过程实现验证登录 DbOperator db = new DbOperator(); SqlConnection cnn = db.GetCon(); SqlCommand cmd = new SqlCommand(); cmd.Connection = cnn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = proc_Login; SqlParameter paUser = new SqlParameter(); paUser.ParameterName = User_Name; paUser.SqlDbType = SqlDbType.VarChar; paUser.Size = 50; paUser.Value = cmbUserList.Text.Trim(); cmd.Parameters.Add(paUser); SqlParameter paPwd = new SqlParameter(); paPwd.ParameterName = User_Pwd; paPwd.SqlDbType = SqlDbType.VarChar; paPwd.Size = 20; paPwd.Value = txtPwd.Text.Trim(); cmd.Parameters .Add (paPwd ); SqlParameter paRe = new SqlParameter(); paRe.ParameterName = re; paRe.SqlDbType = SqlDbType.Int; paRe.Value = 0; paRe.Direction = System.Data.ParameterDirection.Output;/设置 cmd.Parameters.Add (paRe ); cnn.Open (); cmd.ExecuteNonQuery (); int Re = int.Parse(cmd.Parametersre.Value.ToString(); if (Re = 1) frmMain frm = new frmMain(); frm.Show(); else MessageBox.Show(用户名或密码错误!, 提示); cnn.Close(); private void cmbUserList_SelectedIndexChanged(object sender, EventArgs e) DbOperator db = new DbOperator(); SqlConnection cnn = db.GetCon(); SqlCommand cmd = new SqlCommand(); SqlDataReader sqlread = db.getread(select UserName,Power from tbUserInfo where UserName= + cmbUserList.Text.Trim ().ToString () + ); if (sqlread.Read() labPower.Text = sqlreadPower.ToString(); M_str_right = labPower.Text; sqlread.Close(); cnn.Close(); cnn.Dispose(); private void frmLogin_FormClosing(object sender, FormClosingEventArgs e) Application.Exit(); private void txtPwd_KeyPress(object sender, KeyPressEventArgs e) if (e.KeyChar = 13) btnLoad.Focus(); private void cboxUName_KeyPress(object sender, KeyPressEventArgs e) if (e.KeyChar = 13) txtPwd.Focus(); 二、主界面系统代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WMS public partial class frmMain : Form public frmMain() InitializeComponent(); private void 商品采购查选ToolStripMenuItem_Click(object sender, EventArgs e) frmGoodsCGSelect frm = new frmGoodsCGSelect(); frm.Show(); private void 退?出?系统3ToolStripMenuItem_Click(object sender, EventArgs e) if (MessageBox.Show(你确定要退出吗?, 提示, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK) this.Close(); private void 重新登录ToolStripMenuItem_Click(object sender, EventArgs e) frmLogin frm1 = new frmLogin(); frm1.ShowDialog(); private void 商品类别设置ToolStripMenuItem_Click(object sender, EventArgs e) frmGoodsClassSet frm2 = new frmGoodsClassSet(); frm2.Show(); private void 商品信息设置ToolStripMenuItem_Click(object sender, EventArgs e) frmGoodsInfo frm3 = new frmGoodsInfo(); frm3.Show(); private void 供应商设置ToolStripMenuItem_Click(object sender, EventArgs e) frmSupplierInfo frm4 = new frmSupplierInfo(); frm4.Show(); private void 仓库设置ToolStripMenuItem1_Click(object sender, EventArgs e) frmStoreInfo frm5 = new frmStoreInfo(); frm5.Show(); private void 库存盘点toolStripMenuItem23_Click(object sender, EventArgs e) frmKCPD frm6 = new frmKCPD(); frm6.Show(); private void 采购入库atoolStripMenuItem20_Click(object sender, EventArgs e) frmCGRK frm = new frmCGRK(); frm.Show(); private void toolStripMenuItem12_Click(object sender, EventArgs e) frmGoodsInfo frm = new frmGoodsInfo(); frm.Text = 商品信息查询; frm.ShowDialog(); private void toolStripMenuItem22_Click(object sender, EventArgs e) frmCKGL frm = new frmCKGL(); frm.Show(); private void toolStripMenuItem8_Click(object sender, EventArgs e) frmGoodsCGSelect frm = new frmGoodsCGSelect(); frm.Text = 商品采购统计; frm.Show(); private void toolStripMenuItem15_Click(object sender, EventArgs e) frmGoodsInfo frm = new frmGoodsInfo(); frm.Text = 当前库存查询; frm.Show(); private void 更改密码ToolStripMenuItem_Click(object sender, EventArgs e) frmSetUser frm = new frmSetUser(); frm.Show(); private void 权限管理ToolStripMenuItem_Click(object sender, EventArgs e) frmSetUsers frm = new frmSetUsers(); frm.Show(); private void 用户管理ToolStripMenuItem_Click(object sender, EventArgs e) frmSetUsers frm = new frmSetUsers(); frm.Show(); private void toolStripMenuItem9_Click(object sender, EventArgs e) frmSelectSupplier frm = new frmSelectSupplier(); frm.Show(); 三、商品类别设置代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WMS public partial class frmGoodsClassSet : Form public frmGoodsClassSet() InitializeComponent(); private void frmGoodsClassSet_Load(object sender, EventArgs e) LoadGC(); grpbClass.Enabled = false; private void dgvGClass_CellClick(object sender, DataGridViewCellEventArgs e) ShowGC(); private void LoadGC()/将客户表显示在DataGridView中 DbOperator clsC = new DbOperator(); SqlConnection cnn = clsC.GetCon(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = select ClassID as 类别编号,ClassName as 类别名称,ClassUnit as 参考单位, + KCSX as 库存上限,KCXX as 库存下限 from tbGoodsClass; cmd.CommandType = CommandType.Text; cmd.Connection = cnn; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds,tbGoods); dgvGClass.DataSource = ds; dgvGClass.DataSource = ds.Tables0; dgvGClass.Columns0.Visible = true ;/隐藏ID列 da.Dispose(); cmd.Dispose(); cnn.Dispose(); private void ShowGC() if (dgvGClass.RowsdgvGClass.CurrentCell.RowIndex.Cells0.Value.ToString() != ) txtGoodsClassID.Text = dgvGClass.RowsdgvGClass.CurrentCell.RowIndex.Cells0.Value.ToString();txtClassName.Text = dgvGClass.RowsdgvGClass.CurrentCell.RowIndex.Cells1.Value.ToString(); txtClassUnit.Text = dgvGClass.RowsdgvGClass.CurrentCell.RowIndex.Cells2.Value.ToString(); txtKCSX.Text = dgvGClass.RowsdgvGClass.CurrentCell.RowIndex.Cells3.Value.ToString();txtKCXX.Text = dgvGClass.RowsdgvGClass.CurrentCell.RowIndex.Cells4.Value.ToString(); private void OperateRecord(string sSQL)/记录的添加、修改、删除 DbOperator clsC = new DbOperator(); SqlConnection cnn = clsC.GetCon(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = sSQL; cmd.CommandType = CommandType.Text; cmd.Connection = cnn; cnn.Open(); cmd.ExecuteNonQuery(); cnn.Close(); cnn.Dispose(); cmd.Dispose(); private void btnClear_Click(object sender, EventArgs e)/清空文本框 txtGoodsClassID.Text = ; txtClassName.Text = ; txtClassUnit.Text = ; txtKCSX.Text = ; txtKCXX.Text = ; txtGoodsClassID.Focus(); private void btnExit_Click(object sender, EventArgs e)/退出按钮 if (MessageBox.Show(你确定要退出吗? , 提示, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK) this.Close(); private void btnAdd_Click(object sender, EventArgs e)/实现添加功能 if (btnAdd.Text = 添加)/单击添加 grpbClass.Enabled = true;/允许编辑 btnAdd.Text = 保存; btnXG.Enabled = false; btnDelete.Enabled = false; btnReturn.Enabled = true ; txtGoodsClassID.Text = ; txtClassName.Text = ; txtClassUnit.Text = ; txtKCSX.Text = ; txtKCXX.Text = ; txtGoodsClassID.Focus(); else/单击保存 string s = Insert Into tbGoodsClass(ClassID,ClassName,ClassUnit,KCSX,KCXX) Values; s += ( + txtGoodsClassID.Text.Trim() + , + txtClassName.Text.Trim() + , + txtClassUnit.Text.Trim() + , + txtKCSX.Text.Trim() + , + txtKCXX.Text.Trim() + ); OperateRecord(s); grpbClass.Enabled = false; btnAdd.Text = 添加; btnXG.Enabled = true; btnDelete.Enabled = true; btnReturn.Enabled = true; LoadGC(); private void btnDelete_Click(object sender, EventArgs e)/实现删功能 if (txtGoodsClassID.Text != ) if (MessageBox.Show(您确实要删除 + txtClassName.Text + 的类别吗?, 删除类别, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = = DialogResult.Yes) string s = Delete from tbGoodsClass where ClassID= + txtGoodsClassID.Text + ; OperateRecord(s); LoadGC();/重新加载客户表 else MessageBox.Show(您未选中要删除的商品类别! , 错误, MessageBoxButtons.OK, MessageBoxIcon.Error); private void btnXG_Click(object sender, EventArgs e) if (btnXG.Text = 修T改?)/单击修改 grpbClass.Enabled = true;/允许编辑 btnXG.Text = 保存; btnAdd.Enabled = false; btnDelete.Enabled = false; btnReturn.Enabled = false; txtGoodsClassID.Enabled = false; txtClassName.Focus(); else/单击保存 string s = Update tbGoodsClass SET ; s += ClassName= + txtClassName.Text.Trim() + ,ClassUnit= + txtClassUnit.Text.Trim() + ,KCSX= + txtKCSX.Text.Trim() + ,KCXX= + txtKCXX.Text.Trim() + ; s += where ClassID= + txtGoodsClassID. Text + ; OperateRecord(s); grpbClass.Enabled = false; btnXG.Text = 修改; btnAdd.Enabled = true; btnDelete.Enabled = true; btnReturn.Enabled = true; txtGoodsClassID. Enabled = true; LoadGC();/重新加载客户表 四、商品信息using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WMS public partial class frmGoodsInfo : Form public frmGoodsInfo() InitializeComponent(); private void btnQuit_Click(object sender, EventArgs e) if (MessageBox.Show(你确定要退出吗?, 提示, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK) this.Close(); private void ShowDGV() DbOperator db = new DbOperator(); SqlConnection cnn = db.GetCon(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = select GoodsID as 商品编号,GoodsName as 商品名称, ClassID as 类别编号,StoreID as 仓库编号,GPrice as 单价,+ GoodsUnit as 单位,KCNum as 库存数量,KCSX as 库存上限T,KCXX as 库存下限,Availabe as 是否可用,BZ as 备注 from tbGoodsInfo; /cmd.CommandText = select * from tbGoodsInfo; cmd.CommandType = CommandType.Text; cmd.Connection = cnn; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds); /dgvGoodsInfo.DataSource = ds; dgvGoodsInfo.DataSource = ds.Tables0; dgvGoodsInfo.Columns0.Visible = true;/隐藏ID列 da.Dispose(); cmd.Dispose(); cnn.Dispose(); private void btnAdd_Click(object sender, EventArgs e) frmGoodsInfoSet frm = new frmGoodsInfoSet(); frm.Show(); private void btnGSelect_Click(object sender, EventArgs e) if (btnGSelect.Text = 查 询) dgvGoodsInfo.ClearSelection(); DbOperator dbo = new DbOperator(); SqlConnection con = dbo.GetCon(); SqlCommand com = new SqlCommand(); com.CommandType = CommandType.Text; com.CommandText = select GoodsID as 商品编号,GoodsName as 商品名称, + ClassID as 类别编号,StoreID as 仓库编号,GPrice as 单价, GoodsUnit as 单位, +KCNum as 库存数量,KCSX as 库存上限,KCXX as 库存下限,Availabe as 是否可用, +BZ as 备注 from tbGoodsInfo where GoodsID LIKE % + txtGSelect.Text + % OR GoodsName LIKE % + txtGSelect.Text + % OR ClassID LIKE % + txtGSelect.Text + % OR StoreID LIKE % + txtGSelect.Text + %; com.CommandType = CommandType.Text; com.Connection = con; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = com; DataSet ds = new DataSet(); da.Fill(ds, tbg); /dgvGoodsInfo.DataSource = ds; dgvGoodsInfo.ClearSelection(); dgvGoodsInfo.DataSource = ds.Tables0; dgvGoodsInfo.Columns0.Visible = true;/隐藏ID列 da.Dispose(); com.Dispose(); con.Dispose(); private void frmGoodsInfo_Load_1(object sender, EventArgs e) Sho
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论