//Function to create the recieveing advice private void ConvertButton_Click(object sender, EventArgs e) { List <String> words; Globals.outputText = ""; //Split all the words based on the value "|" or "*" words = StringModifiers.WholeTextParse(InputBox.Text); Engine(words); OutputBox.Text = Globals.outputText; }
//Function to create body of receiveing advice private int ReceivingAdviceMaker(List <String> segments) { int SEcount = 0; String asnNum = segments[2]; // builds the BRA Globals.outputText += "BRA*" + asnNum + "*20" + DateTime.Now.ToString("yyMMdd") + "*06*8~\r\n"; // builds the REF Globals.outputText += "REF*SI*" + asnNum + "~\r\n"; // builds the DTM Globals.outputText += "DTM*999" + "*20" + DateTime.Now.ToString("yyMMdd") + "~\r\n"; int lineCount = 0; String tempLIN; String tempQty; String poNum = ""; //Loop runs for each line item in ASN and creates appropriate RC segment. Ends when it reaches the CTT segment while (segments[0] != "CTT") { if (segments[0] == "~") { if (segments[1] == "PRF") { poNum = segments[2]; } else if (segments[1] == "LIN") { lineCount++; tempLIN = StringModifiers.PutBackTogether(segments.GetRange(1, 7)); tempQty = segments[10]; Globals.outputText += "RCD**" + tempQty + "*ST~\r\n"; Globals.outputText += tempLIN + "PRF*" + poNum + "~\r\n"; } segments.RemoveAt(0); } else { segments.RemoveAt(0); } } Globals.outputText += "CTT*" + lineCount.ToString() + "~\r\n"; SEcount = lineCount * 3 + 6; // this is the complex forumla we deduced for the se01 return(SEcount); }
//Main function for converting ASN to RC private void Engine(List <String> words) { List <String> envelope = new List <String>(); List <String> bottomEnvVals = new List <String>(); Boolean flag = true; int SE01; try { // 32 is the size of the envelope for (int i = 0; i < 32; i++) { envelope.Add(words[0]); words.RemoveAt(0); } } catch (Exception e) { Globals.outputText = "Please ensure your ASN is in the proper format."; OutputBox.ForeColor = Color.Red; flag = false; } if (flag) { //Grab top envelope from ASN and covert for RC envelope = Envelope.TopEnvelope(envelope, OriginatorBox.ValueMember, 856); //Getting the values for the bottom envelope. for (int i = 0; i < 3; i++) { bottomEnvVals.Add(envelope[32]); envelope.RemoveAt(32); } //Adds top envelpope to output text Globals.outputText += StringModifiers.PutBackTogether(envelope); //Sets body of RC while returning value for SE01 SE01 = ReceivingAdviceMaker(words); //Add bottom envelope to output text bottomEnvVals.Insert(0, SE01.ToString()); bottomEnvelopeMaker(bottomEnvVals); } }
public String CreateCompany2PO() { String PO = ""; int productID = 111111111; //Blank top envelope for function parameter. If can overload funciton please fix this List <String> topEnvelope = new List <string>(); PO += StringModifiers.PutBackTogether(Envelope.TopEnvelope(topEnvelope, "Company 2", 850)); PO += "BEG*00*SA*"; PO += POnumber; PO += "**20" + DateTime.Now.ToString("yyMMdd") + "~\r\n"; PO += "CUR*BY*USD~\r\n"; PO += "REF*IA*ANGE01~\r\n"; PO += "REF*19*Company 2~\r\n"; PO += "REF*11*4458809~\r\n"; PO += "PER*BD*John Doe*TE*555-555-5555*EM*[email protected]~\r\n"; PO += "PER*DC*Tom Doe*TE*555-555-5555*EM*[email protected]~\r\n"; PO += "PER*SU*Test Supplier*TE*555-555-5555*EM*[email protected]~\r\n"; if (headerSACvalues[0] != "false") { if (headerAllowance) // these need to be radio buttons { PO += "SAC*A*"; } else if (headerCharge) { PO += "SAC*C*"; } // headerSACvalues: [code, amount, percentage] -- the one that doesn't exitst between amt and per will be -1 // unless the user doesnt wants a header SAC: [false, null, null] if (headerSACvalues[0] == "none") { PO = "Please enter values in all required SAC fields."; return(PO); } else { PO += headerSACvalues[0].Substring(0, 4) + "***"; // the allowance/charge code } if (headerSACvalues[2] == "-1") // they want an amount { int decimalLocation = headerSACvalues[1].Length - 3; headerSACvalues[1] = headerSACvalues[1].Remove(decimalLocation, 1); PO += headerSACvalues[1] + "*3**"; } else if (headerSACvalues[1] == "-1") // they want a percent { PO += "*3*" + headerSACvalues[2]; } else { PO = "Please enter values in all required SAC fields."; return(PO); } PO += "********Discount\r\n"; } if (ITDneeded) { PO += "ITD*08*15*" + ITDpercent + "**10**30*****Sample Discount~\r\n"; } PO += "DTM*002*20" + deliveryDate.ToString("yyMMdd") + "~\r\n"; PO += "DTM*010*20" + deliveryDate.AddDays(-2).ToString("yyMMdd") + "~\r\n"; PO += "DTM*118*20" + deliveryDate.ToString("yyMMdd") + "~\r\n"; PO += "TD5*****UPS~\r\n"; PO += "TXI*GS*2~\r\n"; PO += "N9*L1*GEN~\r\n"; PO += "MTX**Test Note.~\r\n"; PO += "N1*ST*Company 2*92*94~\r\n"; PO += "N2*Company 2~\r\n"; PO += "N3*3501 TEST ROAD*Suite 1000~\r\n"; PO += "N3*1st Floor*Last door on the right~\r\n"; PO += "N4*DAVIE*FL*12345*US~\r\n"; PO += "N1*VN*Test Vendor Name*92*1234~\r\n"; PO += "N2*Test Supplier Name~\r\n"; PO += "N3*123 Test Street*Address2~\r\n"; PO += "N3*Address 3*Address 4~\r\n"; PO += "N4*Omaha*NE*12345*US~\r\n"; for (int i = 1; i <= numOfItems; i++) { PO += "PO1*" + i + "*5*EA" + i + ".99**BP*BPN" + i + i + i + "*VN*VPN" + i + i + i + "*UP*" + productID++ + "~\r\n"; PO += "CTP********" + (i * (i + 0.99)) + "~\r\n"; PO += "PID*F*08***Test Item Description " + i + "~\r\n"; PO += "PO4*5****G*2*LB*2*IN~\r\n"; } PO += "CTT*" + numOfItems + "~\r\n"; PO += "SE|38|0047~\r\n"; PO += "GE|1|47~\r\n"; PO += "IEA|1|161~"; return(PO); }
//Function to create a Company 1 PO public String createCompany1PO() { String PO = ""; //Create the top envelope List <String> topEnvelope = new List <string>(); PO += StringModifiers.PutBackTogether(Envelope.TopEnvelope(topEnvelope, "Company 1", 850)); //Generate the static portion of the PO PO += "BEG|00|SA|"; PO += POnumber; PO += "||20" + DateTime.Now.ToString("yyMMdd") + "||AC`\r\n"; PO += "CUR|II|"; PO += currency + "`\r\n"; PO += "REF|PG|100`\r\nREF|PC|1010`\r\n"; PO += "REF|BC|1010`\r\nREF|ZZ|PRODUCTION`\r\n"; PO += "PER|SU|Test Vendor Company|TE|123-123-1234|FX|5874 5896`\r\n"; PO += "PER|BD|Test User|TE|123456789|||EM|[email protected]|DF|||01|EXW|CI|SINGAPORE`\r\n"; PO += "ITD|||||||30|||||Within 30 days due net`\r\n"; PO += "N1|SE|Vendor Factory|92|0000100123`\r\n"; PO += "N3|123 Test Ave #54321`\r\n"; PO += "N4|SINGAPORE||12345|SG`\r\n"; PO += "N1|BT|Company 1|92|1010`\r\n"; PO += "N3|2 Test Avenue`\r\n"; PO += "N4|Singapore||123456|SG`\r\n"; PO += "N1|ST|Company 1|92|1010`\r\n"; PO += "N3|166 Test Circle`\r\n"; PO += "N4|Singapore||123456|SG`\r\n"; //Generate the PO1 loop based on selected tax amounts if (tax0needed && tax7needed) { for (int i = 1; i <= numOfItems; i++) { if (i % 2 == 1) { PO += "PO1|" + lineItemGenerator(i) + "|10|ST|100.99||BP|" + itemNumber + "`\r\n"; PO += "PID|F||||DemoItem" + i + "`\r\n"; PO += "TXI|P4||0|||||||GST on import-MES 0%`\r\n"; PO += "SCH|10|EA|POA|POA|017|" + deliveryDate + "||002|" + deliveryDate + "`\r\n"; itemNumber++; } else { PO += "PO1|" + lineItemGenerator(i) + "|10|ST|100.99||BP|" + itemNumber + "`\r\n"; PO += "PID|F||||DemoItem" + i + "`\r\n"; PO += "TXI|P1||7|||||||Standard - rated 7 %`\r\n"; PO += "SCH|10|EA|POA|POA|017|" + deliveryDate + "||002|" + deliveryDate + "`\r\n"; itemNumber++; } } } else if (tax7needed) { for (int i = 1; i <= numOfItems; i++) { PO += "PO1|" + lineItemGenerator(i) + "|10|ST|100.99||BP|" + itemNumber + "`\r\n"; PO += "PID|F||||DemoItem" + i + "`\r\n"; PO += "TXI|P1||7|||||||Standard - rated 7 %`\r\n"; PO += "SCH|10|EA|POA|POA|017|" + deliveryDate + "||002|" + deliveryDate + "`\r\n"; itemNumber++; } } else if (tax0needed) { for (int i = 1; i <= numOfItems; i++) { PO += "PID|F||||DemoItem" + i + "`\r\n"; PO += "TXI|P4||0|||||||GST on import-MES 0%`\r\n"; PO += "SCH|10|EA|POA|POA|017|" + deliveryDate + "||002|" + deliveryDate + "`\r\n"; itemNumber++; } } else { for (int i = 1; i <= numOfItems; i++) { PO += "PO1|" + lineItemGenerator(i) + "|10|ST|100.99||BP|" + itemNumber + "`\r\n"; PO += "PID|F||||DemoItem" + i + "`\r\n"; PO += "SCH|10|EA|POA|POA|017|" + deliveryDate + "||002|" + deliveryDate + "`\r\n"; itemNumber++; } } PO += "CTT|" + numOfItems.ToString() + "|" + (numOfItems * 10).ToString() + "`\r\n"; PO += "SE|38|0047`\r\n"; PO += "GE|1|47`\r\n"; PO += "IEA|1|161`"; return(PO); }