public ActionResult XoaPhieuThuePhongConfirmed(string id) { PHIEU_THUEPHONG phieu = db.PHIEU_THUEPHONG.Find(id); db.PHIEU_THUEPHONG.Remove(phieu); db.SaveChanges(); return(RedirectToAction("DanhSachPhieuThue")); }
public ActionResult SuaPhieuThuePhong([Bind(Include = "SO_PHIEU,MAKHACH,MA_NHANVIEN,NGAYLAP_PHIEU,NGAYDEN,NGAYDI,DATRAPHONG")] PHIEU_THUEPHONG phieu) { if (ModelState.IsValid) { db.Entry(phieu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("DanhSachPhieuThue")); } ViewBag.tag = "thuephong"; ViewBag.username = ((LoginSessionModel)Session["session"]).name; return(View(phieu)); }
// GET: /Admin/LeTan/SuaPhieuThuePhong/:id // View cập nhật phiếu thuê phòng public ActionResult SuaPhieuThuePhong(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PHIEU_THUEPHONG phieu = db.PHIEU_THUEPHONG.Find(id); if (phieu == null) { return(HttpNotFound()); } ViewBag.tag = "thuephong"; ViewBag.username = ((LoginSessionModel)Session["session"]).name; return(View(phieu)); }
public ActionResult ThemPhieuThuePhong(PhieuLapModel phieuLap) { if (ModelState.IsValid) { string maKhach = Math.Round(((new Random()).NextDouble() * 1e9)).ToString().PadLeft(9, '0'); string soPhieu = Math.Round(((new Random()).NextDouble() * 1e9)).ToString().PadLeft(9, '0'); List <String> phongList = phieuLap.phong.Split(new[] { ',' }).ToList(); List <String> soNguoiList = phieuLap.songuoi.Split(new[] { ',' }).ToList(); List <String> dichVuList = phieuLap.dichvu != null?phieuLap.dichvu.Split(new[] { ',' }).ToList() : new List <string>(); List <String> soLuongList = phieuLap.soluong != null?phieuLap.soluong.Split(new[] { ',' }).ToList() : new List <string>(); PHIEU_THUEPHONG phieu = new PHIEU_THUEPHONG() { SO_PHIEU = soPhieu, KHACH = new KHACH() { MA_KHACH = maKhach, CMND = phieuLap.cmnd, DIENTHOAI = phieuLap.dienthoai, HOTEN_KHACH = phieuLap.tenkhach, QUOCTICH = phieuLap.quoctich, GIOITINH = phieuLap.gioitinh == "1" ? true : false, NGAYSINH = DateTime.Parse(phieuLap.ngaysinh) }, DATRAPHONG = false, NGAYDEN = DateTime.Now, NGAYLAP_PHIEU = DateTime.Now, NGAYDI = DateTime.Parse(phieuLap.ngaydi), MA_NHANVIEN = "NV001", CHITIET_THUEPHONG = phongList.Select((phong, index) => new CHITIET_THUEPHONG() { MAPHONG = phong, SONGUOI = Byte.Parse(soNguoiList[index]), GIAPHONG = db.PHONGs.Find(phong).GIAPHONG, }).ToList(), CHITIET_THUEDICHVU = dichVuList.Select((dv, index) => new CHITIET_THUEDICHVU() { MA_DICHVU = dv, SOLUONG = Byte.Parse(soLuongList[index]), GIA_DICHVU = db.DICHVUs.Find(dv).GIA_DICHVU, }).ToList(), }; db.PHIEU_THUEPHONG.Add(phieu); phongList.ForEach(phong => db.PHONGs.Find(phong).MA_TRANGTHAI = "OC"); db.SaveChanges(); return(RedirectToAction("DanhSachPhieuThue")); } ViewBag.phong = db.PHONGs.Where(phong => phong.MA_TRANGTHAI == "VC").ToList(); ViewBag.dichVus = new SelectList(db.DICHVUs, "MA_DICHVU", "TEN_DICHVU"); ViewBag.tag = "thuephong"; ViewBag.username = ((LoginSessionModel)Session["session"]).name; return(View()); }