예제 #1
0
    private void tOrderNo_KeyPress(object sender, KeyPressEventArgs e)
    {
      if (e.KeyChar == (char)(Keys.Enter))
      {
        if (tOrderNo.Text.Trim() == "")
        {
          return;
        }

        try
        {
          Clear();

          // Load the order
          string sOrderNo = tOrderNo.Text.Trim();

          _oOrder = Order.Retrieve(sOrderNo);

          Event.BeforeOrderLoading.Fire(_oOrder.SiteID, _oOrder.ClientCode, this, _oOrder);

          // Load order detail
          tOrderDetail.Text = _oOrder.OrderSummaryDetail;

          // Load the order into the grid
          dgOrderLines.DataSource = _oOrder.OrderLines;

          Event.AfterOrderLoaded.Fire(_oOrder.SiteID, _oOrder.ClientCode);
        }
        catch(Exception ex)
        {
          MessageBox.Show(Helper.FormatExceptionMessage(ex));
        }
      }
    }
      public static void ChangeBackGroundColor(object sender, Order oOrder)
      {
        Control oControl = (Control)sender;

        ConfigurationValue oValue = Configuration.GetValue(new string[] { oOrder.ClientCode, "BackgroundColor" });

        if (oValue == null || oValue.ObjectType != ConfigurationValue.Type.Text)
        {
          throw new Exception("Configuration value is not expected type of Text");
        }

        if (oValue.Value == null)
        {
          throw new Exception("Configuration value is not set.");
        }

        try
        {
          oControl.BackColor = Color.FromName(oValue.Value.ToString());

          Control oGrid = oControl.Controls.Find("dgOrderLines", true)[0];
          oGrid.ForeColor = Color.FromName(oValue.Value.ToString());
        }
        catch(Exception ex)
        {
          throw new Exception("Configuration value is not a valid known color.", ex);
        }
      }
예제 #3
0
 /// <summary>
 /// Overloaded  constructor for Order Detail.
 /// </summary>
 /// <param name="productName">Product name of Order Detail.</param>
 /// <param name="quantity">Quantity ordered.</param>
 /// <param name="unitPrice">Unit price of product at the time order is placed.</param>
 /// <param name="discount">Discount applied to unit price of product.</param>
 /// <param name="order">Order that Order Detail is part of.</param>
 public OrderDetail(string productName, int quantity, float unitPrice, float discount, Order order)
     : this()
 {
     ProductName = productName;
     Quantity = quantity;
     UnitPrice = unitPrice;
     Discount = discount;
     Order = order; // The parent object
 }
예제 #4
0
        // creates query parameters list from Order object

        object[] Take(Order order)
        {
            return new object[]  
            {
                "@OrderId", order.OrderId,
                "@OrderDate", order.OrderDate,
                "@RequiredDate", order.RequiredDate,
                "@Freight", order.Freight
            };
        }
        public static Order GetOrderWithItemsAndProductAndCustomer(DateTime orderDate) {
            Order retVal = new Order();
            retVal.OrderID = 1;
            retVal.OrderDate = orderDate;
            retVal.Customer = GetCustomer1();
            retVal.OrderDetails.Add(GetOrderDetail1());
            retVal.OrderDetails.Add(GetOrderDetail2());

            return retVal;
        }
    public static void GetForwarderFromConfig(Order order)
    {
      string sForwarderName = "";
      string sForwarderService = "";

      ConfigurationValue oConVal = Configuration.GetValue(new string[] { order.SiteID.ToString(), order.ClientCode, "ForwarderName" });
      if (oConVal != null)
      {
        sForwarderName = (string)oConVal.Value;
      }

      oConVal = Configuration.GetValue(new string[] { order.SiteID.ToString(), order.ClientCode, "ForwarderService" });
      if (oConVal != null)
      {
        sForwarderService = (string)oConVal.Value;
      }
      order.ShippingInfo.Forwarder = Forwarder.Retrieve(sForwarderName, sForwarderService);
    }
      public static void ChangeBackGroundColorFromDO(object sender, Order oOrder)
      {
        string sColor = "";
        foreach (OrderExtension oOrderExtension in oOrder.OrderExtensions)
        {
          if (oOrderExtension.Key.ToUpper() == "COLOR")
          {
            sColor = oOrderExtension.Value;
            break;
          }
        }

        try
        {
          ((Control)sender).BackColor = Color.FromName(sColor);
        }
        catch (Exception ex)
        {
          throw new Exception("Configuration value is not a valid known color.", ex);
        }
      }
    public static void RunOrderDetermination(Order order)
    {
      Event.BeforeRunOrderDetermination.Fire(order.SiteID, order.ClientCode, order);

      Event.DetermineForwarder.Fire(order.SiteID, order.ClientCode, order);
      Event.DeterminePOE.Fire(order.ShippingInfo.Forwarder.Name, order.ShippingInfo.Forwarder.Service, order);
      Event.DetermineShipper.Fire(order.SiteID, order.ClientCode, order);
      Event.DetermineTransportPayer.Fire(order.SiteID, order.ClientCode, order);
      Event.DetermineDutyTaxPayer.Fire(order.SiteID, order.ClientCode, order);
      Event.DetermineImporterOfRecords.Fire(order.SiteID, order.ClientCode, order);

      foreach(OrderLine oOrderLine in order.OrderLines)
      {
        Event.DetermineItemUPCCode.Fire(order.SiteID, order.ClientCode, oOrderLine);
        Event.DetermineItemHSCode.Fire(order.SiteID, order.ClientCode, oOrderLine);
        Event.DetermineItemDeclaredPrice.Fire(order.SiteID, order.ClientCode, oOrderLine);
        Event.DetermineItemUnitPrice.Fire(order.SiteID, order.ClientCode, oOrderLine);
        Event.DetermineItemSalesPrice.Fire(order.SiteID, order.ClientCode, oOrderLine);
      }

      Event.AfterRunOrderDetermination.Fire(order.SiteID, order.ClientCode, order);
    }
 public static string GenerateBoxID(Order order)
 {
   return order.ClientCode.Substring(0,1).ToUpper() + "B" + DateTime.Now.ToString("HHmmssfff");
 }
예제 #10
0
 public static void GetPOE(Order order)
 {
   order.ShippingInfo.POE = (string)Configuration.GetValue(new string[] { "UPS", "SAVER", "US", "POE" }).Value;
 }
 public static void GetImporterOfRecords(Order order)
 {
   order.ShippingInfo.ImporterOfRecords.AccountNo = "IMP-XX001";
   
   order.ShippingInfo.ImporterOfRecords.Contact.Name = "";
   order.ShippingInfo.ImporterOfRecords.Contact.CompanyName = "PCH";
   order.ShippingInfo.ImporterOfRecords.Contact.ContactNo = "(+86) 000 0000000";
 }
    public static void PrintPackingList(Order order)
    {
      ConfigurationValue oConVal = Configuration.GetValue(new string[] { order.ClientCode, "PackingList" });
      if (oConVal == null || oConVal.Value == null)
      {
        return;
      }

      XmlReportSource oReport = new XmlReportSource();
      oReport.Xml = (string)oConVal.Value;

      // Adding the initial parameter values
      oReport.Parameters.Add(new Telerik.Reporting.Parameter("OrderNumber", order.ClientOrderNo));

      ReportViewer oReportViewer = new ReportViewer();
      oReportViewer.ReportSource = oReport;

      Form oForm = new Form();
      oForm.Controls.Add(oReportViewer);
      oReportViewer.Dock = DockStyle.Fill;

      oReportViewer.RefreshReport();

      oForm.StartPosition = FormStartPosition.CenterScreen;
      oForm.WindowState = FormWindowState.Maximized;

      oForm.ShowDialog();
    }
 public static void GetTransportPayer(Order order)
 {
   order.ShippingInfo.TransportPayer.AccountNo = "TRA-XX001";
   
   order.ShippingInfo.TransportPayer.Contact.Name = "Alex";
   order.ShippingInfo.TransportPayer.Contact.CompanyName = "";
   order.ShippingInfo.TransportPayer.Contact.ContactNo = "(+86) 000 0000000";
 }
 public static void GetDutyTaxPayer(Order order)
 {
   order.ShippingInfo.DutyTaxPayer.AccountNo = "D&T-XX001";
   
   order.ShippingInfo.DutyTaxPayer.Contact.Name = "Alex";
   order.ShippingInfo.DutyTaxPayer.Contact.CompanyName = "";
   order.ShippingInfo.DutyTaxPayer.Contact.ContactNo = "(+86) 000 0000000";
 }
    public static void GetShipper(Order order)
    {
      order.ShippingInfo.Shipper.AccountNo = "SHP-XX001";
      //order.ShippingInfo.Shipper.Contact.Name = Event.DetermineShipperContactName.Fire(order.SiteID, order.ClientCode, order);

      order.ShippingInfo.Shipper.Contact.Name = "Receptionist";
      order.ShippingInfo.Shipper.Contact.CompanyName = "PCH";
      order.ShippingInfo.Shipper.Contact.ContactNo = "(+86) 000 0000000";
      order.ShippingInfo.Shipper.Address.Street1 = "DuShiMingYuan";
      order.ShippingInfo.Shipper.Address.Street2 = "Block D/E";
      order.ShippingInfo.Shipper.Address.Street3 = "4th Floor";
      order.ShippingInfo.Shipper.Address.Street4 = "JinTang Street";
      order.ShippingInfo.Shipper.Address.District = "Luohu";
      order.ShippingInfo.Shipper.Address.City = "Shenzhen";
      order.ShippingInfo.Shipper.Address.State = "Guangdong";
      order.ShippingInfo.Shipper.Address.Country = "China";
      order.ShippingInfo.Shipper.Address.PostalCode = "510818";
    }
 public static void GetPOE(Order order)
 {
   order.ShippingInfo.POE = "JFK";
 }
        public void TestMultiDeleteEntity()
        {
            int empKey = -1;
            int ordKey = -1;
            CustomerGroup custGroup = new CustomerGroup();
            custGroup.es.Connection.Name = "ForeignKeyTest";
            EmployeeCollection empColl = new EmployeeCollection();
            empColl.es.Connection.Name = "ForeignKeyTest";
            Employee emp = new Employee();
            emp.es.Connection.Name = "ForeignKeyTest";
            Employee testEmp = new Employee();
            testEmp.es.Connection.Name = "ForeignKeyTest";
            Customer cust = new Customer();
            cust.es.Connection.Name = "ForeignKeyTest";
            Order ord = new Order();
            ord.es.Connection.Name = "ForeignKeyTest";

            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    // Setup
                    custGroup.GroupID = "YYYYY";
                    custGroup.GroupName = "Test";
                    custGroup.Save();

                    emp = empColl.AddNew();
                    emp.LastName = "LastName";
                    emp.FirstName = "FirstName";

                    cust = emp.CustomerCollectionByStaffAssigned.AddNew();
                    cust.CustomerID = "YYYYY";
                    cust.CustomerSub = "YYY";
                    cust.CustomerName = "Test";
                    cust.str().DateAdded = "2007-01-01 00:00:00";
                    cust.Active = true;
                    cust.Manager = 1;

                    ord = emp.OrderCollectionByEmployeeID.AddNew();
                    ord.CustID = "YYYYY";
                    ord.CustSub = "YYY";
                    ord.str().OrderDate = "2007-01-01";

                    empColl.Save();
                    empKey = emp.EmployeeID.Value;
                    ordKey = ord.OrderID.Value;

                    Assert.AreEqual(1, emp.CustomerCollectionByStaffAssigned.Count);
                    Assert.AreEqual(1, emp.OrderCollectionByEmployeeID.Count);
                    Assert.AreEqual(emp.EmployeeID.Value, cust.StaffAssigned.Value);
                    Assert.AreEqual(emp.EmployeeID.Value, ord.EmployeeID.Value);

                    // Test
                    testEmp.LoadByPrimaryKey(empKey);
                    testEmp.OrderCollectionByEmployeeID.MarkAllAsDeleted();
                    testEmp.CustomerCollectionByStaffAssigned.MarkAllAsDeleted();
                    testEmp.MarkAsDeleted();
                    testEmp.Save();

                    emp = new Employee();
                    emp.es.Connection.Name = "ForeignKeyTest";
                    Assert.IsFalse(emp.LoadByPrimaryKey(empKey));

                    ord = new Order();
                    ord.es.Connection.Name = "ForeignKeyTest";
                    Assert.IsFalse(ord.LoadByPrimaryKey(ordKey));

                    cust = new Customer();
                    cust.es.Connection.Name = "ForeignKeyTest";
                    Assert.IsFalse(cust.LoadByPrimaryKey("YYYYY", "YYY"));
                }
            }
            finally
            {
                // Clean up
                ord = new Order();
                ord.es.Connection.Name = "ForeignKeyTest";
                if (ord.LoadByPrimaryKey(ordKey))
                {
                    ord.MarkAsDeleted();
                    ord.Save();
                }

                cust = new Customer();
                cust.es.Connection.Name = "ForeignKeyTest";
                if (cust.LoadByPrimaryKey("YYYYY", "YYY"))
                {
                    cust.MarkAsDeleted();
                    cust.Save();
                }

                emp = new Employee();
                emp.es.Connection.Name = "ForeignKeyTest";
                if (emp.LoadByPrimaryKey(empKey))
                {
                    emp.MarkAsDeleted();
                    emp.Save();
                }

                custGroup = new CustomerGroup();
                custGroup.es.Connection.Name = "ForeignKeyTest";

                if (custGroup.LoadByPrimaryKey("YYYYY"))
                {
                    custGroup.MarkAsDeleted();
                    custGroup.Save();
                }
            }
        }
 /// <summary>
 /// The purpose of this is to show no coverage, that the lamba will show no coverage and no coverage exists for products.
 /// </summary>
 /// <returns></returns>
 public static Order GetOrderNoItemsNoProductsNoCustomer(DateTime orderDate) {
     Order retVal = new Order();
     retVal.OrderID = 1;
     retVal.OrderDate = orderDate;
     return retVal;
 }
예제 #19
0
 public override void ShipBox(Order order, Box box)
 {
   MessageBox.Show(string.Format("Shipping box {0} with UPS. Label size {1}", box.ID, LabelSize.ToString()));
   //Event.ShipBox.Fire(Name, Service, order, box);
 }
    public static void GetForwarderFromDOExtension(Order order)
    {
      string sForwarderName = "";
      string sForwarderService = "";

      foreach(OrderExtension oOrderExtension in order.OrderExtensions)
      {
        if (oOrderExtension.Key.ToUpper() == "CARRIER")
        {
          sForwarderName = oOrderExtension.Value;
        }
        else if (oOrderExtension.Key.ToUpper() == "SERVICE")
        {
          sForwarderService = oOrderExtension.Value;
        }
      }

      if (string.IsNullOrEmpty(sForwarderName) && string.IsNullOrEmpty(sForwarderService))
      {
        throw new Exception("Attempt to load forwarder information from DO failed.");
      }

      order.ShippingInfo.Forwarder = Forwarder.Retrieve(sForwarderName, sForwarderService);
    }
		public void TestSaveComposite()
		{
            int ordKey = -1;
            CustomerGroup custGroup = new CustomerGroup();
            custGroup.es.Connection.Name = "ForeignKeyTest";
            Customer cust = new Customer();
            cust.es.Connection.Name = "ForeignKeyTest";
            Order ord = new Order();
            ord.es.Connection.Name = "ForeignKeyTest";

            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    custGroup.GroupID = "XXXXX";
                    custGroup.GroupName = "Test";
                    custGroup.Save();

                    cust.CustomerID = "XXXXX";
                    cust.CustomerSub = "XXX";
                    cust.CustomerName = "Test";
                    cust.str().DateAdded = "2007-01-01 00:00:00";
                    cust.Active = true;
                    cust.Manager = 1;

                    ord = cust.OrderCollectionByCustID.AddNew();
                    ord.str().OrderDate = "2007-12-31 00:00:00";

                    cust.Save();
                    ordKey = ord.OrderID.Value;

                    Assert.AreEqual(1, cust.OrderCollectionByCustID.Count);
                }
            }
            finally
            {
                // Clean up
                cust = new Customer();
                cust.es.Connection.Name = "ForeignKeyTest";

                if (cust.LoadByPrimaryKey("XXXXX", "XXX"))
                {
                    OrderCollection ordColl = cust.OrderCollectionByCustID;
                    ordColl.MarkAllAsDeleted();
                    cust.MarkAsDeleted();
                    cust.Save();
                }

                custGroup = new CustomerGroup();
                custGroup.es.Connection.Name = "ForeignKeyTest";

                if (custGroup.LoadByPrimaryKey("XXXXX"))
                {
                    custGroup.MarkAsDeleted();
                    custGroup.Save();
                }
            }
		}