예제 #1
0
        public ActionResult BookRoom()
        {
            if (Session["KH"] == null)
            {
                return(RedirectToAction("Login", "KhachHang"));
            }
            tblKhachHang kh = (tblKhachHang)Session["KH"];

            ViewBag.ma_kh    = kh.ma_kh;
            ViewBag.ten_kh   = kh.ho_ten;
            ViewBag.ngay_dat = DateTime.Now;
            ViewBag.ngay_vao = (String)Session["ngay_vao"];
            ViewBag.ngay_ra  = (String)Session["ngay_ra"];

            if (Session["ma_phong"] != null)
            {
                ViewBag.ma_phong = (String)Session["ma_phong"];
                int      map = Int32.Parse((String)Session["ma_phong"]);
                tblPhong p   = (tblPhong)db.tblPhongs.Find(map);
                ViewBag.so_phong = p.so_phong;
            }
            var liP = db.tblPhieuDatPhongs.Where(u => u.ma_kh == kh.ma_kh && u.ma_tinh_trang == 1).ToList();

            return(View(liP));
        }
예제 #2
0
 public ActionResult ResultDoiPhong(String ma_pdp, String ma_phong_cu, String ma_phong_moi)
 {
     if (ma_pdp == null || ma_phong_cu == null || ma_phong_moi == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     try
     {
         tblPhieuDatPhong pdp = db.tblPhieuDatPhongs.Find(Int32.Parse(ma_pdp));
         tblPhong         p   = db.tblPhongs.Find(pdp.tblPhong.ma_phong); // lấy thông tin phòng cũ
         p.ma_tinh_trang   = 3;                                           // set phòng cũ về đang dọn
         db.Entry(p).State = EntityState.Modified;
         pdp.ma_phong      = Int32.Parse(ma_phong_moi);                   // đổi phòng cũ sang mới
         p = db.tblPhongs.Find(Int32.Parse(ma_phong_moi));                // lấy thông tin phòng mới
         p.ma_tinh_trang     = 2;                                         // set phòng mới về đang sd
         db.Entry(p).State   = EntityState.Modified;
         db.Entry(pdp).State = EntityState.Modified;
         db.SaveChanges();
         ViewBag.result = "success";
     }
     catch (Exception e)
     {
         ViewBag.result = "error: " + e;
     }
     return(View());
 }
예제 #3
0
        public JsonResult SaveDataRoom(LevelRoomViewModel model)
        {
            bool   status  = false;
            string message = string.Empty;

            tblLoaiPhong modelLoaiPhong = db.tblLoaiPhongs.Where(x => x.mo_ta == model.Type).SingleOrDefault();
            tblTang      modelTang      = db.tblTangs.Where(x => x.ten_tang == model.Level).SingleOrDefault();

            tblPhong phong = new tblPhong();

            phong.ma_phong      = model.ID;
            phong.so_phong      = model.Name;
            phong.loai_phong    = modelLoaiPhong.loai_phong;
            phong.ma_tang       = modelTang.ma_tang;
            phong.ma_tinh_trang = 1;

            if (model.ID == 0)
            {
                db.tblPhongs.Add(phong);
                try
                {
                    db.SaveChanges();
                    status = true;
                }
                catch (Exception ex)
                {
                    status  = false;
                    message = ex.Message;
                }
            }
            else
            {
                //Đang cập nhật dữ liệu


                var entity = db.tblPhongs.Find(model.ID);
                entity.so_phong   = model.Name;
                entity.ma_tang    = modelTang.ma_tang;
                entity.loai_phong = modelLoaiPhong.loai_phong;

                //entity.CreatedDate = DateTime.Now;
                try
                {
                    db.SaveChanges();
                    status = true;
                }
                catch (Exception ex)
                {
                    status  = false;
                    message = ex.Message;
                }
            }

            return(Json(new
            {
                status = status,
                message = message
            }));
        }
예제 #4
0
        public ActionResult Slider(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblPhong p = db.tblPhongs.Include(a => a.tblLoaiPhong).Where(a => a.ma_phong == id).First();

            return(View(p));
        }
예제 #5
0
        public ActionResult DonPhongXong(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblPhong p = db.tblPhongs.Where(u => u.ma_phong == id).First();

            p.ma_tinh_trang   = 1;
            db.Entry(p).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index", "Index"));
        }
예제 #6
0
 public ActionResult Edit([Bind(Include = "ma_phong,so_phong,loai_phong,ma_tang,ma_tinh_trang")] tblPhong tblPhong)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblPhong).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.loai_phong    = new SelectList(db.tblLoaiPhongs, "loai_phong", "mo_ta", tblPhong.loai_phong);
     ViewBag.ma_tang       = new SelectList(db.tblTangs, "ma_tang", "ten_tang", tblPhong.ma_tang);
     ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhongs, "ma_tinh_trang", "mo_ta", tblPhong.ma_tinh_trang);
     return(View(tblPhong));
 }
예제 #7
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         tblPhong tblPhong = db.tblPhongs.Find(id);
         db.tblPhongs.Remove(tblPhong);
         db.SaveChanges();
     }
     catch
     {
     }
     return(RedirectToAction("Index"));
 }
예제 #8
0
        // GET: Phong/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblPhong tblPhong = db.tblPhongs.Find(id);

            if (tblPhong == null)
            {
                return(HttpNotFound());
            }
            return(View(tblPhong));
        }
예제 #9
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         tblPhong tblPhong = db.tblPhongs.Find(id);
         tblPhong.ma_tinh_trang   = 5;
         db.Entry(tblPhong).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch
     {
     }
     return(RedirectToAction("Index"));
 }
예제 #10
0
        // GET: Phong/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblPhong tblPhong = db.tblPhongs.Find(id);

            if (tblPhong == null)
            {
                return(HttpNotFound());
            }
            ViewBag.loai_phong    = new SelectList(db.tblLoaiPhongs, "loai_phong", "mo_ta", tblPhong.loai_phong);
            ViewBag.ma_tang       = new SelectList(db.tblTangs, "ma_tang", "ten_tang", tblPhong.ma_tang);
            ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhongs, "ma_tinh_trang", "mo_ta", tblPhong.ma_tinh_trang);
            return(View(tblPhong));
        }
예제 #11
0
        public ActionResult XacNhanThanhToan(string ma_hd, string tien_phong, string tien_dich_vu, string phu_thu, string tong_tien)
        {
            if (ma_hd == null || tien_phong == null || tien_dich_vu == null || phu_thu == null || tong_tien == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            try
            {
                tblHoaDon   hd = db.tblHoaDons.Find(Int32.Parse(ma_hd));
                tblNhanVien nv = (tblNhanVien)Session["NhanVien"];
                if (nv != null)
                {
                    hd.ma_nv = nv.ma_nv;
                }

                hd.tien_phong      = Double.Parse(tien_phong);
                hd.tien_dich_vu    = Double.Parse(tien_dich_vu);
                hd.phu_thu         = Double.Parse(phu_thu);
                hd.tong_tien       = Double.Parse(tong_tien);
                hd.ma_tinh_trang   = 2;
                hd.ngay_tra_phong  = DateTime.Now;
                db.Entry(hd).State = EntityState.Modified;

                tblPhong p = db.tblPhongs.Find(hd.tblPhieuDatPhong.ma_phong);
                p.ma_tinh_trang = 3;

                tblPhieuDatPhong pd = db.tblPhieuDatPhongs.Find(hd.tblPhieuDatPhong.ma_pdp);
                pd.ma_tinh_trang = 4;

                db.Entry(p).State  = EntityState.Modified;
                db.Entry(pd).State = EntityState.Modified;
                db.SaveChanges();

                ViewBag.result = "success";
            }
            catch
            {
                ViewBag.result = "error";
            }
            ViewBag.ma_hd = ma_hd;
            return(View());
        }
예제 #12
0
        public ActionResult BookRoom()
        {
            if (Session["KH"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            AutoHuyPhieuDatPhong();
            tblKhachHang kh = (tblKhachHang)Session["KH"];

            ViewBag.ma_kh         = kh.ma_kh;
            ViewBag.ten_dang_nhap = kh.ten_dang_nhap;
            ViewBag.ten_kh        = kh.ho_ten;
            ViewBag.ngay_dat      = DateTime.Now;
            ViewBag.ngay_vao      = (String)Session["ngay_vao"];
            ViewBag.ngay_ra       = (String)Session["ngay_ra"];

            //if (Session["ma_phong"] != null)
            //{
            //    ViewBag.ma_phong = (String)Session["ma_phong"];
            //    int map = Int32.Parse((String)Session["ma_phong"]);
            //    tblPhong p = (tblPhong)db.tblPhongs.Find(map);
            //    ViewBag.so_phong = p.so_phong;
            //}
            String     sp = "";
            List <int> ds;

            ds = (List <int>)Session["ds_ma_phong"];
            if (ds == null)
            {
                ds = new List <int>();
            }
            ViewBag.ma_phong = JsonConvert.SerializeObject(ds);
            foreach (var item in ds)
            {
                tblPhong p = (tblPhong)db.tblPhongs.Find(Int32.Parse(item.ToString()));
                sp += p.so_phong.ToString() + ", ";
            }
            ViewBag.so_phong = sp;
            var liP = db.tblPhieuDatPhongs.Where(u => u.ma_kh == kh.ma_kh && u.ma_tinh_trang == 1).ToList();

            return(View(liP));
        }
예제 #13
0
        public ActionResult GoiDichVu(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblPhong phong = new tblPhong();

            phong = db.tblPhongs.Find(id);

            tblPhieuDatPhong phieudatphong = new tblPhieuDatPhong();

            phieudatphong = db.tblPhieuDatPhongs.Where(x => x.ma_phong == phong.ma_phong && x.ma_tinh_trang == 2 && phong.ma_tinh_trang == 2).FirstOrDefault();

            tblHoaDon hoadon = new tblHoaDon();

            hoadon = db.tblHoaDons.Where(x => x.ma_pdp == phieudatphong.ma_pdp && phieudatphong.ma_tinh_trang == 2 && x.ma_tinh_trang == 1).SingleOrDefault();

            //int ma_hd = db.tblHoaDons.Where(x => x.ma_phong == id && u.ma_tinh_trang == 2).First().ma_hd;
            return(RedirectToAction("GoiDichVu", "HoaDon", new { id = hoadon.ma_hd }));
        }
예제 #14
0
 public ActionResult Result(String ma_tgd)
 {
     if (ma_tgd == null)
     {
         return(RedirectToAction("Index", "Admin"));
     }
     else
     {
         tblHoaDon hd = new tblHoaDon();
         hd.ma_tgd        = Int32.Parse(ma_tgd);
         hd.ma_tinh_trang = 1;
         try
         {
             db.tblHoaDons.Add(hd);
             tblPhieuDatPhong tgd = db.tblPhieuDatPhongs.Find(Int32.Parse(ma_tgd));
             if (tgd == null)
             {
                 return(HttpNotFound());
             }
             tblPhong p = db.tblPhongs.Find(tgd.ma_phong);
             if (p == null)
             {
                 return(HttpNotFound());
             }
             tgd.ma_tinh_trang   = 2;
             db.Entry(tgd).State = EntityState.Modified;
             p.ma_tinh_trang     = 2;
             db.Entry(p).State   = EntityState.Modified;
             ViewBag.ngay_ra     = tgd.ngay_ra;
             db.SaveChanges();
             ViewBag.Result = "success";
         }
         catch
         {
             ViewBag.Result = "error";
         }
     }
     return(View());
 }
예제 #15
0
        public ActionResult Result(String ma_pdp, String hoten1, String hoten2, String hoten3, String hoten4, String tuoi1, String tuoi2, String tuoi3, String tuoi4)
        {
            if (ma_pdp == null)
            {
                return(RedirectToAction("Index", "Index"));
            }
            else
            {
                List <KhachHang> likh;
                tblPhieuDatPhong pt = db.tblPhieuDatPhongs.Find(Int32.Parse(ma_pdp));
                if (pt.thong_tin_khach_thue == null)
                {
                    likh = new List <KhachHang>();
                    likh.Add(new KhachHang("", ""));
                }
                else
                {
                    likh = JsonConvert.DeserializeObject <List <KhachHang> >(pt.thong_tin_khach_thue);
                }
                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.thong_tin_khach_thue = JsonConvert.SerializeObject(likh);
                db.Entry(pt).State      = EntityState.Modified;
                db.SaveChanges();

                tblHoaDon hd = new tblHoaDon();
                hd.ma_pdp        = Int32.Parse(ma_pdp);
                hd.ma_tinh_trang = 1;
                try
                {
                    db.tblHoaDons.Add(hd);
                    tblPhieuDatPhong tgd = db.tblPhieuDatPhongs.Find(Int32.Parse(ma_pdp));
                    if (tgd == null)
                    {
                        return(HttpNotFound());
                    }
                    tblPhong p = db.tblPhongs.Find(tgd.ma_phong);
                    if (p == null)
                    {
                        return(HttpNotFound());
                    }
                    tgd.ma_tinh_trang   = 2;
                    db.Entry(tgd).State = EntityState.Modified;
                    p.ma_tinh_trang     = 2;
                    db.Entry(p).State   = EntityState.Modified;
                    ViewBag.ngay_ra     = tgd.ngay_ra;
                    db.SaveChanges();
                    ViewBag.Result = "success";
                }
                catch
                {
                    ViewBag.Result = "error";
                }
            }
            return(View());
        }