// cancel order
    protected void cancelOrderButton_Click(object sender, EventArgs e)
    {
        string orderId = Session["AdminOrderID"].ToString();

        CommerceLibAccess.UpdateOrderStatus(int.Parse(orderId), 9);
        PopulateControls();
    }
    // cancel order
    protected void cancelOrderButton_Click(object sender, EventArgs e)
    {
        string orderId = Request.QueryString["OrderID"];

        CommerceLibAccess.UpdateOrderStatus(int.Parse(orderId), 9);
        PopulateControls(orderId);
    }
 // update order information
 protected void updateButton_Click(object sender, EventArgs e)
 {
     try
     {
         // Get new order data
         int    orderID     = int.Parse(Session["AdminOrderID"].ToString());
         string dateCreated = dateCreatedTextBox.Text;
         string dateShipped = dateShippedTextBox.Text;
         int    status      = int.Parse(statusDropDown.SelectedValue);
         string authCode    = authCodeTextBox.Text;
         string reference   = referenceTextBox.Text;
         string comments    = commentsTextBox.Text;
         // Update the order
         CommerceLibAccess.UpdateOrder(orderID, dateCreated,
                                       dateShipped, status, authCode, reference, comments);
     }
     catch
     {
         // In case of an error, we simply ignore it
     }
     // Exit edit mode and populate the form again
     SetEditMode(false);
     PopulateControls();
     Page.DataBind();
 }
Beispiel #4
0
 public void UpdateStatus(int status)
 {
     // call static method
     CommerceLibAccess.UpdateOrderStatus(OrderID, status);
     // update field
     Status = status;
 }
Beispiel #5
0
 public void SetDateShipped()
 {
     // call static method
     CommerceLibAccess.SetOrderDateShipped(OrderID);
     // update field
     DateShipped = DateTime.Now.ToString();
 }
Beispiel #6
0
 public void SetAuthCodeAndReference(string authCode, string reference)
 {
     // call static method
     CommerceLibAccess.SetOrderAuthCodeAndReference(OrderId,
                                                    authCode, reference);
     // update fields
     AuthCode  = authCode;
     Reference = reference;
 }
    public CommerceLibOrderInfo(DataRow orderRow)
    {
        Shipping = new ShippingInfo();
        Tax      = new TaxInfo();

        OrderID     = Int32.Parse(orderRow["OrderID"].ToString());
        DateCreated = orderRow["DateCreated"].ToString();
        DateShipped = orderRow["DateShipped"].ToString();
        Comments    = orderRow["Comments"].ToString();
        Status      = Int32.Parse(orderRow["Status"].ToString());
        AuthCode    = orderRow["AuthCode"].ToString();
        Reference   = orderRow["Reference"].ToString();
        Customer    = Membership.GetUser(
            new Guid(orderRow["CustomerID"].ToString()));
        CustomerProfile =
            (HttpContext.Current.Profile as ProfileCommon)
            .GetProfile(Customer.UserName);
        CreditCard   = new SecureCard(CustomerProfile.CreditCard);
        OrderDetails =
            CommerceLibAccess.GetOrderDetails(
                orderRow["OrderID"].ToString());
        // Get Shipping Data
        if (orderRow["ShippingID"] != DBNull.Value &&
            orderRow["ShippingType"] != DBNull.Value &&
            orderRow["ShippingCost"] != DBNull.Value)
        {
            Shipping.ShippingID =
                Int32.Parse(orderRow["ShippingID"].ToString());
            Shipping.ShippingType = orderRow["ShippingType"].ToString();
            Shipping.ShippingCost =
                double.Parse(orderRow["ShippingCost"].ToString());
        }
        else
        {
            Shipping.ShippingID = -1;
        }
        // Get Tax Data
        if (orderRow["TaxID"] != DBNull.Value &&
            orderRow["TaxType"] != DBNull.Value &&
            orderRow["TaxPercentage"] != DBNull.Value)
        {
            Tax.TaxID         = Int32.Parse(orderRow["TaxID"].ToString());
            Tax.TaxType       = orderRow["TaxType"].ToString();
            Tax.TaxPercentage =
                double.Parse(orderRow["TaxPercentage"].ToString());
        }
        else
        {
            Tax.TaxID = -1;
        }
        // set info properties
        Refresh();
    }
Beispiel #8
0
 protected void processButton_Click(object sender, EventArgs e)
 {
     try
     {
         OrderProcessor processor = new OrderProcessor(orderIDBox.Text);
         processor.Process();
         OrderInfo orderInfo = CommerceLibAccess.GetOrder(orderIDBox.Text);
         processResultLabel.Text = "Order processed, status now: "
                                   + orderInfo.Status.ToString();
     }
     catch
     {
         OrderInfo orderInfo = CommerceLibAccess.GetOrder(orderIDBox.Text);
         processResultLabel.Text = "Order processing error, status now: " + orderInfo.Status.ToString();
     }
 }
 // Display orders awaiting shipping
 protected void awaitingShippingGo_Click(object sender, EventArgs e)
 {
     try
     {
         List <OrderInfo> orders = CommerceLibAccess.GetOrdersByStatus(6);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text = "No orders awaiting shipment.";
         }
         grid.DataBind();
     }
     catch
     {
         errorLabel.Text = "Couldn't get the requested orders!";
     }
 }
 // Display orders awaiting stock
 protected void awaitingStockGo_Click(object sender, EventArgs e)
 {
     try
     {
         List <CommerceLibOrderInfo> orders =
             CommerceLibAccess.GetOrdersByStatus(3);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text = "Няма чакащи поръчки наличността проверена.";
         }
         grid.DataBind();
     }
     catch
     {
         errorLabel.Text = "Поисканите поръчки не бяха намерени!";
     }
 }
 // Display orders awaiting stock
 protected void awaitingStockGo_Click(object sender, EventArgs eventArgs)
 {
     try
     {
         List <OrderInfo> orders = CommerceLibAccess.GetOrdersByStatus(3);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text = "No orders awaiting stock check.";
         }
         grid.DataBind();
     }
     catch (Exception e)
     {
         Utilities.LogError(e);
         errorLabel.Text = "Couldn't get the requested orders!";
     }
 }
 // Display orders by customer
 protected void byCustomerGo_Click(object sender, EventArgs e)
 {
     try
     {
         List <OrderInfo> orders = CommerceLibAccess.GetOrdersByCustomer(userDropDown.SelectedValue);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text =
                 "Selected customer has made no orders.";
         }
         grid.DataBind();
     }
     catch
     {
         errorLabel.Text = "Couldn't get the requested orders!";
     }
 }
 // Display single order only
 protected void byIDGo_Click(object sender, EventArgs e)
 {
     try
     {
         Int32.Parse(orderIDBox.Text);
         string destination = String.Format("AdminOrderDetails.aspx?OrderID={0}",
                                            orderIDBox.Text);
         CommerceLibAccess.GetOrder(orderIDBox.Text);
         Response.Redirect(destination);
     }
     catch (IndexOutOfRangeException ex)
     {
         errorLabel.Text = "Няма такова ИД";
     }
     catch (FormatException fe)
     {
         errorLabel.Text = "Няма такова ИД";
     }
 }
 // list the orders that happened between specified dates
 protected void byDateGo_Click(object sender, EventArgs e)
 {
     try
     {
         string           startDate = startDateTextBox.Text;
         string           endDate   = endDateTextBox.Text;
         List <OrderInfo> orders    = CommerceLibAccess.GetOrdersByDate(startDate, endDate);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text = "No orders between selected dates.";
         }
         grid.DataBind();
     }
     catch
     {
         errorLabel.Text = "Couldn't get the requested orders!";
     }
 }
 // Display the most recent orders
 protected void byRecentGo_Click(object sender, EventArgs e)
 {
     try
     {
         int recordCount = Int32.Parse(recentCountTextBox.Text);
         List <CommerceLibOrderInfo> orders =
             CommerceLibAccess.GetOrdersByRecent(recordCount);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text = "Няма пъръчки.";
         }
         grid.DataBind();
     }
     catch
     {
         errorLabel.Text = "Поисканите поръчки не бяха намерени!";
     }
 }
 protected void byRecentGo_Click(object sender, EventArgs eventArgs)
 {
     try
     {
         int recordCount         = Int32.Parse(recentCountTextBox.Text);
         List <OrderInfo> orders = CommerceLibAccess.GetOrdersByRecent(recordCount);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text = "No orders to get.";
         }
         grid.DataBind();
     }
     catch (Exception e)
     {
         Utilities.LogError(e);
         errorLabel.Text = "Couldn't get the requested orders!";
     }
 }
    // Display orders awaiting shipping
    protected void awaitingShippingGo_Click(object sender, EventArgs e)
    {
        try
        {
            List <CommerceLibOrderInfo> orders =
                CommerceLibAccess.GetOrdersByStatus(6);
            grid.DataSource = orders;
            if (orders.Count == 0)
            {
                errorLabel.Text = "Няма продукти очакващи изпращане.";
            }
            grid.DataBind();
        }

        catch
        {
            errorLabel.Text = "Поисканите поръчки не бяха намерени!";
        }
    }
Beispiel #18
0
        public void Process()
        {
            // configure processor
            ContinueNow = true;

            // log start of execution
            CreateAudit("Order Processor started.", 10000);

            // process pipeline section
            try
            {
                while (ContinueNow)
                {
                    ContinueNow = false;
                    GetCurrentPipelineSection();
                    CurrentPipelineSection.Process(this);
                }
            }
            catch (OrderProcessorException ex)
            {
                MailAdmin("Order Processing error occurred.",
                          ex.Message, ex.SourceStage);
                CreateAudit("Order Processing error occurred.", 10002);
                throw new OrderProcessorException(
                          "Error occurred, order aborted. "
                          + "Details mailed to administrator.", 100);
            }
            catch (Exception ex)
            {
                MailAdmin("Order Processing error occurred.", ex.Message,
                          100);
                CreateAudit("Order Processing error occurred.", 10002);
                throw new OrderProcessorException(
                          "Unknown error, order aborted. "
                          + "Details mailed to administrator.", 100);
            }
            finally
            {
                CommerceLibAccess.CreateAudit(Order.OrderID,
                                              "Order Processor finished.", 10001);
            }
        }
 // Display orders by customer
 protected void byCustomerGo_Click(object sender, EventArgs e)
 {
     try
     {
         List <CommerceLibOrderInfo> orders =
             CommerceLibAccess.GetOrdersByCustomer(
                 userDropDown.SelectedValue);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text =
                 "Избранияте клиент не е направил поръчки.";
         }
         grid.DataBind();
     }
     catch
     {
         errorLabel.Text = "Поисканите поръчки не бяха намерени!";
     }
 }
Beispiel #20
0
 protected void processButton_Click(object sender, EventArgs e)
 {
     try
     {
         OrderProcessor processor = new OrderProcessor(orderIDBox.Text);
         processor.Process();
         CommerceLibOrderInfo orderInfo =
             CommerceLibAccess.GetOrder(orderIDBox.Text);
         processResultLabel.Text = "Поръчката е обработена, статус:"
                                   + orderInfo.Status.ToString();
     }
     catch
     {
         CommerceLibOrderInfo orderInfo =
             CommerceLibAccess.GetOrder(orderIDBox.Text);
         processResultLabel.Text =
             "Има проблем с обработката на поръчката, статус: "
             + orderInfo.Status.ToString();
     }
 }
 // Display orders awaiting stock
 protected void awaitingStockGo_Click(object sender, EventArgs e)
 {
     try
     {
         List <CommerceLibOrderInfo> orders =
             CommerceLibAccess.GetOrdersByStatus(3);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text = "<br />No orders awaiting stock check.";
         }
     }
     catch
     {
         errorLabel.Text = "<br />Couldn't get the requested orders!";
     }
     finally
     {
         grid.DataBind();
     }
 }
Beispiel #22
0
 protected void goButton_Click(object sender, EventArgs e)
 {
     try
     {
         CommerceLibOrderInfo orderInfo = CommerceLibAccess.GetOrder(
             orderIDBox.Text);
         resultLabel.Text  = "Order found.";
         addressLabel.Text = orderInfo.CustomerAddressAsString.Replace(
             "\n", "<br />");
         creditCardLabel.Text = orderInfo.CreditCard.CardNumberX;
         orderLabel.Text      =
             orderInfo.OrderAsString.Replace("\n", "<br />");
     }
     catch
     {
         resultLabel.Text     = "No order found, or order is in old format.";
         addressLabel.Text    = "";
         creditCardLabel.Text = "";
         orderLabel.Text      = "";
     }
 }
 // Display orders that happened in a specified period of time
 protected void byDateGo_Click(object sender, EventArgs e)
 {
     try
     {
         string startDate = startDateTextBox.Text;
         string endDate   = endDateTextBox.Text;
         List <CommerceLibOrderInfo> orders =
             CommerceLibAccess.GetOrdersByDate(startDate, endDate);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text =
                 "Няма поръчки между избраните дати.";
         }
         grid.DataBind();
     }
     catch
     {
         errorLabel.Text = "Поисканите поръчки не бяха намерени!";
     }
 }
 // Display the most recent orders
 protected void byRecentGo_Click(object sender, EventArgs e)
 {
     try
     {
         int recordCount = Int32.Parse(recentCountTextBox.Text);
         List <CommerceLibOrderInfo> orders =
             CommerceLibAccess.GetOrdersByRecent(recordCount);
         grid.DataSource = orders;
         if (orders.Count == 0)
         {
             errorLabel.Text = "<br />No orders to get.";
         }
     }
     catch
     {
         errorLabel.Text = "<br />Couldn't get the requested orders!";
     }
     finally
     {
         grid.DataBind();
     }
 }
Beispiel #25
0
 protected void goButton_Click(object sender, EventArgs e)
 {
     try
     {
         CommerceLibOrderInfo orderInfo =
             CommerceLibAccess.GetOrder(orderIDBox.Text);
         resultLabel.Text  = "Поръчката е намерена.";
         addressLabel.Text =
             orderInfo.CustomerAddressAsString.Replace("\n", "<br />");
         creditCardLabel.Text    = orderInfo.CreditCard.CardNumberX;
         orderLabel.Text         = orderInfo.OrderAsString.Replace("\n", "<br />");
         processButton.Enabled   = true;
         processResultLabel.Text = "";
     }
     catch
     {
         resultLabel.Text      = "Не е намерена такава поръчка или е в стар формат.";
         addressLabel.Text     = "";
         creditCardLabel.Text  = "";
         orderLabel.Text       = "";
         processButton.Enabled = false;
     }
 }
    // populate the form with data
    private void PopulateControls(string orderId)
    {
        // obtain order info
        OrderInfo orderInfo = CommerceLibAccess.GetOrder(orderId);

        // populate labels and text boxes with order info
        orderIdLabel.Text            = "Поръчка #" + orderId;
        totalAmountLabel.Text        = String.Format("{0:c} ", orderInfo.TotalCost);
        dateCreatedTextBox.Text      = orderInfo.DateCreated.ToString();
        dateShippedTextBox.Text      = orderInfo.DateShipped.ToString();
        statusDropDown.SelectedIndex = orderInfo.Status;
        authCodeTextBox.Text         = orderInfo.AuthCode;
        referenceTextBox.Text        = orderInfo.Reference;
        commentsTextBox.Text         = orderInfo.Comments;
        customerNameTextBox.Text     = orderInfo.CustomerName;
        shippingAddressTextBox.Text  = orderInfo.CustomerAddressAsString;
        shippingTypeTextBox.Text     = orderInfo.Shipping.ShippingType;
        customerEmailTextBox.Text    = orderInfo.Customer.Email;
        // Decide which one of the buttons should
        // be enabled and which should be disabled
        switch (orderInfo.Status)
        {
        case 8:
        case 9:
            // if the order was canceled or completed...
            processOrderButton.Text    = "Обработи поръчката";
            processOrderButton.Enabled = false;
            cancelOrderButton.Enabled  = false;
            break;

        case 3:
            // if the order is awaiting a stock check...
            processOrderButton.Text    = "Потвърди наличност за поръчката";
            processOrderButton.Enabled = true;
            cancelOrderButton.Enabled  = true;
            break;

        case 6:
            // if the order is awaiting shipment...
            processOrderButton.Text    = "Потвърди доставката на поръчката";
            processOrderButton.Enabled = true;
            cancelOrderButton.Enabled  = true;
            break;

        default:
            // otherwise...
            processOrderButton.Text    = "Обработи поръчката";
            processOrderButton.Enabled = true;
            cancelOrderButton.Enabled  = true;
            break;
        }
        // fill the data grid with order details
        grid.DataSource = orderInfo.OrderDetails;
        grid.DataBind();
        // fill the audit data grid with audit trail
        auditGrid.DataSource = orderInfo.AuditTrail;
        auditGrid.DataBind();

        // show status items
        statusDropDown.Items.Clear();
        for (int i = 0; i < CommerceLibAccess.OrderStatuses.Length; i++)
        {
            statusDropDown.Items.Add(
                new ListItem(CommerceLibAccess.OrderStatuses[i], i.ToString()));
        }
        statusDropDown.SelectedIndex = orderInfo.Status;
    }
Beispiel #27
0
 public OrderProcessor(string orderID)
 {
     // get order
     Order = CommerceLibAccess.GetOrder(orderID);
 }
    // populate the form with data
    private void PopulateControls()
    {
        // obtain order ID from the session
        string orderId = Session["AdminOrderID"].ToString();
        // obtain order info
        CommerceLibOrderInfo orderInfo =
            CommerceLibAccess.GetOrder(orderId);

        // populate labels and text boxes with order info
        orderIdLabel.Text   = "Displaying Order #" + orderId;
        totalCostLabel.Text = String.Format("{0:c} ",
                                            orderInfo.TotalCost);
        dateCreatedTextBox.Text      = orderInfo.DateCreated.ToString();
        dateShippedTextBox.Text      = orderInfo.DateShipped.ToString();
        statusDropDown.SelectedIndex = orderInfo.Status;
        authCodeTextBox.Text         = orderInfo.AuthCode;
        referenceTextBox.Text        = orderInfo.Reference;
        commentsTextBox.Text         = orderInfo.Comments;
        customerNameTextBox.Text     = orderInfo.CustomerName;
        shippingAddressTextBox.Text  = orderInfo.CustomerAddressAsString;
        shippingTypeTextBox.Text     = orderInfo.Shipping.ShippingType;
        customerEmailTextBox.Text    = orderInfo.Customer.Email;
        // Decide which one of the buttons should
        // be enabled and which should be disabled
        switch (orderInfo.Status)
        {
        case 8:
        case 9:
            // if the order was canceled or completed...
            processOrderButton.Text    = "Process Order";
            processOrderButton.Enabled = false;
            cancelOrderButton.Enabled  = false;
            break;

        case 3:
            // if the order is awaiting a stock check...
            processOrderButton.Text    = "Confirm Stock for Order";
            processOrderButton.Enabled = true;
            cancelOrderButton.Enabled  = true;
            break;

        case 6:
            // if the order is awaiting shipment...
            processOrderButton.Text    = "Confirm Order Shipment";
            processOrderButton.Enabled = true;
            cancelOrderButton.Enabled  = true;
            break;

        default:
            // otherwise...
            processOrderButton.Text    = "Process Order";
            processOrderButton.Enabled = true;
            cancelOrderButton.Enabled  = true;
            break;
        }
        // fill the data grid with order details
        grid.DataSource = orderInfo.OrderDetails;
        grid.DataBind();

        // fill the audit data grid with audit trail
        auditGrid.DataSource = orderInfo.AuditTrail;
        auditGrid.DataBind();
    }
Beispiel #29
0
 public void CreateAudit(string message, int messageNumber)
 {
     CommerceLibAccess.CreateAudit(Order.OrderID, message,
                                   messageNumber);
 }
    // fill controls with data
    private void PopulateControls()
    {
        // get the items in the shopping cart
        DataTable dt = ShoppingCartAccess.GetItems();

        // populate the list with the shopping cart contents
        grid.DataSource = dt;
        grid.DataBind();
        // setup controls
        titleLabel.Text =
            "These are the products in your shopping cart:";
        grid.Visible = true;
        // display the total amount
        decimal amount = ShoppingCartAccess.GetTotalAmount();

        totalAmountLabel.Text = String.Format("{0:c}", amount);

        // check customer details
        bool addressOK = true;
        bool cardOK    = true;

        if (Profile.Address1 + Profile.Address2 == "" ||
            Profile.ShippingRegion == "" ||
            Profile.ShippingRegion == "1" ||
            Profile.Country == "")
        {
            addressOK = false;
        }
        if (Profile.CreditCard == "")
        {
            cardOK = false;
        }

        // report / hide place order button / shipping selection
        if (!addressOK)
        {
            if (!cardOK)
            {
                InfoLabel.Text =
                    "You must provide a valid address and credit card "
                    + "before placing your order.";
            }
            else
            {
                InfoLabel.Text =
                    "You must provide a valid address before placing your "
                    + "order.";
            }
        }
        else if (!cardOK)
        {
            InfoLabel.Text = "You must provide a credit card before "
                             + "placing your order.";
        }
        else
        {
            InfoLabel.Text = "Please confirm that the above details are "
                             + "correct before proceeding.";
        }
        placeOrderButton.Visible  = addressOK && cardOK;
        shippingSelection.Visible = addressOK && cardOK;

        // Populate shipping selection
        if (addressOK && cardOK)
        {
            int shippingRegionId = int.Parse(Profile.ShippingRegion);
            List <ShippingInfo> shippingInfoData = CommerceLibAccess.GetShippingInfo(shippingRegionId);
            foreach (ShippingInfo shippingInfo in shippingInfoData)
            {
                shippingSelection.Items.Add(new ListItem(shippingInfo.ShippingType, shippingInfo.ShippingID.ToString()));
            }
            shippingSelection.SelectedIndex = 0;
        }
    }