예제 #1
0
    /// <summary>
    /// Handles the UniGrid'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 id = actionArgument.ToInteger(0);

        switch (actionName.ToLowerCSafe())
        {
        case "edit":
            URLHelper.Redirect("OrderStatus_Edit.aspx?orderstatusid=" + id + "&siteId=" + SiteID);
            break;

        case "delete":
            CheckConfigurationModification();

            var status = OrderStatusInfoProvider.GetOrderStatusInfo(id);
            if (status != null)
            {
                if (status.Generalized.CheckDependencies())
                {
                    // Show error message
                    ShowError(ECommerceHelper.GetDependencyMessage(status));

                    return;
                }

                // Delete OrderStatusInfo object from database
                OrderStatusInfoProvider.DeleteOrderStatusInfo(status);
            }

            break;
        }
    }
예제 #2
0
    /// <summary>
    /// Checks if at least one enabled order status is present.
    /// </summary>
    private void CheckEnabledStatusPresence()
    {
        DataSet ds = OrderStatusInfoProvider.GetOrderStatuses(ConfiguredSiteID, true);

        if (DataHelper.DataSourceIsEmpty(ds))
        {
            ShowWarning(GetString("com.orderstatus.noenabledfound"));
        }
    }
예제 #3
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        // Check if at least one enabled status is present
        DataSet ds = OrderStatusInfoProvider.GetOrderStatuses(ConfiguredSiteID, true);

        if (DataHelper.DataSourceIsEmpty(ds))
        {
            ShowWarning(GetString("com.orderstatus.noenabledfound"));
        }
    }
        public OrdersListViewModel(OrderInfo order)
        {
            if (order == null)
            {
                return;
            }

            OrderID             = order.OrderID;
            OrderInvoiceNumber  = order.OrderInvoiceNumber;
            OrderDate           = order.OrderDate;
            StatusName          = OrderStatusInfoProvider.GetOrderStatusInfo(order.OrderStatusID)?.StatusDisplayName;
            FormattedTotalPrice = String.Format(CurrencyInfoProvider.GetCurrencyInfo(order.OrderCurrencyID).CurrencyFormatString, order.OrderTotalPrice);
        }
    protected void gridElem_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int orderStatId = ValidationHelper.GetInteger(((DataRowView)(e.Row.DataItem)).Row["ToStatusID"], 0);

            OrderStatusInfo osi = OrderStatusInfoProvider.GetOrderStatusInfo(orderStatId);
            if (osi != null)
            {
                e.Row.Style.Add("background-color", osi.StatusColor);
            }
        }
    }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Init header actions
        HeaderActions actions = CurrentMaster.HeaderActions;

        actions.ActionPerformed += HeaderActions_ActionPerformed;

        // New item action
        actions.ActionsList.Add(new HeaderAction()
        {
            Text        = GetString("OrderStatus_List.NewItemCaption"),
            RedirectUrl = ResolveUrl("OrderStatus_Edit.aspx?siteId=" + SiteID),
            ImageUrl    = GetImageUrl("Objects/Ecommerce_OrderStatus/add.png"),
            ControlType = HeaderActionTypeEnum.Hyperlink
        });

        // Show copy from global link when not configuring global statuses.
        if (ConfiguredSiteID != 0)
        {
            // Show "Copy from global" link only if there is at least one global status
            DataSet ds = OrderStatusInfoProvider.GetOrderStatuses(0, false);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                actions.ActionsList.Add(new HeaderAction()
                {
                    Text          = GetString("general.copyfromglobal"),
                    OnClientClick = "return ConfirmCopyFromGlobal();",
                    ImageUrl      = GetImageUrl("Objects/Ecommerce_OrderStatus/fromglobal.png"),
                    CommandName   = "copyFromGlobal",
                    ControlType   = HeaderActionTypeEnum.LinkButton
                });

                // Register javascript to confirm generate
                string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmOrderStatusFromGlobal")) + ");}";
                ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
            }
        }

        gridElem.OnAction             += gridElem_OnAction;
        gridElem.OnExternalDataBound  += gridElem_OnExternalDataBound;
        gridElem.GridView.AllowSorting = false;

        // Configuring global records from specific site
        if ((ConfiguredSiteID == 0) && (SiteID != 0))
        {
            ShowInformation(GetString("com.UsingGlobalSettings"));
        }

        // Filter records by site
        gridElem.WhereCondition = "ISNULL(StatusSiteID, 0) = " + ConfiguredSiteID;
    }
예제 #7
0
    /// <summary>
    /// Checks order statuses.
    /// </summary>
    private void CheckOrderStatuses()
    {
        if (OrderStatusesCheck)
        {
            // Check if at least one order status exists
            DataSet ds = OrderStatusInfoProvider.GetOrderStatuses(SiteContext.CurrentSiteID, true)
                         .TopN(1)
                         .Column("StatusID");

            if (DataHelper.DataSourceIsEmpty(ds))
            {
                DisplayMessage("com.settingschecker.orderstatusnodata");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Init header actions
        var actions = CurrentMaster.HeaderActions;

        actions.ActionPerformed += HeaderActions_ActionPerformed;

        // New item action
        actions.ActionsList.Add(new HeaderAction
        {
            Text        = GetString("OrderStatus_List.NewItemCaption"),
            RedirectUrl = ResolveUrl("OrderStatus_Edit.aspx?siteId=" + SiteID)
        });

        // Show copy from global link when not configuring global statuses.
        if (ConfiguredSiteID != 0)
        {
            // Show "Copy from global" link only if there is at least one global status
            DataSet ds = OrderStatusInfoProvider.GetOrderStatuses(0).TopN(1);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                actions.ActionsList.Add(new HeaderAction
                {
                    Text          = GetString("general.copyfromglobal"),
                    OnClientClick = "return ConfirmCopyFromGlobal();",
                    CommandName   = "copyFromGlobal",
                    ButtonStyle   = ButtonStyle.Default
                });

                // Register javascript to confirm generate
                string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmOrderStatusFromGlobal")) + ");}";
                ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
            }
        }

        gridElem.OnAction             += gridElem_OnAction;
        gridElem.OnExternalDataBound  += gridElem_OnExternalDataBound;
        gridElem.GridView.AllowSorting = false;

        // Show information about usage of global objects when used on site
        HandleGlobalObjectInformation(gridElem.ObjectType);

        // Filter records by site
        gridElem.WhereCondition = "ISNULL(StatusSiteID, 0) = " + ConfiguredSiteID;
    }
예제 #9
0
 public OrderViewModel(OrderInfo order)
 {
     OrderID                = order.OrderID;
     OrderStatusID          = order.OrderStatusID;
     CurrencyFormatString   = CurrencyInfoProvider.GetCurrencyInfo(order.OrderCurrencyID).CurrencyFormatString;
     OrderDate              = order.OrderDate;
     OrderTotalPrice        = order.OrderTotalPrice;
     OrderIsPaid            = order.OrderIsPaid;
     OrderStatusDisplayName = OrderStatusInfoProvider.GetOrderStatusInfo(order.OrderStatusID)?.StatusDisplayName;
     if (order.OrderPaymentResult != null)
     {
         OrderPaymentResult = new OrderPaymentResultViewModel()
         {
             PaymentMethodName  = order.OrderPaymentResult.PaymentMethodName,
             PaymentIsCompleted = order.OrderPaymentResult.PaymentIsCompleted
         };
     }
 }
        public ActionResult OrderDetail(int?orderID)
        {
            if (orderID == null)
            {
                return(RedirectToAction("Index"));
            }

            var order = mOrderRepository.GetById(orderID.Value);

            if ((order == null) || (order.OrderCustomerID != CurrentCustomer?.CustomerID))
            {
                return(RedirectToAction("NotFound", "HttpErrors"));
            }

            var currency = CurrencyInfoProvider.GetCurrencyInfo(order.OrderCurrencyID);

            return(View(new OrderDetailViewModel(currency.CurrencyFormatString)
            {
                InvoiceNumber = order.OrderInvoiceNumber,
                TotalPrice = order.OrderTotalPrice,
                StatusName = OrderStatusInfoProvider.GetOrderStatusInfo(order.OrderStatusID)?.StatusDisplayName,
                OrderAddress = new OrderAddressViewModel(order.OrderBillingAddress),
                OrderItems = OrderItemInfoProvider.GetOrderItems(order.OrderID).Select(orderItem =>
                {
                    return new OrderItemViewModel
                    {
                        SKUID = orderItem.OrderItemSKUID,
                        SKUName = orderItem.OrderItemSKUName,
                        SKUImagePath = orderItem.OrderItemSKU.SKUImagePath,
                        TotalPriceInMainCurrency = orderItem.OrderItemTotalPriceInMainCurrency,
                        UnitCount = orderItem.OrderItemUnitCount,
                        UnitPrice = orderItem.OrderItemUnitPrice
                    };
                })
            }));
        }
        private void GenerateEcommerceData(int siteID)
        {
            var siteName     = SiteInfoProvider.GetSiteName(siteID);
            var currencyInfo = CurrencyInfoProvider.GetCurrencies(siteID)
                               .Where("CurrencyIsMain", QueryOperator.Equals, 1).TopN(1).FirstOrDefault();
            var list1 = PaymentOptionInfoProvider.GetPaymentOptions(siteID).ToList();
            var list2 = ShippingOptionInfoProvider.GetShippingOptions(siteID).ToList();

            var orderStatusList = OrderStatusInfoProvider.GetOrderStatuses(siteID).ToDictionary(status => status.StatusName);

            var manufacturerExceptionList = new List <int>
            {
                ManufacturerInfoProvider.GetManufacturerInfo("Aerobie", siteName).ManufacturerID,
                //ManufacturerInfoProvider.GetManufacturerInfo("Chemex", siteName).ManufacturerID,
                //ManufacturerInfoProvider.GetManufacturerInfo("Espro", siteName).ManufacturerID
            };
            var list3 = SKUInfoProvider.GetSKUs(siteID).ToList().Where(sku =>
            {
                if (sku.IsProduct)
                {
                    return(!manufacturerExceptionList.Contains(sku.SKUManufacturerID));
                }
                return(false);
            }).ToList();
            int         num1;
            IList <int> intList;

            if (CustomerInfoProvider.GetCustomers().WhereEquals("CustomerSiteID", siteID).Count < 50)
            {
                num1    = customerNames.Length;
                intList = new List <int>();
                for (var index = 0; index < num1; ++index)
                {
                    intList.Add(GenerateCustomer(customerNames[index], siteID).CustomerID);
                }
            }
            else
            {
                intList = DataHelper.GetIntegerValues(CustomerInfoProvider.GetCustomers().Column("CustomerID")
                                                      .WhereEquals("CustomerSiteID", siteID).WhereNotEquals("CustomerEmail", "alex").Tables[0],
                                                      "CustomerID");
                num1 = intList.Count;
            }

            var num2 = 0;
            var num3 = 0;

            for (var index1 = 0; index1 <= 30; ++index1)
            {
                ++num2;
                var num4 = 0;
                if (index1 > 5)
                {
                    num4 = rand.Next(-1, 2);
                }
                for (var index2 = 0; index2 < num2 / 2 + num4; ++index2)
                {
                    var orderStatusInfo = index1 >= 25
                        ? index1 >= 29 ? orderStatusList["New"] : orderStatusList["InProgress"]
                        : orderStatusList["Completed"];
                    var orderInfo = new OrderInfo
                    {
                        OrderCustomerID = intList[num3 % num1],
                        OrderCurrencyID = currencyInfo.CurrencyID,
                        OrderSiteID     = siteID,
                        OrderStatusID   = orderStatusInfo.StatusID,
                        OrderIsPaid     = "Completed".Equals(orderStatusInfo.StatusName, StringComparison.Ordinal) ||
                                          (uint)rand.Next(0, 2) > 0U,
                        OrderShippingOptionID         = list2[rand.Next(list2.Count)].ShippingOptionID,
                        OrderPaymentOptionID          = list1[rand.Next(list1.Count)].PaymentOptionID,
                        OrderGrandTotal               = decimal.Zero,
                        OrderGrandTotalInMainCurrency = decimal.Zero,
                        OrderTotalPrice               = decimal.Zero,
                        OrderTotalPriceInMainCurrency = decimal.Zero,
                        OrderTotalShipping            = new decimal(10),
                        OrderTotalTax = new decimal(10)
                    };
                    OrderInfoProvider.SetOrderInfo(orderInfo);
                    var orderItems = GenerateOrderItems(orderInfo, list3);
                    GenerateOrderAddress(orderInfo.OrderID, GetRandomCountryId(), AddressType.Billing);
                    GenerateOrderAddress(orderInfo.OrderID, GetRandomCountryId(), AddressType.Shipping);
                    orderInfo.OrderDate       = DateTime.Now.AddDays(index1 - 30);
                    orderInfo.OrderTotalPrice = orderItems;
                    orderInfo.OrderTotalPriceInMainCurrency = orderItems;
                    orderInfo.OrderGrandTotal = orderItems;
                    orderInfo.OrderGrandTotalInMainCurrency = orderItems;
                    var cartInfoFromOrder = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderInfo.OrderID);
                    orderInfo.OrderInvoiceNumber = OrderInfoProvider.GenerateInvoiceNumber(cartInfoFromOrder);
                    orderInfo.OrderInvoice       = ShoppingCartInfoProvider.GetOrderInvoice(cartInfoFromOrder);
                    OrderInfoProvider.SetOrderInfo(orderInfo);
                    ++num3;
                }
            }

            if (UserInfoProvider.GetUserInfo("alex") != null)
            {
                return;
            }
            var customerInfo = new CustomerInfo
            {
                CustomerEmail             = "*****@*****.**",
                CustomerFirstName         = "Alexander",
                CustomerLastName          = "Adams",
                CustomerSiteID            = siteID,
                CustomerCompany           = "Alex & Co. Ltd",
                CustomerTaxRegistrationID = "12S379BDF798",
                CustomerOrganizationID    = "WRQ7987VRG79"
            };

            CustomerInfoProvider.SetCustomerInfo(customerInfo);
            var userInfo = CustomerInfoProvider.RegisterCustomer(customerInfo, "", "alex");
            var roleInfo = RoleInfoProvider.GetRoleInfo("SilverPartner", siteID);

            if (roleInfo != null)
            {
                UserInfoProvider.AddUserToRole(userInfo.UserID, roleInfo.RoleID);
            }
            for (var index = 0; index < 5; ++index)
            {
                var cart = new ShoppingCartInfo();
                cart.ShoppingCartCulture         = CultureHelper.GetDefaultCultureCode(siteName);
                cart.ShoppingCartCurrencyID      = currencyInfo.CurrencyID;
                cart.ShoppingCartSiteID          = siteID;
                cart.ShoppingCartCustomerID      = customerInfo.CustomerID;
                cart.ShoppingCartBillingAddress  = GenerateAddress(GetRandomCountryId(), customerInfo.CustomerID);
                cart.ShoppingCartShippingAddress = GenerateAddress(GetRandomCountryId(), customerInfo.CustomerID);
                cart.User = userInfo;
                ShoppingCartInfoProvider.SetShoppingCartInfo(cart);
                ShoppingCartInfoProvider.SetShoppingCartItem(cart,
                                                             new ShoppingCartItemParameters(list3.ElementAt(rand.Next(list3.Count)).SKUID, rand.Next(5)));
                cart.Evaluate();
                ShoppingCartInfoProvider.SetOrder(cart);
            }
        }
예제 #12
0
    /// <summary>
    /// Returns where condition based on webpart fields.
    /// </summary>
    private string GetWhereCondition()
    {
        // Orders from current site
        string where = "OrderSiteID = " + CMSContext.CurrentSiteID;

        // Order status filter
        OrderStatusInfo status = OrderStatusInfoProvider.GetOrderStatusInfo(OrderStatus, SiteContext.CurrentSiteName);

        if (status != null)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderStatusID = " + status.StatusID);
        }

        // Customer or company like filter
        if (!string.IsNullOrEmpty(CustomerOrCompany))
        {
            string safeQueryStr = SecurityHelper.GetSafeQueryString(CustomerOrCompany);
            where = SqlHelper.AddWhereCondition(where, "OrderCustomerID  IN (SELECT CustomerID FROM COM_Customer WHERE ((CustomerFirstName + ' ' + CustomerLastName + ' ' + CustomerFirstName) LIKE N'%" + safeQueryStr + "%') OR (CustomerCompany LIKE N'%" + safeQueryStr + "%'))");
        }

        // Filter for orders with note
        if (HasNote)
        {
            where = SqlHelper.AddWhereCondition(where, "(OrderNote != '') AND (OrderNote IS NOT NULL)");
        }

        // Payment method filter
        PaymentOptionInfo payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(PaymentMethod, SiteContext.CurrentSiteName);

        if (payment != null)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderPaymentOptionID = " + payment.PaymentOptionID);
        }

        // Payment status filter
        switch (PaymentStatus.ToLowerCSafe())
        {
        case PAY_STATUS_NOT_PAID:
            where = SqlHelper.AddWhereCondition(where, "(OrderIsPaid = 0) OR (OrderIsPaid IS NULL)");
            break;

        case PAY_STATUS_PAID:
            where = SqlHelper.AddWhereCondition(where, "OrderIsPaid = 1");
            break;
        }

        // Currency filter
        CurrencyInfo currencyObj = CurrencyInfoProvider.GetCurrencyInfo(Currency, SiteContext.CurrentSiteName);

        if (currencyObj != null)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderCurrencyID = " + currencyObj.CurrencyID);
        }

        // Min price in main currency filter
        if (MinPriceInMainCurrency > 0)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderTotalPriceInMainCurrency >= " + MinPriceInMainCurrency);
        }

        // Max price in main currency filter
        if (MaxPriceInMainCurrency > 0)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderTotalPriceInMainCurrency <= " + MaxPriceInMainCurrency);
        }

        // Shipping option filter
        ShippingOptionInfo shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(ShippingOption, SiteContext.CurrentSiteName);

        if (shipping != null)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderShippingOptionID = " + shipping.ShippingOptionID);
        }

        // Shipping country filter
        where = SqlHelper.AddWhereCondition(where, GetCountryWhereCondition());

        // Date filter
        where = SqlHelper.AddWhereCondition(where, GetDateWhereCondition());

        return(where);
    }
예제 #13
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("cms.ecommerce", "orderproperties", false, orderId);
            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;
        }
    }
    private void DoTraitement()
    {
        var ordeID = Request.QueryString["ORDERID"];
        var order  = OrderInfoProvider.GetOrderInfo(Int32.Parse(ordeID));

        if (order == null)
        {
            return;
        }

        var    transactionID   = Request.QueryString["PAYID"];
        string transactionDate = Request.QueryString["TRXDATE"];
        var    modePaiement    = Request.QueryString["PM"];
        var    statutCode      = Request.QueryString["STATUS"];
        var    ncerror         = Request.QueryString["NCERROR"];
        var    sha             = Request.QueryString["SHASIGN"];


        var tab   = transactionDate.Split('/');
        var month = Int32.Parse(tab[0]);
        var day   = Int32.Parse(tab[1]);
        var year  = Int32.Parse(tab[2]);

        var date = new DateTime(year, month, day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);


        var payementResult = new PaymentResultInfo()
        {
            PaymentDate          = GetOgoneTransactionDate(transactionDate),
            PaymentTransactionID = transactionID,
            PaymentIsCompleted   = true,
            PaymentStatusName    = GetOgoneStatutLibelle(statutCode),
            PaymentMethodName    = "Ogone"
        };

        var paymentItem = new PaymentResultItemInfo()
        {
            Header = "Payment by",
            Name   = "PaymentSytem",
            Text   = modePaiement,
            Value  = modePaiement
        };

        payementResult.SetPaymentResultItemInfo(paymentItem);

        order.OrderPaymentResult = payementResult;

        if (statutCode != "1" && statutCode != "0")
        {
            order.OrderStatusID = OrderStatusInfoProvider.GetOrderStatusInfo("PaymentReceived", SiteContext.CurrentSiteName).StatusID;
            order.SetValue("OrderStatus", "1");
        }
        else
        {
            order.OrderStatusID = OrderStatusInfoProvider.GetOrderStatusInfo("Canceled", SiteContext.CurrentSiteName).StatusID;
            order.SetValue("OrderStatus", "2");
        }

        OrderHelper.CreateCustomInvoiceHelper(Int32.Parse(ordeID));
        OrderInfoProvider.SetOrderInfo(order);
    }
        public int GetOrderStatusId(string name)
        {
            var status = OrderStatusInfoProvider.GetOrderStatuses().Where(s => s.StatusName == name).FirstOrDefault();

            return(status?.StatusID ?? 0);
        }