예제 #1
0
 public ActionResult Result(String MAKH, String NGAYVAO, String NGAYRA, string MAPHONG)
 {
     if (MAKH == null || NGAYVAO == null || NGAYRA == null || MAPHONG == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         PHIEUDATPHONG tgd = new PHIEUDATPHONG();
         List <int>    ds  = JsonConvert.DeserializeObject <List <int> >(MAPHONG);
         tgd.MAKH           = int.Parse(MAKH);
         tgd.TINHTRANGPHIEU = 1;
         tgd.NGAYDAT        = DateTime.Now;
         tgd.NGAYVAO        = (DateTime.ParseExact(NGAYVAO, "dd/MM/yyyy", CultureInfo.InvariantCulture)).AddHours(12);
         tgd.NGAYRA         = (DateTime.ParseExact(NGAYRA, "dd/MM/yyyy", CultureInfo.InvariantCulture)).AddHours(12);
         try
         {
             for (int i = 0; i < ds.Count; i++)
             {
                 tgd.MAPHONG = ds[i];
                 db.PHIEUDATPHONGs.Add(tgd);
                 db.SaveChanges();
                 ViewBag.Result = "success";
             }
             ViewBag.ngay_vao = tgd.NGAYVAO;
             setNull();
         }
         catch
         {
             ViewBag.Result = "error";
         }
     }
     return(View());
 }
예제 #2
0
        // GET: PhieuDatPhong/Delete/5
        public ActionResult XoaPhieuDatPhong(int?id)
        {
            KHACHHANG kh = new KHACHHANG();

            if (Session["KH"] != null)
            {
                kh = (KHACHHANG)Session["KH"];
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PHIEUDATPHONG tblPhieuDatPhong = db.PHIEUDATPHONGs.Find(id);

            if (tblPhieuDatPhong == null)
            {
                return(HttpNotFound());
            }
            if (tblPhieuDatPhong.MAKH != kh.MAKH)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View(tblPhieuDatPhong));
        }
예제 #3
0
        public ActionResult SuaPhieuDatPhong(int?id)
        {
            KHACHHANG kh = new KHACHHANG();

            if (Session["KH"] != null)
            {
                kh = (KHACHHANG)Session["KH"];
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PHIEUDATPHONG tblPhieuDatPhong = db.PHIEUDATPHONGs.Find(id);

            if (tblPhieuDatPhong == null)
            {
                return(HttpNotFound());
            }
            if (tblPhieuDatPhong.MAKH != kh.MAKH)
            {
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.ma_kh    = new SelectList(db.KHACHHANGs, "EMAIL", "MATKHAU", tblPhieuDatPhong.MAKH);
            ViewBag.ma_phong = new SelectList(db.PHONGs, "MAPHONG", "SOPHONG", tblPhieuDatPhong.MAPHONG);
            // ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
            return(View(tblPhieuDatPhong));
        }
예제 #4
0
 public ActionResult ResultDoiPhong(String MAPHIEUDAT, String ma_phong_cu, String ma_phong_moi)
 {
     if (MAPHIEUDAT == null || ma_phong_cu == null || ma_phong_moi == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     try
     {
         PHIEUDATPHONG pdp = db.PHIEUDATPHONGs.Find(Int32.Parse(MAPHIEUDAT));
         PHONG         p   = db.PHONGs.Find(pdp.PHONG.MAPHONG); // lấy thông tin phòng cũ
         p.TINHTRANGPHONG  = 1;                                 // set phòng cũ về đang dọn
         db.Entry(p).State = EntityState.Modified;
         pdp.MAPHONG       = Int32.Parse(ma_phong_moi);         // đổi phòng cũ sang mới
         p = db.PHONGs.Find(Int32.Parse(ma_phong_moi));         // lấy thông tin phòng mới
         p.TINHTRANGPHONG    = 2;                               // set phòng mới về đang sd
         db.Entry(p).State   = EntityState.Modified;
         db.Entry(pdp).State = EntityState.Modified;
         db.SaveChanges();
         @ViewBag.NGAYRA = pdp.NGAYRA;
         ViewBag.result  = "success";
     }
     catch (Exception e)
     {
         ViewBag.result = "error: " + e;
     }
     return(View());
 }
        public ActionResult Create(String radSelect, [Bind(Include = "ma_pdp,ma_kh,ngay_dat,ngay_vao,ngay_ra,ma_phong,ma_tinh_trang")] PHIEUDATPHONG tblPhieuDatPhong, [Bind(Include = "hoten,socmt,tuoi,sodt")] KhachHang kh)
        {
            System.Diagnostics.Debug.WriteLine("SS :" + radSelect);
            if (radSelect.Equals("rad2"))
            {
                tblPhieuDatPhong.MAKH = null;
                List <KhachHang> likh = new List <KhachHang>();
                likh.Add(kh);
                String ttkh = JsonConvert.SerializeObject(likh);
                tblPhieuDatPhong.THONGTINKHACHTHUE = ttkh;
            }

            tblPhieuDatPhong.TINHTRANGPHIEU = 1;
            tblPhieuDatPhong.NGAYVAO        = DateTime.Now;
            tblPhieuDatPhong.NGAYDAT        = DateTime.Now;
            db.PHIEUDATPHONGs.Add(tblPhieuDatPhong);
            db.SaveChanges();
            int ma = tblPhieuDatPhong.MAPHIEUDAT;

            return(RedirectToAction("Add", "HoaDon", new { id = ma }));

            // ViewBag.MAKH = new SelectList(db.KHACHHANGs, "MAKH", "MAKH", PHIEUDATPHONG.MAKH);
            // ViewBag.MAPHONG = new SelectList(db.PHONGs, "MAPHONG", "SOPHONG", PHIEUDATPHONG.MAPHONG);
            //ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
            return(View(tblPhieuDatPhong));
        }
예제 #6
0
        public ActionResult GiaHanPhong(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HOADON tblHoaDon = db.HOADONs.Find(id);

            if (tblHoaDon == null)
            {
                return(HttpNotFound());
            }
            PHIEUDATPHONG pdp = db.PHIEUDATPHONGs.Find(tblHoaDon.MAPHIEUDAT);
            String        dt  = null;

            try
            {
                DateTime d = (DateTime)db.PHIEUDATPHONGs.Where(t => t.TINHTRANGPHIEU == 1 && t.MAPHONG == pdp.PHONG.MAPHONG).Select(t => t.NGAYVAO).OrderBy(t => t.Value).First();
                dt = d.ToString();
            }
            catch
            {
            }
            ViewBag.dateMax = dt;
            return(View(pdp));
        }
예제 #7
0
        public ActionResult ConfirmXoaPhieuDatPhong(int id)
        {
            PHIEUDATPHONG tblPhieuDatPhong = db.PHIEUDATPHONGs.Find(id);

            tblPhieuDatPhong.TINHTRANGPHIEU  = 3;
            db.Entry(tblPhieuDatPhong).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("BookRoom", "Home"));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         PHIEUDATPHONG tblPhieuDatPhong = db.PHIEUDATPHONGs.Find(id);
         db.PHIEUDATPHONGs.Remove(tblPhieuDatPhong);
         db.SaveChanges();
     }
     catch
     {
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit([Bind(Include = "ma_pdp,ma_kh,ngay_dat,ngay_vao,ngay_ra,ma_phong,ma_tinh_trang")] PHIEUDATPHONG tblPhieuDatPhong)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblPhieuDatPhong).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ma_kh    = new SelectList(db.KHACHHANGs, "MAKH", "MATKHAU", tblPhieuDatPhong.MAKH);
     ViewBag.ma_phong = new SelectList(db.PHONGs, "MAPHONG", "SOPHONG", tblPhieuDatPhong.MAPHONG);
     //ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
     return(View(tblPhieuDatPhong));
 }
예제 #10
0
 public ActionResult SuaPhieuDatPhong([Bind(Include = "ma_pdp,ma_kh,ngay_dat,ngay_vao,ngay_ra,ma_phong,ma_tinh_trang")] PHIEUDATPHONG tblPhieuDatPhong)
 {
     if (ModelState.IsValid)
     {
         tblPhieuDatPhong.TINHTRANGPHIEU  = 1;
         db.Entry(tblPhieuDatPhong).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("BookRoom", "Home"));
     }
     ViewBag.ma_kh    = new SelectList(db.KHACHHANGs, "ma_kh", "mat_khau", tblPhieuDatPhong.MAKH);
     ViewBag.ma_phong = new SelectList(db.PHONGs, "ma_phong", "so_phong", tblPhieuDatPhong.MAPHONG);
     //ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
     return(RedirectToAction("BookRoom", "Home"));
 }
        // GET: PhieuDatPhong/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PHIEUDATPHONG tblPhieuDatPhong = db.PHIEUDATPHONGs.Find(id);

            if (tblPhieuDatPhong == null)
            {
                return(HttpNotFound());
            }
            return(View(tblPhieuDatPhong));
        }
        // GET: PhieuDatPhong/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PHIEUDATPHONG tblPhieuDatPhong = db.PHIEUDATPHONGs.Find(id);

            if (tblPhieuDatPhong == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ma_kh    = new SelectList(db.KHACHHANGs, "MAKH", "MATKHAU", tblPhieuDatPhong.MAKH);
            ViewBag.ma_phong = new SelectList(db.PHONGs, "MAPHONG", "SOPHONG", tblPhieuDatPhong.MAPHONG);
            //ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
            return(View(tblPhieuDatPhong));
        }
예제 #13
0
        public ActionResult DoiPhong(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HOADON tblHoaDon = db.HOADONs.Find(id);

            if (tblHoaDon == null)
            {
                return(HttpNotFound());
            }
            PHIEUDATPHONG pdp = db.PHIEUDATPHONGs.Find(tblHoaDon.MAPHIEUDAT);

            var li = db.PHONGs.Where(t => t.TINHTRANGPHONG == 1 && !(db.PHIEUDATPHONGs.Where(m => (m.TINHTRANGPHIEU == 1 || m.TINHTRANGPHIEU == 2) && m.NGAYRA > DateTime.Now && m.NGAYVAO < pdp.NGAYRA)).Select(m => m.MAPHONG).ToList().Contains(t.MAPHONG));

            ViewBag.ma_phong_moi = new SelectList(li, "MAPHONG", "SOPHONG");
            return(View(pdp));
        }
예제 #14
0
        public ActionResult ResultGiaHan(String MAPHIEUDAT, String NGAYRA)
        {
            if (MAPHIEUDAT == null || NGAYRA == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            try
            {
                PHIEUDATPHONG pdp    = db.PHIEUDATPHONGs.Find(Int32.Parse(MAPHIEUDAT));
                DateTime      ngayra = DateTime.Parse(NGAYRA);
                pdp.NGAYRA = ngayra;

                ViewBag.result = "success";
                ViewBag.NGAYRA = NGAYRA;
            }
            catch (Exception e)
            {
                ViewBag.result = "error: " + e;
            }
            return(View());
        }
예제 #15
0
        /// <summary>
        /// ///////////////////

        /// <returns></returns>
        ///

        public ActionResult XacNhanThanhToan(String MAHD, String TIENPHONG, String TIENDICHVU, String PHUTHU, String TONGTIEN)
        {
            if (MAHD == null || TIENPHONG == null || TIENDICHVU == null || PHUTHU == null || TONGTIEN == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            try
            {
                HOADON   hd = db.HOADONs.Find(Int32.Parse(MAHD));
                NHANVIEN nv = (NHANVIEN)Session["NV"];
                if (nv != null)
                {
                    hd.MANV = nv.MANV;
                }
                hd.TIENPHONG       = int.Parse(TIENPHONG);
                hd.TIENDICHVU      = int.Parse(TIENDICHVU);
                hd.PHUTHU          = int.Parse(PHUTHU);
                hd.TONGTIEN        = int.Parse(TONGTIEN);
                hd.TINHTRANGHD     = 2;
                hd.NGAYTRAPHONG    = DateTime.Now;
                db.Entry(hd).State = EntityState.Modified;

                PHONG p = db.PHONGs.Find(hd.PHIEUDATPHONG.MAPHONG);
                p.TINHTRANGPHONG = 1;
                PHIEUDATPHONG pd = db.PHIEUDATPHONGs.Find(hd.PHIEUDATPHONG.MAPHIEUDAT);
                pd.TINHTRANGPHIEU  = 4;
                db.Entry(p).State  = EntityState.Modified;
                db.Entry(pd).State = EntityState.Modified;
                db.SaveChanges();

                ViewBag.result = "success";
            }
            catch
            {
                ViewBag.result = "error";
            }
            ViewBag.MAHD = MAHD;
            return(View());
        }
예제 #16
0
        public ActionResult Result(String MAPHIEUDAT /*, String hoten1, String hoten2, String hoten3, String hoten4, String tuoi1, String tuoi2, String tuoi3, String tuoi4*/)
        {
            if (MAPHIEUDAT == null)
            {
                return(RedirectToAction("Index", "Index"));
            }
            else
            {
                //List<KhachHang> likh;
                PHIEUDATPHONG pt = db.PHIEUDATPHONGs.Find(Int32.Parse(MAPHIEUDAT));
                //if (pt.THONGTINKHACHTHUE == null)
                //{
                //    likh = new List<KhachHang>();
                //    likh.Add(new KhachHang("", ""));
                //}
                //else
                //{
                //    likh = JsonConvert.DeserializeObject<List<KhachHang>>(pt.THONGTINKHACHTHUE);
                //}
                //if (!hoten1.Equals(""))
                //    likh.Add(new KhachHang(hoten1, tuoi1));
                //if (!hoten2.Equals(""))
                //    likh.Add(new KhachHang(hoten2, tuoi2));
                //if (!hoten3.Equals(""))
                //    likh.Add(new KhachHang(hoten3, tuoi3));
                //if (!hoten4.Equals(""))
                //    likh.Add(new KhachHang(hoten4, tuoi4));
                //pt.THONGTINKHACHTHUE = JsonConvert.SerializeObject(likh);
                //db.Entry(pt).State = EntityState.Modified;
                //db.SaveChanges();

                HOADON hd = new HOADON();
                hd.MAPHIEUDAT  = Int32.Parse(MAPHIEUDAT);
                hd.TINHTRANGHD = 1;
                try
                {
                    db.HOADONs.Add(hd);
                    PHIEUDATPHONG tgd = db.PHIEUDATPHONGs.Find(Int32.Parse(MAPHIEUDAT));
                    if (tgd == null)
                    {
                        return(HttpNotFound());
                    }
                    PHONG p = db.PHONGs.Find(tgd.MAPHONG);
                    if (p == null)
                    {
                        return(HttpNotFound());
                    }
                    tgd.TINHTRANGPHIEU  = 2;
                    db.Entry(tgd).State = EntityState.Modified;
                    p.TINHTRANGPHONG    = 2;
                    db.Entry(p).State   = EntityState.Modified;
                    ViewBag.NGAYRA      = tgd.NGAYRA;
                    db.SaveChanges();
                    ViewBag.Result = "success";
                }
                catch
                {
                    ViewBag.Result = "error";
                }
            }
            return(View());
        }