private void btnSendWWPO_Click(object sender, EventArgs e) { try { List <WWPO> list = new List <WWPO>(); WWPO wwpo = new WWPO(); if (cbWWPOInOutFlag1.SelectedIndex == 0) { wwpo.PONO = txtWWPONO1.Text; wwpo.POLine = Convert.ToInt32(txtWWPOLine1.Text); wwpo.VendorCode = txtWWPOVendorCode1.Text; } wwpo.FacCode = txtWWPOFacCode1.Text; wwpo.StorageCode = txtWWPOStorageCode1.Text; wwpo.MCode = txtWWPOMCode1.Text; wwpo.Unit = txtWWPOUnit1.Text; wwpo.Qty = Convert.ToDecimal(txtWWPOQty1.Text); wwpo.MesTransDate = Convert.ToInt32(txtWWPOMesTransDate1.Text); wwpo.MesTransNO = txtWWPOMesTransNO1.Text; wwpo.Remark = txtWWPORemark1.Text; wwpo.InOutFlag = cbWWPOInOutFlag1.SelectedIndex == 0 ? "541" : "542"; list.Add(wwpo); if (!string.IsNullOrEmpty(txtWWPOMCode2.Text)) { WWPO wwpo2 = new WWPO(); if (cbWWPOInOutFlag2.SelectedIndex == 0) { wwpo2.PONO = txtWWPONO2.Text; wwpo2.POLine = Convert.ToInt32(txtWWPOLine2.Text); wwpo2.VendorCode = txtWWPOVendorCode2.Text; } wwpo2.FacCode = txtWWPOFacCode2.Text; wwpo2.StorageCode = txtWWPOStorageCode2.Text; wwpo2.MCode = txtWWPOMCode2.Text; wwpo2.Unit = txtWWPOUnit2.Text; wwpo2.Qty = Convert.ToDecimal(txtWWPOQty2.Text); wwpo2.MesTransDate = Convert.ToInt32(txtWWPOMesTransDate2.Text); wwpo2.MesTransNO = txtWWPOMesTransNO2.Text; wwpo2.Remark = txtWWPORemark2.Text; wwpo2.InOutFlag = cbWWPOInOutFlag2.SelectedIndex == 0 ? "541" : "542"; list.Add(wwpo2); } WWPO2SAP wwpo2SAP = new WWPO2SAP(); SAPRfcReturn msg = wwpo2SAP.PostWWPOToSAP(list); ShowMessage("====================" + btnSendWWPO.Text + " " + DateTime.Now + "===================="); ShowMessage("执行结果标识(S表示成功,E表示失败):" + msg.Result); ShowMessage("SAP物料凭证编码:" + msg.MaterialDocument); ShowMessage("执行结果信息:" + msg.Message + "\r\n"); //ShowMessage("========================================================"); } catch (Exception ex) { ShowMessage("Exception:" + ex.Message); } }
private void btnSendScrap_Click(object sender, EventArgs e) { try { List <StockScrap> list = new List <StockScrap>(); StockScrap item = new StockScrap(); item.MESScrapNO = txtScrapNO1.Text; item.LineNO = Convert.ToInt32(txtScrapLineNO1.Text); item.FacCode = txtScrapFacCode1.Text; item.StorageCode = txtScrapStorageCode1.Text; item.MCode = txtScrapMCode1.Text; item.Unit = txtScrapUnit1.Text; item.Qty = Convert.ToDecimal(txtScrapQty1.Text); item.CC = txtScrapCC1.Text; item.DocumentDate = Convert.ToInt32(txtScrapDocumentDate1.Text); item.Remark = txtScrapRemark1.Text; item.Operator = txtScrapOperator1.Text; item.ScrapCode = "551"; list.Add(item); if (!string.IsNullOrEmpty(txtScrapMCode2.Text)) { StockScrap item2 = new StockScrap(); item2.MESScrapNO = txtScrapNO2.Text; item2.LineNO = Convert.ToInt32(txtScrapLineNO2.Text); item2.FacCode = txtScrapFacCode2.Text; item2.StorageCode = txtScrapStorageCode2.Text; item2.MCode = txtScrapMCode2.Text; item2.Unit = txtScrapUnit2.Text; item2.Qty = Convert.ToDecimal(txtScrapQty2.Text); item2.CC = txtScrapCC2.Text; item2.DocumentDate = Convert.ToInt32(txtScrapDocumentDate2.Text); item2.Remark = txtScrapRemark2.Text; item2.Operator = txtScrapOperator2.Text; item2.ScrapCode = "551"; list.Add(item2); } StockScrapToSAP service = new StockScrapToSAP(); SAPRfcReturn msg = service.PostStockScrapToSAP(list); ShowMessage("====================" + btnSendScrap.Text + " " + DateTime.Now + "===================="); ShowMessage("执行结果标识(S表示成功,E表示失败):" + msg.Result); ShowMessage("SAP物料凭证编码:" + msg.MaterialDocument); ShowMessage("执行结果信息:" + msg.Message + "\r\n"); //ShowMessage("========================================================"); } catch (Exception ex) { ShowMessage("Exception:" + ex.Message); } }
private void btnSendUB_Click(object sender, EventArgs e) { try { List <UB> list = new List <UB>(); UB ub = new UB(); ub.UBNO = txtUBNO1.Text; ub.UBLine = Convert.ToInt32(txtUBLine1.Text); ub.FacCode = txtUBFacCode1.Text; ub.StorageCode = txtUBStorageCode1.Text; ub.MCode = txtUBMCode1.Text; ub.Unit = txtUBUnit1.Text; ub.Qty = Convert.ToDecimal(txtUBQty1.Text); ub.DocumentDate = Convert.ToInt32(txtUBDocumentDate1.Text); ub.MesTransNO = txtUBMesTransNum1.Text; ub.ContactUser = txtUBContactUser1.Text; ub.InOutFlag = cbUBInOutFlag1.SelectedIndex == 0 ? "351" : "101"; list.Add(ub); if (!string.IsNullOrEmpty(txtUBNO2.Text)) { UB ub2 = new UB(); ub2.UBNO = txtUBNO2.Text; ub2.UBLine = Convert.ToInt32(txtUBLine2.Text); ub2.FacCode = txtUBFacCode2.Text; ub2.StorageCode = txtUBStorageCode2.Text; ub2.MCode = txtUBMCode2.Text; ub2.Unit = txtUBUnit2.Text; ub2.Qty = Convert.ToDecimal(txtUBQty2.Text); ub2.DocumentDate = Convert.ToInt32(txtUBDocumentDate2.Text); ub2.MesTransNO = txtUBMesTransNum2.Text; ub2.ContactUser = txtUBContactUser2.Text; ub2.InOutFlag = cbUBInOutFlag2.SelectedIndex == 0 ? "351" : "101"; list.Add(ub2); } UBToSAP ubToSAP = new UBToSAP(); SAPRfcReturn msg = ubToSAP.PostUBToSAP(list); ShowMessage("====================" + btnSendUB.Text + " " + DateTime.Now + "===================="); ShowMessage("执行结果标识(S表示成功,E表示失败):" + msg.Result); ShowMessage("SAP物料凭证编码:" + msg.MaterialDocument); ShowMessage("执行结果信息:" + msg.Message + "\r\n"); } catch (Exception ex) { ShowMessage("Exception:" + ex.Message); } }
private void btnSendRS_Click(object sender, EventArgs e) { try { List <RS> list = new List <RS>(); RS rs = new RS(); rs.RSNO = txtRSNO1.Text; rs.RSLine = Convert.ToInt32(txtRSLine1.Text); rs.FacCode = txtRSFacCode1.Text; rs.StorageCode = txtRSStorageCode1.Text; rs.MCode = txtRSMCode1.Text; rs.Unit = txtRSUnit1.Text; rs.Qty = Convert.ToDecimal(txtRSQty1.Text); rs.MesTransNO = txtRSMesTransNO1.Text; rs.DocumentDate = Convert.ToInt32(txtRSDocumentDate1.Text); rs.InOutFlag = cbUBInOutFlag1.SelectedIndex == 0 ? "201" : (cbUBInOutFlag1.SelectedIndex == 1 ? "202" : "241"); list.Add(rs); if (!string.IsNullOrEmpty(txtRSNO2.Text)) { RS rs2 = new RS(); rs2.RSNO = txtRSNO2.Text; rs2.RSLine = Convert.ToInt32(txtRSLine2.Text); rs2.FacCode = txtRSFacCode2.Text; rs2.StorageCode = txtRSStorageCode2.Text; rs2.MCode = txtRSMCode2.Text; rs2.Unit = txtRSUnit2.Text; rs2.Qty = Convert.ToDecimal(txtRSQty2.Text); rs2.MesTransNO = txtRSMesTransNO2.Text; rs2.DocumentDate = Convert.ToInt32(txtRSDocumentDate2.Text); rs2.InOutFlag = cbUBInOutFlag2.SelectedIndex == 0 ? "201" : (cbUBInOutFlag2.SelectedIndex == 1 ? "202" : "241"); list.Add(rs2); } RSToSAP rsToSAP = new RSToSAP(); SAPRfcReturn msg = rsToSAP.PostRSToSAP(list); ShowMessage("====================" + btnSendRS.Text + " " + DateTime.Now + "===================="); ShowMessage("执行结果标识(S表示成功,E表示失败):" + msg.Result); ShowMessage("SAP物料凭证编码:" + msg.MaterialDocument); ShowMessage("执行结果信息:" + msg.Message + "\r\n"); } catch (Exception ex) { ShowMessage("Exception:" + ex.Message); } }
public SAPRfcReturn DNRePGIToSAP(DN dn) { NcoFunction ncoClient = new NcoFunction(); try { string[] rfcArray = ConfigHelper.LoadRFCConfig(ConfigHelper.strDestinationName); ncoClient.Connect(rfcArray[0], "", rfcArray[3], rfcArray[4], "ZH", rfcArray[5], rfcArray[8], 2, 10, "", rfcArray[9]); ncoClient.FunctionName = MES2SAPRfcFunctionName.RePGI; Dictionary <string, object> importParameters = new Dictionary <string, object>(); importParameters.Add("I_VBELN", dn.DNNO); ncoClient.ImportParameters = importParameters; Dictionary <string, object> exportParameters = new Dictionary <string, object>(); ncoClient.Execute(ref exportParameters); //return exportParameters; object parameter = null; SAPRfcReturn re = new SAPRfcReturn(); if (exportParameters != null) { if (exportParameters.TryGetValue("ES_RESULT", out parameter)) { IRfcStructure ROFStrcture = parameter as IRfcStructure; re.Result = ROFStrcture["RETUN"].GetValue().ToString(); re.Message = ROFStrcture["MESSG"].GetValue().ToString(); } } return(re); } catch (Exception ex) { throw ex; } }
public SAPRfcReturn POReceiveToSAP(List <PO> poList) { NcoFunction ncoClient = new NcoFunction(); try { //string name = "Q97"; //string user = "******"; //string passwd = "start567"; //string client = "601"; //string ashost = "218.30.179.199"; //string sysnr = "00"; ////string saprouter = "/H/218.30.179.199/S/3299/H/192.168.129.249"; //string saprouter = "/H/192.168.129.252/S/3299/H/192.168.129.249"; //string kunnr = ""; //ncoClient.Connect(name, "", user, passwd, "ZH", client, sysnr, 2, 10, "", saprouter); string[] rfcArray = ConfigHelper.LoadRFCConfig(ConfigHelper.strDestinationName); ncoClient.Connect(rfcArray[0], "", rfcArray[3], rfcArray[4], "ZH", rfcArray[5], rfcArray[8], 2, 10, "", rfcArray[9]); //ncoClient.Connect(); ncoClient.FunctionName = MES2SAPRfcFunctionName.PO; Dictionary <string, object> importParameters = new Dictionary <string, object>(); //importParameters.Add("EBELN", po.PONO); //importParameters.Add("EBELP", po.POLine); //importParameters.Add("WERKS", po.FacCode); //importParameters.Add("ZNUMBER", po.SerialNO); //importParameters.Add("MATNR", po.MCode); //importParameters.Add("MENGE", po.Qty); //importParameters.Add("MEINS", po.Unit); //importParameters.Add("BWART", po.Status); //importParameters.Add("REDOC", po.SAPMaterialInvoice); //importParameters.Add("SGTXT", po.Operator); //importParameters.Add("XBLNR", po.VendorInvoice); //importParameters.Add("LGORT", po.StorageCode); //importParameters.Add("BKTXT", po.Remark); //importParameters.Add("DATUM", po.InvoiceDate); DataTable dtDetail = new DataTable(); dtDetail.Columns.Add("SERIAL", typeof(string)); dtDetail.Columns.Add("EBELN", typeof(string)); dtDetail.Columns.Add("EBELP", typeof(int)); dtDetail.Columns.Add("WERKS", typeof(string)); dtDetail.Columns.Add("ZNUMBER", typeof(string)); dtDetail.Columns.Add("MATNR", typeof(string)); dtDetail.Columns.Add("MENGE", typeof(decimal)); dtDetail.Columns.Add("MEINS", typeof(string)); dtDetail.Columns.Add("BWART", typeof(string)); dtDetail.Columns.Add("REDOC", typeof(string)); dtDetail.Columns.Add("SGTXT", typeof(string)); dtDetail.Columns.Add("XBLNR", typeof(string)); dtDetail.Columns.Add("LGORT", typeof(string)); dtDetail.Columns.Add("BKTXT", typeof(string)); dtDetail.Columns.Add("DATUM", typeof(int)); foreach (var po in poList) { DataRow row = dtDetail.NewRow(); row["SERIAL"] = po.ZNUMBER; row["EBELN"] = po.PONO; row["EBELP"] = po.POLine; row["WERKS"] = po.FacCode; row["ZNUMBER"] = po.ZNUMBER; row["MATNR"] = po.MCode; row["MENGE"] = po.Qty; row["MEINS"] = po.Unit; row["BWART"] = po.Status; row["REDOC"] = po.SAPMaterialInvoice; row["SGTXT"] = po.Operator; row["XBLNR"] = po.SerialNO; row["LGORT"] = po.StorageCode; row["BKTXT"] = po.Remark; row["DATUM"] = po.InvoiceDate; dtDetail.Rows.Add(row); } IRfcTable rfcTable = ncoClient.ConvertDataTabletoRFCTable(dtDetail, MES2SAPRfcInTableName.PO); importParameters.Add(MES2SAPRfcInTableName.PO, rfcTable); ncoClient.ImportParameters = importParameters; Dictionary <string, object> exportParameters = new Dictionary <string, object>(); ncoClient.Execute(ref exportParameters); //ncoClient.DISConncet(); object parameter = null; SAPRfcReturn re = new SAPRfcReturn(); if (exportParameters != null) { if (exportParameters.TryGetValue("ES_RESULT", out parameter)) { IRfcStructure ROFStrcture = parameter as IRfcStructure; re.Result = ROFStrcture["RETUN"].GetValue().ToString(); re.MaterialDocument = ROFStrcture["MBLNR"].GetValue().ToString(); re.Message = ROFStrcture["MESSG"].GetValue().ToString(); } } return(re); } catch (Exception ex) { //ncoClient.DISConncet(); throw ex; } }
public SAPRfcReturn DNPGIToSAP(List <DN> dnList, bool isAll) { NcoFunction ncoClient = new NcoFunction(); try { string[] rfcArray = ConfigHelper.LoadRFCConfig(ConfigHelper.strDestinationName); ncoClient.Connect(rfcArray[0], "", rfcArray[3], rfcArray[4], "ZH", rfcArray[5], rfcArray[8], 2, 10, "", rfcArray[9]); ncoClient.FunctionName = MES2SAPRfcFunctionName.PGI; Dictionary <string, object> importParameters = new Dictionary <string, object>(); DataTable dtDetail = new DataTable(); dtDetail.Columns.Add("PCBH", typeof(string)); dtDetail.Columns.Add("VBELN", typeof(string)); if (!isAll) { dtDetail.Columns.Add("POSNR", typeof(int)); dtDetail.Columns.Add("KWMENG", typeof(decimal)); } foreach (var dn in dnList) { DataRow row = dtDetail.NewRow(); row["PCBH"] = dn.BatchNO; row["VBELN"] = dn.DNNO; if (!isAll) { row["POSNR"] = dn.DNLine; row["KWMENG"] = dn.Qty; } dtDetail.Rows.Add(row); } IRfcTable rfcTable = ncoClient.ConvertDataTabletoRFCTable(dtDetail, MES2SAPRfcInTableName.DN); importParameters.Add(MES2SAPRfcInTableName.DN, rfcTable); string flag = isAll ? "X" : string.Empty;//是否整单过账,=是,不需要给DN明细,空=否,需要给DN明细 importParameters.Add("I_ZFLAG", flag); ncoClient.ImportParameters = importParameters; Dictionary <string, object> exportParameters = new Dictionary <string, object>(); ncoClient.Execute(ref exportParameters); //return exportParameters; object parameter = null; SAPRfcReturn re = new SAPRfcReturn(); if (exportParameters != null) { if (exportParameters.TryGetValue("ES_RESULT", out parameter)) { IRfcStructure ROFStrcture = parameter as IRfcStructure; re.Result = ROFStrcture["RETUN"].GetValue().ToString(); re.Message = ROFStrcture["MESSG"].GetValue().ToString(); } } return(re); } catch (Exception ex) { throw ex; } }
public SAPRfcReturn PostUBToSAP(List <UB> ubList) { NcoFunction ncoClient = new NcoFunction(); try { string[] rfcArray = ConfigHelper.LoadRFCConfig(ConfigHelper.strDestinationName); ncoClient.Connect(rfcArray[0], "", rfcArray[3], rfcArray[4], "ZH", rfcArray[5], rfcArray[8], 2, 10, "", rfcArray[9]); ncoClient.FunctionName = MES2SAPRfcFunctionName.UB; Dictionary <string, object> importParameters = new Dictionary <string, object>(); DataTable dtDetail = new DataTable(); dtDetail.Columns.Add("EBELN", typeof(string)); dtDetail.Columns.Add("EBELP", typeof(int)); dtDetail.Columns.Add("WERKS", typeof(string)); dtDetail.Columns.Add("BWART", typeof(string)); dtDetail.Columns.Add("MATNR", typeof(string)); dtDetail.Columns.Add("LGORT", typeof(string)); dtDetail.Columns.Add("MENGE", typeof(decimal)); dtDetail.Columns.Add("MEINS", typeof(string)); dtDetail.Columns.Add("DATUM", typeof(int)); dtDetail.Columns.Add("SGTXT", typeof(string)); dtDetail.Columns.Add("UNAME", typeof(string)); foreach (var ub in ubList) { DataRow row = dtDetail.NewRow(); row["EBELN"] = ub.UBNO; row["EBELP"] = ub.UBLine; row["WERKS"] = ub.FacCode; row["BWART"] = ub.InOutFlag; row["MATNR"] = ub.MCode; row["LGORT"] = ub.StorageCode; row["MENGE"] = ub.Qty; row["MEINS"] = ub.Unit; row["DATUM"] = ub.DocumentDate; row["SGTXT"] = ub.MesTransNO; row["UNAME"] = ub.ContactUser; dtDetail.Rows.Add(row); } IRfcTable rfcTable = ncoClient.ConvertDataTabletoRFCTable(dtDetail, MES2SAPRfcInTableName.UB); importParameters.Add(MES2SAPRfcInTableName.UB, rfcTable); ncoClient.ImportParameters = importParameters; Dictionary <string, object> exportParameters = new Dictionary <string, object>(); ncoClient.Execute(ref exportParameters); object parameter = null; SAPRfcReturn re = new SAPRfcReturn(); if (exportParameters != null) { if (exportParameters.TryGetValue("ES_RESULT", out parameter)) { IRfcStructure ROFStrcture = parameter as IRfcStructure; re.Result = ROFStrcture["RETUN"].GetValue().ToString(); re.MaterialDocument = ROFStrcture["MBLNR"].GetValue().ToString(); re.Message = ROFStrcture["MESSG"].GetValue().ToString(); } } return(re); } catch (Exception ex) { throw ex; } }
public SAPRfcReturn PostStockScrapToSAP(List <StockScrap> ssList) { NcoFunction ncoClient = new NcoFunction(); try { string[] rfcArray = ConfigHelper.LoadRFCConfig(ConfigHelper.strDestinationName); ncoClient.Connect(rfcArray[0], "", rfcArray[3], rfcArray[4], "ZH", rfcArray[5], rfcArray[8], 2, 10, "", rfcArray[9]); ncoClient.FunctionName = MES2SAPRfcFunctionName.StockScrap; Dictionary <string, object> importParameters = new Dictionary <string, object>(); DataTable dtDetail = new DataTable(); dtDetail.Columns.Add("ZNUMBER", typeof(string)); dtDetail.Columns.Add("ZEILE", typeof(int)); dtDetail.Columns.Add("MATNR", typeof(string)); dtDetail.Columns.Add("BWART", typeof(string)); dtDetail.Columns.Add("WERKS", typeof(string)); dtDetail.Columns.Add("LGORT", typeof(string)); dtDetail.Columns.Add("MENGE", typeof(decimal)); dtDetail.Columns.Add("MEINS", typeof(string)); dtDetail.Columns.Add("KOSTL", typeof(string)); dtDetail.Columns.Add("SGTXT", typeof(string)); dtDetail.Columns.Add("DATUM", typeof(int)); dtDetail.Columns.Add("UNAME", typeof(string)); foreach (var item in ssList) { DataRow row = dtDetail.NewRow(); row["ZNUMBER"] = item.MESScrapNO; row["ZEILE"] = item.LineNO; row["MATNR"] = item.MCode; row["BWART"] = item.ScrapCode; row["WERKS"] = item.FacCode; row["LGORT"] = item.StorageCode; row["MENGE"] = item.Qty; row["MEINS"] = item.Unit; row["KOSTL"] = item.CC; row["SGTXT"] = item.Remark; row["DATUM"] = item.DocumentDate; row["UNAME"] = item.Operator; dtDetail.Rows.Add(row); } IRfcTable rfcTable = ncoClient.ConvertDataTabletoRFCTable(dtDetail, MES2SAPRfcInTableName.StockScrap); importParameters.Add(MES2SAPRfcInTableName.StockScrap, rfcTable); ncoClient.ImportParameters = importParameters; Dictionary <string, object> exportParameters = new Dictionary <string, object>(); ncoClient.Execute(ref exportParameters); object parameter = null; SAPRfcReturn re = new SAPRfcReturn(); if (exportParameters != null) { if (exportParameters.TryGetValue("ES_RESULT", out parameter)) { IRfcStructure ROFStrcture = parameter as IRfcStructure; re.Result = ROFStrcture["RETUN"].GetValue().ToString(); re.MaterialDocument = ROFStrcture["MBLNR"].GetValue().ToString(); re.Message = ROFStrcture["MESSG"].GetValue().ToString(); } } return(re); } catch (Exception ex) { throw ex; } }
public WWPOComponentResult GetWWPOList(List <WWPOComponentPara> list) { try { NcoFunction ncoClient = new NcoFunction(); string[] rfcArray = ConfigHelper.LoadRFCConfig(ConfigHelper.strDestinationName); ncoClient.Connect(rfcArray[0], "", rfcArray[3], rfcArray[4], "ZH", rfcArray[5], rfcArray[8], 2, 10, "", rfcArray[9]); ncoClient.FunctionName = MES2SAPRfcFunctionName.WWPOComponent; Dictionary <string, object> importParameters = new Dictionary <string, object>(); DataTable dt = new DataTable(); dt.Columns.Add("EBELN", typeof(string)); dt.Columns.Add("EBELP", typeof(int)); foreach (var item in list) { DataRow row = dt.NewRow(); row["EBELN"] = item.PONO; //row["EBELP"] = item.POLine; dt.Rows.Add(row); } IRfcTable rfcTable = ncoClient.ConvertDataTabletoRFCTable(dt, MES2SAPRfcInTableName.WWPOComponent); importParameters.Add(MES2SAPRfcInTableName.WWPOComponent, rfcTable); ncoClient.ImportParameters = importParameters; Dictionary <string, object> exportParameters = new Dictionary <string, object>(); DataSet ds = ncoClient.Execute(ref exportParameters); WWPOComponentResult result = new WWPOComponentResult(); List <WWPOComponent> componentList = new List <WWPOComponent>(); if (ds != null && ds.Tables[MES2SAPRfcOutTableName.WWPOComponent] != null && ds.Tables[MES2SAPRfcOutTableName.WWPOComponent].Rows.Count > 0) { foreach (DataRow row in ds.Tables[MES2SAPRfcOutTableName.WWPOComponent].Rows) { WWPOComponent co = new WWPOComponent(); co.PONO = Convert.ToString(row["EBELN"]); co.POLine = Convert.ToInt32(row["EBELP"]); co.SubLine = Convert.ToInt32(row["RSPOS"]); co.MCode = Convert.ToString(row["MATNR"]); co.HWMCode = Convert.ToString(row["IDNLF"]); co.Qty = Convert.ToDecimal(row["BDMNG"]); co.Unit = Convert.ToString(row["MEINS"]); componentList.Add(co); } } result.WWPOComponentList = componentList; object parameter = null; SAPRfcReturn re = new SAPRfcReturn(); if (exportParameters != null) { if (exportParameters.TryGetValue("ES_RESULT", out parameter)) { IRfcStructure ROFStrcture = parameter as IRfcStructure; re.Result = ROFStrcture["RETUN"].GetValue().ToString(); re.MaterialDocument = null; re.Message = ROFStrcture["MESSG"].GetValue().ToString(); } } result.RfcResult = re; return(result); } catch (Exception ex) { throw ex; } }
private void btnSendPO_Click(object sender, EventArgs e) { try { List <PO> list = new List <PO>(); PO po = new PO(); po.PONO = txtPONO.Text; po.POLine = Convert.ToInt32(txtPOLine.Text); po.FacCode = txtFacCode.Text; po.SerialNO = txtSerialNO.Text; po.MCode = txtMCode.Text; po.Qty = Convert.ToDecimal(txtQty.Text); po.Unit = txtUnit.Text; if (rbPOReceive.Checked == true) { po.Status = "103"; } else if (rbPOReverse.Checked == true) { po.Status = "104"; } else if (rbPOAccept.Checked == true) { po.Status = "105"; } else { po.Status = "101"; } po.SAPMaterialInvoice = txtSAPMaterialInvoice.Text; po.Operator = txtOperator.Text; po.VendorInvoice = txtVendorInvoice.Text; po.StorageCode = txtStorageCode.Text; po.Remark = txtRemark.Text; po.InvoiceDate = Convert.ToInt32(txtInvoiceDate.Text); list.Add(po); if (!string.IsNullOrEmpty(txtPONO2.Text)) { PO po2 = new PO(); po2.PONO = txtPONO2.Text; po2.POLine = Convert.ToInt32(txtPOLine2.Text); po2.FacCode = txtFacCode2.Text; po2.SerialNO = txtSerialNO2.Text; po2.MCode = txtMCode2.Text; po2.Qty = Convert.ToDecimal(txtQty2.Text); po2.Unit = txtUnit2.Text; if (rbPOReceive2.Checked == true) { po2.Status = "103"; } else if (rbPOReverse2.Checked == true) { po2.Status = "104"; } else if (rbPOAccept2.Checked == true) { po2.Status = "105"; } else { po2.Status = "101"; } po2.SAPMaterialInvoice = txtSAPMaterialInvoice2.Text; po2.Operator = txtOperator2.Text; po2.VendorInvoice = txtVendorInvoice2.Text; po2.StorageCode = txtStorageCode2.Text; po2.Remark = txtRemark2.Text; po2.InvoiceDate = Convert.ToInt32(txtInvoiceDate2.Text); list.Add(po2); } POToSAP poToSAP = new POToSAP(); SAPRfcReturn msg = poToSAP.POReceiveToSAP(list); ShowMessage("====================" + btnSendPO.Text + " " + DateTime.Now + "===================="); ShowMessage("执行结果标识(S表示成功,E表示失败):" + msg.Result); ShowMessage("SAP物料凭证编码:" + msg.MaterialDocument); ShowMessage("执行结果信息:" + msg.Message + "\r\n"); //object parameter = null; //if (exportParameters != null) //{ // if (exportParameters.TryGetValue("ES_RESULT", out parameter)) // { // IRfcStructure ROFStrcture = parameter as IRfcStructure; // ShowMessage("执行结果标识(S表示成功,E表示失败):" + ROFStrcture["RETUN"].GetValue().ToString()); // ShowMessage("SAP物料凭证编码:" + ROFStrcture["MBLNR"].GetValue().ToString()); // ShowMessage("执行结果信息:" + ROFStrcture["MESSG"].GetValue().ToString()); // } //} } catch (Exception ex) { ShowMessage("Exception:" + ex.Message); } }
private void btnSendDN_Click(object sender, EventArgs e) { try { List <DN> dnList = new List <DN>(); SAPRfcReturn msg = new SAPRfcReturn(); DNToSAP dnToSAP = new DNToSAP(); DN dn = new DN(); dn.DNNO = txtDNNO.Text; //整单过账 if (cbPGIorRe.SelectedIndex == 0 && cbAllPGI.SelectedIndex == 0) { dnList.Add(dn); msg = dnToSAP.DNPGIToSAP(dnList, true); } else if (cbPGIorRe.SelectedIndex == 1)//PGI冲销 { dnList.Add(dn); msg = dnToSAP.DNRePGIToSAP(dn); } else { dn.DNLine = Convert.ToInt32(txtDNLine1.Text); dn.Qty = Convert.ToDecimal(txtDNActQty1.Text); if (!string.IsNullOrEmpty(txtDNLine2.Text)) { DN dn2 = new DN(); dn2.DNNO = txtDNNO.Text; dn2.DNLine = Convert.ToInt32(txtDNLine2.Text); dn2.Qty = Convert.ToDecimal(txtDNActQty2.Text); dnList.Add(dn2); } if (!string.IsNullOrEmpty(txtDNLine3.Text)) { DN dn3 = new DN(); dn3.DNNO = txtDNNO.Text; dn3.DNLine = Convert.ToInt32(txtDNLine3.Text); dn3.Qty = Convert.ToDecimal(txtDNActQty3.Text); dnList.Add(dn3); } if (!string.IsNullOrEmpty(txtDNLine4.Text)) { DN dn4 = new DN(); dn4.DNNO = txtDNNO.Text; dn4.DNLine = Convert.ToInt32(txtDNLine4.Text); dn4.Qty = Convert.ToDecimal(txtDNActQty4.Text); dnList.Add(dn4); } if (!string.IsNullOrEmpty(txtDNLine5.Text)) { DN dn5 = new DN(); dn5.DNNO = txtDNNO.Text; dn5.DNLine = Convert.ToInt32(txtDNLine5.Text); dn5.Qty = Convert.ToDecimal(txtDNActQty5.Text); dnList.Add(dn5); } msg = dnToSAP.DNPGIToSAP(dnList, false); } ShowMessage("====================" + btnSendDN.Text + " " + DateTime.Now + "===================="); ShowMessage("执行结果标识(S表示成功,E表示失败):" + msg.Result); ShowMessage("执行结果信息:" + msg.Message + "\r\n"); } catch (Exception ex) { ShowMessage("Exception:" + ex.Message); } }