Ejemplo n.º 1
0
        private void showOrderDetails(int orderID)
        {
            pnlOrderDetails.Visible = true;
            // Obtain Order Details from Database
            //      OrdersDB orderHistory = new OrdersDB();
            //      Commerce.OrderDetails myOrderDetails = orderHistory.GetOrderDetails(OrderID, CustomerId);
            OrderController orderController = new OrderController();
            OrderInfo order = orderController.GetOrder(orderID);

            if(order != null)
            {
                // Update labels with summary details
                lblTotal.Text = order.OrderTotal.ToString("C", LocalFormat);
                lblPostage.Text = order.ShippingCost.ToString("C", LocalFormat);
                lblTotalIncPostage.Text = order.GrandTotal.ToString("C", LocalFormat);
                lblOrderNumber.Text = order.OrderID.ToString();
                lblOrderDate.Text = order.OrderDate.ToString(_OrderDateFormat);
                lblShipDate.Text = order.ShipDate.ToShortDateString();

                UserController userController = new UserController();
                UserInfo userInfo = userController.GetUser(this.PortalId, order.CustomerID);
                lblOrderCompany.Text = "Profile: " + userInfo.Profile.GetPropertyValue("Company") + "<br>" + "Wisdom: " + DotNetNuke.Modules.Store.WebControls.CustomerAdmin.getUserCompanyName(order.CustomerID);

                //Tax
                if (order.Tax > 0)
                {
                    lblTax.Text = order.Tax.ToString("C", LocalFormat);
                    trTax.Visible = true;
                }
                else
                {
                    trTax.Visible = false;
                }

                getShipToAddress(order.ShippingAddressID);
                getBillToAddress(order.BillingAddressID);
                ArrayList orderDetails = orderController.GetOrderDetails(orderID);

                // if order was found, display it
                if (orderDetails != null)
                {
                    detailsTable.Visible = true;

                    // Bind Items to GridControl
                    grdOrderDetails.DataSource = orderDetails;
                    grdOrderDetails.DataBind();
                }
                // otherwise display an error message
                else
                {
                    lblDetailsError.Text = Localization.GetString("DetailsNotFound", this.LocalResourceFile);
                    detailsTable.Visible = false;
                }
            }

            if (order.OrderStatusID == (int)OrderInfo.OrderStatusList.AwaitingPayment
                && storeInfo.GatewayName == "PayPalProvider")
            {
                btnPayViaPayPal.Visible = true;
            }
            else
            {
                btnPayViaPayPal.Visible = false;
            }

            //Cancel button
            spanBR.Visible = false;
            if (storeInfo.AuthorizeCancel && !UserInfo.IsSuperUser)
            {
                if (order.OrderStatusID == (int)OrderInfo.OrderStatusList.AwaitingPayment
                    || order.OrderStatusID == (int)OrderInfo.OrderStatusList.AwaitingStock
                    || order.OrderStatusID == (int)OrderInfo.OrderStatusList.Paid)
                {
                    btnCancel.CommandArgument = order.OrderID.ToString();
                    btnCancel.Click += this.btnCancel_Click;
                    btnCancel.Visible = true;
                    if (btnPayViaPayPal.Visible)
                    {
                        spanBR.Visible = true;
                    }
                }
                else
                {
                    btnCancel.Visible = false;
                }
            }
            else
            {
                btnCancel.Visible = false;
            }

            //if (UserInfo.IsInRole("Administrators"))
            if (UserInfo.IsSuperUser || CheckForAdminRole() || UserInfo.IsInRole("ShopAdmin") || UserInfo.IsInRole("Webmaster"))
            {
                ddlOrderStatus.Visible = true;
                lnkbtnSave.Visible = true;
                lblOrderStatus.Visible = false;

                //Bind order status list...
                ddlOrderStatus.DataSource = orderController.GetOrderStatuses();
                ddlOrderStatus.DataTextField = "OrderStatusText";
                ddlOrderStatus.DataValueField = "OrderStatusID";
                ddlOrderStatus.DataBind();

                //Value...
                if (ddlOrderStatus.Items.FindByValue(order.OrderStatusID.ToString()) != null)
                {
                    ddlOrderStatus.Items.FindByValue(order.OrderStatusID.ToString()).Selected = true;
                }
            }
            else
            {
                /*
                ArrayList orderStatusList = orderController.GetOrderStatuses();
                string OrderStatusText = "";
                foreach (OrderStatus orderStatus in orderStatusList)
                {
                    if (orderStatus.OrderStatusID == order.OrderStatusID)
                    {
                        if (order.OrderStatusID > 1)
                        {
                            OrderStatusText = orderStatus.OrderStatusText + " - " + order.ShipDate.ToString(_OrderDateFormat);
                        }
                        else
                        {
                            OrderStatusText = orderStatus.OrderStatusText;
                        }
                        break;
                    }
                }
                */
                string OrderStatusText = "";
                OrderStatusText = GetOrderStatus(order.OrderStatusID, order.OrderIsPlaced);
                if (order.OrderStatusID > 1)
                {
                    OrderStatusText = OrderStatusText + " - " + order.ShipDate.ToString(_OrderDateFormat);
                }
                ddlOrderStatus.Visible = false;
                lnkbtnSave.Visible = false;
                lblOrderStatus.Visible = true;
                lblOrderStatus.Text = OrderStatusText;
            }
        }
Ejemplo n.º 2
0
        private OrderInfo UpdateOrderStatus(int orderID, OrderInfo.OrderStatusList orderStatus)
        {
            OrderController orderController = new OrderController();
            OrderInfo order = orderController.GetOrder(orderID);

            switch (orderStatus)
            {
                case OrderInfo.OrderStatusList.Cancelled:
                    order.OrderStatusID = 6;
                    break;
                case OrderInfo.OrderStatusList.Paid:
                    order.OrderStatusID = 7;
                    break;
            }

            orderController.UpdateOrder(order.OrderID, order.OrderDate, order.OrderNumber, order.ShippingAddressID, order.BillingAddressID, order.Tax, order.ShippingCost, true, order.OrderStatusID, order.CustomerID);

            return order;
        }
Ejemplo n.º 3
0
 private void CancelOrder(int orderID)
 {
     OrderController orderController = new OrderController();
     OrderInfo orderInfo = orderController.GetOrder(orderID);
     orderInfo.OrderStatusID = (int)OrderInfo.OrderStatusList.Cancelled;
     orderController.UpdateOrder(orderInfo.OrderID, orderInfo.OrderDate, orderInfo.OrderNumber, orderInfo.ShippingAddressID, orderInfo.BillingAddressID, orderInfo.Tax, orderInfo.ShippingCost, true, orderInfo.OrderStatusID, orderInfo.CustomerID);
     //SendOrderStatusChangeEmail(orderInfo.CustomerID, orderInfo.OrderID, GetOrderStatus(orderInfo.OrderStatusID), false, true);
     SendOrderStatusChangeEmail(orderInfo.CustomerID, orderInfo.OrderID, GetOrderStatus(orderInfo.OrderStatusID, orderInfo.OrderIsPlaced), false, true);
 }
Ejemplo n.º 4
0
        private void lnkbtnSave_Click(object sender, EventArgs e)
        {
            //Update the order status...
            OrderController orderController = new OrderController();
            OrderInfo orderInfo = orderController.GetOrder(customerNav.OrderID);

            if (orderInfo != null)
            {
                orderController.UpdateOrder(orderInfo.OrderID, orderInfo.OrderDate, orderInfo.OrderNumber, orderInfo.ShippingAddressID, orderInfo.BillingAddressID, orderInfo.Tax, orderInfo.ShippingCost, true, Convert.ToInt32(ddlOrderStatus.SelectedValue), orderInfo.CustomerID);
                SendOrderStatusChangeEmail(orderInfo.CustomerID, orderInfo.OrderID, ddlOrderStatus.SelectedItem.Text, ddlOrderStatus.SelectedItem.Value == "2", false);
                customerNav.OrderID = Null.NullInteger;
                Response.Redirect(customerNav.GetNavigationUrl(), false);
            }
        }
Ejemplo n.º 5
0
        private void btnPayViaPayPal_Click(object sender, EventArgs e)
        {
            OrderController orderController = new OrderController();
            OrderInfo orderInfo = orderController.GetOrder(customerNav.OrderID);

            if (orderInfo.OrderStatusID == 2)
            {
                SetupPayPalFields(orderInfo);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Retrieve the current order from the database as is.
        /// </summary>
        /// <returns></returns>
        private OrderInfo GetExistingOrder()
        {
            OrderController orderController = new OrderController();
            OrderInfo orderInfo = null;

            int orderID = GetOrderIDFromCookie();

            if (orderID >= 0)
            {
                try
                {
                    orderInfo = orderController.GetOrder(orderID);
                }
                catch
                {
                    orderInfo = null;
                }
            }

            return orderInfo;
        }
Ejemplo n.º 7
0
 public OrderInfo GetOrderDetails()
 {
     OrderController orderController = new OrderController();
     return orderController.GetOrder(_orderInfo.OrderID);
 }
Ejemplo n.º 8
0
        private DataTable getOrdersData(int orderId, int customerId, int orderStatusId)
        {
            OrderController orderController = new OrderController();

            //Create Tempory Table
            DataTable dtTemp = new DataTable();

            //Creating Header Row
            dtTemp.Columns.Add("<b>Order Number</b>");  // 0
            dtTemp.Columns.Add("<b>Login</b>");         // 1
            dtTemp.Columns.Add("<b>Name</b>");          // 2
            dtTemp.Columns.Add("<b>Company(Profile)</b>");       // 3
            dtTemp.Columns.Add("<b>Company(Wisdom)</b>");       // 4
            dtTemp.Columns.Add("<b>Order Date</b>");    // 5
            dtTemp.Columns.Add("<b>Order Total</b>");   // 6
            dtTemp.Columns.Add("<b>Status</b>");        // 7
            dtTemp.Columns.Add("<b>Product</b>");       // 8
            dtTemp.Columns.Add("<b>Delivery</b>");      // 9
            dtTemp.Columns.Add("<b>Qty</b>");           // 10
            dtTemp.Columns.Add("<b>SubTotal</b>");      // 11

            UserController userController = new UserController();
            ArrayList orders = new ArrayList();
            DataRow drAddItem;
            if (orderId != -1)
            {
                OrderInfo orderInfo = orderController.GetOrder(orderId);
                ArrayList orderDetailsList = orderController.GetOrderDetails(orderId);

                UserInfo userInfo = userController.GetUser(this.PortalId, orderInfo.CustomerID);

                foreach (OrderDetailsInfo orderDetails in orderDetailsList)
                {
                    drAddItem = dtTemp.NewRow();
                    drAddItem[0] = orderInfo.OrderID + "";
                    drAddItem[1] = userInfo.Username;
                    drAddItem[2] = userInfo.DisplayName;
                    drAddItem[3] = userInfo.Profile.GetPropertyValue("Company");
                    drAddItem[4] = getUserCompanyName(orderInfo.CustomerID);
                    drAddItem[5] = orderInfo.OrderDate.ToString("dd/MM/yyyy HH:mm");
                    drAddItem[6] = orderInfo.OrderTotal + "";
                    drAddItem[7] = GetOrderStatus(orderInfo.OrderStatusID, orderInfo.OrderIsPlaced);
                    // drAddItem[7] = orderInfo.sta;

                    drAddItem[8] = getProductName(orderDetails.ModelName, orderDetails.ProdReference); //orderDetails.ModelName;
                    drAddItem[9] = getProdDeliveryMethodStr(orderDetails.ProdDeliveryMethod);
                    drAddItem[10] = orderDetails.Quantity;
                    drAddItem[11] = orderDetails.ProdCost;

                    dtTemp.Rows.Add(drAddItem);
                }

            }
            else if (customerId != -1)
            {
                orders = orderController.GetCustomerOrders(this.PortalId, customerId);
                foreach (OrderInfo orderInfo in orders)
                {
                    UserInfo userInfo = userController.GetUser(this.PortalId, orderInfo.CustomerID);

                    ArrayList orderDetailsList = orderController.GetOrderDetails(orderInfo.OrderID);

                    foreach (OrderDetailsInfo orderDetails in orderDetailsList)
                    {
                        drAddItem = dtTemp.NewRow();
                        drAddItem[0] = orderInfo.OrderID + "";
                        drAddItem[1] = userInfo.Username;
                        drAddItem[2] = userInfo.DisplayName;
                        drAddItem[3] = userInfo.Profile.GetPropertyValue("Company");
                        drAddItem[4] = getUserCompanyName(orderInfo.CustomerID);
                        drAddItem[5] = orderInfo.OrderDate.ToString("dd/MM/yyyy HH:mm");
                        drAddItem[6] = orderInfo.OrderTotal + "";
                        drAddItem[7] = GetOrderStatus(orderInfo.OrderStatusID, orderInfo.OrderIsPlaced);
                        // drAddItem[7] = orderInfo.sta;

                        drAddItem[8] = getProductName(orderDetails.ModelName, orderDetails.ProdReference); //orderDetails.ModelName;
                        drAddItem[9] = getProdDeliveryMethodStr(orderDetails.ProdDeliveryMethod);
                        drAddItem[10] = orderDetails.Quantity;
                        drAddItem[11] = orderDetails.ProdCost;

                        dtTemp.Rows.Add(drAddItem);
                    }

                }
            }
            else if (orderStatusId != -1)
            {
                orders = orderController.GetOrders(this.PortalId, orderStatusId);
                foreach (OrderInfo orderInfo in orders)
                {
                    UserInfo userInfo = userController.GetUser(this.PortalId, orderInfo.CustomerID);

                    ArrayList orderDetailsList = orderController.GetOrderDetails(orderInfo.OrderID);

                    foreach (OrderDetailsInfo orderDetails in orderDetailsList)
                    {
                        drAddItem = dtTemp.NewRow();
                        drAddItem[0] = orderInfo.OrderID + "";
                        drAddItem[1] = userInfo.Username;
                        drAddItem[2] = userInfo.DisplayName;
                        drAddItem[3] = userInfo.Profile.GetPropertyValue("Company");
                        drAddItem[4] = getUserCompanyName(orderInfo.CustomerID);
                        drAddItem[5] = orderInfo.OrderDate.ToString("dd/MM/yyyy HH:mm");
                        drAddItem[6] = orderInfo.OrderTotal + "";
                        drAddItem[7] = GetOrderStatus(orderInfo.OrderStatusID, orderInfo.OrderIsPlaced);
                        // drAddItem[7] = orderInfo.sta;

                        drAddItem[8] = getProductName(orderDetails.ModelName, orderDetails.ProdReference); //orderDetails.ModelName;
                        drAddItem[9] = getProdDeliveryMethodStr(orderDetails.ProdDeliveryMethod);
                        drAddItem[10] = orderDetails.Quantity;
                        drAddItem[11] = orderDetails.ProdCost;

                        dtTemp.Rows.Add(drAddItem);
                    }
                }
            }

            {
                //                Response.Write("<br>" + ((Decimal)drW["VolumeMillionLitres"]).ToString());
            }
            return dtTemp;
        }
Ejemplo n.º 9
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            /*
            if (cbExport.Checked)   // Export to excel option selected
            {
                //Response.Write("<!-- Going to export to excel -->");
                string strFileName = "orders.xls";

                int orderId = -1;
                int customerID = -1;
                int orderStatusID = -1;
                if (tbOrderNumber.Text.Length > 0)  // Export only the given orderId
                {
                    try { orderId = Convert.ToInt32(tbOrderNumber.Text); }
                    catch (FormatException) { return; }

                }
                else if (lstCustomers.SelectedIndex > 0) // Export all the orders for a given customer
                {
                    customerID = int.Parse(lstCustomers.SelectedValue);

                }
                else if (lstOrderStatus.SelectedIndex > 0) // Export all the orders with the specified status
                {
                    try { orderStatusID = Convert.ToInt32(lstOrderStatus.SelectedValue); }
                    catch (System.FormatException)
                    {
                        return;
                    }
                }

                DataTable dtTemp = getOrdersData(orderId, customerID, orderStatusID);
                ExportToExcel(this.Context, strFileName, dtTemp);
            }
            */
            if (tbOrderNumber.Text.Length > 0)
            {
                lstCustomers.ClearSelection();
                lstOrderStatus.ClearSelection();

                noOrdersFound.Visible = false;
                CustomerNavigation customerNav = new CustomerNavigation(Request.QueryString);
                try { customerNav.OrderID = Convert.ToInt32(tbOrderNumber.Text); }
                catch (FormatException)
                {
                    customerNav.OrderID = Null.NullInteger;
                }
                if (customerNav.OrderID != Null.NullInteger)
                {
                    OrderController orderController = new OrderController();
                    OrderInfo orderInfo = orderController.GetOrder(customerNav.OrderID);
                    if (orderInfo != null)
                    {
                        customerNav.CustomerID = orderInfo.CustomerID;
                        Response.Redirect(customerNav.GetNavigationUrl());
                    }
                    else
                    {
                        customerNav.OrderID = Null.NullInteger;
                        customerNav.CustomerID = Null.NullInteger;
                        noOrdersFound.Visible = true;
                    }
                }
            }
            else if (lstCustomers.SelectedIndex > 0)
            {
                lstOrderStatus.ClearSelection();
                _nav.OrderID = Null.NullInteger;

                noOrdersFound.Visible = false;
                _nav.CustomerID = int.Parse(lstCustomers.SelectedValue);
                _nav.OrderID = Null.NullInteger;
                Response.Redirect(_nav.GetNavigationUrl());
            }
            else if (lstOrderStatus.SelectedIndex > 0)
            {
                //_nav.CustomerID = Null.NullInteger;

                noOrdersFound.Visible = false;
                StoreControlBase ordersControl = (StoreControlBase)LoadControl(ModulePath + "CustomerOrders.ascx");
                ordersControl.ParentControl = this.ParentControl;
                ((CustomerOrders)ordersControl).ShowOrdersInStatus = true;
                try { ((CustomerOrders)ordersControl).OrderStatusID = Convert.ToInt32(lstOrderStatus.SelectedValue); }
                catch (System.FormatException)
                {
                    return;
                }

                plhOrders.Controls.Clear();
                plhOrders.Controls.Add(ordersControl);
                plhOrders.Visible = true;
            }
        }