示例#1
0
        private static MV_LstItems_CLkOrder GetMVRecord(string[] reg, string[] regI, int mvNumber)
        {
            MV_LstItems_CLkOrder mvorder = new MV_LstItems_CLkOrder();

            //Fill the class Multivalue properties
            mvorder.Item             = LinkarDataTypes.GetAlpha(reg[2], mvNumber);
            mvorder.Qty              = LinkarDataTypes.GetDecimal(reg[3], mvNumber);
            mvorder.Price            = LinkarDataTypes.GetDecimal(reg[4], mvNumber);
            mvorder.ITotalLine       = LinkarDataTypes.GetDecimal(regI[3], mvNumber);
            mvorder.IItemDescription = LinkarDataTypes.GetAlpha(regI[1], mvNumber);
            mvorder.IItemStock       = LinkarDataTypes.GetDecimal(regI[2], mvNumber);

            #region Subvalues

            //Get the max number of subvalues dinamically
            int numSV_LstPartial      = 0;
            int tmpCountSV_LstPartial = 0;
            tmpCountSV_LstPartial = MvFunctions.LkDCount(reg[5].Split(DBMV_Mark.VM)[mvNumber], DBMV_Mark.SM_str);
            if (tmpCountSV_LstPartial > numSV_LstPartial)
            {
                numSV_LstPartial = tmpCountSV_LstPartial;
            }
            tmpCountSV_LstPartial = MvFunctions.LkDCount(reg[6].Split(DBMV_Mark.VM)[mvNumber], DBMV_Mark.SM_str);
            if (tmpCountSV_LstPartial > numSV_LstPartial)
            {
                numSV_LstPartial = tmpCountSV_LstPartial;
            }

            if (mvorder.LstLstPartial == null)
            {
                mvorder.LstLstPartial = new List <SV_LstPartial_CLkOrder>();
            }

            //Iterate subvalues
            for (int i = 0; i < numSV_LstPartial; i++)
            {
                if (i < mvorder.LstLstPartial.Count())
                {
                    mvorder.LstLstPartial[i] = GetSVRecord(reg, regI, mvNumber, i);
                }
                else
                {
                    SV_LstPartial_CLkOrder regsv = new SV_LstPartial_CLkOrder();
                    regsv = GetSVRecord(reg, regI, mvNumber, i);
                    mvorder.LstLstPartial.Add(regsv);
                }
            }
            if (numSV_LstPartial < mvorder.LstLstPartial.Count())
            {
                int offset = mvorder.LstLstPartial.Count() - numSV_LstPartial;
                for (int i = 0; i < offset; i++)
                {
                    mvorder.LstLstPartial.RemoveAt(mvorder.LstLstPartial.Count() - 1);
                }
            }

            #endregion

            return(mvorder);
        }
示例#2
0
        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);
        }