1、仓库管理信息系统目 录一、功效模块图3二、登陆3三、主界面 5四、对仓库进行管理 81、库存查询 82、货物入库 93、删除产品信息 114、修改产品信息 13五、用户管理151、添加用户152、查看用户163、修改用户密码 18六、总结 20一、功效模块图登陆对仓库进行管理管理人员信息管理修改密码查询产品信息删除修改信息添加产品查看管理员添加管理员二、登陆实习代码以下:namespace 仓库信息管理系统1 public partial class Login : Form public Login() InitializeComponent(); private void btLogin_
2、Click(object sender, EventArgs e) string username = 用户名.Text.Trim(); /取出账号 string pw = 密码.Text.Trim(); /取出密码 string constr = data source=(local); + Initial Catalog=仓库管理信息系统; + Integrated Security=SSPI; /设置连接字符串 SqlConnection mycon = new SqlConnection(constr); /实例化连接对象 SqlCommand mycom = mycon.Create
3、Command(); /创建SQL命令实施对象 string s1 = select UserName,UserRight from Userinfo where UserName= + username + and UserRight= + pw + ; /编写SQL命令 mycom.CommandText = s1; /实施SQL命令 SqlDataAdapter myDA = new SqlDataAdapter(); /实例化数据适配器 myDA.SelectCommand = mycom; /让适配器实施SELECT命令 DataSet myDS = new DataSet(); /
4、实例化结果数据集 int n = myDA.Fill(myDS, Userinfo); /将结果放入数据适配器,返回元祖个数 if (n != 0) MessageBox.Show(欢迎使用!); /登录成功 Main main = new Main(); this.Hide(); main.Show(); else MessageBox.Show(用户名或密码有错。请重新输入!); 用户名.Text = ; /清空账号 密码.Text = ; /清空密码? 用户名.Focus(); /光标括设置在账号上 private void btExit_Click(object sender, Eve
5、ntArgs e) if (MessageBox.Show(您真要退出本系统吗?, 提醒, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = DialogResult.OK) Application.Exit(); else this.btLogin.Enabled = true; this.Hide(); Login login = new Login(); login.Show(); 三、主界面实现代码以下:namespace 仓库信息管理系统1 public partial class Main : Form privat
6、e int childFormNumber = 0; public Main() InitializeComponent(); private void ShowNewForm(object sender, EventArgs e) Form childForm = new Form(); childForm.MdiParent = this; childForm.Text = 窗口 + childFormNumber+; childForm.Show(); private void OpenFile(object sender, EventArgs e) OpenFileDialog ope
7、nFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = 文本文件(*.txt)|*.txt|全部文件(*.*)|*.*; if (openFileDialog.ShowDialog(this) = DialogResult.OK) string FileName = openFileDialog.FileName; private void
8、 SaveAsToolStripMenuItem_Click(object sender, EventArgs e) SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); saveFileDialog.Filter = 文本文件(*.txt)|*.txt|全部文件(*.*)|*.*; if (saveFileDialog.ShowDialog(thi
9、s) = DialogResult.OK) string FileName = saveFileDialog.FileName; private void ExitToolsStripMenuItem_Click(object sender, EventArgs e) this.Close(); private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.Cascade); private void TileVerticalToolStripMenuItem_Click(
10、object sender, EventArgs e) LayoutMdi(MdiLayout.TileVertical); private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.TileHorizontal); private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.ArrangeIcons); private v
11、oid CloseAllToolStripMenuItem_Click(object sender, EventArgs e) foreach (Form childForm in MdiChildren) childForm.Close(); private void 供货商设置ToolStripMenuItem_Click(object sender, EventArgs e) private void 库存查询ToolStripMenuItem_Click(object sender, EventArgs e) 库存查询 btLook = new 库存查询(); btLook.ShowD
12、ialog(); private void 货物入库ToolStripMenuItem_Click(object sender, EventArgs e) 修改产品信息 RK=new 修改产品信息(); RK.ShowDialog(); private void 删除产品信息ToolStripMenuItem_Click(object sender, EventArgs e) 删除 SC = new 删除(); SC.ShowDialog(); private void 修改产品信息ToolStripMenuItem_Click(object sender, EventArgs e) 修改cs
13、 XG = new 修改cs(); XG.ShowDialog(); private void 添加用户ToolStripMenuItem_Click(object sender, EventArgs e) 添加U TJU = new 添加U(); TJU.ShowDialog(); private void 查看用户ToolStripMenuItem_Click(object sender, EventArgs e) 查看U CKU = new 查看U(); CKU.ShowDialog(); private void 修改用户密码ToolStripMenuItem_Click(object
14、 sender, EventArgs e) 修改U XGU = new 修改U(); XGU.ShowDialog(); 四、对仓库进行管理1、库存查询代码实现:private void btLook_Click(object sender, EventArgs e) if (txtLKWord.Text = ) MessageBox.Show(请输入货物名称); else SqlConnection con = new SqlConnection(Data Source=(local);Database=仓库管理信息系统;Integrated Security=SSPI;Uid=sa;Pwd
15、=); SqlCommand cmd = new SqlCommand(Select GoodsID as 货物编号,GoodsName as 货物名称, + StoreName as 仓库名称,GoodsSpec as 货物规格,GoodsUnit as 计量单位, + GoodsNum as 货物数量,GoodsInPrice as 进货价格,GoodsOutPrice as 出货价格, + Editer as 修改人,EditDate as 修改日期 + from Goodsinfo where GoodsID = GOODSID, con); SqlDataAdapter adp =
16、new SqlDataAdapter(cmd); cmd.Parameters.AddWithValue(GOODSID, txtLKWord.Text); DataSet ds = new DataSet(); con.Open(); adp.Fill(ds, 仓库管理信息系统); dataGridView1.DataSource = ds.Tables0; / 检验你 DataSet 是否有数据 /*MessageBox.Show(ds.Tables0.Rows.Count.ToString(); con.Close(); */ 2、货物入库代码实现: public partial cla
17、ss 货物入库 : Form public 货物入库() InitializeComponent(); private void button1_Click(object sender, EventArgs e) if (textBox1.Text = ) MessageBox.Show( 货物编号不能为空); else if (textBox2.Text = ) MessageBox.Show(货物名称不能为空); else if (textBox3.Text = ) MessageBox.Show(仓库名称不能为空); else if (textBox4.Text = ) MessageB
18、ox.Show(货物规格不能为空); else if (textBox6.Text = ) MessageBox.Show(货物数量不能为空); else if (textBox7.Text = ) MessageBox.Show(进货价格不能为空); else if (textBox8.Text = ) MessageBox.Show(出货价格不能为空); else if (textBox9.Text = ) MessageBox.Show(修改人不能为空); else if (textBox10.Text = ) MessageBox.Show(修改日期不能为空); else string
19、 Sql = server=.;integrated security=sspi;database=仓库管理信息系统; SqlConnection con = new SqlConnection(Sql); string cmd = INSERT INTO Goodsinfo VALUES( + textBox1.Text + , + textBox2.Text + , + textBox3.Text + , + textBox4.Text + , + textBox5.Text + , + textBox6.Text + , + textBox7.Text + , + textBox8.Te
20、xt + , + textBox9.Text + , + textBox10.Text + ); SqlCommand com = new SqlCommand(cmd, con); con.Open();/关闭 if (com.ExecuteNonQuery() != 0)/com.ExecuteNonQuery()实施语句,并返回受影响行数 MessageBox.Show(注册成功!); else MessageBox.Show(注册不成功!); con.Close();/关闭 private void label8_Click(object sender, EventArgs e) pr
21、ivate void textBox1_TextChanged(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e) if (MessageBox.Show(返回主页?, 提醒, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = DialogResult.OK) this.Hide(); else private void button3_Click(object sender, EventArgs e) this.H
22、ide(); 货物入库 RK = new 货物入库(); RK.ShowDialog(); 3、删除产品信息代码实现:namespace 仓库信息管理系统1 public partial class 删除 : Form public 删除() InitializeComponent(); private void button1_Click(object sender, EventArgs e) if (MessageBox.Show(是否删除该编号信息?, 提醒, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = Dialog
23、Result.OK) string Sql = server=.;integrated security=sspi;database=仓库管理信息系统; SqlConnection con = new SqlConnection(Sql); string cmd = delete from Goodsinfo where GoodsID= + textBox1.Text.ToString() + ; SqlCommand com = new SqlCommand(cmd, con); con.Open();/关闭 if (com.ExecuteNonQuery() != 0)/com.Exec
24、uteNonQuery()实施语句,并返回受影响行数 MessageBox.Show(删除成功!); else MessageBox.Show(该编号不存在,请输入正确编号!); con.Close();/关闭 private void button2_Click(object sender, EventArgs e) this.Hide(); 4、修改产品信息代码实现:namespace 仓库信息管理系统1 public partial class 修改cs : Form public 修改cs() InitializeComponent(); private void button1_Cl
25、ick(object sender, EventArgs e) string constr = data source=(local); + Initial Catalog=仓库管理信息系统; + Integrated Security=SSPI; /设置连接字符串 SqlConnection mycon = new SqlConnection(constr); /实例化连接对象 mycon.Open(); if (textBox1.Text != ) SqlCommand mycom = new SqlCommand(select * from Goodsinfo where GoodsID
26、= + textBox1.Text.ToString() + , mycon); SqlDataReader sqldr = mycom.ExecuteReader(); sqldr.Read(); textBox2.Text = sqldrGoodsName.ToString(); textBox3.Text = sqldrStoreName.ToString(); textBox4.Text = sqldrGoodsSpec.ToString(); textBox5.Text = sqldrGoodsUnit.ToString(); textBox6.Text = sqldrGoodsNu
27、m.ToString(); textBox7.Text = sqldrGoodsInprice.ToString(); textBox8.Text = sqldrGoodsOutprice.ToString(); textBox9.Text = sqldrEditer.ToString(); textBox10.Text = sqldrEditDate.ToString(); mycon.Close(); button2.Enabled = true; else MessageBox.Show(请先输入产品编码); private void 修改cs_Load(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e) string constr = server=.;integrated security=sspi;database=仓库管理信息系统; /设置连接字符串 SqlConnection mycon = new SqlConnection(constr); /实例化连接对象