private void buttonigual_Click(object sender, EventArgs e) { N2 = double.Parse(Display.Text); switch (operacion) { case "+": N3 = N1 + N2; Display.Text = N3.ToString(); break; case "-": N3 = N1 - N2; Display.Text = N3.ToString(); break; case "*": N3 = N1 * N2; Display.Text = N3.ToString(); break; case "/": N3 = N1 / N2; Display.Text = N3.ToString(); break; } }
///<Summary> ///<CreatedOn>03/01/2018</CreatedOn> ///<Author>Sunny Bhardwaj</Author> ///<Description>Get N3 segment for All</Description> ///</Summary> /// public static N3 GetN3(string N301, string N302) { N3 N3 = new N3(); N3.N301 = CreateString(N301, (int)SegmentLength.One, (int)SegmentLength.FiftyFive, ' ', true); //Address1 N3.N302 = !string.IsNullOrEmpty(N302) ? CreateString(N302, (int)SegmentLength.One, (int)SegmentLength.FiftyFive, ' ', true) : string.Empty; //Address2 return(N3); }
void Start() { SetDefault(); N1 = Random.Range(0, 9); N2 = Random.Range(0, 9); N3 = Random.Range(0, 9); N4 = Random.Range(0, 9); Debug.Log(N1.ToString() + " " + N2.ToString() + " " + N3.ToString() + " " + N4.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine("N2: " + N2.ToString("0.0")); sb.AppendLine("N3: " + N3.ToString("0.0")); sb.AppendLine("Responsável: " + Responsavel); return(base.ToString() + sb.ToString()); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { N3 n3Value = (N3)value; string ErrorString = ValidateElement.GetValidation(n3Value.N31, Element.Required, 1, 55, "N301") + ValidateElement.GetValidation(n3Value.N32, Element.Situational, 1, 55, "N302"); if (ErrorString == string.Empty) { return(null); } return(new ValidationResult("Pay To Address: " + ErrorString)); }
public static void ProvideRandDataSet(RichTextBox RTB) { int N1, N2, N3, N4, N5; Random random = new Random(); N1 = random.Next(0, 255); N2 = random.Next(0, 255); N3 = random.Next(0, 255); N4 = random.Next(0, 255); N5 = random.Next(0, 255); RTB.Text = N1.ToString() + ", " + N2.ToString() + ", " + N3.ToString() + ", " + N4.ToString() + ", " + N5.ToString(); }
public override bool Equals(object obj) { return(obj is Triangle triangle && Transform.Equals(triangle.Transform) && Material.Equals(triangle.Material) && Parent == triangle.Parent && HasParent == triangle.HasParent && P1.Equals(triangle.P1) && P2.Equals(triangle.P2) && P3.Equals(triangle.P3) && Edge1.Equals(triangle.Edge1) && Edge2.Equals(triangle.Edge2) && Normal.Equals(triangle.Normal) && N1.Equals(triangle.N1) && N2.Equals(triangle.N2) && N3.Equals(triangle.N3) && IsSmoothed == triangle.IsSmoothed); }
public override int GetHashCode() { int hashCode = -2063967696; hashCode = hashCode * -1521134295 + Transform.GetHashCode(); hashCode = hashCode * -1521134295 + Material.GetHashCode(); hashCode = hashCode * -1521134295 + SavedRay.GetHashCode(); hashCode = hashCode * -1521134295 + Parent.GetHashCode(); hashCode = hashCode * -1521134295 + HasParent.GetHashCode(); hashCode = hashCode * -1521134295 + P1.GetHashCode(); hashCode = hashCode * -1521134295 + P2.GetHashCode(); hashCode = hashCode * -1521134295 + P3.GetHashCode(); hashCode = hashCode * -1521134295 + Edge1.GetHashCode(); hashCode = hashCode * -1521134295 + Edge2.GetHashCode(); hashCode = hashCode * -1521134295 + Normal.GetHashCode(); hashCode = hashCode * -1521134295 + N1.GetHashCode(); hashCode = hashCode * -1521134295 + N2.GetHashCode(); hashCode = hashCode * -1521134295 + N3.GetHashCode(); hashCode = hashCode * -1521134295 + IsSmoothed.GetHashCode(); return(hashCode); }
public Data(List <int> a, int n1, int n2, int op) { N1 = n1; N2 = n2; Op = op; Log = n1.ToString(); if (op == 0) { Log += " added too "; N3 = n1 + n2; } else if (op == 1) { Log += " multiplyed by "; N3 = n1 * n2; } else if (op == 2) { Log += " subtracted from "; N3 = n1 - n2; } else { Log += " divided by "; N3 = n1 / n2; if (n1 % n2 != 0) //remove if a decimal number is produced { N3 = 0; } } Log += n2.ToString() + " equals " + N3.ToString(); Before = new List <int>(a); After = new List <int>(a); After.Remove(N1); After.Remove(N2); After.Add(N3); }
public EDI835SchemaModel ParseEDI835(string fileText) { bool payerSeg = false; bool payeeSeg = false; string claimSegment = string.Empty; string segmentValue = string.Empty; string[] ediTextArray = fileText.Split("~"); CLP clp = null; SVC svc = null; bool findNextCLP = false; bool isServiceLineVisited = false; foreach (string stringSegment in ediTextArray) { string[] segmentArray = stringSegment.Split("*"); if (segmentArray != null) { IEnumerable <string> values = Enum.GetValues(typeof(EDI835Segments)) .OfType <EDI835Segments>() .Select(s => Convert.ToString(s)); if (values.Contains(segmentArray[0].TrimStart())) { if (segmentArray[0].TrimStart() != "CLP" && findNextCLP == true) { continue; } //else continue; segmentValue = segmentArray[0].TrimStart(); if (claimSegment == "CLP") { segmentValue = "CLP"; } switch (segmentValue) { case "ISA": { ISA ISA = GetSegmentInfo <ISA>(new ISA(), segmentArray); ediSchemaModel.ISA = ISA; break; } case "GS": { GS GS = GetSegmentInfo <GS>(new GS(), segmentArray); ediSchemaModel.GS = GS; break; } case "ST": { ST ST = GetSegmentInfo <ST>(new ST(), segmentArray); ediSchemaModel.ST = ST; break; } case "BPR": { BPR BPR = GetSegmentInfo <BPR>(new BPR(), segmentArray); ediSchemaModel.BPR = BPR; break; } case "TRN": { TRN TRN = GetSegmentInfo <TRN>(new TRN(), segmentArray); ediSchemaModel.TRN = TRN; break; } case "DTM": { DTM DTM = GetSegmentInfo <DTM>(new DTM(), segmentArray); ediSchemaModel.DTM = DTM; break; } case "N1": { if (segmentArray[1] == "PR") { N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray); ediSchemaModel.PayerInfo = N1; payerSeg = true; } else if (segmentArray[1] == "PE") { N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray); ediSchemaModel.PayeeInfo = N1; payeeSeg = true; } break; } case "N3": { if (payerSeg) { N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray); ediSchemaModel.PayerAddress = N3; } else if (payeeSeg) { N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray); ediSchemaModel.PayeeAddress = N3; } break; } case "N4": { if (payerSeg) { N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray); ediSchemaModel.PayerCityStateZip = N4; payerSeg = false; } else if (payeeSeg) { N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray); ediSchemaModel.PayeeCityStateZip = N4; payeeSeg = false; } break; } case "CLP": { claimSegment = "CLP"; switch (segmentArray[0].TrimStart()) { case "CLP": { findNextCLP = false; if (clp != null) { ediSchemaModel.CLPList.Add(clp); isServiceLineVisited = false; clp = null; } clp = GetSegmentInfo <CLP>(new CLP(), segmentArray); break; } case "SVC": { //if (svc != null) //{ // if (clp.SVCList == null) clp.SVCList = new List<SVC>(); // clp.SVCList.Add(svc); // svc = null; //} svc = GetSegmentInfo <SVC>(new SVC(), segmentArray); if (clp != null && clp.SVCList == null) { clp.SVCList = new List <SVC>(); } clp.SVCList.Add(svc); isServiceLineVisited = true; break; } case "CAS": { if (isServiceLineVisited) { CAS CAS = GetSegmentInfo <CAS>(new CAS(), segmentArray); if (svc.SVCAdjList == null) { svc.SVCAdjList = new List <CAS>(); } svc.SVCAdjList.Add(CAS); CAS = null; } break; } case "REF": { if (segmentArray[1].Trim() == "6R" && svc != null && svc.REF == null) { svc.REF = new REF(); svc.REF = GetSegmentInfo <REF>(new REF(), segmentArray); } break; } case "GE": { if (clp != null) { ediSchemaModel.CLPList.Add(clp); isServiceLineVisited = false; clp = null; findNextCLP = true; } break; } default: { break; } } break; } } } } } return(ediSchemaModel); }
/// <summary> /// Builds Rail Carrier Shipment. /// Original from https://ps.nafta.extra.fcagroup.com/sites/itb-ebus/shared%20Documents/404RailCarrierShipmentInformation.pdf /// </summary> static TS404 BuildRailCarrierShipment(string controlNumber) { var result = new TS404(); // Transaction Set Identifier Code // = “404” (Rail Carrier Shipment Information) // Transaction Set Control Number = 0001 result.ST = new ST(); result.ST.TransactionSetIdentifierCode_01 = "404"; result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0'); // Transaction Set Purpose Code = “00” (Original) // Transportation Method/ Type Code = “R” (Rail) // Shipment Method of Payment // = “11” (Rule 11 Shipment) // Standard Carrier Alpha Code = NS // Weight Unit Code = ”L” (Pounds) // Shipment Qualifier // = “B” (Bill of Lading for Individual Shipment) // Section Seven Code = “N” (Not in Effect) result.BX = new BX(); result.BX.TransactionSetPurposeCode_01 = "00"; result.BX.TransportationMethodTypeCode_02 = "R"; result.BX.ShipmentMethodofPayment_03 = "11"; result.BX.StandardCarrierAlphaCode_05 = "NS"; result.BX.WeightUnitCode_06 = "L"; result.BX.ShipmentQualifier_07 = "B"; result.BX.SectionSevenCode_08 = "N"; // Shipment Weight Code // = “A” (Shipper's Weight Agreement) // Billing Code = “S” (Single Shipment Billing) result.BNX = new BNX(); result.BNX.ShipmentWeightCode_01 = "A"; result.BNX.BillingCode_03 = "S"; // Release Code = “R” (Released with Billing Data) // Date = 03 / 01 / 2000 // Time = 11:16 // Time Code = “LT” (Local Time) result.M3 = new M3(); result.M3.ReleaseCode_01 = "R"; result.M3.Date_02 = "20000301"; result.M3.Time_03 = "1116"; result.M3.TimeCode_04 = "LT"; // Repeating N9 result.N9 = new List <N9>(); // Reference Identification Qualifier // = “BM” (Bill of Lading Number) // Reference Identification = 2041247 // Date = 03 / 01 / 2000 // Time = 11:16 // Time Code = “LT” (Local Time) var n9 = new N9(); n9.ReferenceIdentificationQualifier_01 = "BM"; n9.ReferenceIdentification_02 = "2041247"; n9.Date_04 = "20000301"; n9.Time_05 = "1116"; n9.TimeCode_06 = "LT"; result.N9.Add(n9); // Repeating N7 Loops result.N7Loop = new List <Loop_N7_404>(); // Begin N7 Loop var n7Loop1 = new Loop_N7_404(); // Equipment Initial = CR // Equipment Number = 237522 // Weight = 80,503 // Weight Qualifier = “N” (Actual Net Weight) // Equipment Description Code = “RR” (Rail Car) n7Loop1.N7 = new N7(); n7Loop1.N7.EquipmentInitial_01 = "CR"; n7Loop1.N7.EquipmentNumber_02 = "237522"; n7Loop1.N7.Weight_03 = "80503"; n7Loop1.N7.WeightQualifier_04 = "N"; n7Loop1.N7.EquipmentDescriptionCode_11 = "RR"; // Repeating M7 n7Loop1.M7 = new List <M7>(); // Seal Number = 582127 // Seal Number = 582128 var m7 = new M7(); m7.SealNumber_01 = "582127"; m7.SealNumber_02 = "582128"; n7Loop1.M7.Add(m7); // End N7 Loop result.N7Loop.Add(n7Loop1); // City Name = WARREN // State or Province Code = MI result.F9 = new F9(); result.F9.CityName_02 = "WARREN"; result.F9.StateorProvinceCode_03 = "MI"; // City Name = VALLEY PARK // State or Province Code = MO result.D9 = new D9(); result.D9.CityName_02 = "VALLEY PARK"; result.D9.StateorProvinceCode_03 = "MO"; // Repeating N1 Loops result.N1Loop = new List <Loop_N1_404_3>(); // Begin N1 Loop 1 var n1Loop1 = new Loop_N1_404_3(); // Entity Identifier Code = “11” // (Party to be billed < AAR Accounting Rule 11 >) // Name = CORPAY SOLUTIONS n1Loop1.N1 = new N1(); n1Loop1.N1.EntityIdentifierCode_01 = "11"; n1Loop1.N1.Name_02 = "CORPAY SOLUTIONS"; // Repeating N3 n1Loop1.N3 = new List <N3>(); // Address Information // = PO BOX 195199 / 2065 S CENTER RD var n31 = new N3(); n31.AddressInformation_01 = "PO BOX 195199/2065 S CENTER RD"; n1Loop1.N3.Add(n31); // City Name = BURTON // State or Province Code = MI // Postal Code = 48519 n1Loop1.N4 = new N4(); n1Loop1.N4.CityName_01 = "BURTON"; n1Loop1.N4.StateorProvinceCode_02 = "MI"; n1Loop1.N4.PostalCode_03 = "48519"; // End N1 Loop 1 result.N1Loop.Add(n1Loop1); // Begin N1 Loop 2 var n1Loop2 = new Loop_N1_404_3(); // Entity Identifier Code = “CN” (Consignee) // Name = ST LOUIS ASSEMBLY I // Identification Code Qualifier // = “93” (Code assigned by the organization // originating the transaction set) // Identification Code = 04087 n1Loop2.N1 = new N1(); n1Loop2.N1.EntityIdentifierCode_01 = "CN"; n1Loop2.N1.Name_02 = "ST LOUIS ASSEMBLY I"; n1Loop2.N1.IdentificationCodeQualifier_03 = "93"; n1Loop2.N1.IdentificationCode_04 = "04087"; // Repeating N3 n1Loop2.N3 = new List <N3>(); // Address Information // = 1001 N HIGHWAY DRIVE var n32 = new N3(); n32.AddressInformation_01 = "1001 N HIGHWAY DRIVE"; n1Loop2.N3.Add(n32); // City Name = FENTON // State or Province Code = MO // Postal Code = 63026 n1Loop2.N4 = new N4(); n1Loop2.N4.CityName_01 = "FENTON"; n1Loop2.N4.StateorProvinceCode_02 = "MO"; n1Loop2.N4.PostalCode_03 = "63026"; // End N1 Loop 2 result.N1Loop.Add(n1Loop2); // Begin N1 Loop 3 var n1Loop3 = new Loop_N1_404_3(); // Entity Identifier Code // = “UC” (Ultimate Consignee) // Name = ST LOUIS ASSEMBLY I // Identification Code Qualifier // = “93” (Code assigned by the organization // originating the transaction set) // Identification Code = 04087 n1Loop3.N1 = new N1(); n1Loop3.N1.EntityIdentifierCode_01 = "UC"; n1Loop3.N1.Name_02 = "ST LOUIS ASSEMBLY I"; n1Loop3.N1.IdentificationCodeQualifier_03 = "93"; n1Loop3.N1.IdentificationCode_04 = "04087"; // Repeating N3 n1Loop3.N3 = new List <N3>(); // Address Information // = 1001 N HIGHWAY DRIVE var n33 = new N3(); n33.AddressInformation_01 = "1001 N HIGHWAY DRIVE"; n1Loop3.N3.Add(n33); // City Name = FENTON // State or Province Code = MO // Postal Code = 63026 n1Loop3.N4 = new N4(); n1Loop3.N4.CityName_01 = "FENTON"; n1Loop3.N4.StateorProvinceCode_02 = "MO"; n1Loop3.N4.PostalCode_03 = "63026"; // End N1 Loop 3 result.N1Loop.Add(n1Loop3); // Begin N1 Loop 4 var n1Loop4 = new Loop_N1_404_3(); // Entity Identifier Code = “SH” (Shipper) // Name = STERLING STAMPING // Identification Code Qualifier // = “93” (Code assigned by the organization // originating the transaction set) // Identification Code = 06215 n1Loop4.N1 = new N1(); n1Loop4.N1.EntityIdentifierCode_01 = "SH"; n1Loop4.N1.Name_02 = "STERLING STAMPING"; n1Loop4.N1.IdentificationCodeQualifier_03 = "93"; n1Loop4.N1.IdentificationCode_04 = "06215"; // Repeating N3 n1Loop4.N3 = new List <N3>(); // Address = 35777 VAN DYKE RD var n34 = new N3(); n34.AddressInformation_01 = "35777 VAN DYKE RD"; n1Loop4.N3.Add(n34); // City Name = STERLING HEIGHTS // State or Province Code = MI // Postal Code = 48312 n1Loop4.N4 = new N4(); n1Loop4.N4.CityName_01 = "STERLING HEIGHTS"; n1Loop4.N4.StateorProvinceCode_02 = "MI"; n1Loop4.N4.PostalCode_03 = "48312"; // End N1 Loop 4 result.N1Loop.Add(n1Loop4); // Repeating R2 result.R2 = new List <R2>(); // Standard Carrier Alpha Code = NS // Routing Sequence Code // = “R” (Origin Carrier, Rule 11 Shipment) // City Name = ESTL var r21 = new R2(); r21.StandardCarrierAlphaCode_01 = "NS"; r21.RoutingSequenceCode_02 = "R"; r21.CityName_03 = "ESTL"; result.R2.Add(r21); // Standard Carrier Alpha Code = BNSF // Routing Sequence Code // = “1” (1st Carrier after Origin Carrier) var r22 = new R2(); r22.StandardCarrierAlphaCode_01 = "BNSF"; r22.RoutingSequenceCode_02 = "1"; result.R2.Add(r22); // Repeating LX Loops result.LXLoop = new List <Loop_LX_404>(); // Begin LX Loop var lxLoop1 = new Loop_LX_404(); // Assigned Number = 1 lxLoop1.LX = new LX(); lxLoop1.LX.AssignedNumber_01 = "1"; // Repeating L5 lxLoop1.L5 = new List <L5>(); // Lading Line Item Number = 1 // Lading Description = AUTO PARTS // Commodity Code = 3714993 // Commodity Code Qualifier // = “T” (Standard Transportation Commodity // Code<STCC>) var l5 = new L5(); l5.LadingLineItemNumber_01 = "1"; l5.LadingDescription_02 = "AUTO PARTS"; l5.CommodityCode_03 = "3714993"; l5.CommodityCodeQualifier_04 = "T"; lxLoop1.L5.Add(l5); // Repeating L0 Loops lxLoop1.L0Loop = new List <Loop_L0_404>(); // Begin L0 Loop var l0Loop1 = new Loop_L0_404(); // Lading Line Item Number = 1 // Weight = 80,503 // Weight Qualifier = “N” (Actual Net Weight) // Lading Quantity = 42 // Packaging Form Code = “RCK” (Rack) l0Loop1.L0 = new L0(); l0Loop1.L0.LadingLineItemNumber_01 = "1"; l0Loop1.L0.Weight_04 = "80503"; l0Loop1.L0.WeightQualifier_05 = "N"; l0Loop1.L0.LadingQuantity_08 = "42"; l0Loop1.L0.PackagingFormCode_09 = "RCK"; // End L0 Loop lxLoop1.L0Loop.Add(l0Loop1); // End LX Loop result.LXLoop.Add(lxLoop1); return(result); }
public int GetInt() { return(int.Parse(N1.ToString() + "" + N2.ToString() + "" + N3.ToString() + "" + N4.ToString())); }
public string GetString() { return(N1.ToString() + "" + N2.ToString() + "" + N3.ToString() + "" + N4.ToString()); }
// //Объединение двух статистик в одну (Кнопка 7 - "Объединить статистики") // private void button7_Click(object sender, EventArgs e) { string s, s1; //Вспомогательные переменные int N1, N2, N3; //Данные переменные хранят кол-ва букв, с которых собрана статистика StreamWriter Writer; //Создаем объект для записи в файл StreamReader Reader1, Reader2; //Создаем два объекта для чтения из двух разных файлов со статистикой openFileDialog1.Title = "Окрыть статистику 1"; //Задаем заголовок диалога открыитя файла openFileDialog1.DefaultExt = ".txt"; // Задаем базовое расширение openFileDialog1.Filter = "Text documents (.txt)|*.txt"; // Задаем фильтр openFileDialog1.ShowDialog(); //Выводим диалогове окно на экран try { Reader1 = new StreamReader(openFileDialog1.FileName, Encoding.Default); //Откываем файл для чтения } catch (FileNotFoundException) { MessageBox.Show("Ошибка открытия файла статистики"); //При ошибке открытия выводим сообщение return; //И передаем управление вызывающей функцие } openFileDialog1.Title = ("Открыть статистику 2"); //Задаем заголовок openFileDialog1.ShowDialog(); //Выводим диалогове окно открытия файла try { Reader2 = new StreamReader(openFileDialog1.FileName, Encoding.Default); //Открываем файл для чтения } catch (FileNotFoundException) { MessageBox.Show("Ошибка открытия файла статистики"); //При ошибке открытия выводим сообщение return; //И передаем управление вызывающей функцие } N1 = int.Parse(Reader1.ReadLine()); //Считываем кол-во символов в первой статистике N2 = int.Parse(Reader2.ReadLine()); //Считываем кол-во символов во второй статистике N3 = N1 + N2; //Объединяем иъ List <Data> Letter1 = new List <Data>(); //Создаем три списка объектов для записи статистики List <Data> Letter2 = new List <Data>(); List <Data> Letter3 = new List <Data>(); while (!Reader1.EndOfStream) //Читаем до конца файла { s = Reader1.ReadLine(); //Считываем первую подстроку s1 = Reader2.ReadLine(); //Считываем вторую подстроку Letter1.Add(new Data { Letter = s.Substring(0, 1), freq = double.Parse(s.Substring(2)) }); //Из первой подстроки выделяем букву и частоту из первой статистики Letter2.Add(new Data { Letter = s1.Substring(0, 1), freq = double.Parse(s1.Substring(2)) }); //Из второй подстроки выделяем букву и частоту из втрой статистики Letter3.Add(new Data { Letter = s.Substring(0, 1), freq = 0.00 }); //В третью статистику сначала записываем нулевые частоты для букв } saveFileDialog1.Title = "Сохранить файл как"; //Задаем заголовок диалога для сохранения файла saveFileDialog1.Filter = "Text documents (.txt)|*.txt"; //Задаем фильтр saveFileDialog1.DefaultExt = ".txt"; //Задаем базовое расширение saveFileDialog1.ShowDialog(); //Выводим диалог сохранения файла try { Writer = new StreamWriter(saveFileDialog1.FileName, false, Encoding.Default); //Открываем файл для записи } catch (FileNotFoundException) { MessageBox.Show("Ошибка сохранения файла"); //В случае ошибки выводим сообщение return; //И передаем управление вызывающей функцие } Writer.WriteLine(N3.ToString()); //В файл записываем число букв for (int i = 0; i < Letter3.Count; i++) { Letter3[i].freq = (Letter1[i].freq * N1 + Letter2[i].freq * N2) / N3; //Новые частоты считаем по формуле Writer.WriteLine(Letter3[i].Letter + ' ' + Letter3[i].freq.ToString()); //Обновленные данные записываем в файл } Writer.Close(); //Закрываем файл для записи Reader1.Close(); //Закрываем файл для чтения Reader2.Close(); //Закрываем файл для чтения }
public string BuildEdi(List <Patient> patientList, InsuranceCompany insurance, BillingProvider billingProvider) { var buildEdi = new StringBuilder(); //Begin ISA var buildisa = new Isa(); buildEdi.Append(buildisa.BuildIsa()); //Begin GS var buildGs = new Gs(); buildEdi.Append(buildGs.BuildGs()); //Begin ST var buildSt = new St(); buildEdi.Append(buildSt.BuildSt()); //Begin BPR var buildBpr = new Bpr(); buildEdi.Append(buildBpr.BuildBpr(insurance)); //Build TRN var buildTrn = new Trn(); buildEdi.Append(buildTrn.BuildTrn(insurance)); //Ref Segment conditional, not included at this time //REF Receiver Identification //REF01 Receiver Reference Number //REF02 Receiver Reference Identification //Build DTM Loop Production Date var buildDtm = new Dtm(); buildEdi.Append(buildDtm.BuildDtm(patientList)); //Build N1 Insurance Company Identification Segment 1000A var buildNOne = new N1(); buildEdi.Append(buildNOne.BuildNOne(insurance)); //BuildN3 Insurance Company Identification Segment 1000A var buildNThree = new N3(); buildEdi.Append(buildNThree.BuildNThree(insurance)); // Build N4 Insurance Company Identification 1000A var buildNFour = new N4(); buildEdi.Append(buildNFour.BuildN4(insurance)); //Build Ref Insurance Company Identification 1000A var buildRef = new Ref(); buildEdi.Append(buildRef.BuildRef()); //Build Per Insurance Company Identification 1000A var buildPer = new Per(); buildEdi.Append(buildPer.BuildPerPhone()); //Build Per Insurance Company Website Information 1000A buildEdi.Append(buildPer.BuildPerWebSite()); //Build N1 Provider Identifier Segment 1000B buildEdi.Append(buildNOne.BuildNOne(billingProvider)); //Build N3 Provider Identifier Segment 1000B buildEdi.Append(buildNThree.BuildNThree(billingProvider)); //Build N4 Provider Identifier Segment 1000B buildEdi.Append(buildNFour.BuildN4(billingProvider)); //Build Ref Provider Identifier 1000B buildEdi.Append(buildRef.BuildRefAdditionalPayee()); buildEdi.Append(buildRef.BuildRefAdditionalPayeeTwo()); //LX Segment 2000B var buildLx = new Lx(); buildEdi.Append(buildLx.BuildLx()); //TS3 2000B NOT USED //TS2 2000B NOT USED //CLP Segment 2100 foreach (Patient patient in patientList) { var buildClp = new Clp(); buildEdi.Append(buildClp.BuildClp(patient)); var buildNmOne = new Nm1(); buildEdi.Append(buildNmOne.BuildNm1(patient)); //MIA Inpatient Adjudication Information //MOA Outpatient Adjudication Information //REF Other CLaim Related Identification //Ref Rendering Provider Identifier 2100 buildEdi.Append(buildRef.BuildRef(patient.Provider)); //DTM Statement From or To Date 2100 buildEdi.Append(buildDtm.BuildDtm(patient)); //PER Claim Contact Information 2100 //SVC Level 2110 var buildSvc = new Svc(); buildEdi.Append(buildSvc.BuildSvc(patient.Charge)); buildEdi.Append(buildDtm.BuildDtm(patient.Charge)); var buildCas = new Cas(); if (patient.Charge.AdjustmentList != null) { buildEdi.Append(buildCas.BuildCas(patient.Charge.AdjustmentList)); buildEdi.Append(buildCas.BuildCas(patient.Charge)); } else { buildEdi.Append(buildCas.BuildCas(patient.Charge)); } buildEdi.Append(buildRef.BuildRefControlNumber()); var buildAmt = new Amt(); buildEdi.Append(buildAmt.BuildAmt(patient.Charge)); //QTY 2110 //LQ 2110 //LQ01 Service Line Remittance Remark Code 1 //LQ02 Service Line Remittance Remark Code 2 foreach (AddonCharge addon in patient.Charge.AddonChargeList) { buildEdi.Append(buildSvc.BuildSvc(addon)); buildEdi.Append(buildCas.BuildCas(addon.AdjustmentList)); buildEdi.Append(buildRef.BuildRefControlNumber()); buildEdi.Append(buildAmt.BuildAmt(addon)); } } var buildSe = new Se(); buildEdi.Append(buildSe.BuildSe()); var buildGe = new Ge(); buildEdi.Append(buildGe.BuildGe()); var buildIea = new Iea(); buildEdi.Append(buildIea.BuildIea()); return(buildEdi.ToString()); }
/// <summary> /// Build purchase order. /// Original example from http://www.x12.org/examples/004010X357/tax-exempt-purchase-order/ /// </summary> public static TS850 BuildPurchaseOrder(string controlNumber) { var result = new TS850(); // Indicates the start of a purchase order transaction set and assigns a control number. result.ST = new ST(); result.ST.TransactionSetIdentifierCode_01 = "850"; result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0'); // Indicates that this is original purchase order number XX-1234, dated March 1, 2017, and that no acknowledgment is necessary. result.BEG = new BEG(); result.BEG.TransactionSetPurposeCode_01 = "00"; result.BEG.PurchaseOrderTypeCode_02 = "SA"; result.BEG.PurchaseOrderNumber_03 = "XX-1234"; result.BEG.Date_05 = "20170301"; result.BEG.AcknowledgmentType_07 = "NA"; // Repeating PER result.PER = new List <PER>(); // Indicates that the name of the Buyer is Ed Smith, and his telephone number is (800) 123-4567. var per = new PER(); per.ContactFunctionCode_01 = "BD"; per.Name_02 = "ED SMITH"; per.CommunicationNumberQualifier_03 = "TE"; per.CommunicationNumber_04 = "8001234567"; result.PER.Add(per); // Repeating TAX result.TAX = new List <TAX>(); // Provides state tax exempt ID 53247765. var tax = new TAX(); tax.TaxIdentificationNumber_01 = "53247765"; tax.LocationQualifier_02 = "SP"; tax.LocationIdentifier_03 = "CA"; tax.TaxExemptCode_12 = "9"; result.TAX.Add(tax); // Repeating N1 Loops result.N1Loop = new List <Loop_N1_850>(); // Begin N1 Loop var n1Loop = new Loop_N1_850(); // Indicates that the buyer is ABC Aerospace. ABC's D-U-N-S+4 number is 123456789-0101. n1Loop.N1 = new N1(); n1Loop.N1.EntityIdentifierCode_01 = "BY"; n1Loop.N1.Name_02 = "ABC AEROSPACE"; n1Loop.N1.IdentificationCodeQualifier_03 = "9"; n1Loop.N1.IdentificationCode_04 = "1234567890101"; // Repeating N2 n1Loop.N2 = new List <N2>(); // Provides additional name content for the buyer. var n2 = new N2(); n2.Name_01 = "AIRCRAFT DIVISION"; n1Loop.N2.Add(n2); // Repeating N3 n1Loop.N3 = new List <N3>(); // The buyer’s street address is 2000 Jet Blvd. var n3 = new N3(); n3.AddressInformation_01 = "2000 JET BLVD"; n1Loop.N3.Add(n3); // Repeating N4 n1Loop.N4 = new List <N4>(); // The buyer’s city, state, and ZIP is Fighter Town, CA 98898. var n4 = new N4(); n4.CityName_01 = "FIGHTER TOWN"; n4.StateorProvinceCode_02 = "CA"; n4.PostalCode_03 = "98898"; n1Loop.N4.Add(n4); // End N1 Loop result.N1Loop.Add(n1Loop); // Repeating PO1 Loops result.PO1Loop = new List <Loop_PO1_850>(); // Begin PO1 Loop var pO1Loop = new Loop_PO1_850(); // Indicates Baseline item 1 is a request to purchase 25 units, with a price of $36.00 each, of manufacturer's part number XYZ-1234. pO1Loop.PO1 = new PO1(); pO1Loop.PO1.AssignedIdentification_01 = "1"; pO1Loop.PO1.QuantityOrdered_02 = "25"; pO1Loop.PO1.UnitorBasisforMeasurementCode_03 = "EA"; pO1Loop.PO1.UnitPrice_04 = "36"; pO1Loop.PO1.BasisofUnitPriceCode_05 = "PE"; pO1Loop.PO1.ProductServiceIDQualifier_06 = "MG"; pO1Loop.PO1.ProductServiceID_07 = "XYZ-1234"; // Repeating MEA pO1Loop.MEA = new List <MEA>(); // Indicates that each unit in the order weighs 10 ounces. var mea = new MEA(); mea.MeasurementReferenceIDCode_01 = "WT"; mea.MeasurementQualifier_02 = "WT"; mea.MeasurementValue_03 = "10"; mea.CompositeUnitofMeasure_04 = new C001(); mea.CompositeUnitofMeasure_04.UnitorBasisforMeasurementCode_01 = "OZ"; pO1Loop.MEA.Add(mea); // Indicates that no product substitution is allowed. pO1Loop.IT8 = new IT8(); pO1Loop.IT8.ProductServiceSubstitutionCode_07 = "B0"; // Repeating SCH Loops pO1Loop.SCHLoop = new List <Loop_SCH_850>(); // Begin SCH Loop var schLoop = new Loop_SCH_850(); // Indicates that the 25 units are required to arrive by June 15, 2017. schLoop.SCH = new SCH(); schLoop.SCH.Quantity_01 = "25"; schLoop.SCH.UnitorBasisforMeasurementCode_02 = "EA"; schLoop.SCH.DateTimeQualifier_05 = "106"; schLoop.SCH.Date_06 = "20170615"; // End SCH Loop pO1Loop.SCHLoop.Add(schLoop); // End PO1 Loop result.PO1Loop.Add(pO1Loop); // Begin CTT Loop result.CTTLoop = new Loop_CTT_850(); // Indicates that the purchase order contains 1 line item. result.CTTLoop.CTT = new CTT(); result.CTTLoop.CTT.NumberofLineItems_01 = "1"; // Indicates that the total amount of the purchase order is $900. result.CTTLoop.AMT = new AMT(); result.CTTLoop.AMT.AmountQualifierCode_01 = "TT"; result.CTTLoop.AMT.MonetaryAmount_02 = "900"; // End CTT Loop return(result); }
private static TS850 Import(string[] lines) { var result = new TS850(); if (lines.Length < 2) { throw new Exception("Insufficient number of lines"); } // line[0] is the header var firstLine = lines[1]; // ST result.ST = new Core.Model.Edi.X12.ST(); result.ST.TransactionSetIdentifierCode_01 = "850"; result.ST.TransactionSetControlNumber_02 = "000000001"; var firstLineItems = firstLine.Split(new[] { ',' }); if (firstLineItems.Count() < 13) { throw new Exception("Insufficient number of columns"); } // BEG result.BEG = new BEG(); result.BEG.TransactionSetPurposeCode_01 = "01"; result.BEG.PurchaseOrderTypeCode_02 = "02"; result.BEG.PurchaseOrderNumber_03 = firstLineItems[5]; result.BEG.Date_05 = firstLineItems[6]; // Repeating N1 Loops result.N1Loop = new List <Loop_N1_850>(); // Begin N1 Loop var n1Loop = new Loop_N1_850(); // N1 n1Loop.N1 = new N1(); n1Loop.N1.EntityIdentifierCode_01 = "ST"; n1Loop.N1.Name_02 = firstLineItems[7]; n1Loop.N1.IdentificationCodeQualifier_03 = "ZZ"; n1Loop.N1.IdentificationCode_04 = firstLineItems[8]; // Repeating N3 n1Loop.N3 = new List <N3>(); // N3 var n3 = new N3(); n3.AddressInformation_01 = firstLineItems[9]; n1Loop.N3.Add(n3); // Repeating N4 n1Loop.N4 = new List <N4>(); // N4 var n4 = new N4(); n4.CityName_01 = firstLineItems[10]; n4.StateorProvinceCode_02 = firstLineItems[11]; n4.PostalCode_03 = firstLineItems[12]; n1Loop.N4.Add(n4); // End N1 Loop result.N1Loop.Add(n1Loop); // Repeating PO1 Loops result.PO1Loop = new List <Loop_PO1_850>(); foreach (var line in lines.Skip(1)) { var lineItems = line.Split(new[] { ',' }); if (lineItems.Count() < 13) { throw new Exception("Insufficient number of columns"); } // Begin PO1 Loop var po1Loop = new Loop_PO1_850(); // PO1 po1Loop.PO1 = new PO1(); po1Loop.PO1.AssignedIdentification_01 = lineItems[0]; po1Loop.PO1.QuantityOrdered_02 = lineItems[2]; po1Loop.PO1.UnitorBasisforMeasurementCode_03 = lineItems[4]; po1Loop.PO1.UnitPrice_04 = lineItems[3]; po1Loop.PO1.ProductServiceIDQualifier_06 = "UP"; po1Loop.PO1.ProductServiceID_07 = lineItems[1]; // End PO1 Loop result.PO1Loop.Add(po1Loop); } return(result); }
/// <summary> /// Build invoice. /// Original example from http://www.x12.org/examples/004010X348/basic-invoice/ /// </summary> public static TS810 BuildInvoice(string controlNumber) { var result = new TS810(); // Indicates the start of an invoice transaction set and assigns a control number. result.ST = new ST(); result.ST.TransactionSetIdentifierCode_01 = "810"; result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0'); // Indicates the invoice was created on May 13, 2000 and assigned invoice number SG427254. // The invoice is in response to a purchase order sent on May 6, 2000 with purchase order number 508517 and release number 1001. result.BIG = new BIG(); result.BIG.Date_01 = "20000513"; result.BIG.InvoiceNumber_02 = "SG427254"; result.BIG.Date_03 = "20000506"; result.BIG.PurchaseOrderNumber_04 = "508517"; result.BIG.ReleaseNumber_05 = "1001"; // Repeating N1 Loops result.N1Loop = new List <Loop_N1_810>(); // Begin N1 Loop var n1Loop = new Loop_N1_810(); // Indicates that the ship to party is ABC Aerospace Corporation. ABC's D-U-N-S+4 number is 123456789-0101. n1Loop.N1 = new N1(); n1Loop.N1.EntityIdentifierCode_01 = "ST"; n1Loop.N1.Name_02 = "ABC AEROSPACE CORPORATION"; n1Loop.N1.IdentificationCodeQualifier_03 = "9"; n1Loop.N1.IdentificationCode_04 = "123456789-0101"; // Repeating N3 n1Loop.N3 = new List <N3>(); // The ship to party's street address is 1000 Boardwalk Drive. var n3 = new N3(); n3.AddressInformation_01 = "1000 BOARDWALK DRIVE"; n1Loop.N3.Add(n3); // The ship to party's city, state, and ZIP is Somewhere, CA 98898. n1Loop.N4 = new N4(); n1Loop.N4.CityName_01 = "SOMEWHERE"; n1Loop.N4.StateorProvinceCode_02 = "CA"; n1Loop.N4.PostalCode_03 = "98898"; // End N1 Loop result.N1Loop.Add(n1Loop); // Repeating ITD result.ITD = new List <ITD>(); // Indicates that discounts are not applicable, the terms period is the invoice date, and the net days due is 30 days using an electronic payment system. var itd = new ITD(); itd.TermsTypeCode_01 = "05"; itd.TermsBasisDateCode_02 = "3"; itd.TermsNetDays_07 = "30"; itd.PaymentMethodCode_14 = "E"; result.ITD.Add(itd); // Repeating IT1 Loops result.IT1Loop = new List <Loop_IT1_810>(); // Begin IT1 Loop var it1Loop = new Loop_IT1_810(); // Indicates that the purchase order's line number was 1. The invoice is for 48 units costing $3.00 each for manufacturer's part number R5656-2. it1Loop.IT1 = new IT1(); it1Loop.IT1.AssignedIdentification_01 = "1"; it1Loop.IT1.QuantityInvoiced_02 = "48"; it1Loop.IT1.UnitorBasisforMeasurementCode_03 = "EA"; it1Loop.IT1.UnitPrice_04 = "3"; it1Loop.IT1.ProductServiceIDQualifier_06 = "MG"; it1Loop.IT1.ProductServiceID_07 = "R5656-2"; // End IT1 Loop result.IT1Loop.Add(it1Loop); // Indicates that the total invoice amount is $144.00. result.TDS = new TDS(); result.TDS.Amount_01 = "14400"; // Indicates that the invoice contained 1 line item. result.CTT = new CTT(); result.CTT.NumberofLineItems_01 = "1"; return(result); }
/// <summary> /// 改变数字 /// </summary> /// <param name="num">数字</param> public void ChangeNum(double num) { if (num >= 0 && !IsPostive) { PostiveAndNegativeChanged?.Invoke(this, new PostiveAndNegativeChangedEventArgs { OldValue = IsPostive, NewValue = true }); IsPostive = true; } else if (num < 0 && IsPostive) { PostiveAndNegativeChanged?.Invoke(this, new PostiveAndNegativeChangedEventArgs { OldValue = IsPostive, NewValue = false }); IsPostive = false; } num = Math.Abs(num); string numstr = num.ToString(); if (numstr.IndexOf("E+") >= 0) { string[] numstmp = Regex.Split(numstr, "E+"); numstr = numstmp[0]; int x = 1; if (numstmp[0].IndexOf(".") >= 0) { numstr = numstr.Replace(".", ""); x = numstmp[0].Length - numstmp[0].IndexOf("."); } for (int i = x - 1; i < int.Parse(numstmp[1]); i++) { numstr += "0"; } } int[] numids = new int[6]; if (num >= 10000) { if (num >= 100000000) { string tmp1 = numstr.Split('.')[0]; string tmp2 = tmp1.Substring(0, tmp1.Length - 8); //整数部分 string tmp3 = tmp1.Substring(tmp2.Length, 1); //小数部分 numids[5] = -2; numids[4] = int.Parse(tmp1.Substring(tmp2.Length + 1, 1)) >= 5 ? int.Parse(tmp3) + 1 : int.Parse(tmp3); if (numids[4] >= 10) { numids[4] -= 10; tmp2 = (int.Parse(tmp2) + 1).ToString(); } for (int i = 1; i <= 4; i++) { if (tmp2.Length - i >= 0) { numids[4 - i] = int.Parse(tmp2.Substring(tmp2.Length - i, 1)); } else { if (4 - i == 3) { numids[3] = 0; } else { numids[4 - i] = -3; } } } } else { string tmp1 = numstr.Split('.')[0]; string tmp2 = tmp1.Substring(0, tmp1.Length - 4); //整数部分 string tmp3 = tmp1.Substring(tmp2.Length, 1); //小数部分 numids[5] = -1; numids[4] = int.Parse(tmp1.Substring(tmp2.Length + 1, 1)) >= 5 ? int.Parse(tmp3) + 1 : int.Parse(tmp3); if (numids[4] >= 10) { numids[4] -= 10; tmp2 = (int.Parse(tmp2) + 1).ToString(); } for (int i = 1; i <= 4; i++) { if (tmp2.Length - i >= 0) { numids[4 - i] = int.Parse(tmp2.Substring(tmp2.Length - i, 1)); } else { numids[4 - i] = -3; } } } } else { string[] tmp1 = numstr.Split('.'); for (int i = 1; i <= 4; i++) { if (tmp1[0].Length - i >= 0) { numids[4 - i] = int.Parse(tmp1[0].Substring(tmp1[0].Length - i, 1)); } else { numids[4 - i] = -3; } } if (tmp1.Length > 1) { for (int i = 0; i < 2; i++) { if (tmp1[1].Length - i > 0) { numids[4 + i] = int.Parse(tmp1[1].Substring(i, 1)); } else { numids[4 + i] = 0; } } } } N4.ChangeNum(numids[0]); N3.ChangeNum(numids[1]); N2.ChangeNum(numids[2]); N1.ChangeNum(numids[3]); if (numids[4] == 0 && numids[5] == 0) { numpoint.Visibility = Visibility.Hidden; P1.Visibility = Visibility.Hidden; P2.Visibility = Visibility.Hidden; ViewPanel.Margin = new Thickness(30, 0, -28, 0); } else { numpoint.Visibility = Visibility.Visible; P1.Visibility = Visibility.Visible; P2.Visibility = Visibility.Visible; ViewPanel.Margin = new Thickness(1, 0, 1, 0); P1.ChangeNum(numids[4]); P2.ChangeNum(numids[5]); } }
/// <summary> /// Builds freight invoice. /// Original from https://ps.extra.chrysler.com/sites/itb-ebus/Documents/210FreightPaymentInvoice.pdf /// </summary> static TS210 BuildFreightInvoice(string controlNumber) { var result = new TS210(); // Transaction Set Identifier Code = “210” // (Motor Carrier Freight Details and Invoice) // Transaction Set Control Number = 00000001 result.ST = new ST(); result.ST.TransactionSetIdentifierCode_01 = "210"; result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0'); // Invoice Number = 3410889 // Shipment Identification Number = 545930791T // Shipment Method of Payment // = “TP” (Third Party) // Weight Unit Code = “L” (Pounds) // Date = 10 / 31 / 2007 // Net Amount Due = 51.65 // Delivery Date = 10 / 29 / 2007 // Date / Time Qualifier = “035” (Delivered) // Standard Carrier Alpha Code = NLMI result.B3 = new B3(); result.B3.InvoiceNumber_02 = "3410889"; result.B3.ShipmentIdentificationNumber_03 = "545930791T"; result.B3.ShipmentMethodofPayment_04 = "TP"; result.B3.WeightUnitCode_05 = "L"; result.B3.Date_06 = "20071031"; result.B3.NetAmountDue_07 = "5165"; result.B3.DeliveryDate_09 = "20071029"; result.B3.DateTimeQualifier_10 = "035"; result.B3.StandardCarrierAlphaCode_11 = "NLMI"; // Currency Code = USD (U.S.) result.C3 = new C3(); result.C3.CurrencyCode_01 = "USD"; // Repeating N9 result.N9 = new List <N9>(); // Reference Identification Qualifier = “AE” // (Authorization for Expense<AFE> Number) // Reference Identification = 260451 var n91 = new N9(); n91.ReferenceIdentificationQualifier_01 = "AE"; n91.ReferenceIdentification_02 = "260451"; result.N9.Add(n91); // Reference Identification Qualifier // = “OP” (Original Purchase Order) // Reference Identification = 3410889 var n92 = new N9(); n92.ReferenceIdentificationQualifier_01 = "OP"; n92.ReferenceIdentification_02 = "3410889"; result.N9.Add(n92); // Repeating G62 result.G62 = new List <G62>(); // Date Qualifier = “86” (Actual Pickup Date) // Date = 10 / 31 / 2007 var g62 = new G62(); g62.DateQualifier_01 = "86"; g62.Date_02 = "20071031"; result.G62.Add(g62); // Repeating R3 result.R3 = new List <R3>(); // Standard Carrier Alpha Code = EXEM // Routing Sequence Code // = “B” (Origin / Delivery Carrier < Any Mode >) // Transportation Method/ Type Code // = “AE” (Air Express) // Date = 10 / 31 / 2007 // Amount = 379.05 var r3 = new R3(); r3.StandardCarrierAlphaCode_01 = "EXEM"; r3.RoutingSequenceCode_02 = "B"; r3.TransportationMethodTypeCode_04 = "AE"; r3.Date_07 = "20071031"; r3.Amount_08 = "37905"; result.R3.Add(r3); // Repeating N1 Loops result.N1Loop = new List <Loop_N1_210>(); // Begin N1 Loop 1 var n1Loop1 = new Loop_N1_210(); // Entity Identifier Code = “SH” (Shipper) // Name = SIEMENS VDO S A DE C V – // SIEMENS AUTOMOTIVE // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 99999 n1Loop1.N1 = new N1(); n1Loop1.N1.EntityIdentifierCode_01 = "SH"; n1Loop1.N1.Name_02 = "SIEMENS VDO S A DE C V - SIEMENS AUTOMOTIVE"; n1Loop1.N1.IdentificationCodeQualifier_03 = "94"; n1Loop1.N1.IdentificationCode_04 = "99999"; // Repeating N3 n1Loop1.N3 = new List <N3>(); // Address Information // = PERIFERICO SUR 7999D COMPLEJO IND var n31 = new N3(); n31.AddressInformation_01 = "PERIFERICO SUR 7999D COMPLEJO IND"; n1Loop1.N3.Add(n31); // City Name = TLAQUEPAQUE // State or Province Code = MX // Postal Code = 99999 // Country Code = MX n1Loop1.N4 = new N4(); n1Loop1.N4.CityName_01 = "TLAQUEPAQUE"; n1Loop1.N4.StateorProvinceCode_02 = "MX"; n1Loop1.N4.PostalCode_03 = "99999"; n1Loop1.N4.CountryCode_04 = "MX"; // End N1 Loop 1 result.N1Loop.Add(n1Loop1); // Begin N1 Loop 2 var n1Loop2 = new Loop_N1_210(); // Entity Identifier Code = “CN” (Consignee) // Name = BRAMPTON ASSEMBLY – COLLINS // AND AIKMAN // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 09126B n1Loop2.N1 = new N1(); n1Loop2.N1.EntityIdentifierCode_01 = "CN"; n1Loop2.N1.Name_02 = "BRAMPTON ASSEMBLY - COLLINS AND AIKMAN"; n1Loop2.N1.IdentificationCodeQualifier_03 = "94"; n1Loop2.N1.IdentificationCode_04 = "09126B"; // Repeating N3 n1Loop2.N3 = new List <N3>(); // Address Information // = 500 LAIRD ROAD~GUELPH PRODUCTS var n32 = new N3(); n32.AddressInformation_01 = "500 LAIRD ROAD"; n32.AddressInformation_02 = "GUELPH PRODUCTS"; n1Loop2.N3.Add(n32); // City Name = GUELPH // State or Province Code = ON // Postal Code = 99999 // Country Code = CA n1Loop2.N4 = new N4(); n1Loop2.N4.CityName_01 = "GUELPH"; n1Loop2.N4.StateorProvinceCode_02 = "ON"; n1Loop2.N4.PostalCode_03 = "99999"; n1Loop2.N4.CountryCode_04 = "CA"; // End N1 Loop 2 result.N1Loop.Add(n1Loop2); // Begin N1 Loop 3 var n1Loop3 = new Loop_N1_210(); // Entity Identifier Code = “BT” (Bill-to-Party) // Name = BRAMPTON ASSEMBLY - MAIN // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 09126 n1Loop3.N1 = new N1(); n1Loop3.N1.EntityIdentifierCode_01 = "BT"; n1Loop3.N1.Name_02 = "BRAMPTON ASSEMBLY - MAIN"; n1Loop3.N1.IdentificationCodeQualifier_03 = "94"; n1Loop3.N1.IdentificationCode_04 = "09126"; // Repeating N3 n1Loop3.N3 = new List <N3>(); // Address Information // = 2000 WILLIAMS PARKWAY EAST var n33 = new N3(); n33.AddressInformation_01 = "2000 WILLIAMS PARKWAY EAST"; n1Loop3.N3.Add(n33); // City Name = BRAMPTON // State or Province Code = ON // Postal Code = 99999 // Country Code = CA n1Loop3.N4 = new N4(); n1Loop3.N4.CityName_01 = "BRAMPTON"; n1Loop3.N4.StateorProvinceCode_02 = "ON"; n1Loop3.N4.PostalCode_03 = "99999"; n1Loop3.N4.CountryCode_04 = "CA"; // End N1 Loop 3 result.N1Loop.Add(n1Loop3); // Begin N1 Loop 4 var n1Loop4 = new Loop_N1_210(); // Entity Identifier Code = “CA” (Carrier) // Name // = NATIONAL LOGISTICS MANAGEMENT // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 45795 n1Loop4.N1 = new N1(); n1Loop4.N1.EntityIdentifierCode_01 = "CA"; n1Loop4.N1.Name_02 = "NATIONAL LOGISTICS MANAGEMENT"; n1Loop4.N1.IdentificationCodeQualifier_03 = "94"; n1Loop4.N1.IdentificationCode_04 = "45795"; // Repeating N3 n1Loop4.N3 = new List <N3>(); // Address Information = 14320 JOY RD. var n34 = new N3(); n34.AddressInformation_01 = "14320 JOY RD."; n1Loop4.N3.Add(n34); // City Name = DETROIT // State or Province Code = MI // Postal Code = 48228 // Country Code = US n1Loop4.N4 = new N4(); n1Loop4.N4.CityName_01 = "DETROIT"; n1Loop4.N4.StateorProvinceCode_02 = "MI"; n1Loop4.N4.PostalCode_03 = "48228"; n1Loop4.N4.CountryCode_04 = "US"; // End N1 Loop 4 result.N1Loop.Add(n1Loop4); // Begin N1 Loop 5 var n1Loop5 = new Loop_N1_210(); // Entity Identifier Code = “ZZ” (Mutually Defined) // Name = EXPEDITORS / EMERY WORLDWIDE // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 37905 n1Loop5.N1 = new N1(); n1Loop5.N1.EntityIdentifierCode_01 = "ZZ"; n1Loop5.N1.Name_02 = "EXPEDITORS/EMERY WORLDWIDE"; n1Loop5.N1.IdentificationCodeQualifier_03 = "94"; n1Loop5.N1.IdentificationCode_04 = "37905"; // Repeating N3 n1Loop5.N3 = new List <N3>(); // Address Information = 10881 LOWELL AVENUE var n35 = new N3(); n35.AddressInformation_01 = "10881 LOWELL AVENUE"; n1Loop5.N3.Add(n35); // City Name = OVERLANDPARK // State or Province Code = KS // Postal Code = 66201 // Country Code = US n1Loop5.N4 = new N4(); n1Loop5.N4.CityName_01 = "OVERLANDPARK"; n1Loop5.N4.StateorProvinceCode_02 = "KS"; n1Loop5.N4.PostalCode_03 = "66201"; n1Loop5.N4.CountryCode_04 = "US"; // Repeating N9 n1Loop5.N9 = new List <N9>(); // Reference Identification Qualifier // = “IK” (Invoice Number) // Reference Identification = 545930791T var n9 = new N9(); n9.ReferenceIdentificationQualifier_01 = "IK"; n9.ReferenceIdentification_02 = "545930791T"; n1Loop5.N9.Add(n9); // End N1 Loop 5 result.N1Loop.Add(n1Loop5); // Repeating N7 Loops result.N7Loop = new List <Loop_N7_210>(); // Begin N7 Loop var n7Loop1 = new Loop_N7_210(); // Equipment Number = 53456 // Equipment Description Code // = “TL” (Trailer < not otherwise specified>) // Equipment Length = 53 Feet // Equipment Type // = “53ST” (53 Foot Standard Trailer) n7Loop1.N7 = new N7(); n7Loop1.N7.EquipmentNumber_02 = "53456"; n7Loop1.N7.EquipmentDescriptionCode_11 = "TL"; n7Loop1.N7.EquipmentLength_15 = "5300"; n7Loop1.N7.EquipmentType_22 = "53ST"; // End N7 Loop result.N7Loop.Add(n7Loop1); // Repeating LX Loops result.LXLoop = new List <Loop_LX_210>(); // Begin LX Loop var lxLoop1 = new Loop_LX_210(); // Assigned Number = 1 lxLoop1.LX = new LX(); lxLoop1.LX.AssignedNumber_01 = "1"; // Repeating L5 lxLoop1.L5 = new List <L5>(); // Lading Line Item Number= 1 // Commodity Code = “2” (Auto Parts) // Commodity Code Qualifier // = “Z” (Mutually defined) var l5 = new L5(); l5.LadingLineItemNumber_01 = "1"; l5.CommodityCode_03 = "2"; l5.CommodityCodeQualifier_04 = "Z"; lxLoop1.L5.Add(l5); // Repeating L0 lxLoop1.L0 = new List <L0>(); // Lading Line Item Number = 1 // Billed / Rated -as Quantity = 1499 // Billed / Rated -as Qualifier = “FR” (Flat Rate) // Weight = 1499 // Weight Qualifier = “G” (Gross) // Weight Unit Code = “L” (Pounds) var l0 = new L0(); l0.LadingLineItemNumber_01 = "1"; l0.BilledRatedasQuantity_02 = "1499"; l0.BilledRatedasQualifier_03 = "FR"; l0.Weight_04 = "1499"; l0.WeightQualifier_05 = "G"; l0.WeightUnitCode_11 = "L"; lxLoop1.L0.Add(l0); // Repeating L0 lxLoop1.L1 = new List <L1>(); // Lading Line Item Number = 1 // Freight Rate = 51.65 // Rate / Value Qualifier = “FR” (Flat Rate) // Charge = 51.65 // Special Charge or Allowance Code // = “400” (Freight) var l1 = new L1(); l1.LadingLineItemNumber_01 = "1"; l1.FreightRate_02 = "51.65"; l1.RateValueQualifier_03 = "FR"; l1.Charge_04 = "5165"; l1.SpecialChargeorAllowanceCode_08 = "400"; lxLoop1.L1.Add(l1); // End LX Loop result.LXLoop.Add(lxLoop1); // Weight = 2619 // Weight Qualifier = “G” (Gross Weight) // Charge = 51.65 result.L3 = new L3(); result.L3.Weight_01 = "2619"; result.L3.WeightQualifier_02 = "G"; result.L3.Charge_05 = "5165"; return(result); }
public void TestMatricesFromNoisedPoints() { List <Image <Arthmetic, double> > ptsReal = new List <Image <Arthmetic, double> >(); List <PointF> pts1 = new List <PointF>(); List <PointF> pts2 = new List <PointF>(); List <PointF> pts3 = new List <PointF>(); List <PointF> pts1Ref = new List <PointF>(); List <PointF> pts2Ref = new List <PointF>(); List <PointF> pts3Ref = new List <PointF>(); Random rand = new Random(1003); double stddev = 3; int pointsCount = 100; for (int i = 0; i < pointsCount; ++i) { var real = new Image <Arthmetic, double>(new double[, , ] { { { rand.Next(100, 200) } }, { { rand.Next(100, 200) } }, { { rand.Next(50, 100) } }, { { 1 } }, }); ptsReal.Add(real); var i1 = P1.Multiply(real).ToPointF(); pts1Ref.Add(i1); i1 = new PointF(i1.X + Noise(stddev, rand), i1.Y + Noise(stddev, rand)); pts1.Add(i1); var i2 = P2.Multiply(real).ToPointF(); pts2Ref.Add(i2); i2 = new PointF(i2.X + Noise(stddev, rand), i2.Y + Noise(stddev, rand)); pts2.Add(i2); var i3 = P3.Multiply(real).ToPointF(); pts3Ref.Add(i3); i3 = new PointF(i3.X + Noise(stddev, rand), i3.Y + Noise(stddev, rand)); pts3.Add(i3); } double rangeLx = pts1.Max((x) => x.X) - pts1.Min((x) => x.X); double rangeLy = pts1.Max((x) => x.Y) - pts1.Min((x) => x.Y); double rangeRx = pts2.Max((x) => x.X) - pts2.Min((x) => x.X); double rangeRy = pts2.Max((x) => x.Y) - pts2.Min((x) => x.Y); var pts1_n = new List <PointF>(pts1); var pts2_n = new List <PointF>(pts2); var pts3_n = new List <PointF>(pts3); FindTransformation.NormalizePoints2d(pts1_n, out Image <Arthmetic, double> N1); FindTransformation.NormalizePoints2d(pts2_n, out Image <Arthmetic, double> N2); FindTransformation.NormalizePoints2d(pts3_n, out Image <Arthmetic, double> N3); var F = ComputeMatrix.F(new VectorOfPointF(pts1_n.ToArray()), new VectorOfPointF(pts2_n.ToArray())); var F23 = ComputeMatrix.F(new VectorOfPointF(pts2_n.ToArray()), new VectorOfPointF(pts3_n.ToArray())); // F is normalized - lets denormalize it F = N2.T().Multiply(F).Multiply(N1); F23 = N3.T().Multiply(F23).Multiply(N2); var E = ComputeMatrix.E(F, K); var E23 = ComputeMatrix.E(F23, K); var svd = new Svd(E); var svd23 = new Svd(E23); FindTransformation.DecomposeToRTAndTriangulate(pts1, pts2, K, E, out var RR, out var TT, out Image <Arthmetic, double> estReal_); FindTransformation.DecomposeToRTAndTriangulate(pts2, pts3, K, E23, out var RR23, out var TT23, out Image <Arthmetic, double> estReal23_); var rr0 = RotationConverter.MatrixToEulerXYZ(R12); var rr1 = RotationConverter.MatrixToEulerXYZ(RR); double idealScale = T23.Norm / T12.Norm; double idealScale2 = T12.Norm / T23.Norm; var tt0 = T12.Mul(1 / T12.Norm); var tt1 = TT.Mul(1 / TT.Norm).Mul(T12[0, 0] * TT[0, 0] < 0 ? -1 : 1); var tt1_23 = TT23.Mul(1 / TT23.Norm).Mul(T23[0, 0] * TT23[0, 0] < 0 ? -1 : 1); FindTransformation.TriangulateChieral(pts1, pts2, K, RR, tt1, out var estReal12); FindTransformation.TriangulateChieral(pts2, pts3, K, RR23, tt1_23, out var estReal23); RansacScaleEstimation ransacModel = new RansacScaleEstimation(estReal12, estReal23, RR, ComputeMatrix.Center(tt1, RR)); int sampleSize = (int)(0.1 * pointsCount); int minGoodPoints = (int)(0.2 * pointsCount); int maxIterations = 1000; double meanRefPointSize = ScaleBy3dPointsMatch.GetMeanSize(estReal12); double threshold = meanRefPointSize * meanRefPointSize * 0.1; var result = RANSAC.ProcessMostInliers(ransacModel, maxIterations, sampleSize, minGoodPoints, threshold, 1.0); double scale = (double)result.BestModel; var estRealRef23To12 = ScaleBy3dPointsMatch.TransfromBack3dPoints(RR, tt1, estReal23, scale); double simpleScaleMean = 0.0; for (int i = 0; i < pointsCount; ++i) { var p12 = new Image <Arthmetic, double>(new double[, , ] { { { estReal12[1, i] } }, { { estReal12[2, i] } }, { { estReal12[3, i] } }, }); var p23 = new Image <Arthmetic, double>(new double[, , ] { { { estReal23[0, i] } }, { { estReal23[1, i] } }, { { estReal23[2, i] } }, }); double n1 = p12.Norm; double n2 = p23.Norm; double simpleScale = n2 / n1; simpleScaleMean += simpleScale; } simpleScaleMean /= pointsCount; double simpleScaleMean2 = 1 / simpleScaleMean; // TODO: compute below only on inliers Image <Arthmetic, double> inliersOnly12 = new Image <Arthmetic, double>(result.Inliers.Count, 4); Image <Arthmetic, double> inliersOnly12Ref = new Image <Arthmetic, double>(result.Inliers.Count, 4); Image <Arthmetic, double> inliersOnly23 = new Image <Arthmetic, double>(result.Inliers.Count, 4); for (int i = 0; i < result.Inliers.Count; ++i) { int k = result.Inliers[i]; for (int j = 0; j < 4; ++j) { inliersOnly12[j, i] = estReal12[j, k]; inliersOnly12Ref[j, i] = ptsReal[k][j, 0]; inliersOnly23[j, i] = estRealRef23To12[j, k]; } } var ptsRealM = Utils.Matrixify(ptsReal); Errors.TraingulationError(ptsRealM, estReal12, out double mean1x, out double median1x, out List <double> errors1x); Errors.TraingulationError(ptsRealM, estRealRef23To12, out double mean1z, out double median1z, out List <double> errors1z); Errors.TraingulationError(inliersOnly12Ref, inliersOnly12, out double mean_in1, out double median_in1, out List <double> errors_in1); Errors.TraingulationError(inliersOnly12Ref, inliersOnly23, out double mean_in2, out double median_in2, out List <double> errors_in2); Errors.TraingulationError(inliersOnly12, inliersOnly23, out double mean_in3, out double median_in3, out List <double> errors_in3); var ptsReal23M = ForwardProject3dPoints(ptsRealM, R12, C2); Errors.TraingulationError(ptsReal23M, estReal23, out double mean1h, out double median1h, out List <double> errors1h); var estC2 = ComputeMatrix.Center(tt1, RR); var ptsEst23M = ForwardProject3dPoints(estReal12, RR, estC2); Errors.TraingulationError(ptsEst23M, estReal23, out double mean1t, out double median1t, out List <double> errors1t); int dummy = 0; //Errors.TraingulationError(ptsReal, estReal, out double mean1, out double median1, out List<double> errors1); //Errors.ReprojectionError(estReal, pts2, K, RR, tt1, out double mean_r1a, out double median_r1a, out List<double> _1); //Errors.ReprojectionError(estReal, pts2Ref, K, RR, tt1, out double mean_r1b, out double median_r1b, out List<double> _2); //Errors.ReprojectionError(estReal, pts2Ref, K, R12, tt0, out double mean_r1c, out double median_r1c, out List<double> _3); //Errors.ReprojectionError(Errors.Matrixify(ptsReal), pts2Ref, K, RR, tt1, out double mean_r1e, out double median_r1e, out List<double> _5); var H1 = FindTransformation.EstimateHomography(pts1, pts2, K); var H2 = FindTransformation.EstimateHomography(pts1Ref, pts2Ref, K); var hrr1 = RotationConverter.MatrixToEulerXYZ(H1); var hrr2 = RotationConverter.MatrixToEulerXYZ(H2); //var zeroT = new Image<Arthmetic, double>(1, 3); //var H3 = RotationConverter.EulerXYZToMatrix(hrr1); //var hrr3 = RotationConverter.MatrixToEulerXYZ(H1); //var svdH = new Svd(H1); bool isRotation = FindTransformation.IsPureRotation(H1); int dummy2 = 0; //Errors.ReprojectionError2d(pts1Ref, pts2Ref, K, H2, out double mean_h2, out double median_h2, out var err_h2); //Errors.ReprojectionError2d(pts1, pts2, K, H1, out double mean_h1, out double median_h1, out var err_h1); //Errors.ReprojectionError2d(pts1, pts2, K, H3, out double mean_h3, out double median_h3, out var err_h3); //Errors.ReprojectionError2dWithT(pts1, pts2, K, H1, zeroT, out double scale1, out double mean_h1a, out double median_h1a, out var err_h1a); //Errors.ReprojectionError2dWithT(pts1, pts2, K, H3, zeroT, out double scale1x, out double mean_h1ax, out double median_h1ax, out var err_h1ax); //// Errors.ReprojectionError2dWithT(pts1, pts2, K, R12, tt0, out double scale2, out double mean_h1b, out double median_h1b, out var err_h1b); //Errors.ReprojectionError2dWithT(pts1, pts2, K, RR, tt1, out double scale3, out double mean_h1c, out double median_h1c, out var err_h1c); //Errors.ReprojectionError2dWithT(pts1, pts2, K, R12, tt1, out double scale5, out double mean_h1c1, out double median_h1c1, out var err_h1c1); //Errors.ReprojectionError2dWithT(pts1Ref, pts2Ref, K, R12, tt0, out double scale6, out double mean_h1c2, out double median_h1c2, out var err_h1c2); //Errors.ReprojectionError2dWithT(pts1, pts2, K, H1, tt1, out double scale4, out double mean_h1d, out double median_h1d, out var err_h1d); //var KK = EstimateCameraFromImagePair.K(F, 600, 500); //var EE = ComputeMatrix.E(F, KK); //var svd2 = new Svd(EE); //FindTransformation.DecomposeToRTAndTriangulate(pts1, pts2, KK, EE, out var RR2, out var TT2, out Image<Arthmetic, double> estReal2); //var tt2 = TT2.Mul(1 / TT2.Norm); //var rr2 = RotationConverter.MatrixToEulerXYZ(RR2); //Errors.TraingulationError(ptsReal, estReal2, out double mean2, out double median2, out List<double> errors2); //Errors.ReprojectionError(estReal2, pts2, KK, RR2, tt2, out double mean_r2a, out double median_r2a, out List<double> _1x); //Errors.ReprojectionError(estReal2, pts2Ref, KK, RR2, tt2, out double mean_r2b, out double median_r2b, out List<double> _2x); //Errors.ReprojectionError(estReal2, pts2Ref, KK, R12, tt0, out double mean_r2c, out double median_r2c, out List<double> _3x); //Errors.ReprojectionError(Errors.Matrixify(ptsReal), pts2Ref, KK, RR2, tt2, out double mean_r2e, out double median_r2e, out List<double> _5x); }