/// <summary> /// 提交出库数量到SAP当中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCommit_Click(object sender, EventArgs e) { bool ischecked = false; foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { int SAPDocentry = 0; double number = 0; string MaterialNo = ""; string commnets = ""; string date = DateTime.Now.ToString("yyyy-MM-dd"); string LineNumber = ""; SAPDocentry = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["SAPdocEntry"].ToString()); MaterialNo = this.grid.DataKeys[gvrow.RowIndex]["MaterialNo"].ToString(); commnets = "由WMS提交" + this.grid.DataKeys[gvrow.RowIndex]["Mark"].ToString(); number = Convert.ToDouble(this.grid.DataKeys[gvrow.RowIndex]["Number"]); LineNumber = this.grid.DataKeys[gvrow.RowIndex]["LineNumber"].ToString(); SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); string strResult = sapService.IGE1_Web_Add_From_WMS(Convert.ToDateTime(date), commnets, SAPDocentry,int.Parse(LineNumber), MaterialNo, number,"01"); if (strResult.Split('&')[0] == "1") { //修改出库数据 string command = "Update OtherOutInPickOutPlan set isSAPOutStock = 1 where DocEntry = " + SAPDocentry + " and LineNum = " + LineNumber + " "; SQLHelperDM.ExecuteNonQuery(HS.Config.SqlDataObject.GetJoeyConnectionString, command); ischecked = true; } else if (strResult.Split('&')[0] == "0") { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); return; } } } if (ischecked) { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP出库成功!\");", true); } }
/// <summary> /// 提交SAP /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCommit_Click(object sender, EventArgs e) { DMWJEXECUTE services = new DMWJEXECUTE(); IList<string> messList = new List<string>(); messList.Clear(); try { bool isChecked = false; //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { int financeBillId = 0, financeBillLineNum = 0; string strMaterialNo = "", custNo = "", custNm = ""; DateTime stockDt, arriveDt; double num = 0; financeBillId = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["financeBillId"]); financeBillLineNum = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["financeBillLineNum"]); strMaterialNo = this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString(); num = Convert.ToDouble(this.grid.DataKeys[gvrow.RowIndex]["num"]); stockDt = Convert.ToDateTime(this.grid.DataKeys[gvrow.RowIndex]["stockDt"]); arriveDt = Convert.ToDateTime(this.grid.DataKeys[gvrow.RowIndex]["arriveDt"]); custNo = this.grid.DataKeys[gvrow.RowIndex]["custNo"].ToString(); custNm = this.grid.DataKeys[gvrow.RowIndex]["custNm"].ToString(); string mess = Convert.ToInt32(chkId.ValidationGroup).ToString() + ";" + financeBillId.ToString() + ";" + financeBillLineNum.ToString() + ";" + strMaterialNo + ";" + num.ToString() + ";" + stockDt + ";" + arriveDt + ";" + custNo + ";" + custNm; messList.Add(mess); //strResult = services.SAPInStock(Convert.ToInt32(chkId.ValidationGroup), financeBillId, // financeBillLineNum, strMaterialNo, num, stockDt, arriveDt, custNo, custNm); //if (strResult.Split('&')[0] == "1") //{ // isChecked = true; //} //else if (strResult.Split('&')[0] == "0") //{ // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); // return; //} } } if (messList.Count > 0) { SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); SapOnlineService.POR1[] list = new SapOnlineService.POR1[messList.Count]; for (int i = 0; i < messList.Count; i++) { SapOnlineService.POR1 por1 = new SapOnlineService.POR1(); por1.DocEntry = Convert.ToInt32(messList[i].Split(';')[1].ToString()); por1.LineNum = Convert.ToInt32(messList[i].Split(';')[2].ToString()); por1.ItemCode = messList[i].Split(';')[3].ToString(); por1.Quantity = Convert.ToDouble(messList[i].Split(';')[4].ToString());//数量 list[i] = por1; } string strResult = sapService.Web_AddPDN_For_POR1(messList[0].Split(';')[7].ToString(), messList[0].Split(';')[8].ToString(), Convert.ToDateTime(messList[0].Split(';')[5].ToString()), "由WMS同步", Convert.ToDateTime(messList[0].Split(';')[5].ToString()), "由WMS同步", Convert.ToDateTime(messList[0].Split(';')[6].ToString()), list); if (strResult.Split('&')[0] == "1") { for (int i = 0; i < messList.Count; i++) { BArriveDetailData arriveDetailModel = new BArriveDetailData(); BArriveDetailBB arriveDetailBB = new BArriveDetailBB(); SCommBB commBB = new SCommBB(); arriveDetailModel = arriveDetailBB.GetModel(Convert.ToInt32(messList[i].Split(';')[0])); 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='" + messList[i].Split(';')[1].ToString() + "' and financeBillLineNum='" + messList[i].Split(';')[2].ToString() + "' and materialNo='" + messList[i].Split(';')[3].ToString() + "'" +" or oldMaterialNo ='"+ messList[i].Split(';')[3].ToString() + "'" +" and isSapInStock=0 and inStockDt is not null and arriveBillNo='" + arriveDetailModel.arriveBillNo + "' and financeBillId='" + messList[i].Split(';')[1].ToString() + "' and financeBillLineNum='" + messList[i].Split(';')[2].ToString()+"'"); } isChecked = true; } else if (strResult.Split('&')[0] == "0") { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); return; } } if (isChecked) { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP入库成功!\");", true); } } catch (Exception error) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + error.Message + "\");", true); } finally { services.Dispose(); } }
/// <summary> /// 提交按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCommit_Click(object sender, EventArgs e) { DMWJEXECUTE services = new DMWJEXECUTE(); IList<string> messList = new List<string>(); messList.Clear(); try { bool isChecked = false; //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { int financeBillId = 0, financeBillLineNum = 0; string strMaterialNo = "", custNo = "", custNm = ""; string financeBillNo = ""; DateTime stockDt, arriveDt; double num = 0; string SAPDocEntry = ""; string arrivebillNO = ""; //financeBillId = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["financeBillId"]); financeBillLineNum = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["financeBillLineNum"]); arrivebillNO = this.grid.DataKeys[gvrow.RowIndex]["arriveBillNo"].ToString(); financeBillNo = this.grid.DataKeys[gvrow.RowIndex]["financeBillNo"].ToString(); SAPDocEntry = arrivebillNO.Remove(0, 2); strMaterialNo = this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString(); num = Convert.ToDouble(this.grid.DataKeys[gvrow.RowIndex]["num"]); stockDt = Convert.ToDateTime(this.grid.DataKeys[gvrow.RowIndex]["stockDt"]); arriveDt = Convert.ToDateTime(this.grid.DataKeys[gvrow.RowIndex]["arriveDt"]); custNo = this.grid.DataKeys[gvrow.RowIndex]["custNo"].ToString(); custNm = this.grid.DataKeys[gvrow.RowIndex]["custNm"].ToString(); SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); string strResult = sapService.IGN1_Web_Add_From_WMS(Convert.ToDateTime(stockDt), financeBillNo, int.Parse(SAPDocEntry), strMaterialNo, num, "01"); int id = Convert.ToInt32(chkId.ValidationGroup); if (strResult.Split('&')[0] == "1") { BArriveDetailData arriveDetailModel = new BArriveDetailData(); BArriveDetailBB arriveDetailBB = new BArriveDetailBB(); SCommBB commBB = new SCommBB(); arriveDetailModel = arriveDetailBB.GetModel(id); 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 financeBillLineNum='" + financeBillLineNum + "' and materialNo='" +strMaterialNo + "'" + " or oldMaterialNo ='" +strMaterialNo+ "'" + " and isSapInStock=0 and inStockDt is not null and arriveBillNo='" + arriveDetailModel.arriveBillNo + "'and financeBillLineNum='" + financeBillLineNum + "'"); isChecked = true; } else if (strResult.Split('&')[0] == "0") { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); return; } } if (isChecked) { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP入库成功!\");", true); } } } catch (Exception error) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + error.Message + "\");", true); } finally { services.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 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 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(); } }
/// <summary> /// 提交SAP /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCommit_Click(object sender, EventArgs e) { CSaleDetailBB saleDetailBB = new CSaleDetailBB(); DMWJEXECUTE services = new DMWJEXECUTE(); IList<string> messList = new List<string>(); IList<string> datalist = new List<string>(); messList.Clear(); try { bool isChecked = false; //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { string strMaterialNo = "", strInvoiceNo = "", palletNO = "", custNo = "", custNm = "", outdata = ""; ; int docEntry = 0, lineNum = 0; double num = 0; bool isSapOutstock = true; CSaleDetailData saleDetailModel = new CSaleDetailData(); docEntry = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["docEntry"].ToString()); lineNum = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["lineNum"].ToString()); strMaterialNo = this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString(); num = Convert.ToDouble(this.grid.DataKeys[gvrow.RowIndex]["num"]); strInvoiceNo = this.grid.DataKeys[gvrow.RowIndex]["invoiceNo"].ToString(); palletNO = this.grid.DataKeys[gvrow.RowIndex]["palletNo"].ToString(); // palletNO = "1"; custNo = this.grid.DataKeys[gvrow.RowIndex]["custNo"].ToString(); custNm = this.grid.DataKeys[gvrow.RowIndex]["custNm"].ToString(); outdata = this.grid.DataKeys[gvrow.RowIndex]["outStockDt"].ToString(); string suid = this.grid.DataKeys[gvrow.RowIndex]["suid"].ToString(); //获取销售单明细实例 saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(chkId.ValidationGroup)); if (Convert.ToBoolean(saleDetailModel.isSapOutStock) == false) { isSapOutstock = false; } if (isSapOutstock == true) { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前到货单下的物料已经提交SAP入库!\");", true); return; } string mess = docEntry + ";" + lineNum + ";" + strMaterialNo + ";" + num +";" + strInvoiceNo+";"+Convert.ToString(Convert.ToInt32(chkId.ValidationGroup))+";"+palletNO+";"+custNo+";"+custNm+";"+outdata+";"+suid; messList.Add(mess); datalist.Add(mess); //if (datalist.Count == 0) //{ // datalist.Add(docEntry.ToString() + lineNum.ToString()); //} //else //{ // int m = 0; // for (int i = 0; i < datalist.Count; i++) // { // if (docEntry.ToString() + lineNum.ToString() == datalist[i].ToString().ToString()) // { // m = 1; // break; // } // } // if (m == 0) // { // datalist.Add(docEntry.ToString() + lineNum.ToString()); // } //} // strResult = services.SAPOutStock(Convert.ToInt32(chkId.ValidationGroup), docEntry, lineNum, strMaterialNo, num, strInvoiceNo, palletNO); //if (strResult.Split('&')[0] == "1") //{ // isChecked = true; //} //else if (strResult.Split('&')[0] == "0") //{ // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); // return; //} } } if (messList.Count > 0) { try { IList<string> newMessList = new List<string>(); for (int j = 0; j < datalist.Count; j++) { int num =0; for(int i=0;i<messList.Count;i++) { if ((datalist[j].Split(';')[0].ToString() + datalist[j].Split(';')[1].ToString() + datalist[j].Split(';')[2].ToString() ) == (messList[i].Split(';')[0].ToString() + messList[i].Split(';')[1].ToString() + messList[i].Split(';')[2].ToString() )) { num=num+Convert.ToInt32(messList[i].Split(';')[3].ToString()); //num =Convert.ToInt32(messList[i].Split(';')[3].ToString()); //datalist[i].Split(';')[3] =Convert.ToString(Convert.ToInt32(datalist[i].Split(';')[3].ToString())+Convert.ToInt32(messList[i].Split(';')[3].ToString())); } } string compare =datalist[j].Split(';')[0].ToString() + ";" + datalist[j].Split(';')[1].ToString() + ";" + datalist[j].Split(';')[2].ToString() + ";" + num + ";" + datalist[j].Split(';')[4].ToString() + ";" + datalist[j].Split(';')[5].ToString() + ";" + datalist[j].Split(';')[6].ToString() + ";" + datalist[j].Split(';')[7].ToString() + ";" + datalist[j].Split(';')[8].ToString() + ";" + datalist[j].Split(';')[9].ToString(); //datalist[j].Split(';')[3] =Convert.ToString(num); if (newMessList.Count == 0) { newMessList.Add(compare); } else { int nn = 0; for (int m = 0; m < newMessList.Count; m++) { if ((newMessList[m].Split(';')[0].ToString() + newMessList[m].Split(';')[1].ToString() + newMessList[m].Split(';')[2].ToString()) == (compare.Split(';')[0].ToString() + compare.Split(';')[1].ToString() + compare.Split(';')[2].ToString())) { nn = 1; break; } } if (nn == 0) { newMessList.Add(compare); } } } SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[newMessList.Count]; for (int i = 0; i < newMessList.Count; i++) { SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New(); por1.DocEntry = Convert.ToInt32(newMessList[i].Split(';')[0].ToString()); por1.LineNum = Convert.ToInt32(newMessList[i].Split(';')[1].ToString()); por1.ItemCode = newMessList[i].Split(';')[2].ToString(); por1.Quantity = Convert.ToInt32(newMessList[i].Split(';')[3].ToString()); list[i] = por1; } string strResult = sapService.AddODLN(newMessList[0].Split(';')[7].ToString(), newMessList[0].Split(';')[8].ToString(), Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", newMessList[0].Split(';')[4].ToString(), list); if (strResult.Split('&')[0] == "1") { for (int i = 0; i < datalist.Count; i++) { CSaleDetailData saleDetailModel = new CSaleDetailData(); saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(datalist[i].Split(';')[5])); //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成 //首先是将状态从05改为06,然后再进行别的处理 CStockUpDetailBB bb = new CStockUpDetailBB(); bb.ModifyRecord1("06", datalist[i].Split(';')[10]); //bb.ModifyRecord("06", datalist[i].Split(';')[6]);//首先将05的状态改成06 然后 if (bb.GetStatus(Convert.ToInt32(datalist[i].Split(';')[5]))) { saleDetailModel.isSapOutStock = true;//是否已提交SAP出库 saleDetailBB.ModifyRecord(saleDetailModel); } } isChecked = true; } else if (strResult.Split('&')[0] == "0") { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); return; } if (isChecked) { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP出库成功!\");", true); } // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + datalist[j].ToString() + "\");", true); //SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); //SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[messList.Count]; //IList<string> newMessList = new List<string>(); //for (int i = 0; i < messList.Count; i++) //{ // if (Convert.ToDateTime(messList[i].Split(';')[9].ToString()).ToString("yyyy-MM-dd") == datalist[j].ToString()) // { // newMessList.Add(messList[i]); // } //} //SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); //SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[newMessList.Count]; //for (int i = 0; i < newMessList.Count; i++) //{ // SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New(); // por1.DocEntry = Convert.ToInt32(newMessList[i].Split(';')[0].ToString()); // por1.LineNum = Convert.ToInt32(newMessList[i].Split(';')[1].ToString()); // por1.ItemCode = newMessList[i].Split(';')[2].ToString(); // por1.Quantity = Convert.ToInt32(newMessList[i].Split(';')[3].ToString()); // list[i] = por1; //} //string strResult = sapService.AddODLN(newMessList[0].Split(';')[7].ToString(), newMessList[0].Split(';')[8].ToString(), Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", newMessList[0].Split(';')[4].ToString(), list); //if (strResult.Split('&')[0] == "1") //{ // for (int i = 0; i < newMessList.Count; i++) // { // CSaleDetailData saleDetailModel = new CSaleDetailData(); // saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(newMessList[i].Split(';')[5])); // //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成 // //首先是将状态从05改为06,然后再进行别的处理 // CStockUpDetailBB bb = new CStockUpDetailBB(); // bb.ModifyRecord("06", newMessList[i].Split(';')[6]);//首先将05的状态改成06 然后 // if (bb.GetStatus(Convert.ToInt32(newMessList[i].Split(';')[5]))) // { // saleDetailModel.isSapOutStock = true;//是否已提交SAP出库 // saleDetailBB.ModifyRecord(saleDetailModel); // } // } // isChecked = true; // } // //else if (strResult.Split('&')[0] == "0") // //{ // // isChecked = false; // // this.BindGrid(); // // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"日期是" + newMessList[0].Split(';')[9].ToString() + "的数据没有同步成功,SAP返回:"+strResult+"\");", true); // // return; // //} //} //if (isChecked) //{ // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP出库成功!\");", true); //} } catch { } } else if (messList.Count == 0) { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"对不起你没有选择数据!\");", true); } //if(messList.Count>0) //{ // SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); // SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[messList.Count]; // for (int i = 0; i < messList.Count; i++) // { // SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New(); // por1.DocEntry = Convert.ToInt32(messList[i].Split(';')[0].ToString()); // por1.LineNum = Convert.ToInt32(messList[i].Split(';')[1].ToString()); // por1.ItemCode = messList[i].Split(';')[2].ToString(); // por1.Quantity = Convert.ToInt32(messList[i].Split(';')[3].ToString()); // list[i] = por1; // } // string strResult = sapService.AddODLN(messList[0].Split(';')[7].ToString(), messList[0].Split(';')[8].ToString(), Convert.ToDateTime(messList[0].Split(';')[9].ToString()), "由WMS同步", Convert.ToDateTime(messList[0].Split(';')[9].ToString()), "由WMS同步", messList[0].Split(';')[4].ToString(), list); // // string strResult = sapService.AddODLN(Convert.ToInt32(messList[0].Split(';')[0].ToString()), System.DateTime.Today, "从仓库系统生成", messList[0].Split(';')[4].ToString(), list); // // string strResult = services.SAPOutStock(Convert.ToInt32(chkId.ValidationGroup), docEntry, lineNum, strMaterialNo, num, strInvoiceNo, palletNO); // if (strResult.Split('&')[0] == "1") // { // for (int i = 0; i < messList.Count; i++) // { // CSaleDetailData saleDetailModel = new CSaleDetailData(); // saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(messList[i].Split(';')[5])); // //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成 // //首先是将状态从05改为06,然后再进行别的处理 // CStockUpDetailBB bb = new CStockUpDetailBB(); // bb.ModifyRecord("06", messList[i].Split(';')[6]);//首先将05的状态改成06 然后 // if (bb.GetStatus(Convert.ToInt32(messList[i].Split(';')[5]))) // { // saleDetailModel.isSapOutStock = true;//是否已提交SAP出库 // saleDetailBB.ModifyRecord(saleDetailModel); // } // } // isChecked = true; // } // else if (strResult.Split('&')[0] == "0") // { // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); // return; // } // if (isChecked) // { // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP出库成功!\");", true); // } //} //else if (messList.Count == 0) //{ // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"对不起你没有选择数据!\");", true); //} } finally { saleDetailBB.Dispose(); services.Dispose(); } }