public string PrintBoxLabel(WareHouse myMain, int iAmt) { SAPXML mySX; SAPPost sp; XmlDocument xmlDoc = new XmlDocument(); XmlNodeList oNodes; string strDateTimeholder; string strModelDescription = ""; try { if (getSAPDescription(myMain.strPOMaterial.Trim()).Equals("NG")) { strDateTimeholder = DateTime.Today.Year.ToString(); strDateTimeholder += DateTime.Today.Month.ToString().PadLeft(2, '0'); strDateTimeholder += DateTime.Today.Day.ToString().PadLeft(2, '0'); sp = new SAPPost("Z_BAPI_BOM_PULL_LEVEL"); sp.setProperty("MATERIAL_NUMBER", myMain.strPOMaterial.Trim()); sp.setProperty("VALID_FROM", strDateTimeholder); sp.setProperty("VALID_TO", strDateTimeholder); mySX = sp.Post(strSAPAddress); xmlDoc = mySX.getXDOC(); oNodes = xmlDoc.GetElementsByTagName("MAT_DESC"); strModelDescription = oNodes.Item(0).InnerText.Trim(); writeSAPDescription(myMain.strPOMaterial.Trim(), strModelDescription); } else { strModelDescription = getSAPDescription(myMain.strPOMaterial.Trim()); } } catch (Exception ex) { MessageBox.Show("Error Printing Box Label:" + ex.Message); } try { myMain.btLabel.setPrintFile(2, myMain.strPrintOverPackContent); myMain.btLabel.findFieldandSubstitute(2, "SPART", myMain.strPOMaterial.Trim()); myMain.btLabel.findFieldandSubstitute(2, "DESC", strModelDescription); myMain.btLabel.findFieldandSubstitute(2, "PRODORDER", myMain.strPONumber.Trim()); //if (strProductMap.Equals("BASE")) myMain.btLabel.findFieldandSubstitute(2, "PARTREV", strPORev); myMain.btLabel.findFieldandSubstitute(2, "AMT", iAmt.ToString().Trim()); myMain.btLabel.findFieldandSubstitute(2, "ZDATE", getDateTime()); myMain.btLabel.findFieldandSubstitute(2, "BOX", box); myMain.btLabel.doPrint(2, false, false); } catch (Exception ex) { MessageBox.Show("Error Printing Box Label=" + ex.Message); } return("OK"); }
public override StepResult RunTest() { SAPXML mySAPXML; SAPPost sp; XmlDocument xmlDoc = new XmlDocument(); XmlNodeList oNodes; XmlNode aNode; int qty; string strAddress; DataTable myTable; int iRows; clsDiagnosticTest.InputDialogBox ib = new InputDialogBox(); ib.Caption = "Enter a Production Order"; ib.Prompt = "Enter the valid Production Order number ( or a valid Production Order)"; ib.Response = ""; ib.ShowDialog(); if (ib.exitOK == InputDialogBox.inputresponse.OK) { string strProdOrder = (string)ib.Response.ToString().Clone(); string strlongProdOrder; // = String.Format("{000000000000}", strProdOrder.Trim()); strlongProdOrder = strProdOrder.PadLeft(12, '0'); ib.Close(); this.setResultLabel("(" + strlongProdOrder.Trim() + ")"); /* clsDiagnosticTest.InputDialogBox ib = new clsDiagnosticTest.InputDialogBox(); * * * * ib.FormPrompt = "Enter aNode Production OrderedEnumerableRowCollection"; * ib.FormCaption = "Test Production Order"; * ib.DefaultValue = "000600001234"; * ib.ShowDialog(); * string s = ib.InputResponse; */ try { sp = new SAPPost("ZC_SEND_PODAT_AS"); sp.setProperty("AUFNR", strlongProdOrder); // sp.setProperty("VALID_FROM", strDateTimeholder); // sp.setProperty("VALID_TO", strDateTimeholder); // string strAddress = HomeAddress; //+ "/sap/PRD/default.asp"; strAddress = "http://home/sap/PRD/default.asp"; mySAPXML = sp.Post(strAddress); xmlDoc = mySAPXML.getXDOC(); myTable = mySAPXML.getDataTable("PODAT_AS"); iRows = myTable.Rows.Count; if (iRows < 2) { MessageBox.Show("Error getting BOM for PO - call IT"); ExplanationForm myForm = new ExplanationForm(); myForm.strLabel1 = "Failed to get BOM for Production Order =[" + strlongProdOrder + "]"; myForm.strLabel2 = "Contact your IT department"; myForm.ShowDialog(); return(StepResult.stepFailed); } } catch (Exception ex) { MessageBox.Show("Got BOMPull exception=" + ex.Message); return(StepResult.stepFailed); } try { sp = new SAPPost("ZC_SEND_POSERIALDATA_AS"); sp.setProperty("AUFNR", strlongProdOrder); // sp.setProperty("VALID_FROM", strDateTimeholder); // sp.setProperty("VALID_TO", strDateTimeholder); // string strAddress = HomeAddress; //+ "/sap/PRD/default.asp"; // strAddress = "http://home/sap/PRD/default.asp"; mySAPXML = sp.Post(strAddress); xmlDoc = mySAPXML.getXDOC(); myTable = mySAPXML.getDataTable("ZSERIALNR_AS"); iRows = myTable.Rows.Count; if (iRows < 2) { MessageBox.Show("Error getting Serials for production order. Contact IT"); ExplanationForm myForm = new ExplanationForm(); myForm.strLabel1 = "Failed to get Serial Numbers for Production Order=[" + strlongProdOrder + "]"; myForm.strLabel2 = "Contact your IT department"; myForm.ShowDialog(); return(StepResult.stepFailed); } } catch (Exception ex) { MessageBox.Show("Got serial number pull error=" + ex.Message); return(StepResult.stepFailed); } } else { return(StepResult.stepUserCancelled); } return(StepResult.stepPassed); }
public static void ReloadSerialbyPO(string strPONumber) { SAPXML mySX; SAPPost sp; XmlDocument xmlDoc = new XmlDocument(); XmlNodeList oNodes; XmlNode atestNode; long lRetCode = -1; string strPOMaterial; string strCurrentMaterial; //load to list form saplink SqlConnection sqlConnection4; try { sp = new SAPPost("ZRFC_SEND_POSERIALDATA_ACS"); sp.setProperty("AUFNR", strPONumber.PadLeft(12, '0')); mySX = sp.Post(MainWindow.strSAPAddress); xmlDoc = mySX.getXDOC(); DataTable myTable = mySX.getDataTable("ZSERIALNR_ACS"); int iRows = myTable.Rows.Count; if (iRows > 0) { for (int i = 0; i < iRows; i++) { clsPOSerials aPOSerial = new clsPOSerials(); aPOSerial.strPONumber = strPONumber; aPOSerial.strMaterial = myTable.Rows[i]["MATNR"].ToString().Trim(); aPOSerial.strSerial = myTable.Rows[i]["SERNR"].ToString().Trim(); if (aPOSerial.strMaterial != "" && aPOSerial.strMaterial != null) { strPOMaterial = aPOSerial.strMaterial; } strCurrentMaterial = aPOSerial.strMaterial.Trim(); if (aPOSerial.strSerial.Trim() != "") { try { using (sqlConnection4 = new SqlConnection(strSqlConnection4_608FFCPACKING)) { sqlConnection4.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = sqlConnection4; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "ame_T_addSerialToTFFC_serialnumbers";//"ame_T_addSerialToConsume"; //cmd.Parameters.Add("@ProductMap", SqlDbType.Char, 30); //cmd.Parameters["@ProductMap"].Value = strProductMap; //cmd.Parameters["@ProductMap"].Direction = ParameterDirection.Input; cmd.Parameters.Add("@ProdOrder", SqlDbType.Char, 30); cmd.Parameters["@ProdOrder"].Value = aPOSerial.strPONumber; cmd.Parameters["@ProdOrder"].Direction = ParameterDirection.Input; cmd.Parameters.Add("@Material", SqlDbType.Char, 30); cmd.Parameters["@Material"].Value = aPOSerial.strMaterial; cmd.Parameters["@Material"].Direction = ParameterDirection.Input; cmd.Parameters.Add("@Serial", SqlDbType.Char, 30); cmd.Parameters["@Serial"].Value = aPOSerial.strSerial; cmd.Parameters["@Serial"].Direction = ParameterDirection.Input; SqlDataReader rec = cmd.ExecuteReader(); sqlConnection4.Close(); } } catch (SqlException ex) { MessageBox.Show("Error add Serial into server:" + ex.Message); //return "NG"; } } } } //return "OK"; } catch (Exception ex) { if (!ConfigurationManager.AppSettings.Get("runLocation").ToString().Trim().Equals("EUGENE")) { string strEnglishphrase = ""; string strForeignphrase = ""; MessageBox.Show("Error on RFC to get serial numbers (" + ex.Message); } else { MessageBox.Show("Error on RFC to get serial numbers=" + ex.Message); } } //writ to tffc_serial }