public string SAPInStock(int arriveDetailId, int financeBillId, int financeBillLineNum, string strMaterialNo, double num, DateTime stockDt, DateTime arriveDt, string custNo, string custNm) { SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); SCommBB commBB = new SCommBB(); BArriveDetailBB arriveDetailBB = new BArriveDetailBB(); try { SapOnlineService.POR1[] list = null; SapOnlineService.POR1 por1 = new SapOnlineService.POR1(); BArriveDetailData arriveDetailModel = new BArriveDetailData(); string strResult = ""; //SAP入库 //需要传递:采购订单号、行号、物料号、数量 list = new SapOnlineService.POR1[1]; por1.DocEntry = financeBillId;//采购订单号 por1.LineNum = financeBillLineNum;//采购订单行号 por1.ItemCode = strMaterialNo;//物料编号 por1.Quantity = num;//数量 list[0] = por1; strResult = sapService.Web_AddPDN_For_POR1(custNo, custNm, stockDt, "由WMS同步", stockDt, "由WMS同步", stockDt, list); // strResult = sapService.Web_AddPDN_For_POR1(por1.DocEntry, stockDt, "从仓库系统生成", arriveDt, list); if (strResult.Split('&')[0] == "1") { //更改到货中间表数据 arriveDetailModel = arriveDetailBB.GetModel(arriveDetailId); arriveDetailModel.isSapInStock = true;//是否已提交SAP入库 arriveDetailBB.ModifyRecord(arriveDetailModel); //更改物料箱的“是否已提交SAP入库”状态 commBB.ExecuteSql(@"update dbo.BArrangeBillBox set isSapInStock=1 where isSapInStock=0 and inStockDt is not null and arriveBillNo='" + arriveDetailModel.arriveBillNo + "' and financeBillId='" + financeBillId + "' and financeBillLineNum='" + financeBillLineNum + "' and materialNo='" + strMaterialNo + "'"); } return strResult; } finally { sapService.Dispose(); arriveDetailBB.Dispose(); commBB.Dispose(); } }
public string SAPOutStock(int saleDetailId, int docEntry, int lineNum, string strMaterialNo, double num, string strInvoiceNo, String palletNO) { SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); CSaleDetailBB saleDetailBB = new CSaleDetailBB(); try { SapOnlineService.DLN1New[] list = null; SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New(); CSaleDetailData saleDetailModel = new CSaleDetailData(); string strResult = ""; //生成SAP出库单 //需要传递:销售订单ID、行号、物料号、数量 list = new SapOnlineService.DLN1New[1]; por1.DocEntry = docEntry; por1.LineNum = lineNum; por1.ItemCode = strMaterialNo; por1.Quantity = num; list[0] = por1; //strResult = sapService.AddODLN(por1.DocEntry, System.DateTime.Today, "从仓库系统生成", strInvoiceNo, list); ////更改销售中间表数据 //if (strResult.Split('&')[0] == "1") //{ // saleDetailModel = saleDetailBB.GetModel(saleDetailId); // //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成 // //首先是将状态从05改为06,然后再进行别的处理 // CStockUpDetailBB bb = new CStockUpDetailBB(); // bb.ModifyRecord("06",palletNO);//首先将05的状态改成06 然后 // if (bb.GetStatus(saleDetailId)) // { // saleDetailModel.isSapOutStock = true;//是否已提交SAP出库 // saleDetailBB.ModifyRecord(saleDetailModel); // } //} return strResult; } finally { sapService.Dispose(); saleDetailBB.Dispose(); } }
public string SAPConverMaterialOutInStock(string strStockUpBillNo, string MarkText) { SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); CSaleDetailBB saleDetailBB = new CSaleDetailBB(); SCommBB commBB = new SCommBB(); try { SapOnlineService.WebFaHuoModel2[] faHuoList = null; SapOnlineService.WebShouHuoModel2[] shouHuoList = null; SapOnlineService.IGE1_Return IGEReturn = null; SapOnlineService.IGN1_Return IGNReturn = null; SapOnlineService.IGE1[] IGEArray = null; StringBuilder struFaHuo = new StringBuilder(); StringBuilder struShouHuo = new StringBuilder(); DataTable dtPickOutPlan = new DataTable(); string strResult = "", strError = ""; //获取所有需要收发货的拣货计划 dtPickOutPlan = commBB.Query("exec Proc_GetSAPKCSFH '" + strStockUpBillNo + "'").Tables[0]; if (dtPickOutPlan.Rows.Count == 0) { strResult = "0&当前拣货单没有需要收发货物料!"; return strResult; } #region 库存发货 foreach (DataRow rowPickOutPlan in dtPickOutPlan.Rows) { double num = 0; string strAbsEntry = "", strDocEntry = "", strMaterialNo_FH = "", strMaterialNo_SH = ""; strAbsEntry = rowPickOutPlan["absEntry"].ToString();//提货单ID strDocEntry = rowPickOutPlan["docEntry"].ToString();//销售订单ID strMaterialNo_FH = rowPickOutPlan["materialNo_FH"].ToString();//库存发货物料 strMaterialNo_SH = rowPickOutPlan["materialNo_SH"].ToString();//库存收货物料 num = Convert.ToDouble(rowPickOutPlan["num"]);//剩余未SAP库存收发货数量 //库存发货 if (Convert.ToBoolean(rowPickOutPlan["isSAPOutStock"]) == false) { struFaHuo.Append(strMaterialNo_FH + "," + num + ",01," + strDocEntry + "," + strAbsEntry + "," + strMaterialNo_SH + ",GHBZ-WMS;"); } } if (struFaHuo.ToString() != "") { string[] array_FaHuo = struFaHuo.ToString().Trim(';').Split(';'); faHuoList = new SapOnlineService.WebFaHuoModel2[array_FaHuo.Length]; //发货 for (int i = 0; i < array_FaHuo.Length; i++) { string[] array_FaHuoDetail = array_FaHuo[i].Split(','); SapOnlineService.WebFaHuoModel2 faHuo = new SapOnlineService.WebFaHuoModel2(); faHuo.ItemCode = array_FaHuoDetail[0];//ItemCode faHuo.Quantity = Convert.ToDouble(array_FaHuoDetail[1]);//Quantity faHuo.WhsCode = array_FaHuoDetail[2];//WhsCode faHuo.U_ORDR = array_FaHuoDetail[3];//U_ORDR faHuo.U_PKL = array_FaHuoDetail[4];//U_PKL faHuo.U_ItemCode = array_FaHuoDetail[5];//U_ItemCode faHuo.U_YongT = "GHBZ-WMS";//U_YongT faHuoList[i] = faHuo; } //库存发货 IGEReturn = sapService.IGE1_Web_Add_ForCangKu(System.DateTime.Now, "由WMS提交-" + MarkText, faHuoList); strResult = IGEReturn.ResultSucess; strError = IGEReturn.ErrMesg; if (strResult == "1") { IGEArray = IGEReturn.ListIGE1; for (int i = 0; i < IGEArray.Length; i++) { //更改发货状态 commBB.ExecuteSql("update dbo.CPickOutPlan set isSAPOutStock=1,sapStockPrice=" + IGEArray[i].StockPrice + " where absEntry='" + IGEArray[i].U_PKL + "' and docEntry='" + IGEArray[i].U_ORDR + "' and materialNo='" + IGEArray[i].ItemCode + "'"); } } else { return "0&" + strError; } } #endregion 库存发货 #region 库存收货 //获取所有需要收货的拣货计划 dtPickOutPlan = commBB.Query("exec Proc_GetSAPKCSFH '" + strStockUpBillNo + "'").Tables[0]; foreach (DataRow rowPickOutPlan in dtPickOutPlan.Rows) { double num = 0, price = 0; string strAbsEntry = "", strDocEntry = "", strMaterialNo_FH = "", strMaterialNo_SH = ""; strAbsEntry = rowPickOutPlan["absEntry"].ToString();//提货单ID strDocEntry = rowPickOutPlan["docEntry"].ToString();//销售订单ID strMaterialNo_FH = rowPickOutPlan["materialNo_FH"].ToString();//库存发货物料 strMaterialNo_SH = rowPickOutPlan["materialNo_SH"].ToString();//库存收货物料 num = Convert.ToDouble(rowPickOutPlan["num"]);//剩余未SAP库存收发货数量 price = Convert.ToDouble(rowPickOutPlan["sapStockPrice"]);//价格 //库存收货 if (Convert.ToBoolean(rowPickOutPlan["isSAPInStock"]) == false) { struShouHuo.Append(strMaterialNo_SH + "," + num + ",01," + strDocEntry + "," + strAbsEntry + "," + strMaterialNo_FH + ",GHBZ-WMS," + price.ToString() + ";"); } } //组织库存收发货数据 if (struShouHuo.ToString() != "") { string[] array_ShouHuo = struShouHuo.ToString().Trim(';').Split(';'); shouHuoList = new SapOnlineService.WebShouHuoModel2[array_ShouHuo.Length]; //收货 for (int i = 0; i < array_ShouHuo.Length; i++) { string[] array_ShouHuoDetail = array_ShouHuo[i].Split(','); SapOnlineService.WebShouHuoModel2 shouHuo = new SapOnlineService.WebShouHuoModel2(); shouHuo.ItemCode = array_ShouHuoDetail[0];//ItemCode shouHuo.Quantity = Convert.ToDouble(array_ShouHuoDetail[1]);//Quantity shouHuo.WhsCode = array_ShouHuoDetail[2];//WhsCode shouHuo.U_ORDR = array_ShouHuoDetail[3];//U_ORDR shouHuo.U_PKL = array_ShouHuoDetail[4];//U_PKL shouHuo.U_ItemCode = array_ShouHuoDetail[5];//U_ItemCode shouHuo.U_YongT = "GHBZ-WMS";//U_YongT shouHuo.Price = Convert.ToDouble(array_ShouHuoDetail[7]);//Price shouHuoList[i] = shouHuo; } //库存收货 IGNReturn = sapService.IGN1_Web_Add_ForCangKu(System.DateTime.Now, "由WMS提交-库存收货", shouHuoList); strResult = IGNReturn.ResultSucess; strError = IGNReturn.ErrMesg; //更改收货状态 if (IGNReturn.ResultSucess == "1") { foreach (SapOnlineService.WebShouHuoModel2 shouHuo in shouHuoList) { commBB.ExecuteSql("update dbo.CPickOutPlan set isSAPInStock=1 where absEntry='" + shouHuo.U_PKL + "' and docEntry='" + shouHuo.U_ORDR + "' and materialNo='" + shouHuo.U_ItemCode + "'"); } } else { return "0&" + strError; } } #endregion 库存收货 return strResult; } finally { sapService.Dispose(); saleDetailBB.Dispose(); commBB.Dispose(); } }