public static void GetItemHSCode(OrderLine orderLine) { orderLine.ItemHSCode = orderLine.ItemCode + "-HS"; }
public static void GetItemUPCCode(OrderLine orderLine) { orderLine.ItemUPCCode = orderLine.ItemCode + "-UPC"; }
public static List<Order> CreateOrdersFromXML(int iSiteID, string sClientCode, string xml, out Dictionary<string, string> oErrors) { List<Order> oOrders = new List<Order>(); oErrors = new Dictionary<string, string>(); XmlDocument oXmlDoc = new XmlDocument(); Order oOrder = null; try { Event.ValidateXmlSchema.Fire(iSiteID, sClientCode, xml); } catch (Exception ex) { throw new Exception("Schema validation failed. " + Helper.FormatExceptionMessage(ex)); } oXmlDoc.LoadXml(xml); // In order to validate the xml, we need at least the site and client, so that the correct xml schema can be loaded from the configuration. XmlNodeList oNodes = oXmlDoc.SelectNodes("//Orders/DN"); foreach (XmlElement oXmlElement in oNodes) { try { oOrder = new Order(); oOrder.OrderNo = Event.GenerateOrderNo.Fire(iSiteID, sClientCode); oOrder.SiteID = iSiteID; oOrder.ClientCode = sClientCode; oOrder.DateCreated = DateTime.Now; foreach (XmlElement oInnerElement in oXmlElement.ChildNodes) { if (oInnerElement.Name.ToUpper() == "LINE") { // We ignore the LINE elements because it will be used later to create order lines. continue; } if (oInnerElement.Name.ToUpper() == "ORDERNO") { oOrder.ClientOrderNo = oInnerElement.InnerText; } else { // Custom elements OrderExtension oOrderExtension = new OrderExtension(); oOrderExtension.OrderNo = oOrder.OrderNo; oOrderExtension.LineNo = 0; oOrderExtension.Key = oInnerElement.Name; oOrderExtension.Value = oInnerElement.InnerText; oOrder.OrderExtensions.Add(oOrderExtension); } } foreach (XmlElement oInnerElement in oXmlElement.ChildNodes) { if (oInnerElement.Name.ToUpper() != "LINE") { // We ignore the LINE elements because it will be used later to create order lines. continue; } OrderLine oOrderLine = new OrderLine(); oOrderLine.OrderNo = oOrder.OrderNo; foreach (XmlElement oLineElement in oInnerElement.ChildNodes) { if (oLineElement.Name.ToUpper() == "NO") { oOrderLine.LineNo = Convert.ToInt32(oLineElement.InnerText); break; } } foreach (XmlElement oLineElement in oInnerElement.ChildNodes) { if (oLineElement.Name.ToUpper() == "NO") { continue; } if (oLineElement.Name.ToUpper() == "ITEMCODE") { oOrderLine.ItemCode = oLineElement.InnerText; } else if (oLineElement.Name.ToUpper() == "QUANTITY") { oOrderLine.Quantity = Convert.ToDouble(oLineElement.InnerText); } else { // Custom elements OrderExtension oOrderExtension = new OrderExtension(); oOrderExtension.OrderNo = oOrder.OrderNo; oOrderExtension.LineNo = oOrderLine.LineNo; oOrderExtension.Key = oLineElement.Name; oOrderExtension.Value = oLineElement.InnerText; oOrder.OrderExtensions.Add(oOrderExtension); } } oOrder.OrderLines.Add(oOrderLine); } oOrders.Add(oOrder); } catch (Exception ex) { oErrors.Add(oOrder.ClientOrderNo == "" ? "NA" : oOrder.ClientOrderNo, "Could not create order from xml. " + Helper.FormatExceptionMessage(ex)); } } return oOrders; }
public static List<OrderLine> Retrieve(string OrderNo) { DataTable oData = Data.OperationalDB.LoadOrderLines(OrderNo); if (oData.Rows.Count == 0) { throw new Exception(string.Format("Error loading order, no order lines with order number {0} could be located.", OrderNo)); } List<OrderLine> oOrderLines = new List<OrderLine>(); foreach(DataRow oRow in oData.Rows) { OrderLine oOrderLine = new OrderLine(); oOrderLine.OrderNo = oData.Rows[0]["ORDER_NO"].ToString(); oOrderLine.LineNo = Convert.ToInt32(oData.Rows[0]["LINE_NO"]); oOrderLine.ItemCode = oData.Rows[0]["ITEM_CODE"].ToString(); oOrderLine.ItemUPCCode = oData.Rows[0]["ITEM_UPC_CODE"].ToString(); oOrderLine.Quantity = Convert.ToDouble(oData.Rows[0]["QUANTITY"]); oOrderLine.ItemHSCode = oData.Rows[0]["ITEM_HS_CODE"].ToString(); oOrderLine.DeclaredPrice = Convert.ToDecimal(oData.Rows[0]["DECLARED_PRICE"] == DBNull.Value ? 0 : oData.Rows[0]["DECLARED_PRICE"]); oOrderLine.UnitPrice = Convert.ToDecimal(oData.Rows[0]["UNIT_PRICE"] == DBNull.Value ? 0 : oData.Rows[0]["UNIT_PRICE"]); oOrderLine.SalesPrice = Convert.ToDecimal(oData.Rows[0]["SALES_PRICE"] == DBNull.Value ? 0 : oData.Rows[0]["SALES_PRICE"]); oOrderLines.Add(oOrderLine); } return oOrderLines; }
public static object Fire(int siteID, string clientCode, OrderLine orderLine) { return Fire(typeof(DetermineItemHSCode), new string[] { siteID.ToString(), clientCode }, new object[] { orderLine }); }