//update Sub category

        public int UpdateSub(Master_SubCategory a)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                string     q   = "update Master_SubCategory set SubCategoryName=@SubCategoryName,SubCategoryDes=@SubCategoryDes where SubCategoryID=@SubCategoryID";
                SqlCommand com = new SqlCommand(q, con);
                com.Parameters.AddWithValue("@SubCategoryID", a.SubCategoryID);
                com.Parameters.AddWithValue("@SubCategoryName", a.SubCategoryName);
                com.Parameters.AddWithValue("@SubCategoryDes", a.SubCategoryDes);

                i = com.ExecuteNonQuery();
            }
            return(i);
        }
        //add sub category

        public int AddSubS(Master_SubCategory s)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                string q = "insert into Master_SubCategory(SubCategoryName,SubCategoryDes,MainCategoryID) values(@SubCategoryName,@SubCategoryDes,@MainCategoryID)";

                SqlCommand com = new SqlCommand(q, con);
                //com.Parameters.AddWithValue("@SubCategoryID", s.SubCategoryID);
                com.Parameters.AddWithValue("@SubCategoryName", s.SubCategoryName);
                com.Parameters.AddWithValue("@SubCategoryDes", s.SubCategoryDes);
                com.Parameters.AddWithValue("@MainCategoryID", s.MainCategoryID);

                i = com.ExecuteNonQuery();
            }
            return(i);
        }
示例#3
0
 public JsonResult update(Master_SubCategory sc)
 {
     return(Json(db.UpdateSub(sc), JsonRequestBehavior.AllowGet));
 }
示例#4
0
 public JsonResult AddSub(Master_SubCategory s)
 {
     return(Json(db.AddSubS(s), JsonRequestBehavior.AllowGet));
 }