示例#1
0
        public IList <CouponDetailInfo> GetDetailList(int startRowIndexId, int maxNumberRows, int userId)
        {
            Database  database          = DatabaseFactory.CreateDatabase();
            DbCommand storedProcCommand = database.GetStoredProcCommand("PR_Common_GetList");

            database.AddInParameter(storedProcCommand, "@StartRows", DbType.Int32, startRowIndexId);
            database.AddInParameter(storedProcCommand, "@PageSize", DbType.Int32, maxNumberRows);
            database.AddInParameter(storedProcCommand, "@SortColumn", DbType.String, "I.ID");
            database.AddInParameter(storedProcCommand, "@StrColumn", DbType.String, "*");
            database.AddInParameter(storedProcCommand, "@Sorts", DbType.String, "DESC");
            database.AddInParameter(storedProcCommand, "@Filter", DbType.String, "I.UserID =" + userId);
            database.AddInParameter(storedProcCommand, "@TableName", DbType.String, "PE_CouponItem I INNER JOIN PE_Coupon C ON I.CouponID = C.CouponID");
            database.AddOutParameter(storedProcCommand, "@Total", DbType.Int32, maxNumberRows);
            IList <CouponDetailInfo> list = new List <CouponDetailInfo>();

            using (NullableDataReader reader = new NullableDataReader(database.ExecuteReader(storedProcCommand)))
            {
                while (reader.Read())
                {
                    CouponDetailInfo item = new CouponDetailInfo();
                    item.CouponInfo     = GetCouponInfoFromrdataReader(reader);
                    item.CouponItemInfo = CouponItem.GetItemInfoFromrdataReader(reader);
                    list.Add(item);
                }
            }
            this.m_TotalOfCoupon = (int)database.GetParameterValue(storedProcCommand, "@Total");
            return(list);
        }
示例#2
0
        public IList <CouponDetailInfo> GetAllDetailList(int startRowIndexId, int maxNumberRows, int searchType, string keyword)
        {
            Database  database          = DatabaseFactory.CreateDatabase();
            DbCommand storedProcCommand = database.GetStoredProcCommand("PR_Common_GetList");
            string    str = "1 = 1";

            switch (searchType)
            {
            case 1:
                str = str + " AND I.Usetimes = 0";
                break;

            case 2:
                str = str + " AND I.Usetimes > 0";
                break;

            case 3:
                str = str + " AND C.UseEndDate + 1 >= GETDATE()";
                break;

            case 4:
                str = str + " AND C.UseEndDate + 1 < GETDATE()";
                break;
            }
            if (!string.IsNullOrEmpty(keyword))
            {
                switch (searchType)
                {
                case 10:
                    str = str + " AND C.CouponName LIKE '%" + DBHelper.FilterBadChar(keyword) + "%'";
                    break;

                case 11:
                    str = str + " AND U.UserName LIKE '%" + DBHelper.FilterBadChar(keyword) + "%'";
                    break;

                case 12:
                    str = str + " AND I.CouponNum LIKE '%" + DBHelper.FilterBadChar(keyword) + "%'";
                    break;
                }
            }
            database.AddInParameter(storedProcCommand, "@StartRows", DbType.Int32, startRowIndexId);
            database.AddInParameter(storedProcCommand, "@PageSize", DbType.Int32, maxNumberRows);
            database.AddInParameter(storedProcCommand, "@SortColumn", DbType.String, "I.ID");
            database.AddInParameter(storedProcCommand, "@StrColumn", DbType.String, "C.*, I.*, U.UserName");
            database.AddInParameter(storedProcCommand, "@Sorts", DbType.String, "DESC");
            database.AddInParameter(storedProcCommand, "@Filter", DbType.String, str);
            database.AddInParameter(storedProcCommand, "@TableName", DbType.String, "PE_CouponItem I LEFT JOIN PE_Users U ON I.UserID = U.UserID INNER JOIN PE_Coupon C ON I.CouponID = C.CouponID");
            database.AddOutParameter(storedProcCommand, "@Total", DbType.Int32, maxNumberRows);
            IList <CouponDetailInfo> list = new List <CouponDetailInfo>();

            using (NullableDataReader reader = new NullableDataReader(database.ExecuteReader(storedProcCommand)))
            {
                while (reader.Read())
                {
                    CouponDetailInfo item = new CouponDetailInfo();
                    item.CouponInfo     = GetCouponInfoFromrdataReader(reader);
                    item.CouponItemInfo = CouponItem.GetItemInfoFromrdataReader(reader);
                    item.UserName       = reader.GetString("UserName");
                    list.Add(item);
                }
            }
            this.m_TotalOfAllCoupon = (int)database.GetParameterValue(storedProcCommand, "@Total");
            return(list);
        }