Example #1
0
 public List<Category> GetAllByLanguage(string language)
 {
     List<Category> all = new List<Category>();
     using (StoredProcedure sp = new StoredProcedure("Categories_GetAllByLanguage"))
     {
         sp.Params.Add("@LangCode", SqlDbType.NChar).Value = language;
         using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
         {
             if (r != null)
             {
                 while (r.Read())
                 {
                     Category item = new Category();
                     item.ID = Convert.ToInt32(r["ID"]);
                     item.LangCode = Convert.ToString(r["LangCode"]);
                     item.Name = Convert.ToString(r["Name"]);
                     item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                     item.ParentID = Convert.ToInt32(r["ParentID"]);
                     item.GroupID = Convert.ToInt32(r["GroupID"]);
                     all.Add(item);
                 }
             }
         }
     }
     return all;
 }
Example #2
0
        public bool DeleteGroup(Category item)
        {
            bool result = false;
            using (StoredProcedure sp = new StoredProcedure("Categories_DeleteGroup"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;

                result = sp.ExecuteNonQuery() > 0;
            }
            return result;
        }
Example #3
0
 public int AddUpdate(Category item)
 {
     int newID = 0;
     using (StoredProcedure sp = new StoredProcedure("Categories_AddUpdateItem"))
     {
         sp.Params.Add("LangCode", System.Data.SqlDbType.NChar).Value = item.LangCode;
         sp.Params.Add("OrderNumber", System.Data.SqlDbType.Int).Value = item.OrderNumber;
         sp.Params.Add("ParentID", System.Data.SqlDbType.Int).Value = item.ParentID;
         sp.Params.Add("Name", System.Data.SqlDbType.NVarChar).Value = item.Name;
         sp.Params.Add("GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;
         newID = Convert.ToInt32(sp.ExecuteScalar());
         item.ID = newID;
     }
     return newID;
 }
Example #4
0
 public Category GetByID(int id)
 {
     Category item = null;
     using (StoredProcedure sp = new StoredProcedure("Categories_GetByID"))
     {
         sp.Params.Add("@ID", System.Data.SqlDbType.Int).Value = id;
         using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
         {
             if (r != null && r.Read())
             {
                 item = new Category();
                 item.ID = Convert.ToInt32(r["ID"]);
                 item.LangCode = Convert.ToString(r["LangCode"]);
                 item.Name = Convert.ToString(r["Name"]);
                 item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                 item.ParentID = Convert.ToInt32(r["ParentID"]);
                 item.GroupID = Convert.ToInt32(r["GroupID"]);
             }
         }
     }
     return item;
 }
Example #5
0
 public Category GetByLangGroup(string language, int groupId)
 {
     Category item = null;
     using (StoredProcedure sp = new StoredProcedure("Categories_GetByLangGroup"))
     {
         sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = groupId;
         sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = language;
         using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
         {
             if (r != null && r.Read())
             {
                 item = new Category();
                 item.ID = Convert.ToInt32(r["ID"]);
                 item.LangCode = Convert.ToString(r["LangCode"]);
                 item.Name = Convert.ToString(r["Name"]);
                 item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                 item.ParentID = Convert.ToInt32(r["ParentID"]);
                 item.GroupID = Convert.ToInt32(r["GroupID"]);
             }
             //else
             //{
             //    item = new Category();
             //    item.LangCode = language;
             //    item.GroupID = groupId;
             //}
         }
     }
     return item;
 }