⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shoppingcartui.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace PowerEasy.WebSite.Shop
{
    using PowerEasy.Common;
    using PowerEasy.Components;
    using PowerEasy.Contents;
    using PowerEasy.Model.Contents;
    using PowerEasy.Model.Shop;
    using PowerEasy.Model.UserManage;
    using PowerEasy.Shop;
    using PowerEasy.Web.UI;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class ShoppingCartUI : DynamicPage
    {
        protected Button BtnClearCart;
        protected Button BtnModifyCart;
        protected Button BtnPayment;
        protected Button BtnShopping;
        protected string cartId;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        protected Label LblBalance;
        protected Label LblDiscount_Member;
        protected Label LblGroupName;
        protected Label LblUserExp;
        protected Label LblUserName;
        protected Label LblUserPoint;
        protected HyperLink LnkLogin;
        private string m_Action;
        private int m_ProductCount;
        private string m_UserName = PEContext.Current.User.UserName;
        protected Panel PanEmptyText;
        protected StringBuilder productNumList;
        protected Repeater RptShoppingCart;
        protected HtmlTableRow ShowTips_Login;
        protected decimal total;

        protected void AddToCart()
        {
            ShopConfig shopConfig = SiteConfig.ShopConfig;
            if ((shopConfig.OrderProductNumber != 0) && (shopConfig.OrderProductNumber <= ShoppingCart.GetInfoByCart(this.cartId, false).Count))
            {
                DynamicPage.WriteErrMsg("<li>超出系统所设置的购物车商品种类数量:" + shopConfig.OrderProductNumber + "</li>", "ShoppingCart.aspx");
            }
            ShoppingCartInfo shoppingcartinfo = new ShoppingCartInfo();
            int productId = 0;
            string tableName = string.Empty;
            CommonModelInfo commonModelInfoById = ContentManage.GetCommonModelInfoById(BasePage.RequestInt32("ID"));
            if (commonModelInfoById.IsNull)
            {
                DynamicPage.WriteErrMsg("<li>找不到指定的商品</li>");
            }
            else
            {
                productId = commonModelInfoById.ItemId;
                tableName = commonModelInfoById.TableName;
            }
            string property = DataSecurity.FilterBadChar(BasePage.RequestString("Property"));
            if (!this.ProductExist(this.cartId, productId, tableName, property))
            {
                if (Product.IsEnableSale(productId, tableName, property, this.cartId))
                {
                    shoppingcartinfo.Quantity = 1;
                    shoppingcartinfo.ProductId = productId;
                    shoppingcartinfo.TableName = tableName;
                    shoppingcartinfo.Property = property;
                    shoppingcartinfo.UserName = this.m_UserName;
                    shoppingcartinfo.UpdateTime = DateTime.Now;
                    shoppingcartinfo.IsPresent = false;
                    shoppingcartinfo.CartId = this.cartId;
                    ShoppingCart.Add(shoppingcartinfo);
                }
                else
                {
                    DynamicPage.WriteErrMsg(Product.ErrMsgOfEnableSale);
                }
            }
        }

        private void BatchAddToCart()
        {
            string str = BasePage.RequestString("IDList");
            if (string.IsNullOrEmpty(str))
            {
                DynamicPage.WriteErrMsg("对不起,传递的参数不正确,请从正确的路径访问!");
            }
            foreach (string str2 in str.Split(new char[] { ',' }))
            {
                string[] strArray2 = str2.Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries);
                string property = string.Empty;
                if (strArray2.Length == 3)
                {
                    property = strArray2[2];
                }
                int generalId = DataConverter.CLng(strArray2[0]);
                int num2 = DataConverter.CLng(strArray2[1], 1);
                ShoppingCartInfo shoppingcartinfo = new ShoppingCartInfo();
                int productId = 0;
                string tableName = string.Empty;
                CommonModelInfo commonModelInfoById = ContentManage.GetCommonModelInfoById(generalId);
                if (!commonModelInfoById.IsNull)
                {
                    productId = commonModelInfoById.ItemId;
                    tableName = commonModelInfoById.TableName;
                }
                if (!this.ProductExist(this.cartId, productId, tableName, property) && Product.IsEnableSale(productId, tableName, property, this.cartId))
                {
                    shoppingcartinfo.Quantity = num2;
                    shoppingcartinfo.ProductId = productId;
                    shoppingcartinfo.TableName = tableName;
                    shoppingcartinfo.Property = property;
                    shoppingcartinfo.UserName = this.m_UserName;
                    shoppingcartinfo.UpdateTime = DateTime.Now;
                    shoppingcartinfo.IsPresent = false;
                    shoppingcartinfo.CartId = this.cartId;
                    ShoppingCart.Add(shoppingcartinfo);
                }
            }
        }

        protected void BtnClearCart_Click(object sender, EventArgs e)
        {
            ShoppingCart.Delete(this.cartId);
            this.RptShoppingCart_DataBind();
        }

        protected void BtnModifyCart_Click(object sender, EventArgs e)
        {
            this.ModifyCart();
        }

        protected void BtnPayment_Click(object sender, EventArgs e)
        {
            this.ModifyCart();
            if (this.m_ProductCount == 0)
            {
                DynamicPage.WriteErrMsg("购物车为空,不能去收银台!");
            }
            base.Response.Redirect("Payment.aspx");
        }

        protected void BtnShopping_Click(object sender, EventArgs e)
        {
            string continueBuy = SiteConfig.ShopConfig.ContinueBuy;
            if (string.IsNullOrEmpty(continueBuy))
            {
                continueBuy = "~/Category.aspx?id=4";
            }
            BasePage.ResponseRedirect(continueBuy);
        }

        private string GetParameterList(string checkboxId, string productIdControlId, string numberControlId, string tableNameControlId, string propertyControlId)
        {
            string str = "";
            string str2 = "";
            string str3 = "";
            StringBuilder builder = new StringBuilder("");
            IList<ShoppingCartInfo> list = this.ViewState["CartList"] as IList<ShoppingCartInfo>;
            StringBuilder sb = new StringBuilder();
            foreach (ShoppingCartInfo info in list)
            {
                if (!info.IsPresent)
                {
                    StringHelper.AppendString(sb, info.ProductId + "|" + info.TableName);
                }
            }
            for (int i = this.RptShoppingCart.Items.Count - 1; i >= 0; i--)
            {
                if ((this.RptShoppingCart.Items[i].ItemType == ListItemType.Item) || (this.RptShoppingCart.Items[i].ItemType == ListItemType.AlternatingItem))
                {
                    CheckBox box = (CheckBox) this.RptShoppingCart.Items[i].FindControl(checkboxId);
                    if ((box != null) && box.Checked)
                    {
                        string str4 = "";
                        str = ((HiddenField) this.RptShoppingCart.Items[i].FindControl(productIdControlId)).Value;
                        int amount = DataConverter.CLng(((TextBox) this.RptShoppingCart.Items[i].FindControl(numberControlId)).Text, 1);
                        if (amount <= 0)
                        {
                            amount = 1;
                        }
                        str2 = ((HiddenField) this.RptShoppingCart.Items[i].FindControl(tableNameControlId)).Value;
                        str3 = ((HiddenField) this.RptShoppingCart.Items[i].FindControl(propertyControlId)).Value;
                        if (list != null)
                        {
                            str4 = Product.CheckStocks(list[i].ProductInfomation, list[i].Property, amount, sb);
                        }
                        if (string.IsNullOrEmpty(str4))
                        {
                            if (builder.Length != 0)
                            {
                                builder.Append("$$$");
                            }
                            builder.Append(str);
                            builder.Append(",");
                            builder.Append(str2);
                            builder.Append(",");
                            builder.Append(amount.ToString());
                            builder.Append(",");
                            builder.Append(str3);
                        }
                        else
                        {
                            DynamicPage.WriteErrMsg(str4);
                            break;
                        }
                    }
                }
            }
            return builder.ToString();
        }

        private string GetPresentParameterList(string checkboxId, string idControl, string numberControlId)
        {
            string str = "";
            string str2 = "";
            StringBuilder builder = new StringBuilder("");
            for (int i = 0; i < this.RptShoppingCart.Items.Count; i++)
            {
                CheckBox box = (CheckBox) this.RptShoppingCart.Items[i].FindControl(checkboxId);
                if ((box != null) && box.Checked)
                {
                    str = ((HiddenField) this.RptShoppingCart.Items[i].FindControl(idControl)).Value.ToString();
                    str2 = ((Literal) this.RptShoppingCart.Items[i].FindControl(numberControlId)).Text.ToString();
                    if (builder.Length != 0)
                    {
                        builder.Append("$$$");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -