Exemplo n.º 1
0
 public static void AddCustomerGroup(CustomerGroup customerGroup)
 {
     customerGroup.CustomerGroupId = SQLDataAccess.ExecuteScalar <int>("INSERT INTO [Customers].[CustomerGroup] ([GroupName], [GroupDiscount]) VALUES (@GroupName, @GroupDiscount); SELECT SCOPE_IdENTITY();",
                                                                       CommandType.Text,
                                                                       new SqlParameter("@GroupName", customerGroup.GroupName),
                                                                       new SqlParameter("@GroupDiscount", customerGroup.GroupDiscount));
 }
Exemplo n.º 2
0
 public static void AddCustomerGroup(CustomerGroup customerGroup)
 {
     customerGroup.CustomerGroupId = SQLDataAccess.ExecuteScalar<int>("INSERT INTO [Customers].[CustomerGroup] ([GroupName], [GroupDiscount]) VALUES (@GroupName, @GroupDiscount); SELECT SCOPE_IdENTITY();",
                                                                         CommandType.Text,
                                                                         new SqlParameter("@GroupName", customerGroup.GroupName),
                                                                         new SqlParameter("@GroupDiscount", customerGroup.GroupDiscount));
 }
Exemplo n.º 3
0
 public static void UpdateCustomerGroup(CustomerGroup customerGroup)
 {
     SQLDataAccess.ExecuteNonQuery(" UPDATE [Customers].[CustomerGroup] SET [GroupName] = @GroupName, [GroupDiscount] = @GroupDiscount " +
                                   " WHERE CustomerGroupId = @CustomerGroupId", CommandType.Text,
                                   new SqlParameter("@CustomerGroupId", customerGroup.CustomerGroupId),
                                   new SqlParameter("@GroupName", customerGroup.GroupName),
                                   new SqlParameter("@GroupDiscount", customerGroup.GroupDiscount));
 }
Exemplo n.º 4
0
 public static void UpdateCustomerGroup(CustomerGroup customerGroup)
 {
     SQLDataAccess.ExecuteNonQuery(" UPDATE [Customers].[CustomerGroup] SET [GroupName] = @GroupName, [GroupDiscount] = @GroupDiscount " +
                                   " WHERE CustomerGroupId = @CustomerGroupId", CommandType.Text,
                                   new SqlParameter("@CustomerGroupId", customerGroup.CustomerGroupId),
      new SqlParameter("@GroupName", customerGroup.GroupName),
                                   new SqlParameter("@GroupDiscount", customerGroup.GroupDiscount));
 }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            customerGroup = CustomerSession.CurrentCustomer.CustomerGroup;
            lDemoWarning.Visible = Demo.IsDemoEnabled || Trial.IsTrialEnabled;

            btnConfirm.Visible = ShoppingCartService.CurrentShoppingCart.HasItems;

            aCheckOut.Visible = true;

            if (!IsPostBack)
            {
                if (Request["productid"].IsNotEmpty())
                {
                    int productId = Request["productid"].TryParseInt();
                    int amount = Request["amount"].TryParseInt(1);
                    if (productId != 0 && ProductService.IsProductEnabled(productId))
                    {
                        IList<EvaluatedCustomOptions> listOptions = null;
                        string selectedOptions = HttpUtility.UrlDecode(Request["AttributesXml"]);
                        try
                        {
                            listOptions = CustomOptionsService.DeserializeFromXml(selectedOptions);
                        }
                        catch (Exception)
                        {
                            listOptions = null;
                        }

                        if (CustomOptionsService.DoesProductHaveRequiredCustomOptions(productId) && listOptions == null)
                        {
                            Response.Redirect(SettingsMain.SiteUrl + UrlService.GetLinkDB(ParamType.Product, productId));
                            return;
                        }

                        ShoppingCartService.AddShoppingCartItem(new ShoppingCartItem
                            {
                                OfferId = ProductService.GetProduct(productId).Offers[0].OfferId,
                                Amount = amount,
                                ShoppingCartType = ShoppingCartType.ShoppingCart,
                                AttributesXml = listOptions != null ? selectedOptions : string.Empty,
                            });

                        Response.Redirect("~/shoppingcart.aspx");
                    }
                }

                UpdateBasket();
                SetMeta(
                    new MetaInfo(string.Format("{0} - {1}", SettingsMain.ShopName,
                                               Resource.Client_ShoppingCart_ShoppingCart)), string.Empty);
            }
            //relatedProducts.ProductIds = ShoppingCartService.CurrentShoppingCart.Where(p => p.ItemType == ShoppingCartItem.EnumItemType.Product).Select(p => p.EntityId).ToList();
        }
Exemplo n.º 6
0
        public static float CalculateProductPrice(float price, float productDiscount, CustomerGroup customerGroup, IList<EvaluatedCustomOptions> customOptions)
        {
            float customOptionPrice = 0;
            if (customOptions != null)
            {
                customOptionPrice = CustomOptionsService.GetCustomOptionPrice(price, customOptions);
            }

            float groupDiscount = customerGroup.CustomerGroupId == 0 ? 0 : customerGroup.GroupDiscount;

            float finalDiscount = Math.Max(productDiscount, groupDiscount);

            return price * (100 - finalDiscount) / 100 + customOptionPrice;
        }
Exemplo n.º 7
0
        protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteCustomerGroup")
            {
                CustomerGroupService.DeleteCustomerGroup(SQLDataHelper.GetInt(e.CommandArgument));
            }

            if (e.CommandName == "AddCustomerGroup")
            {
                GridViewRow footer = grid.FooterRow;
                float discount = 0;
                if (!float.TryParse(((TextBox)footer.FindControl("txtNewGroupDiscount")).Text, out discount))
                {
                    discount = -1;
                }

                if (discount < 0 || string.IsNullOrEmpty(((TextBox)footer.FindControl("txtNewGroupName")).Text))
                {
                    grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ffcccc");
                    return;
                }

                var customerGroup = new CustomerGroup
                    {
                        GroupName = ((TextBox)footer.FindControl("txtNewGroupName")).Text,
                        GroupDiscount = discount,
                    };

                CustomerGroupService.AddCustomerGroup(customerGroup);
                grid.ShowFooter = false;
            }

            if (e.CommandName == "CancelAdd")
            {
                grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ccffcc");
                grid.ShowFooter = false;
            }
        }
Exemplo n.º 8
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            float discount = 0;
            if (grid.UpdatedRow != null && (float.TryParse(grid.UpdatedRow["GroupDiscount"].Replace("%", ""), out discount)) && (discount >= 0) && (discount < 100))
            {
                int customerGroupId = 0;
                int.TryParse(grid.UpdatedRow["ID"], out customerGroupId);

                var customerGroup = new CustomerGroup
                    {
                        CustomerGroupId = customerGroupId,
                        GroupName = grid.UpdatedRow["GroupName"],
                        GroupDiscount = discount,
                    };

                CustomerGroupService.UpdateCustomerGroup(customerGroup);
            }

            DataTable data = _paging.PageItems;
            while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1)
            {
                _paging.CurrentPageIndex--;
                data = _paging.PageItems;
            }

            var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection };
            data.Columns.Add(clmn);
            if ((_selectionFilter != null) && (_selectionFilter.Values != null))
            {
                for (int i = 0; i <= data.Rows.Count - 1; i++)
                {
                    int intIndex = i;
                    if (Array.Exists(_selectionFilter.Values, c => c == data.Rows[intIndex]["ID"].ToString()))
                    {
                        data.Rows[i]["IsSelected"] = !_inverseSelection;
                    }
                }
            }

            if (data.Rows.Count < 1)
            {
                goToPage.Visible = false;
            }

            grid.DataSource = data;
            grid.DataBind();

            pageNumberer.PageCount = _paging.PageCount;
            lblFound.Text = _paging.TotalRowsCount.ToString();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Render product price
        /// </summary>
        /// <param name="productPrice">product price</param>
        /// <param name="discount">total discount price</param>
        /// <param name="showDiscount">display discount</param>
        /// <param name="customerGroup">customer group</param>
        /// <param name="customOptions">custom options</param>
        /// <param name="isWrap">wrap</param>
        /// <param name="showCode">show currency code</param>
        /// <returns></returns>
        public static string RenderPrice(float productPrice, float discount, bool showDiscount, CustomerGroup customerGroup, string customOptions = null, bool isWrap = false, bool showCode = true)
        {
            if (productPrice == 0)
            {
                return String.Format("<div class=\'price\'>{0}</div>", Resource.Client_Catalog_ContactWithUs);
            }
            string res;

            float price = CalculateProductPrice(productPrice, 0, customerGroup, CustomOptionsService.DeserializeFromXml(customOptions));
            float priceWithDiscount = CalculateProductPrice(productPrice, discount, customerGroup, CustomOptionsService.DeserializeFromXml(customOptions));

            float groupDiscount = customerGroup.CustomerGroupId == 0 ? 0 : customerGroup.GroupDiscount;

            float finalDiscount = Math.Max(discount, groupDiscount);

            if (price == priceWithDiscount || !showDiscount)
            {
                res = String.Format("<div class=\'price\'>{0}</div>", GetStringPrice(priceWithDiscount, isWrap, showCode));
            }
            else
            {
                res = String.Format("<div class=\"price-old\">{0}</div><div class=\"price\">{1}</div><div class=\"price-benefit\">{2} {3} {4} {5}% </div>",
                                    GetStringPrice(productPrice),
                                    GetStringPrice(priceWithDiscount),
                                    Resource.Client_Catalog_Discount_Benefit,
                                    GetStringPrice(productPrice - priceWithDiscount),
                                    Resource.Client_Catalog_Discount_Or,
                                    FormatPriceInvariant(finalDiscount));
            }

            return res;
        }