public BECategorys GetCategorys(SQLHelper sqlHelper, int startIndex, int maxRows, string categoryName)
        {
            string sql      = string.Empty;
            string subQuery = string.Empty;
            int    startRow = (startIndex - 1) * maxRows + 1;
            int    endRow   = startIndex + maxRows - 1;

            BECategorys Categorys = new BECategorys();

            try
            {
                subQuery = GetSubQuery(sqlHelper, categoryName);
                sql      = sqlHelper.MakeSQL(@"SELECT * FROM TblCategory WHERE IsDeleted=$b $q ORDER BY CATEGORYID", false, subQuery);
                if (maxRows > 0)
                {
                    sql = DBUtility.GetPagingSQL(sql, startRow, endRow);
                }

                IDataReader reader = sqlHelper.ExecuteQuery(sql);
                AddToCategoryCollection(Categorys, reader);
                reader.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(Categorys);
        }
        public BECategory GetCategory(SQLHelper sqlHelper, int categoryId)
        {
            string      sql       = string.Empty;
            BECategorys categorys = new BECategorys();

            try
            {
                sql = sqlHelper.MakeSQL(@"SELECT * FROM TblCategory WHERE CategoryId =$n ORDER BY Code, CategoryName", categoryId);
                IDataReader reader = sqlHelper.ExecuteQuery(sql);
                AddToCategoryCollection(categorys, reader);
                reader.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            if (categorys.Count > 0)
            {
                return(categorys[0]);
            }
            else
            {
                return(new BECategory());
            }
        }
        public int GetCategorysCount(SQLHelper sqlHelper, string categoryName)
        {
            string      sql       = string.Empty;
            string      subQuery  = string.Empty;
            BECategorys Categorys = new BECategorys();
            int         rowCount  = 0;

            try
            {
                subQuery = GetSubQuery(sqlHelper, categoryName);
                sql      = sqlHelper.MakeSQL("SELECT COUNT(CATEGORYID) FROM TblCategory WHERE IsDeleted=$b $q", false, subQuery);
                IDataReader reader = sqlHelper.ExecuteQuery(sql);

                if (reader.Read())
                {
                    rowCount = Convert.ToInt32(reader[0].ToString());
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(rowCount);
        }
        private BECategorys AddToCategoryCollection(BECategorys categorys, IDataReader reader)
        {
            NULLHandler nullHandler = new NULLHandler(reader);

            while (reader.Read())
            {
                categorys.Add(PreaperCategoryObject(nullHandler));
            }
            return(categorys);
        }
Beispiel #5
0
 public BECategorys GetCategorys(int startIndex, int maxRows, string categoryName)
 {
     try
     {
         BECategorys categorys = null;
         sqlHelper = new SQLHelper();
         categorys = daCategory.GetCategorys(sqlHelper, startIndex, maxRows, categoryName);
         sqlHelper.CommitTran();
         return(categorys);
     }
     catch (Exception ex)
     {
         RnD.BLTemp.Common.Utility.SaveErrorLog(this.GetType().ToString(), "", ex);
         if (sqlHelper != null)
         {
             sqlHelper.Rollback();
         }
         throw ex;
     }
 }