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

📄 shoppingcartlist.aspx.cs

📁 易想商城系统
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using YXShop.Common;
using Shop.Web.UI;

namespace YXShop.Web.Admin.Product
{
    public partial class ShoppingCartList : System.Web.UI.Page
    {
        public PageSet ps; BasePage bp = null;
        protected void Page_Load(object sender, EventArgs e)
        {

            AjaxPro.Utility.RegisterTypeForAjax(typeof(YXShop.Web.Admin.Product.ShoppingCartList));
            if (!PowerTree.PowerPass.isPass("004000000", PowerTree.PowerPanel.PowerType.look))
            {
                bp = new BasePage();
                bp.PageError("对不起,你没有查看此页面的权限!", "../index.aspx");
            }
            if ((!IsPostBack) || ((Request["Event"] != null) && (Request["Event"] != "")))
            {
                BindData();
            }
            if (!IsPostBack && Request.QueryString["Del"] != null)
            {
                YXShop.BLL.ShoppingCart data = new YXShop.BLL.ShoppingCart();
                string str = Request.QueryString["Del"];
                if (!PowerTree.PowerPass.isPass("004000003",PowerTree.PowerPanel.PowerType.del))
                {
                    bp = new BasePage();
                    bp.PageError("对不起,你没有清除购物车的权限!", "../index.aspx");
                }
                if (str != string.Empty)
                {
                    switch (str)
                    {
                        case "3"://今天
                            data.Delete("day(LastActivityDate)=day(getDate())");
                            break;
                        case "1"://本月
                            data.Delete("month(LastActivityDate)= month(getDate())");
                            break;
                        case "2"://本周
                            data.Delete("datediff(week,LastActivityDate,getDate())=0");
                            break;
                        case "4"://会员
                            data.Delete("is  not null");
                            break;
                    }
                }
                BindData();
            }

        }
        #region 列表
        private void BindData()
        {
            int pageIndex = Request["pageIndex"] == null ? 0 : int.Parse(Request["pageIndex"]);
            if (pageIndex < 0)
            {
                pageIndex = 0;
            }
            if ((Request["Event"] == null) || (Request["Event"] == ""))
            {
                pageIndex = 0;
            }
            YXShop.BLL.ShoppingCart data = new YXShop.BLL.ShoppingCart();
            List<YXShop.Model.ShoppingCart> datas = data.GetAllProfile();
            string str = Request.QueryString["Ty"];
            if (str != string.Empty)
            {
                //if (!PowerTree.PowerPass.isPass("004000006", PowerTree.PowerPanel.PowerType.other))
                //{
                //    bp = new BasePage();
                //    bp.PageError("对不起,你没有查看此页面的权限!", "../index.aspx");
                //}
                switch (str)
                {
                    case "1"://今天
                        datas = data.GetListByColumnProfilebay("day(LastActivityDate)=day(getDate())");
                        break;
                    case "2"://本月
                        datas = data.GetListByColumnProfilebay("month(LastActivityDate)= month(getDate())");
                        break;
                    case "3"://本周
                        datas = data.GetListByColumnProfilebay("datediff(week,LastActivityDate,getDate())=0");
                        break;
                    case "4"://会员
                        datas = data.GetListByColumnProfileMember();
                        break;
                }
            }
            dgTBShoppCart.DataSource = datas;


            ps = new PageSet(datas.Count, PageSet.PageSize, pageIndex);
            if (ps.PageCount <= pageIndex + 1)
            {
                pageIndex = ps.PageCount - 1;
            }

            dgTBShoppCart.PageSize = PageSet.PageSize;
            dgTBShoppCart.PageIndex = pageIndex;
            if (datas.Count < 1)
            {
                dgTBShoppCart.BackColor = System.Drawing.Color.White;
            }
            
            dgTBShoppCart.DataBind();
        }

        protected void dgTBShoppCart_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (!(e.Row.DataItem is YXShop.Model.ShoppingCart))
            {
                return;
            }
            YXShop.Model.ShoppingCart data = (e.Row.DataItem as YXShop.Model.ShoppingCart);
            if (data != null)
            {
                e.Row.Cells[0].Text = "<a href='ShoppingCartContent.aspx?id="+data.UniqueID+"'>"+data.Username+"</a>";
                e.Row.Cells[2].Text = this.ProductCount(data.UniqueID);
                e.Row.Cells[3].Text = this.ProductTotalPrice(data.UniqueID) != "0" ? this.ProductTotalPrice(data.UniqueID) : "";
            }
        }
        #endregion

        #region 查询产品
        protected string ProductCount(int id)
        {
            string str = "";
            YXShop.BLL.ShoppingCart data = new YXShop.BLL.ShoppingCart();
            List<YXShop.Model.ShoppingCart> datas = data.GetListByColumnCart("UniqueID", id);
            if (datas.Count > 0)
            {
                str = datas.Count.ToString();
            }
            return str.ToString();
        }
        protected string ProductTotalPrice(int id)
        {
            decimal price = 0;
            YXShop.BLL.ShoppingCart data = new YXShop.BLL.ShoppingCart();
            List<YXShop.Model.ShoppingCart> datas = data.GetListByColumnCart("UniqueID", id);
            if (datas.Count > 0)
            {
                foreach (YXShop.Model.ShoppingCart da in datas)
                {
                    price += Convert.ToDecimal(da.Price);
                }
            }
            return price.ToString();
        }
        #endregion



       
    }
}

⌨️ 快捷键说明

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