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

📄 shoppingcartui.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
                    }
                    builder.Append(str);
                    builder.Append(",");
                    builder.Append(str2);
                }
            }
            return builder.ToString();
        }

        private void ModifyCart()
        {
            ShoppingCartInfo shoppingcartinfo = new ShoppingCartInfo();
            shoppingcartinfo.UserName = this.m_UserName;
            shoppingcartinfo.UpdateTime = DateTime.Now;
            shoppingcartinfo.CartId = this.cartId;
            string[] strArray = this.GetParameterList("ChkProductId", "HdfProductId", "TxtProductAmount", "HdfTableName", "HdfProperty").Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries);
            this.m_ProductCount = strArray.Length;
            string[] strArray2 = this.GetPresentParameterList("ChkPresentId", "HdnPresentId", "LitPresentNum").Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries);
            ShoppingCart.Delete(this.cartId);
            for (int i = 0; i < strArray.Length; i++)
            {
                string[] strArray3 = strArray[i].Split(new char[] { ',' });
                shoppingcartinfo.IsPresent = false;
                shoppingcartinfo.ProductId = DataConverter.CLng(strArray3[0]);
                shoppingcartinfo.TableName = DataSecurity.FilterBadChar(strArray3[1]);
                shoppingcartinfo.Quantity = DataConverter.CLng(strArray3[2], 1);
                shoppingcartinfo.Property = DataSecurity.FilterBadChar(strArray3[3]);
                ShoppingCart.Add(shoppingcartinfo);
            }
            if (strArray2.Length != 0)
            {
                for (int j = 0; j < strArray2.Length; j++)
                {
                    string[] strArray4 = strArray2[j].Split(new char[] { ',' });
                    shoppingcartinfo.IsPresent = true;
                    shoppingcartinfo.ProductId = DataConverter.CLng(strArray4[0]);
                    shoppingcartinfo.Quantity = DataConverter.CLng(strArray4[1]);
                    ShoppingCart.Add(shoppingcartinfo);
                }
            }
            this.RptShoppingCart_DataBind();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            string applicationName = PayOnline.GetApplicationName();
            if (base.Request.Cookies["Cart" + applicationName] == null)
            {
                this.cartId = Guid.NewGuid().ToString();
                base.Response.Cookies["Cart" + applicationName]["CartID"] = this.cartId;
                base.Response.Cookies["Cart" + applicationName].Expires = DateTime.Now.AddYears(1);
            }
            else
            {
                this.cartId = base.Request.Cookies["Cart" + applicationName]["CartID"];
            }
            this.m_Action = BasePage.RequestStringToLower("Action");
            if (!base.IsPostBack)
            {
                if (string.IsNullOrEmpty(this.m_UserName))
                {
                    this.LblUserName.Text = "";
                    this.LblGroupName.Text = "游客";
                    this.LblDiscount_Member.Text = "100";
                    this.LblBalance.Text = "0";
                    this.LblUserPoint.Text = "0";
                    this.LblUserExp.Text = "0";
                    this.ShowTips_Login.Visible = true;
                    this.LnkLogin.NavigateUrl = "../User/Login.aspx?ReturnUrl=" + HttpUtility.UrlEncode("../Shop/ShoppingCart.aspx");
                }
                else
                {
                    UserInfo userInfo = PEContext.Current.User.UserInfo;
                    this.LblUserName.Text = this.m_UserName;
                    this.LblGroupName.Text = PEContext.Current.User.UserInfo.GroupName;
                    this.LblDiscount_Member.Text = PEContext.Current.User.PurviewInfo.Discount.ToString();
                    this.LblBalance.Text = userInfo.Balance.ToString("0.00");
                    this.LblUserPoint.Text = userInfo.UserPoint.ToString();
                    this.LblUserExp.Text = userInfo.UserExp.ToString();
                }
                if (this.m_Action == "addtocart")
                {
                    this.AddToCart();
                }
                if ((this.m_Action == "wholesale") || (this.m_Action == "batchadd"))
                {
                    this.BatchAddToCart();
                }
                this.RptShoppingCart_DataBind();
            }
        }

        protected bool PresentExist(string shoppingCartId, int productId)
        {
            foreach (ShoppingCartInfo info in ShoppingCart.GetInfoByCart(shoppingCartId, true))
            {
                if ((info.ProductId == productId) && info.IsPresent)
                {
                    return true;
                }
            }
            return false;
        }

        protected bool ProductExist(string shoppingCartId, int productId, string tableName, string property)
        {
            foreach (ShoppingCartInfo info in ShoppingCart.GetInfoByCart(shoppingCartId, false))
            {
                if (((info.ProductId == productId) && (info.TableName == tableName)) && (info.Property == property))
                {
                    return true;
                }
            }
            return false;
        }

        private void RptShoppingCart_DataBind()
        {
            IList<ShoppingCartInfo> list = ShoppingCart.GetList(0, 0, 4, this.cartId);
            if (list.Count == 0)
            {
                this.RptShoppingCart.Visible = false;
                this.PanEmptyText.Visible = true;
                this.BtnClearCart.Visible = false;
                this.BtnModifyCart.Visible = false;
                this.BtnPayment.Visible = false;
            }
            this.RptShoppingCart.DataSource = list;
            this.RptShoppingCart.DataBind();
            this.ViewState["CartList"] = list;
        }

        protected void RptShoppingCart_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType != ListItemType.Item) && (e.Item.ItemType != ListItemType.AlternatingItem))
            {
                return;
            }
            int productNum = 0;
            string str = "";
            string str2 = "";
            decimal subTotal = 0M;
            ((CheckBox) e.Item.FindControl("ChkProductId")).Checked = true;
            ShoppingCartInfo dataItem = e.Item.DataItem as ShoppingCartInfo;
            if (dataItem == null)
            {
                return;
            }
            productNum = dataItem.Quantity;
            ((TextBox) e.Item.FindControl("TxtProductAmount")).Text = productNum.ToString();
            bool haveWholesalePurview = false;
            if (PEContext.Current.User.PurviewInfo != null)
            {
                haveWholesalePurview = PEContext.Current.User.PurviewInfo.Enablepm;
            }
            str2 = ShoppingCart.GetSaleType(dataItem.ProductInfomation, productNum, haveWholesalePurview);
            str = ShoppingCart.GetProductType(dataItem.ProductInfomation, productNum, haveWholesalePurview);
            AbstractItemInfo info2 = new ConcreteProductInfo(productNum, dataItem.Property, dataItem.ProductInfomation, PEContext.Current.User.UserInfo, false, false, haveWholesalePurview);
            info2.GetItemInfo();
            subTotal = info2.SubTotal;
            this.total += subTotal;
            if (!string.IsNullOrEmpty(dataItem.Property))
            {
                ((Literal) e.Item.FindControl("LitProperty")).Text = "(" + info2.Property + ")";
            }
            ((Literal) e.Item.FindControl("LitProductName")).Text = info2.ProductName;
            ((Literal) e.Item.FindControl("LitProductUnit")).Text = info2.Unit;
            ((Literal) e.Item.FindControl("LitPriceMarket")).Text = info2.PriceMarket.ToString("0.00");
            ((Literal) e.Item.FindControl("LitProductType")).Text = str;
            ((Literal) e.Item.FindControl("LitSaleType")).Text = str2;
            ((Literal) e.Item.FindControl("LitTruePrice")).Text = info2.Price.ToString("0.00");
            ((Literal) e.Item.FindControl("LitSubTotal")).Text = subTotal.ToString("0.00");
            if (((dataItem.ProductInfomation.SalePromotionType <= 0) || (productNum < dataItem.ProductInfomation.MinNumber)) || dataItem.IsPresent)
            {
                return;
            }
            e.Item.FindControl("PresentInfomation").Visible = true;
            string str3 = "";
            string str4 = "";
            string str5 = "";
            int productId = 0;
            AbstractItemInfo info3 = new ConcreteSalePromotionType(productNum, dataItem.ProductInfomation, false, null);
            info3.GetItemInfo();
            switch (dataItem.ProductInfomation.SalePromotionType)
            {
                case 1:
                case 3:
                    str4 = "<font color=red>(赠品)</font>";
                    str3 = "赠送礼品";
                    str5 = "赠送";
                    productId = info3.Id;
                    goto Label_0360;

                case 2:
                case 4:
                    if (info3.Price <= 0M)
                    {
                        str4 = "<font color=red>(赠送赠品)</font>";
                        str5 = "赠送";
                        break;
                    }
                    str4 = "<font color=red>(换购赠品)</font>";
                    str5 = "换购";
                    break;

                default:
                    goto Label_0360;
            }
            str3 = "促销礼品";
            productId = info3.Id;
        Label_0360:
            ((HiddenField) e.Item.FindControl("HdnPresentId")).Value = productId.ToString();
            ((Literal) e.Item.FindControl("LitPresentName")).Text = info3.ProductName + str4;
            ((Literal) e.Item.FindControl("LitPresentUnit")).Text = info3.Unit;
            ((Literal) e.Item.FindControl("LitPresentNum")).Text = info3.Amount.ToString();
            ((Literal) e.Item.FindControl("LitPresentType")).Text = str3;
            ((Literal) e.Item.FindControl("LitPresentSaleType")).Text = str5;
            ((Literal) e.Item.FindControl("LitPresentPriceMarket")).Text = info3.PriceMarket.ToString("0.00");
            ((Literal) e.Item.FindControl("LitPresentTruePrice")).Text = info3.Price.ToString("0.00");
            ((Literal) e.Item.FindControl("LitPresentSubtotal")).Text = info3.SubTotal.ToString("0.00");
            if (this.PresentExist(this.cartId, productId))
            {
                ((CheckBox) e.Item.FindControl("ChkPresentId")).Checked = true;
                this.total += info3.SubTotal;
            }
        }
    }
}

⌨️ 快捷键说明

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