示例#1
0
        } // PopulateFreightLine

        #endregion

        #region public_methods
        /// <summary>
        /// Populate the Freight data structure
        /// </summary>
        /// <param name="csv"></param>
        /// <returns>Populated Freight data structure</returns>
        public static Freight CSVToFreight(FreightCSV csv)
        {
            double  pkgnumber     = 0;
            Freight freightUpdate = new Freight();

            freightUpdate.freight_lines = new List <FreightLine>();
            /* Get a list of the order numbers */
            List <string> orders = csv.DT.AsEnumerable().Select(n => n.Field <String>("ORDER #")).Distinct().ToList();

            /* Loop through each order number */
            foreach (string order in orders)
            {
                pkgnumber = 0;
                /* Now grab all the orders with the same order number */
                List <DataRow> orderList = csv.DT.AsEnumerable().Where(n => order == n.Field <String>("ORDER #")).ToList();
                foreach (DataRow r in orderList)
                {
                    pkgnumber++;
                    FreightLine line = PopulateFreightLine(r, pkgnumber);
                    freightUpdate.freight_lines.Add(line);
                }
            }
            // Now populate all the shipment numbers based on the order numbers
            JDE.GetShipmentNumbers(ref freightUpdate, orders);
            return(freightUpdate);
        } // CSVToFreight