public ActionResult UpdateCate(OChuDe model) { if (ModelState.IsValid) { var pro = chuDeService.Get(new OChuDe { MaChuDe = model.MaChuDe }); if (pro != null) { try { chuDeService.Update(model); return(RedirectToAction("SearchCate", "QuanLySanPham")); } catch (Exception e) { } } } var categories = chuDeService.GetByParentId(); var listCate = new SelectList(categories, "MaChuDeCha", "Ten"); ViewBag.ListCate = listCate; ViewBag.IsEdit = true; return(View(model)); }
public void Delete(OChuDe chuDe) { conn.connect(); var comm = new SqlCommand("ChuDe_Delete", conn.db); comm.CommandType = System.Data.CommandType.StoredProcedure; comm.Parameters.Add("@ma", SqlDbType.Int).Value = chuDe.MaChuDe; comm.ExecuteNonQuery(); conn.Close(); }
public ActionResult CreateCate() { OChuDe data = new OChuDe(); data.TrangThai = false; List <OChuDe> listCate = chuDeService.GetByParentId(); ViewBag.ListTacGia = new SelectList(tacGiaService.GetAll(), "MaTacGia", "Ten"); ViewBag.ListCate = new SelectList(listCate, "MaChuDe", "Ten"); return(View("UpdateCate", data)); }
public void Update(OChuDe chuDe) { conn.connect(); var comm = new SqlCommand("ChuDe_Edit", conn.db); comm.CommandType = System.Data.CommandType.StoredProcedure; comm.Parameters.Add("@ma", SqlDbType.Int).Value = chuDe.MaChuDe; comm.Parameters.Add("@name", SqlDbType.NVarChar).Value = chuDe.Ten; comm.Parameters.Add(new SqlParameter("@ghichu", chuDe.GhiChu ?? (object)DBNull.Value)); comm.Parameters.Add("@IsActive", SqlDbType.Bit).Value = chuDe.TrangThai; comm.Parameters.Add("@ParentId", SqlDbType.Int).Value = chuDe.MaChuDeCha; comm.Parameters.Add("@TenVanTat", SqlDbType.NVarChar).Value = Helper.convertToUnSign3(chuDe.Ten); comm.ExecuteNonQuery(); conn.Close(); }
public OChuDe GetByShortName(string shortname) { OChuDe chuDe = new OChuDe(); conn.connect(); var comm = new SqlCommand("ChuDe_GetByShortName", conn.db); comm.CommandType = System.Data.CommandType.StoredProcedure; comm.Parameters.Add("@TenVanTat", SqlDbType.NVarChar).Value = shortname; DataTable dt = new DataTable(); dt.Load(comm.ExecuteReader()); chuDe = Help.DAL.ConvertDataTable <OChuDe>(dt).FirstOrDefault(); conn.Close(); return(chuDe); }
public List <OChuDe> GetAllByParentId(OChuDe oChuDe) { List <OChuDe> list = new List <OChuDe>(); conn.connect(); var comm = new SqlCommand("ChuDe_GetAllParent", conn.db); comm.CommandType = System.Data.CommandType.StoredProcedure; comm.Parameters.Add("@ParentId", SqlDbType.Int).Value = oChuDe.MaChuDeCha; DataTable dt = new DataTable(); dt.Load(comm.ExecuteReader()); list = Help.DAL.ConvertDataTable <OChuDe>(dt); conn.Close(); return(list); }
public OChuDe Get(OChuDe chuDe) { conn.connect(); var comm = new SqlCommand("ChuDe_Get", conn.db); comm.CommandType = System.Data.CommandType.StoredProcedure; comm.Parameters.Add("@MaChuDe", SqlDbType.Int).Value = chuDe.MaChuDe; OChuDe item = new OChuDe(); DataTable dt = new DataTable(); dt.Load(comm.ExecuteReader()); item = Help.DAL.ConvertDataTable <OChuDe>(dt).FirstOrDefault(); conn.Close(); return(item); }
public ActionResult CreateCate(OChuDe model) { try { chuDeService.Add(model); var idSach = sanphamService.GetLastId(); return(RedirectToAction("SearchCate", "QuanLySanPham")); } catch (Exception e) { } List <OChuDe> listCate = chuDeService.GetByParentId(); ViewBag.ListCate = new SelectList(listCate, "MaChuDeCha", "Ten"); ViewBag.IsEdit = true; return(View("UpdateCate", model)); }