| | |
| | | hinqty = decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()) |
| | | } |
| | | }); |
| | | labcode = labcode + arra[i]["labcont"][j]["labcode"].ToString() + ","; |
| | | |
| | | //写入库存表 |
| | | sql = @"insert into TK_WMS_Stock(labcode,materiel_code,batchno,storehouse_code,location_code,customercode,qty,lm_user,lm_date) |
| | | values(@labcode,materiel_code,batchno,storehouse_code,location_code,customercode,qty,lm_user,lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | labcode = arra[i]["labcont"][j]["labcode"].ToString(), |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | batchno = batchno, |
| | | storehouse_code = arra[i]["storehousecode"].ToString(), |
| | | location_code = arra[i]["warehousecode"].ToString(), |
| | | customercode = arra[i]["customercode"].ToString(), |
| | | qty = suminqty, |
| | | lm_user = username, |
| | | lm_date = datetime, |
| | | } |
| | | }); |
| | | |
| | | |
| | | //labcode = labcode + arra[i]["labcont"][j]["labcode"].ToString() + ","; |
| | | suminqty = suminqty + decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()); |
| | | partlabqty = partlabqty + decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()); |
| | | batchno = arra[i]["labcont"][j]["batch"].ToString(); |
| | | |
| | | } |
| | | |
| | | //更新采购订单子表入库数量 |
| | |
| | | }); |
| | | |
| | | //写入采购入库单子表 |
| | | sql = @"insert into TK_WMS_Inwh_Sub(hbillno,labcode,rownumber,materiel_code,storehouse_code,location_code,qty,batchno) |
| | | values(@hbillno,@labcode,@rownumber,@materiel_code,@storehouse_code,@location_code,@qty,@batchno)"; |
| | | labcode = string.Format("'{0}'", labcode.Substring(0, labcode.Length - 1).Replace(",", "','")); |
| | | sql = @"insert into TK_WMS_Inwh_Sub(hbillno,rownumber,materiel_code,storehouse_code,location_code,qty,batchno) |
| | | values(@hbillno,@rownumber,@materiel_code,@storehouse_code,@location_code,@qty,@batchno)"; |
| | | //labcode = string.Format("'{0}'", labcode.Substring(0, labcode.Length - 1).Replace(",", "','")); |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | batchno = batchno |
| | | } |
| | | }); |
| | | //写入库存表前查询当前物料在库存表中是否存在,写入或更新库存表 |
| | | sql = @"select * from TK_WMS_Stock where materiel_code=@materiel_code"; |
| | | dynamicParams.Add("@materiel_code", arra[i]["partcode"].ToString()); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data1.Rows.Count > 0) |
| | | { |
| | | sql = @"update TK_WMS_Stock set qty=qty+@suminqty |
| | | where materiel_code=@materiel_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | suminqty = suminqty |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | sql = @"insert into TK_WMS_Stock(materiel_code,batchno,storehouse_code,location_code,customercode,qty,lm_user,lm_date) |
| | | values(materiel_code,batchno,storehouse_code,location_code,customercode,qty,lm_user,lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | batchno = batchno, |
| | | storehouse_code= arra[i]["storehousecode"].ToString(), |
| | | location_code= arra[i]["warehousecode"].ToString(), |
| | | customercode= arra[i]["customercode"].ToString(), |
| | | qty= suminqty, |
| | | lm_user=username, |
| | | lm_date= datetime, |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /*写入ERP采购入库单************ |
| | | * *********************** |
| | | * ********************** |
| | |
| | | hinqty = decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()) |
| | | } |
| | | }); |
| | | |
| | | //更新库存表 |
| | | sql = @"update TK_WMS_Stock set qty=qty-@inqty |
| | | where materiel_code=@materiel_code and labcode=@labcode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | labcode = arra[i]["labcont"][j]["labcode"].ToString(), |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | inqty = decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()) |
| | | } |
| | | }); |
| | | |
| | | labcode = labcode + arra[i]["labcont"][j]["labcode"].ToString() + ","; |
| | | suminqty = suminqty + decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()); |
| | | partlabqty = partlabqty + decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()); |
| | |
| | | batchno = batchno |
| | | } |
| | | }); |
| | | //写入库存表前查询当前物料在库存表中是否存在,写入或更新库存表 |
| | | sql = @"select * from TK_WMS_Stock where materiel_code=@materiel_code"; |
| | | dynamicParams.Add("@materiel_code", arra[i]["partcode"].ToString()); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data1.Rows.Count > 0) |
| | | { |
| | | sql = @"update TK_WMS_Stock set qty=qty-@suminqty |
| | | where materiel_code=@materiel_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | suminqty = suminqty |
| | | } |
| | | }); |
| | | } |
| | | /*写入ERP采购退货单************ |
| | | * *********************** |
| | | * ********************** |