private static SV_LstPartial_CLkOrder GetSVRecord(string[] reg, string[] regI, int mvNumber, int svNumber) { SV_LstPartial_CLkOrder svorder = new SV_LstPartial_CLkOrder(); //Fill the class Multivalue properties string _DeliveryDateTime = LinkarDataTypes.GetDateTime(reg[5], mvNumber, svNumber); if (!string.IsNullOrWhiteSpace(_DeliveryDateTime)) { int dias; int.TryParse(_DeliveryDateTime, out dias); svorder.DeliveryDateTime = new DateTime(1967, 12, 31).AddDays(dias); } else { svorder.DeliveryDateTime = null; } svorder.PartialQuantity = LinkarDataTypes.GetDecimal(reg[6], mvNumber, svNumber); return(svorder); }
public static Order GetRecord(string recordID, string record, string recordCalculated) { Order order = new Order(); //Create empty record string[] reg = new string[7]; for (int j = 0; j < reg.Length; j++) { reg[j] = ""; } //Fill the record if (!string.IsNullOrEmpty(record)) { string[] aux = record.Split(DBMV_Mark.AM); for (int j = 0; j < aux.Length; j++) { reg[j] = aux[j]; } } //Create empty calculated record string[] regI = new string[6]; for (int k = 0; k < regI.Length; k++) { regI[k] = ""; } //Fill the calculated record if (recordCalculated != null && recordCalculated != "") { string[] auxI = recordCalculated.Split(DBMV_Mark.AM); int k = 0; for (; k < auxI.Length; k++) { regI[k] = auxI[k]; } } //Fill the record ID property order.Code = recordID; if (record == null || record == "") { return(null); } //Fill the class properties order.Customer = LinkarDataTypes.GetAlpha(reg[0]); string _Date = LinkarDataTypes.GetDateTime(reg[1]); if (!string.IsNullOrWhiteSpace(_Date)) { int dias; int.TryParse(_Date, out dias); order.Date = new DateTime(1967, 12, 31).AddDays(dias); } else { order.Date = null; } order.ITotalOrder = LinkarDataTypes.GetDecimal(regI[4]); order.ICustomerName = LinkarDataTypes.GetAlpha(regI[0]); #region Multivalues //Get the max number of multivalues dinamically int numMV_LstItems = 0; int tmpCountMV_LstItems = 0; tmpCountMV_LstItems = MvFunctions.LkDCount(reg[2], DBMV_Mark.VM_str); if (tmpCountMV_LstItems > numMV_LstItems) { numMV_LstItems = tmpCountMV_LstItems; } tmpCountMV_LstItems = MvFunctions.LkDCount(reg[3], DBMV_Mark.VM_str); if (tmpCountMV_LstItems > numMV_LstItems) { numMV_LstItems = tmpCountMV_LstItems; } tmpCountMV_LstItems = MvFunctions.LkDCount(reg[4], DBMV_Mark.VM_str); if (tmpCountMV_LstItems > numMV_LstItems) { numMV_LstItems = tmpCountMV_LstItems; } tmpCountMV_LstItems = MvFunctions.LkDCount(regI[3], DBMV_Mark.VM_str); if (tmpCountMV_LstItems > numMV_LstItems) { numMV_LstItems = tmpCountMV_LstItems; } tmpCountMV_LstItems = MvFunctions.LkDCount(regI[1], DBMV_Mark.VM_str); if (tmpCountMV_LstItems > numMV_LstItems) { numMV_LstItems = tmpCountMV_LstItems; } tmpCountMV_LstItems = MvFunctions.LkDCount(regI[2], DBMV_Mark.VM_str); if (tmpCountMV_LstItems > numMV_LstItems) { numMV_LstItems = tmpCountMV_LstItems; } tmpCountMV_LstItems = MvFunctions.LkDCount(reg[5], DBMV_Mark.VM_str); if (tmpCountMV_LstItems > numMV_LstItems) { numMV_LstItems = tmpCountMV_LstItems; } tmpCountMV_LstItems = MvFunctions.LkDCount(reg[6], DBMV_Mark.VM_str); if (tmpCountMV_LstItems > numMV_LstItems) { numMV_LstItems = tmpCountMV_LstItems; } if (order.LstLstItems == null) { order.LstLstItems = new List <MV_LstItems_CLkOrder>(); } //Iterate multivalues for (int i = 0; i < numMV_LstItems; i++) { if (i < order.LstLstItems.Count()) { order.LstLstItems[i] = GetMVRecord(reg, regI, i); } else { MV_LstItems_CLkOrder regmv = new MV_LstItems_CLkOrder(); regmv = GetMVRecord(reg, regI, i); order.LstLstItems.Add(regmv); } } if (numMV_LstItems < order.LstLstItems.Count()) { int offset = order.LstLstItems.Count() - numMV_LstItems; for (int i = 0; i < offset; i++) { order.LstLstItems.RemoveAt(order.LstLstItems.Count() - 1); } } #endregion return(order); }