private void OUTB_DELIVERY_Cancel(string VebelNO, string OutboundNo, out int flag) { string Mes = string.Empty; DataSet dsReturn = new DataSet(); DataTable returnTable; string rfcFuntionName = "ZDZSW_XSDD"; IServerObjFactory sapserverFactory = CallRemotingService.GetRemoteObject(); flag = 1; if (null != sapserverFactory) { IRFCEngine rfcCallObj = sapserverFactory.Get <IRFCEngine>(); DataSet dsParams = new DataSet(); dsParams.ExtendedProperties.Add("WK_VBELN", VebelNO); dsParams.ExtendedProperties.Add("BZ", "WF"); //调用BAPI dsReturn = rfcCallObj.ExecuteRFC(rfcFuntionName, dsParams); returnTable = dsReturn.Tables["LI_RETURN"]; if (returnTable.Rows.Count > 0) { for (int i = 0; i < returnTable.Rows.Count; i++) { //失败的产品信息 string type = returnTable.Rows[i]["TYPE"].ToString(); string id = returnTable.Rows[i]["id"].ToString(); string number = returnTable.Rows[i]["NUMBER"].ToString(); string message = returnTable.Rows[i]["MESSAGE"].ToString(); string system = returnTable.Rows[i]["SYSTEM"].ToString(); string REF_EXT1 = returnTable.Rows[i]["MESSAGE_V1"].ToString(); string REF_EXT2 = returnTable.Rows[i]["MESSAGE_V2"].ToString(); string REF_EXT3 = returnTable.Rows[i]["MESSAGE_V3"].ToString(); Mes = Mes + type + message + "\r\n"; if ((type == "E") || (type == "A")) { flag = 0; } } } if (flag == 0) { Mes = "外向交货单过账取消失败:" + Mes; } else { Mes = "外向交货单过账取消成功!"; } MessageService.ShowMessage(Mes, "提示"); } }
private void toolStripButton1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TBVbeln.Text)) { MessageBox.Show(this, "请输入销售订单号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ClearDataset(); string rfcFuntionName = "ZAST_GET_SO"; IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); if (null != serverFactory) { IRFCEngine rfcCallObj = serverFactory.Get <IRFCEngine>(); DataSet dsParams = new DataSet(); dsParams.ExtendedProperties.Add("WK_VBELN", this.TBVbeln.Text); ds = rfcCallObj.ExecuteRFC(rfcFuntionName, dsParams); } if (ds.Tables["RT_VBAP"].Rows.Count <= 0) { MessageBox.Show(this, "没有查询到你所要的数据,请核对查询条件!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } addCol(ds.Tables["RT_VBAP"], "Sapqty", typeof(float)); addCol(ds.Tables["RT_VBAP"], "OutBQty", typeof(float)); addCol(ds.Tables["RT_VBAP"], "CI", typeof(string)); addCol(ds.Tables["RT_VBAP"], "ShipmentType", typeof(string)); addCol(ds.Tables["RT_VBAP"], "ShipmentNo", typeof(string)); addCol(ds.Tables["RT_CUSTOMER_RQ"], "DEC", typeof(string)); addCol(ds.Tables["RT_CUSTOMER_RQ"], "FATNAM", typeof(string)); addCol(ds.Tables["RT_AUSP"], "DEC", typeof(string)); addCol(ds.Tables["RT_AUSP"], "FATNAM", typeof(string)); addCol(ds.Tables["RT_VBAP"], "CONTAINER_CODE", typeof(string)); addCol(ds.Tables["RT_VBAP"], "CONTAINER_KEY", typeof(string)); addCol(ds.Tables["RT_VBAP"], "PALLET", typeof(string)); foreach (DataRow DR in ds.Tables["RT_VBAP"].Rows) { DR["Sapqty"] = float.Parse(DR["KWMENG"].ToString()); DR["OutBQty"] = 0; DR["PALLET"] = ""; } try { DataSet dsATINN = new DataSet(); serverFactory = CallRemotingService.GetRemoteObject(); dsATINN = serverFactory.Get <IPickOperationEngine>().GetCRRelation(); //foreach (DataRow dr in dsATINN.Tables["AWMS_ATINN"].Rows) //{ // DataRow[] drmatrix = ds.Tables["RT_CUSTOMER_RQ"].Select(" ATINN = '" + dr["ATINN"].ToString() + "'"); // foreach ( DataRow dm in drmatrix ) // { // dm["ATINN"] = dr["ATNAM"].ToString(); // dm["FATNAM"] = dr["FATNAM"].ToString(); // dm["DEC"] = dr["DEC"].ToString(); // } //} //foreach (DataRow dr in ds.Tables["RT_CUSTOMER_RQ"].Rows) //{ // if (string.IsNullOrEmpty(dr["FATNAM"].ToString()) == true) // { // dr.Delete(); // } //} //ds.Tables["RT_CUSTOMER_RQ"].AcceptChanges(); foreach (DataRow dr in dsATINN.Tables["AWMS_ATINN"].Rows) { DataRow[] drmatrix = ds.Tables["RT_AUSP"].Select(" ATINN = '" + dr["ATINN"].ToString() + "'"); foreach (DataRow dm in drmatrix) { dm["ATINN"] = dr["ATNAM"].ToString(); dm["FATNAM"] = dr["FATNAM"].ToString(); dm["DEC"] = dr["DEC"].ToString(); } } foreach (DataRow dr in ds.Tables["RT_AUSP"].Rows) //去除无关特性 { if (string.IsNullOrEmpty(dr["FATNAM"].ToString()) == true) { dr.Delete(); } } ds.Tables["RT_AUSP"].AcceptChanges(); //foreach (DataRow dr in ds.Tables["RT_AUSP"].Rows) // //{ // if (string.IsNullOrEmpty(dr["ATWRT"].ToString()) == true) // { // dr["ATWRT"] = float.Parse(dr["ATFLV"].ToString()).ToString(); // } //} //ds.Tables["RT_AUSP"].AcceptChanges(); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { CallRemotingService.UnregisterChannel(); } ds.Tables["RT_VBAP"].AcceptChanges(); this.Content.DataSource = ds.Tables["RT_VBAP"]; this.gridControl1.DataSource = ds.Tables["RT_AUSP"].DefaultView; Content_Click(this, EventArgs.Empty); }
private void btConfirm_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(edOutBandNO.Text) == true) { MessageBox.Show(this, "请输入出库单号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); edOutBandNO.Focus(); return; } string SAPVBELN = ""; string vbeln = ""; DataTable REQUEST; //-----------------------------------------从数据库中读取已经保存的信息-------------------------------------------- try { DataSet dsReturn = new DataSet(); IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); dsReturn = serverFactory.Get <IPickOperationEngine>().ImportPickdata(edOutBandNO.Text); REQUEST = dsReturn.Tables["REQUEST"].Copy(); REQUEST.Columns.Add("DOCUMENT_TYPE", typeof(string)); REQUEST.Columns.Add("SHIP_TO", typeof(string)); REQUEST.Columns.Add("SOLD_TO", typeof(string)); if (dsReturn.Tables["CK_CONTAINER"].Rows.Count > 0) { MessageBox.Show(this, "不存在此单号或者此订单已经确认,请核对单号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (REQUEST.Rows.Count <= 0) { MessageBox.Show(this, "不存在此单号或者此订单已经确认,请核对单号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } for (int i = 0; i < REQUEST.Rows.Count; i++) { REQUEST.Rows[i]["DOCUMENT_TYPE"] = "A"; REQUEST.Rows[i]["SHIP_TO"] = dsReturn.Tables["HEADER"].Rows[0]["SHIPTO"].ToString(); REQUEST.Rows[i]["SOLD_TO"] = dsReturn.Tables["HEADER"].Rows[0]["SALESTO"].ToString(); } vbeln = REQUEST.Rows[0]["DOCUMENT_NUMB"].ToString(); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { CallRemotingService.UnregisterChannel(); } //-------------------------------------------------------------------------------------------------------------- //-----------------------------------------同步SAP生成外向交货单------------------------------------------------ try { string rfcFuntionName = "ZSOLAR_OUTBAND_DELIVERY";//BAPI_DELIVERYPROCESSING_EXEC IServerObjFactory sapserverFactory = CallRemotingService.GetRemoteObject(); if (null != sapserverFactory) { IRFCEngine rfcCallObj = sapserverFactory.Get <IRFCEngine>(); DataSet dsParams = new DataSet(); dsParams.Tables.Add(REQUEST); dsParams.Tables[0].TableName = "REQUEST"; //dsParams.ExtendedProperties.Add("WK_VBELN", this.TBVbeln.Text); ds = rfcCallObj.ExecuteRFC(rfcFuntionName, dsParams); SAPVBELN = ds.Tables["CREATEDITEMS"].Rows[0]["DOCUMENT_NUMB"].ToString(); } if (string.IsNullOrEmpty(SAPVBELN)) { MessageBox.Show(this, "同步SAP失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { CallRemotingService.UnregisterChannel(); } //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------保存状态----------------------------------------------------------- try { IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); serverFactory.Get <IPickOperationEngine>().UpdateSapVbeln(SAPVBELN, edOutBandNO.Text); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { CallRemotingService.UnregisterChannel(); } //-------------------------------------------------------------------------------------------------------------- MessageBox.Show("成功生成外向交货单:" + SAPVBELN); //---------------------------------------更新拣配数量------------------------------------------- //System.Threading.Thread.Sleep(1000); //DataTable VBKOK_WA = new DataTable(); //DataTable VBPOK_TAB = new DataTable(); //VBKOK_WA.Columns.Add("VBELN_VL",typeof(string)); //VBKOK_WA.Columns.Add("VBELN", typeof(string)); //DataRow dr = VBKOK_WA.NewRow(); //dr["VBELN_VL"] = vbeln ; //dr["VBELN"] = SAPVBELN; //VBKOK_WA.Rows.Add(dr); //VBPOK_TAB.Columns.Add("VBELN_VL", typeof(string)); //VBPOK_TAB.Columns.Add("VBELN", typeof(string)); //VBPOK_TAB.Columns.Add("POSNR_VL", typeof(string)); //VBPOK_TAB.Columns.Add("POSNN", typeof(string)); //VBPOK_TAB.Columns.Add("VBTYP_N", typeof(string)); //VBPOK_TAB.Columns.Add("PIKMG", typeof(string)); //VBPOK_TAB.Columns.Add("MEINS", typeof(string)); //VBPOK_TAB.Columns.Add("NDIFM", typeof(string)); //VBPOK_TAB.Columns.Add("TAQUI", typeof(string)); //VBPOK_TAB.Columns.Add("CHARG", typeof(string)); //VBPOK_TAB.Columns.Add("ORPOS", typeof(string)); //for (int i = 0; i < REQUEST.Rows.Count; i++) //{ // DataRow drV = VBPOK_TAB.NewRow(); // drV["VBELN_VL"] = REQUEST.Rows[i]["DOCUMENT_NUMB"]; // drV["POSNR_VL"] = REQUEST.Rows[i]["DOCUMENT_ITEM"]; // drV["VBELN"] = SAPVBELN; // drV["POSNN"] = REQUEST.Rows[i]["POSNR"]; // drV["VBTYP_N"] = "Q"; // drV["PIKMG"] = REQUEST.Rows[i]["QUANTITY_SALES_UOM"]; // drV["MEINS"] = REQUEST.Rows[i]["SALES_UNIT"]; // drV["NDIFM"] = "0"; // drV["TAQUI"] = ""; // //dr["CHARG"] = REQUEST.Rows[i]["BATCH"]; // drV["ORPOS"] = "0"; // VBPOK_TAB.Rows.Add(drV); //} //rfcFuntionName = "WS_DELIVERY_UPDATE"; //sapserverFactory = CallRemotingService.GetRemoteObject(); //if (null != sapserverFactory) //{ // IRFCEngine rfcCallObj = sapserverFactory.Get<IRFCEngine>(); // DataSet dsParams = new DataSet(); // dsParams.Tables.Add(VBKOK_WA); // dsParams.Tables.Add(VBPOK_TAB); // dsParams.Tables[0].TableName = "VBKOK_WA"; // dsParams.Tables[0].TableName = "VBPOK_TAB"; // dsParams.ExtendedProperties.Add("UPDATE_PICKING", "X"); // dsParams.ExtendedProperties.Add("DELIVERY", SAPVBELN); // ds = rfcCallObj.ExecuteRFC(rfcFuntionName, dsParams); //} }
private void btADD_Click(object sender, EventArgs e) { try { if (dsReturn.Tables["OUTB_TAB"].Rows.Count <= 0) { return; } } catch { return; } string Sapvbeln = dsReturn.Tables["OUTB_TAB"].Rows[0]["REF_NO"].ToString(); if (string.IsNullOrEmpty(Sapvbeln) == true) { MessageBox.Show(this, "无法获取相关销售订单信息", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string rfcFuntionName = "ZAST_GET_SO"; IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); if (null != serverFactory) { IRFCEngine rfcCallObj = serverFactory.Get <IRFCEngine>(); DataSet dsParams = new DataSet(); dsParams.ExtendedProperties.Add("WK_VBELN", Sapvbeln); dsAdd = rfcCallObj.ExecuteRFC(rfcFuntionName, dsParams); } if (dsAdd.Tables["RT_VBAP"].Rows.Count <= 0) { MessageBox.Show(this, "没有可添加的数据!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } dsAdd.Tables["RT_VBAP"].Columns.Add("Sapqty", typeof(string)); dsAdd.Tables["RT_VBAP"].Columns.Add("OutBQty", typeof(float)); dsAdd.Tables["RT_VBAP"].Columns.Add("CI", typeof(string)); dsAdd.Tables["RT_VBAP"].Columns.Add("ShipmentType", typeof(string)); dsAdd.Tables["RT_VBAP"].Columns.Add("ShipmentNo", typeof(string)); dsAdd.Tables["RT_CUSTOMER_RQ"].Columns.Add("DEC", typeof(string)); dsAdd.Tables["RT_CUSTOMER_RQ"].Columns.Add("FATNAM", typeof(string)); if (dsAdd.Tables["RT_VBAP"].Columns.Contains("CONTAINER_CODE") == false) //判断是否包含指定列 { dsAdd.Tables["RT_VBAP"].Columns.Add("CONTAINER_CODE", typeof(string)); } if (dsAdd.Tables["RT_VBAP"].Columns.Contains("CONTAINER_KEY") == false) //判断是否包含指定列 { dsAdd.Tables["RT_VBAP"].Columns.Add("CONTAINER_KEY", typeof(string)); } for (int i = 0; i < ds.Tables["RT_VBAP"].Rows.Count; i++) { dsAdd.Tables["RT_VBAP"].Rows[i]["Sapqty"] = dsAdd.Tables["RT_VBAP"].Rows[i]["KWMENG"]; dsAdd.Tables["RT_VBAP"].Rows[i]["OutBQty"] = 0; } PMAddProd pmadd = new PMAddProd(dsAdd); pmadd.ShowDialog(); if (dsAdd.Tables.IndexOf("SelectedRow") < 0) //若没有选中或者不存在数据,返回 { return; } if (dsAdd.Tables["SelectedRow"].Rows.Count <= 0) { MessageBox.Show(this, "未选中任何行", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < dsAdd.Tables["SelectedRow"].Rows.Count; i++) { DataRow[] drM = dsReturn.Tables["OUTB_TAB"].Select(" REF_NO = '" + dsAdd.Tables["SelectedRow"].Rows[i]["VBELN"] + "' and REF_ITEM = '" + dsAdd.Tables["SelectedRow"].Rows[i]["POSNR"] + "'"); if (drM.Length <= 0) //若已存在此行,则不添加,否则添加 { DataRow Newrow = dsReturn.Tables["OUTB_TAB"].NewRow(); Newrow["PLANT"] = dsAdd.Tables["SelectedRow"].Rows[i]["WERKS"].ToString(); Newrow["STORAGELOCATION"] = dsAdd.Tables["SelectedRow"].Rows[i]["LGORT"].ToString(); Newrow["CPBH"] = dsAdd.Tables["SelectedRow"].Rows[i]["matnr"].ToString(); Newrow["XHGG"] = dsAdd.Tables["SelectedRow"].Rows[i]["ARKTX"].ToString(); Newrow["OBDQTY"] = 0; Newrow["UNIT"] = dsAdd.Tables["SelectedRow"].Rows[i]["VRKME"].ToString(); Newrow["VSTEL"] = dsAdd.Tables["SelectedRow"].Rows[i]["VSTEL"].ToString(); Newrow["REF_NO"] = dsAdd.Tables["SelectedRow"].Rows[i]["VBELN"].ToString(); Newrow["REF_ITEM"] = dsAdd.Tables["SelectedRow"].Rows[i]["POSNR"].ToString(); Newrow["LAST_CNG_BY"] = PropertyService.Get(PROPERTY_FIELDS.USER_NAME_MZ); Newrow["DemandNO"] = dsAdd.Tables["SelectedRow"].Rows[i]["AUFNR"].ToString(); Newrow["DemardPOS"] = dsAdd.Tables["SelectedRow"].Rows[i]["VGPOS"].ToString(); Newrow["DemardSch"] = dsAdd.Tables["SelectedRow"].Rows[i]["GRKOR"].ToString(); dsReturn.Tables["OUTB_TAB"].Rows.Add(Newrow); } dsReturn.Tables["OUTB_TAB"].AcceptChanges(); } }
private void btDelete_Click(object sender, EventArgs e) { string t1 = ""; try { if (dsReturn.Tables["OUTB_TAB"].Rows.Count <= 0) { return; } } catch { return; } string Sapvbeln = dsReturn.Tables["OUTB_TAB"].Rows[0]["VBELN"].ToString(); DataSet dsBAPI = new DataSet(); string rfcFuntionName = "ZDZSW_XSDD"; IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); if (null != serverFactory) { IRFCEngine rfcCallObj = serverFactory.Get <IRFCEngine>(); DataSet dsParams = new DataSet(); dsParams.ExtendedProperties.Add("BZ", "WD"); dsParams.ExtendedProperties.Add("WK_VBELN", Sapvbeln); dsBAPI = rfcCallObj.ExecuteRFC(rfcFuntionName, dsParams); bool isSuccess = true; string errstr = ""; for (int i = 0; i < dsBAPI.Tables["LI_RETURN"].Rows.Count; i++) { if (dsBAPI.Tables["LI_RETURN"].Rows[i]["TYPE"].ToString() == "E") { errstr += dsBAPI.Tables["LI_RETURN"].Rows[i]["MESSAGE"].ToString() + 13; isSuccess = false; } } if (isSuccess == false) { MessageBox.Show(this, errstr, "删除失败", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } try { serverFactory = CallRemotingService.GetRemoteObject(); serverFactory.Get <IPickOperationEngine>().DeleteOutBand(Sapvbeln, 1); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { CallRemotingService.UnregisterChannel(); } try { dsReturn.Clear(); ds.Clear(); dsReturn.AcceptChanges(); ds.AcceptChanges(); } catch { }; MessageBox.Show(this, "删除成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
/// <summary> /// 进行外向交货过帐 /// </summary> /// <param name="VebelNO"></param> private void OUTB_DELIVERY_CONFIRM(string VebelNO, string OutboundNo, out int flag) { DataSet ds = new DataSet(); DataTable H_DATA = new DataTable(); DataTable H_CONTROL = new DataTable(); DataTable returnTable; string strReturn = string.Empty; string Mes = string.Empty; flag = 1; string rfcFuntionName = "BAPI_OUTB_DELIVERY_CONFIRM_DEC"; IServerObjFactory sapserverFactory = CallRemotingService.GetRemoteObject(); if (null != sapserverFactory) { IRFCEngine rfcCallObj = sapserverFactory.Get <IRFCEngine>(); DataSet dsParams = new DataSet(); DataRow HEADER_DATA; DataRow HEADER_CONTROL; //定义一个table用于传入HEADER_DATA H_DATA.Columns.Add("DELIV_NUMB", typeof(string)); //传入HEADER_DATA值 HEADER_DATA = H_DATA.NewRow(); HEADER_DATA["DELIV_NUMB"] = VebelNO; H_DATA.Rows.Add(HEADER_DATA); //定义一个table用于传入HEADER_CONTROL H_CONTROL.Columns.Add("DELIV_NUMB", typeof(string)); H_CONTROL.Columns.Add("POST_GI_FLG", typeof(string)); H_CONTROL.Columns.Add("DELIV_DATE_FLG", typeof(string)); H_CONTROL.Columns.Add("GROSS_WT_FLG", typeof(string)); //传入HEADER_CONTROL值 HEADER_CONTROL = H_CONTROL.NewRow(); HEADER_CONTROL["DELIV_NUMB"] = VebelNO; HEADER_CONTROL["POST_GI_FLG"] = "X"; HEADER_CONTROL["DELIV_DATE_FLG"] = "X"; HEADER_CONTROL["GROSS_WT_FLG"] = "X"; H_CONTROL.Rows.Add(HEADER_CONTROL); //将table加入dataset dsParams.Tables.Add(H_DATA); dsParams.Tables[0].TableName = "HEADER_DATA"; dsParams.Tables.Add(H_CONTROL); dsParams.Tables[1].TableName = "HEADER_CONTROL"; //dsParams.ExtendedProperties.Add("HEADER_DATA", HEADER_DATA); //dsParams.ExtendedProperties.Add("HEADER_CONTROL", HEADER_CONTROL); dsParams.ExtendedProperties.Add("DELIVERY", VebelNO); //调用BAPI ds = rfcCallObj.ExecuteRFC(rfcFuntionName, dsParams); returnTable = ds.Tables["RETURN"]; if (returnTable.Rows.Count > 0) { for (int i = 0; i < returnTable.Rows.Count; i++) { //失败的产品信息dsOutboudInfo.Tables[0].Rows[0][0].ToString() string type = returnTable.Rows[i]["TYPE"].ToString(); string id = returnTable.Rows[i]["id"].ToString(); string number = returnTable.Rows[i]["NUMBER"].ToString(); string message = returnTable.Rows[i]["MESSAGE"].ToString(); string system = returnTable.Rows[i]["SYSTEM"].ToString(); string REF_EXT1 = returnTable.Rows[i]["MESSAGE_V1"].ToString(); string REF_EXT2 = returnTable.Rows[i]["MESSAGE_V2"].ToString(); string REF_EXT3 = returnTable.Rows[i]["MESSAGE_V3"].ToString(); Mes = Mes + type + message; if ((type == "E") || (type == "A")) { flag = 0; } } } if (flag == 0) { Mes = "外向交货单过账失败:" + Mes; } else { Mes = "外向交货单过账成功!"; } } //return Mes; MessageService.ShowMessage(Mes, "提示"); this._entity.UpdateTable(strReturn, VebelNO, OutboundNo, flag); }
/// <summary> /// 同步过账 /// </summary> public bool SynSAP(string ZMBLNR, string SYNMAN, out string returnStr) { returnStr = String.Empty; string sql = String.Format(@"SELECT ZMBLNR, WERKS, ZMMTYP, AUFNR FROM AWMS_WH_ENTRY WHERE ZMBLNR = '{0}'", ZMBLNR.PreventSQLInjection()); DataSet dsHead = db.ExecuteDataSet(CommandType.Text, sql); DataTable dtHead = dsHead.Tables[0]; DataRow drHead = dtHead.Rows[0]; string WERKS = drHead["WERKS"].ToString(); string ZMMTYP = drHead["ZMMTYP"].ToString(); string AUFNR = drHead["AUFNR"].ToString(); ServerObjFactory factory = new ServerObjFactory(); IRFCEngine rfcEngine = factory.Get <IRFCEngine>(); sql = String.Format(@"SELECT ZMBLNR, ZEILE, BWART, MATNR, LGORT, MENGE, CHARG, XP001 AS CHR01, XP002 AS CHR02, XP003 AS CHR03, XP004 AS CHR04, XP005 AS CHR05, XP006 AS CHR06, XP007 AS CHR07, XP008 AS CHR08, XP009 AS CHR09, XP010 AS CHR10, XP011 AS CHR11, XP012 AS CHR12 FROM AWMS_WH_ENTRY_DETAIL WHERE ZMBLNR = '{0}' AND ITEMSTATUS = '正常' ORDER BY ZEILE", ZMBLNR.PreventSQLInjection()); DataSet dsParams = db.ExecuteDataSet(CommandType.Text, sql); dsParams.Tables[0].TableName = "MSEGITEM"; //字段 dsParams.ExtendedProperties.Add("ZMBLNR", ZMBLNR); dsParams.ExtendedProperties.Add("WERKS", WERKS); dsParams.ExtendedProperties.Add("ZMMTYP", ZMMTYP); dsParams.ExtendedProperties.Add("AUFNR", AUFNR); dsParams.ExtendedProperties.Add("CDATE", String.Format("{0:yyyyMMdd}", DateTime.Now)); DataSet dsReturn = rfcEngine.ExecuteRFC("ZMM_GOODSMVT_CREATE", dsParams); string MBLNR = dsReturn.ExtendedProperties["MBLNR"].ToString(); string MBLNR1 = dsReturn.ExtendedProperties["MBLNR1"].ToString(); if (!String.IsNullOrEmpty(MBLNR) || !String.IsNullOrEmpty(MBLNR1)) { DbConnection dbConn = null; DbTransaction dbTran = null; try { dbConn = db.CreateConnection(); dbConn.Open(); dbTran = dbConn.BeginTransaction(); sql = String.Format(@"UPDATE AWMS_WH_ENTRY SET MBLNR = '{0}', MBLNR1 = '{1}', SYNMAN = '{2}', SYNDATE = '{3}', ISSYN = '{4}' WHERE ZMBLNR = '{5}'", MBLNR, MBLNR1, SYNMAN, DateTime.Now, "1", ZMBLNR); db.ExecuteNonQuery(dbTran, CommandType.Text, sql); DataTable dtResultItem = dsReturn.Tables["MSEGITEM"]; for (int i = 0; i < dtResultItem.Rows.Count; i++) { DataRow dr = dtResultItem.Rows[i]; string retZMBLNR = dr["ZMBLNR"].ToString(); string retBWART = dr["BWART"].ToString(); string retCHARG = dr["CHARG"].ToString(); string retMEINS = dr["MEINS"].ToString(); string retXP002 = dr["CHR02"].ToString(); string retXP004 = dr["CHR04"].ToString(); string retXP007 = dr["CHR07"].ToString(); string retXP008 = dr["CHR08"].ToString(); string retXP009 = dr["CHR09"].ToString(); string retXP010 = dr["CHR10"].ToString(); string retXP011 = dr["CHR11"].ToString(); string retXP012 = dr["CHR12"].ToString(); string retXP001 = dr["CHR01"].ToString(); string retXP003 = dr["CHR03"].ToString(); string retXP005 = dr["CHR05"].ToString(); string retXP006 = dr["CHR06"].ToString(); string retMBLNR = retBWART.Equals("101") ? MBLNR : MBLNR1; sql = String.Format(@"UPDATE AWMS_WH_ENTRY_DETAIL SET CHARG = '{0}', MEINS = '{1}', XP002 = '{2}', XP007 = '{3}', XP008 = '{4}', XP009 = '{5}', XP010 = '{6}', XP011 = '{7}', XP012 = '{8}', MBLNR = '{9}', XP001 = '{10}', XP003 = '{11}', XP005 = '{12}', XP006 = '{13}' WHERE ZMBLNR = '{14}' AND XP004 = '{15}' AND ITEMSTATUS = '正常'", retCHARG, retMEINS, retXP002, retXP007, retXP008, retXP009, retXP010, retXP011, retXP012, retMBLNR, retXP001, retXP003, retXP005, retXP006, retZMBLNR, retXP004); db.ExecuteNonQuery(dbTran, CommandType.Text, sql); sql = String.Format(@"UPDATE DBO.WIP_CONSIGNMENT SET CS_DATA_GROUP = '3' WHERE CONSIGNMENT_KEY IN ( SELECT KEYNO FROM AWMS_WH_ENTRY_DETAIL WHERE ZMBLNR = '{0}' AND XP004 = '{1}' AND ITEMSTATUS = '正常')", retZMBLNR, retXP004); db.ExecuteNonQuery(dbTran, CommandType.Text, sql); } dbTran.Commit(); } catch (Exception ex) { LogService.LogError("WarehouseWarrant Error: " + ex.Message); returnStr = ex.Message; if (dbTran != null) { dbTran.Rollback(); } return(false); } finally { if (dbConn != null) { dbConn.Close(); } dbConn = null; dbTran = null; } returnStr = String.Format("过账成功!101移动凭证号:{0},531移动凭证号:{1}", String.IsNullOrEmpty(MBLNR)? "无" : MBLNR, String.IsNullOrEmpty(MBLNR1)? "无" : MBLNR1); return(true); } else { returnStr += "过账失败!"; DataTable dtResult = dsReturn.Tables["TBAPIRET"]; for (int i = 0; i < dtResult.Rows.Count; i++) { DataRow dr = dtResult.Rows[i]; string type = dr["TYPE"].ToString(); string id = dr["id"].ToString(); int number = Convert.ToInt32(dr["NUMBER"]); string message = dr["MESSAGE"].ToString(); string system = dr["SYSTEM"].ToString(); string REF_EXT1 = dr["MESSAGE_V1"].ToString(); string REF_EXT2 = dr["MESSAGE_V2"].ToString(); string REF_EXT3 = dr["MESSAGE_V3"].ToString(); returnStr += '\n' + type + ' ' + id + ' ' + number.ToString() + ' ' + message + ' ' + system + ' ' + REF_EXT1 + ' ' + REF_EXT2 + ' ' + REF_EXT3; } return(false); } }