private void initalData() { Memange_service myservice = new Memange_service(); InKu_service inservice = new InKu_service(); Outku_service outservice = new Outku_service(); IList <Remain> remainlist = myservice.getAllRemainInfos(); IList <InKu> inkulist = inservice.getAllInkus(); IList <Outku> outkulist = outservice.getAllOutkus(); this.dataGridView1.Rows.Clear(); this.inku_datagridview.Rows.Clear(); this.dataGridView2.Rows.Clear(); for (int i = 0; i < remainlist.Count; i++) { Remain remain = remainlist[i]; String[] row = { remain.Cangkuname, remain.Productname, remain.Remainnum.ToString() }; this.dataGridView1.Rows.Add(row); } for (int j = 0; j < inkulist.Count; j++) { InKu inku = inkulist[j]; String[] row1 = { inku.In_id, inku.Pro_id, inku.In_time, inku.Cangku_id, inku.In_num.ToString() }; this.inku_datagridview.Rows.Add(row1); } for (int k = 0; k < outkulist.Count; k++) { Outku outku = outkulist[k]; String[] row2 = { outku.Out_id, outku.Pro_id, outku.Out_time, outku.Cangku_id, outku.Out_num.ToString() }; this.dataGridView2.Rows.Add(row2); } }
//显示所有的出库单内容 private void button7_Click(object sender, EventArgs e) { Outku_service out_ser = new Outku_service(); IList <Outku> list = out_ser.getAllOutkus(); this.dataGridView2.Rows.Clear(); int count = list.Count; for (int i = 0; i < count; i++) { Outku outku = list[i]; String[] row = { outku.Out_id, outku.Pro_id, outku.Out_time, outku.Cangku_id, outku.Out_num.ToString() }; this.dataGridView2.Rows.Add(row); } }
public IList <Outku> getOutkusByCangkuid(String cangkuid) { IList <Outku> list = new List <Outku>(); String sql = "select * from out_table where storehouse_id='" + cangkuid + "'"; MySqlDataReader reader = helper.GetReader(sql); Product_service pro_ser = new Product_service(); while (reader.Read()) { Outku outku = new Outku(); outku.Out_id = reader["idout_table"].ToString(); outku.Pro_id = reader["out_product"].ToString(); outku.Out_time = reader["out_time"].ToString(); outku.Out_num = Convert.ToInt32(reader["out_num"].ToString()); outku.Cangku_id = reader["storehouse_id"].ToString(); list.Add(outku); } return(list); }
private void button9_Click(object sender, EventArgs e) { Product_service pro_ser = new Product_service(); Memange_service me_ser = new Memange_service(); Outku_service out_ser = new Outku_service(); IList <Outku> WhatToInKus = new List <Outku>(); // 出库之前先检查库存是否有这种产品,要是没有,出库失败,要是有,添加出库单,然后修改库存表 for (int i = 0; i < WhatToInKu.Count / 3; i++) { Outku outku = new Outku(); // inku.In_id = WhatToInKu[3 * i + 0]; //获取产品ID String id = pro_ser.getIdByName(WhatToInKu[3 * i + 0]); if (id.Length == 0) { //插入产品及库存 MessageBox.Show("仓库中不存在" + WhatToInKu[3 * i + 0]); return; } else { //修改库存表 Remain remain = new Remain(); remain.Cangkuname = WhatToInKu[3 * i + 1]; Console.WriteLine(me_ser.getRemainNum(pro_ser.getIdByName(WhatToInKu[3 * i + 0]))); Console.WriteLine(Convert.ToInt32(WhatToInKu[3 * i + 2])); remain.Remainnum = me_ser.getRemainNum(pro_ser.getIdByName(WhatToInKu[3 * i + 0])) - Convert.ToInt32(WhatToInKu[3 * i + 2]); Console.WriteLine(remain.Remainnum); remain.Productname = pro_ser.getIdByName(WhatToInKu[3 * i + 0]); me_ser.updateRemain(remain); } outku.Pro_id = pro_ser.getIdByName(WhatToInKu[3 * i + 0]); outku.Out_time = DateTime.Now.Date.ToShortDateString(); outku.Cangku_id = WhatToInKu[3 * i + 1]; outku.Out_num = Convert.ToInt32(WhatToInKu[3 * i + 2]); WhatToInKus.Add(outku); } int result = out_ser.outKu(WhatToInKus); if (result != 0) { MessageBox.Show("出库成功!"); initalData(); } else { MessageBox.Show("添加失败!"); } int count = WhatToInKu.Count; for (int i = count - 1; i >= 0; i--) { WhatToInKu.RemoveAt(i); } }