private void DeleteOrder()
    {
        // Prepare the parameters
        //string where = "CustomerLastName LIKE N'My New Registered%'";
        CustomerInfo customer = null;

        // Get the customer
        DataSet customers = CustomerInfoProvider.GetCustomers(null, null);

        if (!DataHelper.DataSourceIsEmpty(customers))
        {
            // Create object from DataRow
            customer = new CustomerInfo(customers.Tables[0].Rows[0]);
        }

        if (customer != null)
        {
            //  string whereOrder = "OrderCustomerID='" + customer.CustomerID + "'";

            // Get the order
            DataSet orders = OrderInfoProvider.GetOrders(null, null);
            if (!DataHelper.DataSourceIsEmpty(orders))
            {
                // Create object from DataRow
                //  OrderInfo order = new OrderInfo(orders.Tables[0].Rows[0]);
                foreach (DataRow userDr in orders.Tables[0].Rows)
                {
                    OrderInfo order = new OrderInfo(userDr);
                    // Delete the order
                    OrderInfoProvider.DeleteOrderInfo(order);
                }
            }
        }
    }
Пример #2
0
    /// <summary>
    /// Handles the grid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        int             orderId = ValidationHelper.GetInteger(actionArgument, 0);
        OrderInfo       oi      = null;
        OrderStatusInfo osi     = null;

        switch (actionName.ToLowerCSafe())
        {
        case "edit":
            string redirectToUrl = UIContextHelper.GetElementUrl("CMS.Ecommerce", "OrderProperties", false, orderId);
            if (customerId > 0)
            {
                redirectToUrl += "&customerId=" + customerId;
            }
            URLHelper.Redirect(redirectToUrl);
            break;


        case "delete":
            // Check 'ModifyOrders' and 'EcommerceModify' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
            {
                AccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyOrders");
            }

            // delete OrderInfo object from database
            OrderInfoProvider.DeleteOrderInfo(orderId);
            break;

        case "previous":
            // Check 'ModifyOrders' and 'EcommerceModify' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
            {
                AccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyOrders");
            }

            oi = OrderInfoProvider.GetOrderInfo(orderId);
            if (oi != null)
            {
                osi = OrderStatusInfoProvider.GetPreviousEnabledStatus(oi.OrderStatusID);
                if (osi != null)
                {
                    oi.OrderStatusID = osi.StatusID;
                    // Save order status changes
                    OrderInfoProvider.SetOrderInfo(oi);
                }
            }
            break;

        case "next":
            // Check 'ModifyOrders' and 'EcommerceModify' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
            {
                AccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyOrders");
            }

            oi = OrderInfoProvider.GetOrderInfo(orderId);
            if (oi != null)
            {
                osi = OrderStatusInfoProvider.GetNextEnabledStatus(oi.OrderStatusID);
                if (osi != null)
                {
                    oi.OrderStatusID = osi.StatusID;
                    // Save order status changes
                    OrderInfoProvider.SetOrderInfo(oi);
                }
            }
            break;
        }
    }
Пример #3
0
    /// <summary>
    /// Handles the gridElem's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        int             orderId = ValidationHelper.GetInteger(actionArgument, 0);
        OrderInfo       oi;
        OrderStatusInfo osi;

        switch (actionName.ToLowerCSafe())
        {
        case "edit":
            string redirectToUrl = UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, "orderproperties", false, orderId);
            URLHelper.Redirect(redirectToUrl);
            break;

        case "delete":
            // Check 'ModifyOrders' and 'EcommerceModify' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission(EcommercePermissions.ORDERS_MODIFY))
            {
                return;
            }

            // Delete OrderInfo object from database
            OrderInfoProvider.DeleteOrderInfo(orderId);
            break;

        case "previous":
            // Check 'ModifyOrders' and 'EcommerceModify' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission(EcommercePermissions.ORDERS_MODIFY))
            {
                return;
            }

            oi = OrderInfoProvider.GetOrderInfo(orderId);
            if (oi != null)
            {
                osi = OrderStatusInfoProvider.GetPreviousEnabledStatus(oi.OrderStatusID);
                if (osi != null)
                {
                    oi.OrderStatusID = osi.StatusID;
                    // Save order status changes
                    OrderInfoProvider.SetOrderInfo(oi);
                }
            }
            break;

        case "next":
            // Check 'ModifyOrders' and 'EcommerceModify' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission(EcommercePermissions.ORDERS_MODIFY))
            {
                return;
            }

            oi = OrderInfoProvider.GetOrderInfo(orderId);
            if (oi != null)
            {
                osi = OrderStatusInfoProvider.GetNextEnabledStatus(oi.OrderStatusID);
                if (osi != null)
                {
                    oi.OrderStatusID = osi.StatusID;
                    // Save order status changes
                    OrderInfoProvider.SetOrderInfo(oi);
                }
            }
            break;
        }
    }
Пример #4
0
    /// <summary>
    /// Handles the gridElem's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        int             orderId = ValidationHelper.GetInteger(actionArgument, 0);
        OrderInfo       oi      = null;
        OrderStatusInfo osi     = null;

        switch (actionName.ToLowerCSafe())
        {
        case "edit":
            string redirectToUrl = "~/CMSModules/Ecommerce/Pages/Tools/Orders/Order_Edit.aspx?orderID=" + orderId.ToString();
            URLHelper.Redirect(redirectToUrl);
            break;

        case "delete":
            // Check 'ModifyOrders' and 'EcommerceModify' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
            {
                return;
            }

            // Delete OrderInfo object from database
            OrderInfoProvider.DeleteOrderInfo(orderId);
            break;

        case "previous":
            // Check 'ModifyOrders' and 'EcommerceModify' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
            {
                return;
            }

            oi = OrderInfoProvider.GetOrderInfo(orderId);
            if (oi != null)
            {
                osi = OrderStatusInfoProvider.GetPreviousEnabledStatus(oi.OrderStatusID);
                if (osi != null)
                {
                    oi.OrderStatusID = osi.StatusID;
                    // Save order status changes
                    OrderInfoProvider.SetOrderInfo(oi);
                }
            }
            break;

        case "next":
            // Check 'ModifyOrders' and 'EcommerceModify' permission
            if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
            {
                return;
            }

            oi = OrderInfoProvider.GetOrderInfo(orderId);
            if (oi != null)
            {
                osi = OrderStatusInfoProvider.GetNextEnabledStatus(oi.OrderStatusID);
                if (osi != null)
                {
                    oi.OrderStatusID = osi.StatusID;
                    // Save order status changes
                    OrderInfoProvider.SetOrderInfo(oi);
                }
            }
            break;
        }
    }