예제 #1
0
        public static DBtblUserCollection GetAllItem()
        {
            string key  = SETTINGS_ALL_KEY;
            object obj2 = dtpCache.Get(key);

            if ((obj2 != null))
            {
                return((DBtblUserCollection)obj2);
            }
            DBtblUserCollection ItemCollection = new DBtblUserCollection();
            Database            db             = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand           dbCommand      = db.GetStoredProcCommand("dtp_tblUser_GetAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBtblUser item = GetItemFromReader(dataReader);
                    ItemCollection.Add(item);
                }
            }

            dtpCache.Max(key, ItemCollection);

            return(ItemCollection);
        }
예제 #2
0
        public static DBtblUserCollection GetItemPagging(int page, int rec, string strSearch, out int TotalRecords)
        {
            TotalRecords = 0;
            DBtblUserCollection ItemCollection = new DBtblUserCollection();
            Database            db             = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand           dbCommand      = db.GetStoredProcCommand("tblUser_Paging");

            db.AddInParameter(dbCommand, "Page", DbType.Int32, page);
            db.AddInParameter(dbCommand, "RecsPerPage", DbType.Int32, rec);
            db.AddInParameter(dbCommand, "SearchValue", DbType.String, strSearch);
            db.AddOutParameter(dbCommand, "TotalRecords", DbType.Int32, 0);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBtblUser item = GetItemFromReader(dataReader);
                    ItemCollection.Add(item);
                }
            }
            TotalRecords = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TotalRecords"));
            return(ItemCollection);
        }