Exemple #1
0
        //public List<UserCouponInfo> SearchList(int currentPage, int pageSize, UserCouponSearchInfo searchInfo, ref int count)
        //{
        //    using (var conn = new SqlConnection(connectString))
        //    {
        //        ShopMssqlPagerClass pc = new ShopMssqlPagerClass();
        //        pc.TableName = "UsrCoupon";
        //        pc.Fields = "[Id],[CouponId],[GetType],[Number],[Password],[IsUse],[OrderId],[UserId],[UserName]";
        //        pc.CurrentPage = currentPage;
        //        pc.PageSize = pageSize;
        //        pc.OrderField = "[Id]";
        //        pc.MssqlCondition = PrepareCondition(searchInfo);

        //        count = pc.Count;
        //        return conn.Query<UserCouponInfo>(pc).ToList();
        //    }
        //}
        public List <UserCouponInfo> SearchList(int currentPage, int pageSize, UserCouponSearchInfo searchInfo, ref int count)
        {
            using (var conn = new SqlConnection(connectString))
            {
                ShopMssqlPagerClass pc = new ShopMssqlPagerClass();
                if (searchInfo.IsTimeOut == (int)BoolType.True)//已过期
                {
                    pc.TableName = @"	(SELECT UsrCoupon.[Id],[CouponId],[GetType],[Number],[Password],[IsUse],[OrderId],[UserId],[UserName],[Money],[UseMinAmount]
		                        FROM UsrCoupon INNER JOIN Coupon 
		                        ON UsrCoupon.[CouponId]=Coupon.[Id] 
		                        AND [UseEndDate]<getdate()) temp"        ;
                }
                if (searchInfo.IsTimeOut == (int)BoolType.False)//未过期
                {
                    pc.TableName = @"	(SELECT UsrCoupon.[Id],[CouponId],[GetType],[Number],[Password],[IsUse],[OrderId],[UserId],[UserName],[Money],[UseMinAmount]
		                        FROM UsrCoupon INNER JOIN Coupon 
		                        ON UsrCoupon.[CouponId]=Coupon.[Id] 
		                        AND [UseStartDate]<=getdate() AND [UseEndDate]>=getdate()) temp"        ;
                }
                if (searchInfo.IsTimeOut == -1)//所有
                {
                    pc.TableName = "UsrCoupon";
                }
                pc.Fields         = "[Id],[CouponId],[GetType],[Number],[Password],[IsUse],[OrderId],[UserId],[UserName]";
                pc.CurrentPage    = currentPage;
                pc.PageSize       = pageSize;
                pc.OrderField     = "[Id]";
                pc.MssqlCondition = PrepareCondition(searchInfo);

                count = pc.Count;
                return(conn.Query <UserCouponInfo>(pc).ToList());
            }
        }
Exemple #2
0
        protected void ExportButton_Click(object sender, EventArgs e)
        {
            UserCouponSearchInfo userCouponSearch = new UserCouponSearchInfo();

            userCouponSearch.CouponId = RequestHelper.GetQueryString <int>("CouponID");
            userCouponSearch.UserId   = RequestHelper.GetQueryString <int>("UserID");
            userCouponSearch.GetType  = RequestHelper.GetQueryString <int>("GetType");
            userCouponSearch.Number   = RequestHelper.GetQueryString <string>("Number");
            userCouponSearch.IsUse    = RequestHelper.GetQueryString <int>("IsUse");
            List <UserCouponInfo> userCouponList = UserCouponBLL.SearchList(userCouponSearch);
            StringBuilder         sb             = new StringBuilder();

            sb.Append("ID\t优惠券编号\t密码\t获取类型\t所属用户\t是否使用\n");
            foreach (UserCouponInfo userCoupon in userCouponList)
            {
                sb.Append(userCoupon.Id.ToString() + "\t#" + userCoupon.Number + "\t" + userCoupon.Password + "\t" + userCoupon.GetType + "\t" + userCoupon.UserName + "\t" + ShopCommon.GetBoolString(userCoupon.IsUse) + "\n");
            }
            Response.Clear();
            Response.Buffer  = true;
            Response.Charset = "GB2312";
            Response.AppendHeader("Content-Disposition", "attachment;filename=userCoupon.xls");
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            Response.ContentType     = "application/ms-excel";
            Response.Write(sb.ToString());
            Response.End();
        }
Exemple #3
0
        protected override void PageLoad()
        {
            base.PageLoad();
            this.action = RequestHelper.GetQueryString <string>("Action");
            int queryString = RequestHelper.GetQueryString <int>("Page");

            if (queryString < 1)
            {
                queryString = 1;
            }
            int    pageSize = 20;
            int    count    = 0;
            string action   = this.action;

            if (action != null)
            {
                if (!(action == "NotUse") && !(action == "HasUse"))
                {
                    if ((action != "AddCoupon") && (action == "AddUserCoupon"))
                    {
                        this.AddUserCoupon();
                    }
                }
                else
                {
                    UserCouponSearchInfo userCoupon = new UserCouponSearchInfo();
                    userCoupon.UserID = base.UserID;
                    if (this.action == "NotUse")
                    {
                        userCoupon.IsUse = 0;
                    }
                    else
                    {
                        userCoupon.IsUse = 1;
                    }
                    this.userCouponList             = UserCouponBLL.SearchUserCouponList(queryString, pageSize, userCoupon, ref count);
                    this.ajaxPagerClass.CurrentPage = queryString;
                    this.ajaxPagerClass.PageSize    = pageSize;
                    this.ajaxPagerClass.Count       = count;
                    string str = string.Empty;
                    foreach (UserCouponInfo info2 in this.userCouponList)
                    {
                        if (str == string.Empty)
                        {
                            str = info2.CouponID.ToString();
                        }
                        else
                        {
                            str = str + "," + info2.CouponID.ToString();
                        }
                    }
                    if (str != string.Empty)
                    {
                        CouponSearchInfo coupon = new CouponSearchInfo();
                        coupon.InCouponID = str;
                        this.couponList   = CouponBLL.SearchCouponList(coupon);
                    }
                }
            }
        }
Exemple #4
0
        public List <UserCouponInfo> SearchList(UserCouponSearchInfo searchInfo)
        {
            using (var conn = new SqlConnection(connectString))
            {
                string sql = "select * from UsrCoupon";
                if (searchInfo.IsTimeOut == (int)BoolType.True)//已过期
                {
                    sql = @"select * from	(SELECT UsrCoupon.[Id],[CouponId],[GetType],[Number],[Password],[IsUse],[OrderId],[UserId],[UserName],[Money],[UseMinAmount]
		                        FROM UsrCoupon INNER JOIN Coupon 
		                        ON UsrCoupon.[CouponId]=Coupon.[Id] 
		                        AND [UseEndDate]<getdate()) temp"        ;
                }
                if (searchInfo.IsTimeOut == (int)BoolType.False)//未过期
                {
                    sql = @"select * from	(SELECT UsrCoupon.[Id],[CouponId],[GetType],[Number],[Password],[IsUse],[OrderId],[UserId],[UserName],[Money],[UseMinAmount]
		                        FROM UsrCoupon INNER JOIN Coupon 
		                        ON UsrCoupon.[CouponId]=Coupon.[Id] 
		                        AND [UseStartDate]<=getdate() AND [UseEndDate]>=getdate()) temp"        ;
                }

                string condition = PrepareCondition(searchInfo).ToString();
                if (!string.IsNullOrEmpty(condition))
                {
                    sql += " where " + condition;
                }

                return(conn.Query <UserCouponInfo>(sql).ToList());
            }
        }
Exemple #5
0
 public void PrepareCondition(MssqlCondition mssqlCondition, UserCouponSearchInfo userCouponSearch)
 {
     mssqlCondition.Add("[CouponID]", userCouponSearch.CouponID, ConditionType.Equal);
     mssqlCondition.Add("[GetType]", userCouponSearch.GetType, ConditionType.Equal);
     mssqlCondition.Add("[Number]", userCouponSearch.Number, ConditionType.Like);
     mssqlCondition.Add("[IsUse]", userCouponSearch.IsUse, ConditionType.Equal);
     mssqlCondition.Add("[UserID]", userCouponSearch.UserID, ConditionType.Equal);
 }
Exemple #6
0
        public MssqlCondition PrepareCondition(UserCouponSearchInfo searchInfo)
        {
            MssqlCondition mssqlCondition = new MssqlCondition();

            mssqlCondition.Add("[CouponId]", searchInfo.CouponId, ConditionType.Equal);
            mssqlCondition.Add("[GetType]", searchInfo.GetType, ConditionType.Equal);
            mssqlCondition.Add("[Number]", searchInfo.Number, ConditionType.Like);
            mssqlCondition.Add("[IsUse]", searchInfo.IsUse, ConditionType.Equal);
            mssqlCondition.Add("[UserId]", searchInfo.UserId, ConditionType.Equal);

            return(mssqlCondition);
        }
Exemple #7
0
        public List <UserCouponInfo> SearchUserCouponList(UserCouponSearchInfo userCouponSearch)
        {
            MssqlCondition mssqlCondition = new MssqlCondition();

            this.PrepareCondition(mssqlCondition, userCouponSearch);
            List <UserCouponInfo> userCouponList = new List <UserCouponInfo>();

            SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@condition", SqlDbType.NVarChar) };
            pt[0].Value = mssqlCondition.ToString();
            using (SqlDataReader reader = ShopMssqlHelper.ExecuteReader(ShopMssqlHelper.TablePrefix + "SearchUserCouponList", pt))
            {
                this.PrepareUserCouponModel(reader, userCouponList);
            }
            return(userCouponList);
        }
Exemple #8
0
        /// <summary>
        /// 用户优惠券列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetUserCoupon()
        {
            int couponType = RequestHelper.GetQueryString <int>("userCouponType");
            UserCouponSearchInfo searchInfo = new UserCouponSearchInfo();

            searchInfo.UserId    = uid;
            searchInfo.IsTimeOut = -1;//不限期限有没过期
            //未使用
            if (couponType == 1)
            {
                searchInfo.IsUse     = (int)BoolType.False;
                searchInfo.IsTimeOut = (int)BoolType.False;
            }
            //已使用
            if (couponType == 2)
            {
                searchInfo.IsUse     = (int)BoolType.True;
                searchInfo.IsTimeOut = -1;//不限期限有没过期
            }
            //已过期
            if (couponType == 3)
            {
                searchInfo.IsUse     = (int)BoolType.False;
                searchInfo.IsTimeOut = (int)BoolType.True;
            }

            var ucouponlist = UserCouponBLL.SearchList(searchInfo);

            List <VirtualCoupon> vucoupon = new List <VirtualCoupon>();

            foreach (var item in ucouponlist)
            {
                CouponInfo    tempCoupon = CouponBLL.Read(item.CouponId);
                VirtualCoupon vcou       = new VirtualCoupon()
                {
                    id        = item.Id,
                    name      = tempCoupon.Name,
                    money     = tempCoupon.Money,
                    minmoney  = tempCoupon.UseMinAmount,
                    startdate = tempCoupon.UseStartDate,
                    enddate   = tempCoupon.UseEndDate,
                    isused    = item.IsUse,
                };
                vucoupon.Add(vcou);
            }

            return(Json(new { ucouponlist = vucoupon }, JsonRequestBehavior.AllowGet));
        }
Exemple #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         CheckAdminPower("ReadUserCoupon", PowerCheckType.Single);
         UserCouponSearchInfo userCouponSearch = new UserCouponSearchInfo();
         userCouponSearch.CouponId  = RequestHelper.GetQueryString <int>("CouponID");
         userCouponSearch.GetType   = RequestHelper.GetQueryString <int>("GetType");
         userCouponSearch.Number    = RequestHelper.GetQueryString <string>("Number");
         userCouponSearch.IsUse     = RequestHelper.GetQueryString <int>("IsUse");
         userCouponSearch.UserId    = RequestHelper.GetQueryString <int>("UserID");
         userCouponSearch.IsTimeOut = -1;//所有
         GetType.Text = RequestHelper.GetQueryString <string>("GetType");
         Number.Text  = RequestHelper.GetQueryString <string>("Number");
         IsUse.Text   = RequestHelper.GetQueryString <string>("IsUse");
         PageSize     = 10;
         BindControl(UserCouponBLL.SearchList(CurrentPage, PageSize, userCouponSearch, ref Count), RecordList, MyPager);
     }
 }
Exemple #10
0
        protected override void PageLoad()
        {
            base.PageLoad();
            type = RequestHelper.GetQueryString <string>("type");
            int currentPage = RequestHelper.GetQueryString <int>("Page");

            if (currentPage < 1)
            {
                currentPage = 1;
            }
            int pageSize = 10;
            int count    = 0;

            UserCouponSearchInfo userCouponSearch = new UserCouponSearchInfo();

            userCouponSearch.UserId = base.UserId;
            if (!string.IsNullOrEmpty(type))
            {
                if (type == "1")//未使用
                {
                    userCouponSearch.IsUse     = (int)BoolType.False;
                    userCouponSearch.IsTimeOut = (int)BoolType.False;
                }
                else if (type == "2")//已使用
                {
                    userCouponSearch.IsUse     = (int)BoolType.True;
                    userCouponSearch.IsTimeOut = -1;//不限期限有没过期
                }
                else//已过期
                {
                    userCouponSearch.IsUse     = (int)BoolType.False;
                    userCouponSearch.IsTimeOut = (int)BoolType.True;
                }
            }
            else //所有
            {
                userCouponSearch.IsTimeOut = -1;
            }
            userCouponList = UserCouponBLL.SearchList(currentPage, pageSize, userCouponSearch, ref count);
            commonPagerClass.Init(currentPage, pageSize, count, !string.IsNullOrEmpty(isMobile));

            string idList = string.Empty;

            foreach (UserCouponInfo userCoupon in userCouponList)
            {
                if (idList == string.Empty)
                {
                    idList = userCoupon.CouponId.ToString();
                }
                else
                {
                    idList += "," + userCoupon.CouponId.ToString();
                }
            }
            if (idList != string.Empty)
            {
                CouponSearchInfo couponSearch = new CouponSearchInfo();
                couponSearch.InCouponIds = Array.ConvertAll <string, int>(idList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), i => Convert.ToInt32(i));
                couponList = CouponBLL.SearchList(couponSearch);
            }
        }
Exemple #11
0
 public static List <UserCouponInfo> SearchUserCouponList(int currentPage, int pageSize, UserCouponSearchInfo userCoupon, ref int count)
 {
     return(dal.SearchUserCouponList(currentPage, pageSize, userCoupon, ref count));
 }
Exemple #12
0
 public static List <UserCouponInfo> SearchUserCouponList(UserCouponSearchInfo userCoupon)
 {
     return(dal.SearchUserCouponList(userCoupon));
 }
Exemple #13
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected override void PageLoad()
        {
            base.PageLoad();
            action = RequestHelper.GetQueryString <string>("Action");
            int currentPage = RequestHelper.GetQueryString <int>("Page");

            if (currentPage < 1)
            {
                currentPage = 1;
            }
            int pageSize = 20;
            int count    = 0;

            switch (action)
            {
            case "NotUse":
            case "HasUse":
            case "TimeOut":
                UserCouponSearchInfo userCouponSearch = new UserCouponSearchInfo();
                userCouponSearch.UserId = base.UserId;
                if (action == "NotUse")
                {
                    userCouponSearch.IsUse     = (int)BoolType.False;
                    userCouponSearch.IsTimeOut = (int)BoolType.False;
                }
                else if (action == "HasUse")
                {
                    userCouponSearch.IsUse     = (int)BoolType.True;
                    userCouponSearch.IsTimeOut = -1;    //不限期限有没过期
                }
                else
                {
                    userCouponSearch.IsUse     = (int)BoolType.False;
                    userCouponSearch.IsTimeOut = (int)BoolType.True;
                }
                userCouponList             = UserCouponBLL.SearchList(currentPage, pageSize, userCouponSearch, ref count);
                ajaxPagerClass.CurrentPage = currentPage;
                ajaxPagerClass.PageSize    = pageSize;
                ajaxPagerClass.Count       = count;
                ajaxPagerClass.FirstPage   = "<<首页";
                ajaxPagerClass.PreviewPage = "<<上一页";
                ajaxPagerClass.NextPage    = "下一页>>";
                ajaxPagerClass.LastPage    = "末页>>";
                ajaxPagerClass.ListType    = false;
                ajaxPagerClass.DisCount    = false;
                ajaxPagerClass.PrenextType = true;

                string idList = string.Empty;
                foreach (UserCouponInfo userCoupon in userCouponList)
                {
                    if (idList == string.Empty)
                    {
                        idList = userCoupon.CouponId.ToString();
                    }
                    else
                    {
                        idList += "," + userCoupon.CouponId.ToString();
                    }
                }
                if (idList != string.Empty)
                {
                    CouponSearchInfo couponSearch = new CouponSearchInfo();
                    couponSearch.InCouponIds = Array.ConvertAll <string, int>(idList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), i => Convert.ToInt32(i));
                    couponList = CouponBLL.SearchList(couponSearch);
                }
                break;

            case "AddCoupon":
                break;

            case "AddUserCoupon":
                AddUserCoupon();
                break;

            default:
                break;
            }
        }
 public static List <UserCouponInfo> SearchList(UserCouponSearchInfo searchInfo)
 {
     return(dal.SearchList(searchInfo));
 }
Exemple #15
0
        public List <UserCouponInfo> SearchUserCouponList(int currentPage, int pageSize, UserCouponSearchInfo userCouponSearch, ref int count)
        {
            List <UserCouponInfo> userCouponList = new List <UserCouponInfo>();
            ShopMssqlPagerClass   class2         = new ShopMssqlPagerClass();

            class2.TableName   = ShopMssqlHelper.TablePrefix + "UserCoupon";
            class2.Fields      = "[ID],[CouponID],[GetType],[Number],[Password],[IsUse],[OrderID],[UserID],[UserName]";
            class2.CurrentPage = currentPage;
            class2.PageSize    = pageSize;
            class2.OrderField  = "[ID]";
            class2.OrderType   = OrderType.Desc;
            this.PrepareCondition(class2.MssqlCondition, userCouponSearch);
            class2.Count = count;
            count        = class2.Count;
            using (SqlDataReader reader = class2.ExecuteReader())
            {
                this.PrepareUserCouponModel(reader, userCouponList);
            }
            return(userCouponList);
        }