Exemplo n.º 1
0
        public DataTable GetUserCoupons(int userId, int useType = 0, EnumCouponType couponType = EnumCouponType.Coupon)
        {
            string str = string.Empty;

            switch (useType)
            {
            case 1:
                str = " AND UsedTime IS NULL AND ClosingTime >= @ClosingTime";
                break;

            case 2:
                str = " AND UsedTime IS NOT NULL";
                break;

            case 3:
                str = " AND UsedTime IS NULL AND ClosingTime < @ClosingTime";
                break;
            }
            str  = ((couponType != 0) ? (str + " AND RedEnvelopeId > 0 ") : (str + " AND CouponId > 0 "));
            str += " ORDER BY GetDate desc ";
            DbCommand sqlStringCommand = base.database.GetSqlStringCommand("SELECT * FROM Hishop_CouponItems WHERE UserId = @UserId " + str);

            base.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, userId);
            base.database.AddInParameter(sqlStringCommand, "ClosingTime", DbType.DateTime, DateTime.Now);
            return(base.database.ExecuteDataSet(sqlStringCommand).Tables[0]);
        }
Exemplo n.º 2
0
        public IList <CouponInfo> GetUsedCoupons(EnumCouponType couponType = EnumCouponType.Coupon)
        {
            string             query            = "SELECT * FROM Hishop_Coupons WHERE StartTime <= getDate() AND ClosingTime >= getDate() and CouponId > 0 ";
            DbCommand          sqlStringCommand = base.database.GetSqlStringCommand(query);
            IList <CouponInfo> result           = new List <CouponInfo>();

            using (IDataReader objReader = base.database.ExecuteReader(sqlStringCommand))
            {
                result = DataHelper.ReaderToList <CouponInfo>(objReader);
            }
            return(result);
        }
Exemplo n.º 3
0
 public static IList <CouponInfo> GetUsedCoupons(EnumCouponType couponType = EnumCouponType.Coupon)
 {
     return(new CouponDao().GetUsedCoupons(couponType));
 }