Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 //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());
 }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
 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());
 }