Esempio n. 1
0
       public IList<CategoryInfo> GetCategory(CategoryType categoryType, int categoryID)
       {
           SqlHelper objSqlHelper = new SqlHelper();
           
           List<CategoryInfo> categorys = new List<CategoryInfo>();
           SqlParameter[] objParams = new SqlParameter[2];
           objParams[0] = new SqlParameter("@categoryType", SqlDbType.Int, 4);
           objParams[1] = new SqlParameter("@categoryID", SqlDbType.Int, 4);
           objParams[0].Value = (int)categoryType;
           objParams[1].Value = categoryID;

           SqlDataReader reader = objSqlHelper.ExecuteReader("je_Cat_GetCategory", objParams); ;
           while (reader.Read())
           {
               
               CategoryInfo item = new CategoryInfo();
               item.CategoryID = reader.GetInt32(reader.GetOrdinal("categoryID"));
               item.CategoryName = reader.GetString(reader.GetOrdinal("categoryName"));
               item.ParentID = reader.GetInt32(reader.GetOrdinal("parentID"));
               item.IsMain = reader.GetBoolean(reader.GetOrdinal("IsMain"));
               categorys.Add(item);
           }
           reader.Close();
           objSqlHelper.close();
           
           return categorys;
       }
Esempio n. 2
0
 public void InsertCategory(CategoryInfo category)
 {
     SqlHelper objSqlHelper = new SqlHelper();
     SqlParameter[] objParams = new SqlParameter[3];
     objParams[0] = new SqlParameter("@categoryName", category.CategoryName);
     objParams[1] = new SqlParameter("@parentID", category.ParentID);
     objParams[2] = new SqlParameter("@IsMain", category.IsMain);
     objSqlHelper.ExecuteNonQuery("je_Cat_InsertCategory", objParams);
 }
Esempio n. 3
0
 public int UpdateCategory(CategoryInfo category)
 {
     SqlHelper objSqlHelper = new SqlHelper();
     SqlParameter[] objParams = new SqlParameter[4];
     objParams[0] = new SqlParameter("@categoryName", category.CategoryName);
     objParams[1] = new SqlParameter("@parentID", category.ParentID);
     objParams[2] = new SqlParameter("@IsMain", category.IsMain);
     objParams[3] = new SqlParameter("@categoryID", category.CategoryID);
     return objSqlHelper.ExecuteNonQuery("je_Cat_UpdateCategory", objParams);
 }
Esempio n. 4
0
 public CategoryInfo GetCategoryByID(int categoryID)
 {
     SqlHelper objSqlHelper = new SqlHelper();
     SqlParameter[] objParams = new SqlParameter[1];
     objParams[0] = new SqlParameter("@categoryID", SqlDbType.Int, 4);
     objParams[0].Value = categoryID;
     SqlDataReader reader = objSqlHelper.ExecuteReader("je_Cat_GetCategoryByID", objParams);
     CategoryInfo item = new CategoryInfo();
     while (reader.Read())
     {
         item.CategoryID = reader.GetInt32(reader.GetOrdinal("categoryID"));
         item.CategoryName = reader.GetString(reader.GetOrdinal("categoryName"));
         item.ParentID = reader.GetInt32(reader.GetOrdinal("parentID"));
         item.IsMain = reader.GetBoolean(reader.GetOrdinal("IsMain"));
     }
     reader.Close();
     
     return item;
 }
Esempio n. 5
0
 /// <summary>
 /// 更新分类
 /// </summary>
 /// <param name="category"></param>
 public static int UpdateCategory(CategoryInfo category)
 {
     return categorys.UpdateCategory(category);
 }
Esempio n. 6
0
 /// <summary>
 /// 新增分类
 /// </summary>
 /// <param name="category"></param>
 public static void InsertCategory(CategoryInfo category)
 {
     categorys.InsertCategory(category);
 }