// GET: Admin/Phongontroller public async Task <IActionResult> Index(int?id, string?s_name_ph, string?s_stt) { PhongModel phong = null; if (id != null) { phong = await _context.tb_Phong.FirstOrDefaultAsync(m => m.Id == id); } if (s_name_ph != null) { if (s_stt == null) { ViewBag.ListPh = (from n in _context.tb_Phong where n.TenPhong.IndexOf(s_name_ph) >= 0 select n).ToList(); } else { ViewBag.ListPh = (from n in _context.tb_Phong where n.TenPhong.IndexOf(s_name_ph) >= 0 && n.TrangThai == Convert.ToBoolean(s_stt) select n).ToList(); } } else { ViewBag.ListPh = (from n in _context.tb_Phong where n.TrangThai == true select n).ToList(); } return(View(phong)); }
public async Task <IActionResult> PutPhongModel(int id, PhongModel phongModel) { if (id != phongModel.Id) { return(BadRequest()); } _context.Entry(phongModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhongModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//tạo mới public ActionResult Create(HOADON hoaDon) { if (ModelState.IsValid) { var hdon = new HoaDonModel(); var hdon1 = new UserModel(); var hdon2 = new PhongModel(); if (hdon.Find(hoaDon.MaHD) != null) { SetAlert("Mã hóa đơn đã tồn tại", "error"); return(RedirectToAction("Create", "HoaDon")); } if (hdon1.Find(hoaDon.MaNV) == null) { SetAlert("Mã nhân viên không có trong CSDL", "error"); return(RedirectToAction("Create", "HoaDon")); } if (hdon2.Find(hoaDon.MaPhong) == null) { SetAlert("Mã phòng không có trong CSDL", "error"); return(RedirectToAction("Create", "HoaDon")); } String result = hdon.Insert(hoaDon); if (!String.IsNullOrEmpty(result)) { SetAlert("Tạo mới hóa đơn thành công", "success"); return(RedirectToAction("Index", "HoaDon")); } else { ModelState.AddModelError("", "Tạo mới hóa đơn không thành công"); } } return(View()); }
public async Task <bool> Edit(int id, [Bind("Id,TenPhong,MaRap,TrangThai")] PhongModel phongModel) { if (id != phongModel.Id) { return(false); } if (ModelState.IsValid) { try { _context.Update(phongModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhongModelExists(phongModel.Id)) { return(false); } else { throw; } } return(true); } return(false); }
public async Task <ActionResult <PhongModel> > PostPhongModel(PhongModel phongModel) { _context.tb_Phong.Add(phongModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPhongModel", new { id = phongModel.Id }, phongModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdPhong,TenPhong,MaRap")] PhongModel phongModel) { if (id != phongModel.IdPhong) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(phongModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhongModelExists(phongModel.IdPhong)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaRap"] = new SelectList(_context.rapModels, "IdRap", "DiaChiRap", phongModel.MaRap); return(View(phongModel)); }
public ActionResult Edit(HOADON hoaDon) { if (ModelState.IsValid) { var hd = new HoaDonModel(); //var hdon = new HoaDonModel(); var hdon1 = new UserModel(); var hdon2 = new PhongModel(); if (hdon1.Find(hoaDon.MaNV) == null) { SetAlert("Mã nhân viên không có trong CSDL", "error"); return(RedirectToAction("Index", "HoaDon")); } if (hdon2.Find(hoaDon.MaPhong) == null) { SetAlert("Mã phòng không có trong CSDL", "error"); return(RedirectToAction("Index", "HoaDon")); } var result = hd.Update(hoaDon); if (result) { SetAlert("Sửa hóa đơn thành công", "success"); return(RedirectToAction("Index", "HoaDon")); } else { ModelState.AddModelError("", "Sửa hóa đơn không thành công"); } } return(View()); }
public ActionResult Delete(string MaPhong) { PhongModel ph = new PhongModel(); ph.Delete(MaPhong); return(RedirectToAction("Index", "Phong")); }
public ActionResult Edit(PhongModel model) { if (!_quyenServices.Authorize((int)EnumQuyen.PHONG_SUA)) { return(RedirectToAction("ViewDenied", "QLKS")); } if (!ModelState.IsValid) { TempData["Message"] = "Có lỗi xảy ra! Vui lòng kiểm tra lại thông tin."; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(View("Edit", model)); } var item = db.PHONGs.Where(c => c.ID == model.ID).FirstOrDefault(); if (item == null) { TempData["Message"] = "Có lỗi xảy ra"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("List")); } //map from model to database object item = Mapper.Map(model, item); db.SaveChanges(); _lichSuServices.LuuLichSu((int)Session["ID"], (int)EnumLoaiHanhDong.SUA, item.GetType().ToString()); TempData["Message"] = "Cập nhật thành công"; TempData["NotiType"] = "success"; //success là class trong bootstrap return(RedirectToAction("List")); }
public async Task <IActionResult> Edit(int id, [Bind("Id,IdRapChieu,TenPhong,SoLuongHang,SoLuongCot")] PhongModel phongModel) { if (id != phongModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(phongModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhongModelExists(phongModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdRapChieu"] = new SelectList(_context.RapChieuPhim, "Id", "TenRap", phongModel.IdRapChieu); return(View(phongModel)); }
public ActionResult Edit(PHONG phong) { if (ModelState.IsValid) { var dao = new PhongModel(); var result = dao.Update(phong); try { if (result) { SetAlert("Chỉnh sửa thông tin phòng thành công ", "success"); return(RedirectToAction("Index", "Phong")); } else { if (phong.SoCho > 8) { ModelState.AddModelError("", "Mỗi phòng chỉ có 8 chỗ!"); } else { ModelState.AddModelError("", "Mã phòng không được sửa"); } } }catch (Exception e) { } } return(View()); }
// GET: Admin/VatTuPhong public ActionResult Index() { PhongModel phong = new PhongModel(); phong.MSGIANGVIEN = ((TaiKhoanDangNhapModel)Session[Contains.SESSIONKEYDANGNHAP]).MSGIANGVIEN; ViewData["DSPhong"] = phong.DanhSachPhongTheoGiangVien(); ViewData["DSNhomLinhVuc"] = new NhomLinhVucModel().DanhSach(); return(View()); }
public async Task <IActionResult> Create([Bind("IDPhong,SoPhong,TrangThai,IDRap")] PhongModel phongModel) { if (ModelState.IsValid) { _context.Add(phongModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IDRap"] = new SelectList(_context.Rap, "IDRap", "IDRap", phongModel.IDRap); return(View(phongModel)); }
public async Task <IActionResult> Create([Bind("Id,IdRapChieu,TenPhong,SoLuongHang,SoLuongCot")] PhongModel phongModel) { if (ModelState.IsValid) { _context.Add(phongModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdRapChieu"] = new SelectList(_context.RapChieuPhim, "Id", "TenRap", phongModel.IdRapChieu); return(View(phongModel)); }
public async Task <bool> Create([Bind("Id,TenPhong,MaRap,TrangThai")] PhongModel phongModel) { if (ModelState.IsValid) { _context.Add(phongModel); await _context.SaveChangesAsync(); return(true); } return(false); }
public async Task <IActionResult> Create([Bind("IdPhong,TenPhong,MaRap")] PhongModel phongModel) { if (ModelState.IsValid) { _context.Add(phongModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaRap"] = new SelectList(_context.rapModels, "IdRap", "DiaChiRap", phongModel.MaRap); return(View(phongModel)); }
// GET: Phong public ActionResult Index(string searchString) { var sv = new PhongModel(); if (searchString == "") { SetAlert("Vui lòng nhập thông tin tìm kiếm", "error"); } var model = sv.ListWhereAll(searchString); @ViewBag.SearchString = searchString; return(View(model)); }
public ActionResult Create(PHONGSV sinhVien) { if (ModelState.IsValid) { var daoPSV = new QLPSVModel(); var daoSV = new QLSVsModel(); var daoPhong = new PhongModel(); if (daoPSV.Find(sinhVien.MaPhongSV) != null) { SetAlert("Mã phòng sinh viên đã tồn tại", "error"); return(RedirectToAction("Create", "QLPSV")); } else if (daoPSV.Find(sinhVien.MaSV) != null) { SetAlert("Mã sinh viên này đã có phòng", "error"); return(RedirectToAction("Create", "QLPSV")); } else if (daoPhong.Find(sinhVien.MaPhong) == null) { SetAlert(" Phòng không có trong CSDL", "error"); return(RedirectToAction("Create", "QLPSV")); } else if (daoSV.Find(sinhVien.MaSV) == null) { SetAlert("Sinh viên không có trong CSDL", "error"); return(RedirectToAction("Create", "QLPSV")); } String result = daoPSV.Insert(sinhVien); if (!String.IsNullOrEmpty(result)) { SetAlert("Thêm sinh viên vào phòng thành công", "success"); return(RedirectToAction("Index", "QLPSV")); } else { ModelState.AddModelError("", "Thêm sinh viên vào phòng không thành công"); } } return(View()); }
public IActionResult DatVe(int?id, int?idsc) { if (id == null) { return(NotFound()); } if (idsc == null) { return(NotFound()); } var p1 = _context.SuatChieu.Find(idsc); var ListLichChieu = (from sc in _context.SuatChieu join lc in _context.LichChieu on sc.IdLichChieu equals lc.Id join p in _context.Phong on lc.IdPhong equals p.Id join r in _context.RapChieuPhim on p.IdRapChieu equals r.Id where lc.Id == p1.IdLichChieu && (from sc in lc.dsSuatChieu where lc.NgayChieu.Date.CompareTo(DateTime.Now.Date) == 1 && sc.GioChieu.TimeOfDay.CompareTo(DateTime.Now.TimeOfDay) == 1 select sc).Count() > 0 select sc).ToList(); if (ListLichChieu.Count() > 0) { ViewBag.Ten = _context.Phim.Find(p1.IdPhim).TenPhim; PhongModel phong = _context.Phong.Find(id); ViewData["Id"] = idsc; try { JObject nguoidung = JObject.Parse(HttpContext.Session.GetString("nguoidung")); } catch { return(RedirectToAction("Index", "Login")); } return(View(phong)); } return(NotFound()); }
public ActionResult Create() { if (!_nguoiDungServices.isLoggedIn()) { TempData["Message"] = "Bạn chưa đăng nhập, vui lòng đăng nhập"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("Login", "NguoiDung")); } if (!_quyenServices.Authorize((int)EnumQuyen.PHONG_THEM)) { return(RedirectToAction("ViewDenied", "QLKS")); } var phongModel = new PhongModel(); var maxId = db.PHONGs.Select(c => c.ID).DefaultIfEmpty(0).Max(); var newId = (maxId + 1).ToString().PadLeft(4, '0'); phongModel.SoPhong = "P" + " " + newId; phongModel.DanhSachLoaiPhong = _loaiPhongServices.PrepareSelectListLoaiPhong(0); phongModel.DanhSachTinhTrang = _loaiTinhTrangServices.PrepareLoaiTinhTrangPhong(0); return(View(phongModel)); }
// GET: Admin/Phong public async Task <IActionResult> Index(int?id, String?s_name, String?s_stt) { PhongModel phong = null; if (id != null) { phong = await _context.Phong.FirstOrDefaultAsync(m => m.Id == id); } if (s_name != null) { if (s_stt == null) { ViewBag.ListPhong = (from p in _context.Phong where p.TenPhong.IndexOf(s_name) >= 0 select p).ToList(); } else { ViewBag.ListPhong = (from p in _context.Phong where p.TenPhong.IndexOf(s_name) >= 0 && p.Daxoa == Convert.ToBoolean(s_stt) select p).ToList(); } } else { if (s_stt == null) { ViewBag.ListPhong = (from p in _context.Phong select p).ToList(); } else { ViewBag.ListPhong = (from p in _context.Phong where p.Daxoa == (s_stt.Equals("true") ? true : false) select p).ToList(); } } return(View(phong)); }
public ActionResult Create(PHONG phong) { if (ModelState.IsValid) { var dao = new PhongModel(); if (dao.Find(phong.MaPhong) != null) { SetAlert("Mã phòng này đã có trong hệ thống", "error"); return(RedirectToAction("Create", "Phong")); } String result = dao.Insert(phong); if (!String.IsNullOrEmpty(result)) { SetAlert("Thêm phòng thành công", "success"); return(RedirectToAction("Index", "Phong")); } else { ModelState.AddModelError("", "Thêm phòng không thành công"); } } return(View()); }
public ActionResult Create(PhongModel model) { if (!_quyenServices.Authorize((int)EnumQuyen.PHONG_THEM)) { return(RedirectToAction("ViewDenied", "QLKS")); } if (!ModelState.IsValid) { TempData["Message"] = "Có lỗi xảy ra! Vui lòng kiểm tra lại thông tin."; TempData["NotiType"] = "success"; //success là class trong bootstrap return(View("Create", model)); } var item = AutoMapper.Mapper.Map <PHONG>(model); int a = 0; db.Database.ExecuteSqlCommand("exec SP_CreateOrUpdate_PHONG @Type, @ID, @SoPhong, @SoTang, @LoaiPhong, @LoaiTinhTrang, @UpdateID", new SqlParameter("@Type", int.Parse("0")), new SqlParameter("@ID", a), new SqlParameter("@SoPhong", item.SoPhong), new SqlParameter("@SoTang", item.SoTang), new SqlParameter("@LoaiPhong", item.LOAIPHONG_ID), new SqlParameter("@UpdateID", int.Parse("0")), new SqlParameter("@LoaiTinhTrang", item.LOAITINHTRANG_ID)); //db.PHONGs.Add(item); db.SaveChanges(); _lichSuServices.LuuLichSu((int)Session["ID"], (int)EnumLoaiHanhDong.THEM, item.GetType().ToString()); TempData["Message"] = "Thêm mới thành công"; TempData["NotiType"] = "success"; return(RedirectToAction("List")); }
public ActionResult Edit(string maPhong) { var phong = new PhongModel().getByMaPhong(maPhong); return(View(phong)); }