Exemple #1
0
        private void BindCoupons()
        {
            UserCouponQuery query = this.GetQuery();

            DbQueryResult queryCoupon = TradeHelper.GetUserCouponInfo(query);

            this.coupons.DataSource = queryCoupon.Data;
            this.coupons.DataBind();
            this.pager.TotalRecords = queryCoupon.TotalRecords;
        }
Exemple #2
0
        public UserCouponQuery GetQuery()
        {
            UserCouponQuery userCouponQuery = new UserCouponQuery();

            userCouponQuery.UserID    = new int?(HiContext.Current.User.UserId);
            userCouponQuery.Status    = new int?(this.CouponStatus);
            userCouponQuery.ClaimCode = this.ClaimCode;

            userCouponQuery.PageIndex = this.pager.PageIndex;
            userCouponQuery.PageSize  = this.pager.PageSize;
            userCouponQuery.SortBy    = "VoucherId";
            userCouponQuery.SortOrder = SortAction.Desc;
            return(userCouponQuery);
        }
Exemple #3
0
        public DataSet GetUserCoupons(UserCouponQuery query)
        {
            DataSet dataSet = new DataSet();
            string  str     = "SELECT c.*, ci.ClaimCode,ci.CouponStatus  FROM Hishop_CouponItems ci INNER JOIN Hishop_Coupons c ON c.CouponId = ci.CouponId ";
            string  str2    = " where 1=1 ";

            if (query.Status.HasValue)
            {
                if (query.Status == 1)
                {
                    str2 += "AND ci.CouponStatus = 0 AND ci.UsedTime is NULL and c.ClosingTime > @ClosingTime";
                }
                else if (query.Status == 2)
                {
                    str2 += " AND ci.UsedTime is not NULL and c.ClosingTime > @ClosingTime";
                }
                else if (query.Status == 3)
                {
                    str2 += " AND c.ClosingTime<getdate()";
                }
            }
            if (query.UserID.HasValue)
            {
                str2 += " AND ci.UserId = @UserId";
            }
            if (!string.IsNullOrEmpty(query.ClaimCode))
            {
                str2 += " and ClaimCode=@ClaimCode";
            }
            str2 = ((!query.CouponType.HasValue) ? (str2 + " and (ci.TypeId=0 or ci.TypeId IS NULL)") : (str2 + " and ci.TypeId=@TypeId"));
            str += str2;
            str += " Order by ci.GetDate desc";
            DbCommand sqlStringCommand = base.database.GetSqlStringCommand(str);

            base.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, query.UserID);
            base.database.AddInParameter(sqlStringCommand, "ClosingTime", DbType.DateTime, DateTime.Now);
            base.database.AddInParameter(sqlStringCommand, "ClaimCode", DbType.String, query.ClaimCode);
            if (query.CouponType.HasValue)
            {
                base.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, (int)query.CouponType.Value);
            }
            return(base.database.ExecuteDataSet(sqlStringCommand));
        }