public ActionResult ThemmoiCD(CHUDE chude, HttpPostedFileBase fileupload) { ViewBag.MaPL = new SelectList(data.PHANLOAIs.ToList().OrderBy(n => n.TenPL), "MaPL", "TenPL"); if (fileupload == null) { ViewBag.Thongbao = "Vui lòng chọn ảnh bìa"; return(View()); } else { if (ModelState.IsValid) { var fileName = Path.GetFileName(fileupload.FileName); var path = Path.Combine(Server.MapPath("~/Img/ChuDe"), fileName); if (System.IO.File.Exists(path)) { ViewBag.Thongbao = "Hình ảnh đã tồn tại"; } else { fileupload.SaveAs(path); } chude.AnhCD = fileName; data.CHUDEs.InsertOnSubmit(chude); data.SubmitChanges(); } } return(View()); }
public ActionResult XoaChuDe(int id) { CHUDE chude = data.CHUDEs.SingleOrDefault(n => n.MaCD == id); data.CHUDEs.DeleteOnSubmit(chude); data.SubmitChanges(); return(RedirectToAction("ChuDe")); }
public ActionResult DeleteConfirmed(int id) { CHUDE cHUDE = db.CHUDEs.Find(id); db.CHUDEs.Remove(cHUDE); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Xóa chủ đề trong db /// </summary> /// <param name="id">Id của chủ đề</param> public static void delete(int id) { DBConnection db = new DBConnection(); CHUDE cd = new CHUDE(); cd = db.CHUDEs.Find(id); db.CHUDEs.Remove(cd); db.SaveChanges(); }
public ActionResult themchude(CHUDE chude) { if (ModelState.IsValid) { db.CHUDEs.Add(chude); db.SaveChanges(); } return(RedirectToAction("chude")); }
public ActionResult ThemChuDe(CHUDE chude) { if (ModelState.IsValid) { data.CHUDEs.InsertOnSubmit(chude); data.SubmitChanges(); } return(RedirectToAction("ChuDe")); }
public ActionResult Xoasach(int id, CHUDE chude, NHAXUATBAN nxb) { SACH sach = data.SACHes.SingleOrDefault(n => n.Masach == id); ViewBag.Masach = sach.Masach; data.SACHes.DeleteOnSubmit(sach); data.SubmitChanges(); return(RedirectToAction("Sach")); }
public ActionResult Suachude(CHUDE chude, FormCollection f) { if (ModelState.IsValid) { db.Entry(chude).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } ViewBag.MaDC = chude.MaCD; return(RedirectToAction("QLChude")); }
public ActionResult ChinhSua(CHUDE cd) { if (ModelState.IsValid) { db.Entry(cd).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cd)); }
public ActionResult ThemMoi(CHUDE cd) { if (ModelState.IsValid) { ViewBag.ThongBao = "Thêm mới chủ đề thành công."; db.CHUDEs.Add(cd); db.SaveChanges(); } return(View()); }
public ActionResult Edit([Bind(Include = "MaCD,TenCD")] CHUDE cHUDE) { if (ModelState.IsValid) { db.Entry(cHUDE).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cHUDE)); }
public ActionResult suachude(CHUDE chudesach, FormCollection f) { if (ModelState.IsValid) { db.Entry(chudesach).State = System.Data.EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("chude")); }
public ActionResult Themmoichude(CHUDE chude, FormCollection f) { if (ModelState.IsValid) { db.Entry(chude).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); } return(RedirectToAction("QLChude")); }
public ActionResult Xoa(int machude) { CHUDE cd = db.CHUDEs.SingleOrDefault(n => n.MaCD == machude); if (cd == null) { Response.StatusCode = 404; return(null); } return(View(cd)); }
public ActionResult Create([Bind(Include = "MaCD,TenCD")] CHUDE cHUDE) { if (ModelState.IsValid) { db.CHUDEs.Add(cHUDE); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cHUDE)); }
public ActionResult Suachude(int id) { CHUDE chude = db.CHUDEs.SingleOrDefault(n => n.MaCD == id); if (chude == null) { Response.StatusCode = 404; return(null); } return(View(chude)); }
public List <CHUDE> LoadChuDe() { List <CHUDE> result = new List <CHUDE>(); DataTable data = DataProvider.Instance.ExcuteQuery("Select * from dbo.CHUDE"); foreach (DataRow row in data.Rows) { CHUDE temp = new CHUDE(row); result.Add(temp); } return(result); }
public ActionResult suachude(int macd) { //lay doi tuong theo mã CHUDE cd = db.CHUDEs.SingleOrDefault(n => n.MaChuDe == macd); if (cd == null) { Response.StatusCode = 404; return(null); } return(View(cd)); }
public ActionResult CapNhatChuDe(CHUDE cd) { if (Session["TKAD"] == null) { return(RedirectToAction("Login", "HomeAdmin")); } if (ModelState.IsValid) { UpdateModel(cd); db.SubmitChanges(); } return(RedirectToAction("QLChuDe")); }
public ActionResult XacNhanXoa(int machude) { CHUDE cd = db.CHUDEs.SingleOrDefault(n => n.MaCD == machude); if (cd == null) { Response.StatusCode = 404; return(null); } db.CHUDEs.Remove(cd); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Suachude(int id) { //Lay ra doi tuong sach theo ma CHUDE cd = db.CHUDEs.SingleOrDefault(n => n.MaCD == id); ViewBag.Machude = cd.MaCD; if (cd == null) { Response.StatusCode = 404; return(null); } return(View(cd)); }
public ActionResult SachTheoChuDe(int machude) { CHUDE cd = db.CHUDEs.SingleOrDefault(m => m.MaCD == machude); if (cd == null) { ViewBag.ThongBao = "Không tìm thấy sách loại này!"; return(View()); } List <SACH> sach = db.SACHes.Where(n => n.MaCD == machude).ToList(); return(View(sach)); }
/// <summary> /// Chỉnh sửa chủ đề /// </summary> /// <param name="id">ID của chủ đề cần chỉnh sửa</param> /// <param name="name">Tên mới của chủ đề</param> public static void edit(int id, string name, bool xoa) { CHUDE cd = new CHUDE(); DBConnection db = new DBConnection(); cd = db.CHUDEs.Find(id); cd.TEN = name; if (cd.ISDELETE != xoa) { cd.ISDELETE = xoa; } db.SaveChanges(); }
public ActionResult Suachude(CHUDE cd) { if (ModelState.IsValid) { //chen du lieu vao bang khach hang UpdateModel(cd); //luu vao co so du lieu db.SubmitChanges(); return(RedirectToAction("Chude", "Admin")); } return(View()); }
// GET: CHUDE/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CHUDE cHUDE = db.CHUDEs.Find(id); if (cHUDE == null) { return(HttpNotFound()); } return(View(cHUDE)); }
public ActionResult Xacnhanchude(int macd) { CHUDE cd = db.CHUDEs.SingleOrDefault(n => n.MaChuDe == macd); ViewBag.Masach = cd.MaChuDe; if (cd == null) { Response.StatusCode = 404; return(null); } db.CHUDEs.Remove(cd); db.SaveChanges(); return(RedirectToAction("chude")); }
public ActionResult Chacchanxoa(int id) { CHUDE chude = db.CHUDEs.SingleOrDefault(n => n.MaCD == id); ViewBag.MaCD = chude.MaCD; if (chude == null) { Response.StatusCode = 404; return(null); } db.CHUDEs.DeleteOnSubmit(chude); db.SubmitChanges(); return(RedirectToAction("chudesp")); }
public ActionResult ThemChuDe(CHUDE cd) { if (Session["TKAD"] == null) { return(RedirectToAction("Login", "HomeAdmin")); } if (ModelState.IsValid) { db.CHUDEs.InsertOnSubmit(cd); db.SubmitChanges(); } // Lưu vào cơ sở dữ liệu return(RedirectToAction("QLChuDe", "HomeAdmin")); }
public ActionResult XacnhanXoachude(int id) { CHUDE chude = db.CHUDEs.SingleOrDefault(n => n.MaCD == id); ViewBag.MaCD = chude.MaCD; if (chude == null) { Response.StatusCode = 404; return(null); } db.Entry(chude).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return(RedirectToAction("QLChude")); }
public ActionResult Themmoichude(CHUDE cd) { if (ModelState.IsValid) { //chen du lieu vao bang khach hang db.CHUDEs.InsertOnSubmit(cd); //luu vao co so du lieu db.SubmitChanges(); return(RedirectToAction("Chude", "Admin")); } return(View()); }