public int LoadOrders(Products itemList) { var orders = SqlHelper.GetPendingOrders(); var lineCount = orders.Rows.Count; InitProgressBar(this, new ProgressBarEventArgs(0, lineCount)); foreach (DataRow row in orders.Rows) { var objOrdLine = new OrderLine(row); IncrementProgressBar(this, new ProgressBarEventArgs()); Logger.Log( String.Format(" Loaded order line {0}, Item - {1}", objOrdLine.Key, objOrdLine.ProductId), LogLevel.Debug); var itemNum = objOrdLine.ProductId; Product item; if (!_cachedItems.TryGetValue(itemNum, out item)) { item = itemList.GetItem(itemNum); _cachedItems.Add(itemNum, item); } objOrdLine.Item = item; Add(objOrdLine.Key, objOrdLine); } return(lineCount); }
public void SetCarrier(Products itemList) { if (CustInfo.POBox) { // Must use US Mail for PO Box addresses. Carrier = "USPS"; return; } if (multiItem == "M") { // Must use UPS for multiple item packages. Carrier = "UPS"; return; } // Single item package carrier determined by flag on item. Carrier = (itemList.GetItem(itemNum).ShipUSMail ? "USPS" : "UPS"); }
public void CalcWeightAndSize(Products itemList) { foreach (var kvpItem in items) { var tempItem = itemList.GetItem(kvpItem.Key); if (String.IsNullOrEmpty(ItemNumber)) { ItemNumber = tempItem.ItemNumber; Description = tempItem.Description; } TotalWeight += tempItem.GetWeightByQty(kvpItem.Value); if (tempItem.CubicSize > cubicSize) { H = tempItem.H; L = tempItem.L; W = tempItem.W; cubicSize = tempItem.CubicSize; } } }
public void CreatePackages() { Package shipPkg = null; InitProgressBar(this, new ProgressBarEventArgs(0, prePkgObjs.Values.Count + 1)); foreach (var prePkg in prePkgObjs.Values) { IncrementProgressBar(this, new ProgressBarEventArgs()); var objOrder = orderList[prePkg.Key]; var objCustomer = custList[prePkg.CustomerKey]; XmlNode pkgNode; if (prePkg.SinglePackItems.Count > 0) { foreach (var objOrdItem in prePkg.SinglePackItems.Values) { pkgNode = xrefList.CreatePackageNode(packageID, objOrdItem.OrderInfo); // ReSharper disable PossibleNullReferenceException Logger.Log(String.Format(" Package node created, {0} - {1}", pkgNode.Attributes["ID"].Value, pkgNode.Attributes["Key"].Value), LogLevel.Debug); // ReSharper restore PossibleNullReferenceException xrefList.AddOrderNode(pkgNode, objOrdItem.OrderInfo, objOrdItem.Quantity); Logger.Log(String.Format(" Order line added, {0} - {1} - {2}", objOrdItem.OrderInfo.OrderNumber, objOrdItem.OrderInfo.OrderItemId, objOrdItem.OrderInfo.OrderId), LogLevel.Debug); var objItem = objOrdItem.Item; var shipUSMail = (objItem.ShipUSMail || objCustomer.POBox); shipPkg = new Package(packageID, objItem, objOrder, objOrdItem.OrderInfo.OrderItemId, objCustomer, (shipUSMail ? "USPS" : "UPS")); if (objItem.HasDimensions) { shipPkg.SetDimensions(objItem); } shipPkg.Weight = objItem.Weight; Add(packageID.ToString(), shipPkg); xrefList.AddPackageNode(pkgNode); Logger.Log(String.Format(" Package node added, {0}", pkgNode.Attributes["ID"].Value), LogLevel.Debug); packageID++; if (objItem.IsKit) { { for (int i = 0; i < objItem.SubItems.Count - 1; i++) { var tempItem = itemList.GetItem(objItem.SubItems[i]); var newShipPkg = new Package(packageID, shipPkg, tempItem); if (tempItem.HasDimensions) { newShipPkg.SetDimensions(tempItem); } newShipPkg.Weight = tempItem.Weight; Add(packageID.ToString(), newShipPkg); packageID++; } } } } } pkgNode = null; foreach (var multiPackList in prePkg.MultiPackItems.Values) { // ReSharper disable PossibleNullReferenceException if (multiPackList.Count > 0) { var multiItemList = new PackageItems(); foreach (var objOrdItem in multiPackList.Values) { multiItemList.AddItem(objOrdItem); if (pkgNode == null) { pkgNode = xrefList.CreatePackageNode(packageID, objOrdItem.OrderInfo); shipPkg = new Package(packageID, objOrder, objCustomer, objOrdItem.OrderInfo); Logger.Log(String.Format(" Package node created, {0} - {1}", pkgNode.Attributes["ID"].Value, pkgNode.Attributes["Key"].Value), LogLevel.Debug); } xrefList.AddOrderNode(pkgNode, objOrdItem.OrderInfo, objOrdItem.Quantity); Logger.Log(String.Format(" Order line added, {0} - {1} - {2}", objOrdItem.OrderInfo.OrderNumber, objOrdItem.OrderInfo.OrderItemId, objOrdItem.OrderInfo.OrderId), LogLevel.Debug); } multiItemList.CalcWeightAndSize(itemList); shipPkg.AddItems(multiItemList); shipPkg.SetCarrier(itemList); Add(packageID.ToString(), shipPkg); xrefList.AddPackageNode(pkgNode); Logger.Log(String.Format(" Package node added, {0}", pkgNode.Attributes["ID"].Value), LogLevel.Debug); packageID++; } pkgNode = null; // ReSharper restore PossibleNullReferenceException } } xrefList.SaveDocument(); Settings.PackageID = packageID; }