Exemple #1
0
        public ActionResult Xoadungcu(int id)
        {
            //Lay ra doi tuong sach can xoa theo ma
            DUNGCU dc = db.DUNGCUs.SingleOrDefault(n => n.Madungcu == id);

            ViewBag.Madungcu = dc.Madungcu;
            if (dc == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(dc));
        }
Exemple #2
0
        public ActionResult Xacnhanxoa(int id)
        {
            //Lay ra doi tuong sach can xoa theo ma
            DUNGCU dc = db.DUNGCUs.SingleOrDefault(n => n.Madungcu == id);

            ViewBag.Madungcu = dc.Madungcu;
            if (dc == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            db.DUNGCUs.DeleteOnSubmit(dc);
            db.SubmitChanges();
            return(RedirectToAction("DungCu"));
        }
Exemple #3
0
        public ActionResult Suadungcu(int id)
        {
            //Lay ra doi tuong sach theo ma
            DUNGCU dc = db.DUNGCUs.SingleOrDefault(n => n.Madungcu == id);

            ViewBag.Madungcu = dc.Madungcu;
            if (dc == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            //Dua du lieu vao dropdownList
            //Lay ds tu tabke chu de, sắp xep tang dan trheo ten chu de, chon lay gia tri Ma CD, hien thi thi Tenchude
            ViewBag.MaCD  = new SelectList(db.CHUDEs.ToList().OrderBy(n => n.TenCD), "MaCD", "TenCD", dc.MaCD);
            ViewBag.MaHSX = new SelectList(db.HANGSANXUATs.ToList().OrderBy(n => n.TenHSX), "MaHSX", "TenHSX", dc.MaHSX);
            return(View(dc));
        }
Exemple #4
0
 public ActionResult ThemmoiDungCu(DUNGCU dc, HttpPostedFileBase fileUpload)
 {
     //Dua du lieu vao dropdownload
     ViewBag.MaCD  = new SelectList(db.CHUDEs.ToList().OrderBy(n => n.TenCD), "MaCD", "TenCD");
     ViewBag.MaHSX = new SelectList(db.HANGSANXUATs.ToList().OrderBy(n => n.TenHSX), "MaHSX", "TenHSX");
     //Kiem tra duong dan file
     if (fileUpload == null)
     {
         ViewBag.Thongbao = "Vui lòng chọn ảnh bìa";
         return(View());
     }
     //Them vao CSDL
     else
     {
         if (ModelState.IsValid)
         {
             //Luu ten fie, luu y bo sung thu vien using System.IO;
             var fileName = Path.GetFileName(fileUpload.FileName);
             //Luu duong dan cua file
             var path = Path.Combine(Server.MapPath("~/ImageSRC"), fileName);
             //Kiem tra hình anh ton tai chua?
             if (System.IO.File.Exists(path))
             {
                 ViewBag.Thongbao = "Hình ảnh đã tồn tại";
             }
             else
             {
                 //Luu hinh anh vao duong dan
                 fileUpload.SaveAs(path);
             }
             dc.Anhbia = fileName;
             //Luu vao CSDL
             db.DUNGCUs.InsertOnSubmit(dc);
             db.SubmitChanges();
         }
         return(RedirectToAction("DungCu"));
     }
 }