Esempio n. 1
0
 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());
 }
Esempio n. 2
0
        public ActionResult XoaChuDe(int id)
        {
            CHUDE chude = data.CHUDEs.SingleOrDefault(n => n.MaCD == id);

            data.CHUDEs.DeleteOnSubmit(chude);
            data.SubmitChanges();
            return(RedirectToAction("ChuDe"));
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            CHUDE cHUDE = db.CHUDEs.Find(id);

            db.CHUDEs.Remove(cHUDE);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        /// <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();
        }
Esempio n. 5
0
 public ActionResult themchude(CHUDE chude)
 {
     if (ModelState.IsValid)
     {
         db.CHUDEs.Add(chude);
         db.SaveChanges();
     }
     return(RedirectToAction("chude"));
 }
Esempio n. 6
0
 public ActionResult ThemChuDe(CHUDE chude)
 {
     if (ModelState.IsValid)
     {
         data.CHUDEs.InsertOnSubmit(chude);
         data.SubmitChanges();
     }
     return(RedirectToAction("ChuDe"));
 }
Esempio n. 7
0
        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"));
        }
Esempio n. 8
0
 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"));
 }
Esempio n. 9
0
 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));
 }
Esempio n. 10
0
 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());
 }
Esempio n. 11
0
 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));
 }
Esempio n. 12
0
        public ActionResult suachude(CHUDE chudesach, FormCollection f)
        {
            if (ModelState.IsValid)
            {
                db.Entry(chudesach).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("chude"));
        }
Esempio n. 13
0
        public ActionResult Themmoichude(CHUDE chude, FormCollection f)
        {
            if (ModelState.IsValid)
            {
                db.Entry(chude).State = System.Data.Entity.EntityState.Added;
                db.SaveChanges();
            }

            return(RedirectToAction("QLChude"));
        }
Esempio n. 14
0
        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));
        }
Esempio n. 15
0
        public ActionResult Create([Bind(Include = "MaCD,TenCD")] CHUDE cHUDE)
        {
            if (ModelState.IsValid)
            {
                db.CHUDEs.Add(cHUDE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cHUDE));
        }
Esempio n. 16
0
        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));
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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"));
 }
Esempio n. 20
0
        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"));
        }
Esempio n. 21
0
        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));
        }
Esempio n. 22
0
        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));
        }
Esempio n. 23
0
        /// <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();
        }
Esempio n. 24
0
        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());
        }
Esempio n. 25
0
        // 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));
        }
Esempio n. 26
0
        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"));
        }
Esempio n. 27
0
        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"));
 }
Esempio n. 29
0
        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"));
        }
Esempio n. 30
0
        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());
        }