コード例 #1
0
        public ActionResult AddPhieuDongTienPhong()
        {
            if (Session["LoggedCNT"] == null || Session["LoggedCNT"].ToString() == "")
            {
                return(RedirectToAction("Index", "Home"));
            }
            chunhatro cnt = (chunhatro)Session["LoggedCNT"];

            ViewBag.Phong = db.phongtros.ToList().OrderBy(n => n.Sophong);
            return(View());
        }
コード例 #2
0
        public ActionResult SuaPhieuDongTienPhong(int id)
        {
            if (Session["LoggedCNT"] == null || Session["LoggedCNT"].ToString() == "")
            {
                return(RedirectToAction("Index", "Home"));
            }
            chunhatro cnt = (chunhatro)Session["LoggedCNT"];

            ViewBag.Phong = db.phongtros.ToList().OrderBy(n => n.Sophong);
            return(View(db.phieudongtienphongs.SingleOrDefault(n => n.Maphieudongtienphong == id)));
        }
コード例 #3
0
        public ActionResult AddRooms(phongtro pt, HttpPostedFileBase fileupload)
        {
            if (Session["LoggedCNT"] == null || Session["LoggedCNT"].ToString() == "")
            {
                return(RedirectToAction("Index", "Home"));
            }
            //Kiem tra duong dan file
            try {
                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("~/images/phongtro/"), 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);
                        }
                        pt.Images = fileName;
                        //Luu vao CSDL

                        DateTime  date = DateTime.Now;
                        chunhatro cnt  = (chunhatro)Session["LoggedCNT"];
                        pt.Machunhatro = cnt.Machunhatro;
                        db.phongtros.InsertOnSubmit(pt);
                        db.SubmitChanges();
                    }
                }
                TempData["message"] = "success";
            }
            catch (Exception ex) { TempData["message"] = "fail"; }
            TempData["message2"] = "add";
            return(RedirectToAction("Room"));
        }
コード例 #4
0
 public ActionResult EditRoom(phongtro pt, HttpPostedFileBase fileupload)
 {
     if (Session["LoggedCNT"] == null || Session["LoggedCNT"].ToString() == "")
     {
         return(RedirectToAction("Index", "Home"));
     }
     try {
         phongtro  ptt = db.phongtros.SingleOrDefault(n => n.Maphongtro == pt.Maphongtro);
         chunhatro cnt = (chunhatro)Session["LoggedCNT"];
         ptt.Machunhatro    = cnt.Machunhatro;
         ptt.Googlemap      = "";
         ptt.Sophong        = pt.Sophong;
         ptt.Diachi         = pt.Diachi;
         ptt.Tiendatcoc     = pt.Tiendatcoc;
         ptt.Noiquyphongtro = pt.Noiquyphongtro;
         ptt.Mota           = pt.Mota;
         if (ModelState.IsValid)
         {
             if (fileupload == null)
             {
                 ptt.Images = db.phongtros.SingleOrDefault(n => n.Maphongtro == pt.Maphongtro).Images;
             }
             else
             {
                 if (ModelState.IsValid)
                 {
                     var fileName = Path.GetFileName(fileupload.FileName);
                     var path     = Path.Combine(Server.MapPath("~/images/phongtro"), fileName);
                     if (System.IO.File.Exists(path))
                     {
                         pt.Images        = fileName;
                         ViewBag.Thongbao = "Hình ảnh đã tồn tại";
                         return(View(pt));
                     }
                     else
                     {
                         fileupload.SaveAs(path);
                         ptt.Images = fileName;
                     }
                 }
             }
             db.SubmitChanges();
             TempData["message"] = "success";
         }
     } catch (Exception ex) { TempData["message"] = "fail"; }
     TempData["message2"] = "edit";
     return(RedirectToAction("Room"));
 }
コード例 #5
0
        public ActionResult XoaChunhatro(string id)
        {
            try
            {
                chunhatro cnt = db.chunhatros.SingleOrDefault(m => m.Machunhatro == id);
                db.chunhatros.DeleteOnSubmit(cnt);
                db.SubmitChanges();
                TempData["message"] = "success";
            } catch (Exception ex)
            {
                TempData["message"] = "fail";
            }

            TempData["message2"] = "delete";
            return(RedirectToAction("Chunhatro"));
        }
コード例 #6
0
 public ActionResult Suachunhatro(chunhatro cnt, HttpPostedFileBase fileupload)
 {
     if (Session["LoggedAD"] == null || Session["LoggedAD"].ToString() == "")
     {
         return(RedirectToAction("Login", "Admin"));
     }
     try {
         chunhatro cntt = db.chunhatros.SingleOrDefault(n => n.Machunhatro == cnt.Machunhatro);
         cntt.Tenchunhatro = cnt.Tenchunhatro;
         cntt.Namsinh      = cnt.Namsinh;
         cntt.SDT          = cnt.SDT;
         cntt.Hokhau       = cnt.Hokhau;
         if (ModelState.IsValid)
         {
             ViewBag.Lop = db.lops.ToList().OrderBy(n => n.Tenlop);
             if (fileupload == null)
             {
                 cntt.Imagees = db.chunhatros.SingleOrDefault(n => n.Machunhatro == cnt.Machunhatro).Imagees;
             }
             else
             {
                 if (ModelState.IsValid)
                 {
                     var fileName = Path.GetFileName(fileupload.FileName);
                     var path     = Path.Combine(Server.MapPath("~/images/chunhatro"), fileName);
                     if (System.IO.File.Exists(path))
                     {
                         cnt.Imagees      = fileName;
                         ViewBag.Thongbao = "Hình ảnh đã tồn tại";
                         return(View(cnt));
                     }
                     else
                     {
                         fileupload.SaveAs(path);
                         cntt.Imagees = fileName;
                     }
                 }
             }
             db.SubmitChanges();
             TempData["message"] = "success";
         }
     } catch (Exception ex) { TempData["message"] = "fail"; }
     TempData["message2"] = "edit";
     return(RedirectToAction("Chunhatro"));
 }
コード例 #7
0
        public ActionResult Index(FormCollection collection)
        {
            Session["LoggedCNT"] = "";
            Session["LoggedSV"]  = "";
            Session["LoggedAD"]  = "";
            chunhatro cnt     = new chunhatro();
            sinhvien  sv      = new sinhvien();
            nguoidung admin   = new nguoidung();
            var       tendn   = collection["username"];
            var       matkhau = collection["password"];

            if (String.IsNullOrEmpty(tendn))
            {
                ViewData["Loi1"] = "Phải nhập tên đăng nhập";
            }
            else if (String.IsNullOrEmpty(matkhau))
            {
                ViewData["Loi2"] = "Phải nhập mật khẩu";
            }
            else
            {
                cnt = Db.chunhatros.SingleOrDefault(n => n.Machunhatro == tendn && n.Pass == matkhau);
                sv  = Db.sinhviens.SingleOrDefault(n => n.Masv == tendn && n.Pass == matkhau);


                if (cnt != null)
                {
                    Session["LoggedCNT"] = cnt;
                    Session["cnt"]       = cnt.Tenchunhatro;
                    return(RedirectToAction("Index", "ChuNT"));
                }
                else if (sv != null)
                {
                    Session["LoggedSV"] = sv;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Thongbao = "Tên đăng nhập hoặc mật khẩu không đúng";
                }
            }
            return(View());
        }
コード例 #8
0
 public ActionResult AddCTService(ctdv ct, HttpPostedFileBase fileupload)
 {
     if (Session["LoggedCNT"] == null || Session["LoggedCNT"].ToString() == "")
     {
         return(RedirectToAction("Index", "Home"));
     }
     try {
         chunhatro cnt = (chunhatro)Session["LoggedCNT"];
         ct.Macnt = cnt.Machunhatro;
         db.ctdvs.InsertOnSubmit(ct);
         db.SubmitChanges();
         TempData["message"] = "success";
     }
     catch (Exception ex)
     {
         TempData["message"] = "fail";
     }
     TempData["message2"] = "add";
     return(RedirectToAction("CTService"));
 }
コード例 #9
0
 public ActionResult AddPhieuDongTienPhong(phieudongtienphong dtp)
 {
     if (Session["LoggedCNT"] == null || Session["LoggedCNT"].ToString() == "")
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         chunhatro cnt = (chunhatro)Session["LoggedCNT"];
         dtp.Machunhatro = cnt.Machunhatro;
         db.phieudongtienphongs.InsertOnSubmit(dtp);
         db.SubmitChanges();
         TempData["message"] = "success";
     }
     catch (Exception ex)
     {
         TempData["message"] = "fail";
     }
     TempData["message2"] = "add";
     return(RedirectToAction("PhieuDongTienPhong"));
 }