コード例 #1
0
        public ActionResult Create(String radSelect, [Bind(Include = "ma_pdp,ma_kh,ngay_dat,ngay_vao,ngay_ra,ma_phong,ma_tinh_trang")] tblPhieuDatPhong tblPhieuDatPhong, [Bind(Include = "hoten,socmt,tuoi,sodt")] KhachHang kh)
        {
            System.Diagnostics.Debug.WriteLine("SS :" + radSelect);
            if (radSelect.Equals("rad2"))
            {
                tblPhieuDatPhong.ma_kh = null;
                List <KhachHang> likh = new List <KhachHang>();
                likh.Add(kh);
                String ttkh = JsonConvert.SerializeObject(likh);
                tblPhieuDatPhong.thong_tin_khach_thue = ttkh;
            }

            tblPhieuDatPhong.ma_tinh_trang = 1;
            tblPhieuDatPhong.ngay_vao      = DateTime.Now;
            tblPhieuDatPhong.ngay_dat      = DateTime.Now;
            db.tblPhieuDatPhongs.Add(tblPhieuDatPhong);
            db.SaveChanges();
            int ma = tblPhieuDatPhong.ma_pdp;

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

            ViewBag.ma_kh         = new SelectList(db.tblKhachHangs, "ma_kh", "ma_kh", tblPhieuDatPhong.ma_kh);
            ViewBag.ma_phong      = new SelectList(db.tblPhongs, "ma_phong", "so_phong", tblPhieuDatPhong.ma_phong);
            ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
            return(View(tblPhieuDatPhong));
        }
コード例 #2
0
ファイル: HoaDonController.cs プロジェクト: Shiba22222/QLKS
 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 ActionResult Result(String ma_kh, String ngay_vao, String ngay_ra, String ma_phong)
 {
     if (ma_kh == null || ngay_vao == null || ngay_ra == null || ma_phong == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         tblPhieuDatPhong tgd = new tblPhieuDatPhong();
         tgd.ma_kh         = ma_kh;
         tgd.ma_phong      = Int32.Parse(ma_phong);
         tgd.ma_tinh_trang = 1;
         tgd.ngay_dat      = DateTime.Now;
         tgd.ngay_vao      = DateTime.ParseExact(ngay_vao, "dd/MM/yyyy", CultureInfo.InvariantCulture);
         tgd.ngay_ra       = DateTime.ParseExact(ngay_ra, "dd/MM/yyyy", CultureInfo.InvariantCulture);
         try
         {
             db.tblPhieuDatPhongs.Add(tgd);
             db.SaveChanges();
             ViewBag.Result = "success";
             setNull();
         }
         catch
         {
             ViewBag.Result = "error";
         }
     }
     return(View());
 }
コード例 #4
0
        public ActionResult SuaPhieuDatPhong(int?id)
        {
            tblKhachHang kh = new tblKhachHang();

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

            if (tblPhieuDatPhong == null)
            {
                return(HttpNotFound());
            }
            if (tblPhieuDatPhong.ma_kh != kh.ma_kh)
            {
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.ma_kh         = new SelectList(db.tblKhachHangs, "ma_kh", "mat_khau", tblPhieuDatPhong.ma_kh);
            ViewBag.ma_phong      = new SelectList(db.tblPhongs, "ma_phong", "so_phong", tblPhieuDatPhong.ma_phong);
            ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
            return(View(tblPhieuDatPhong));
        }
コード例 #5
0
        // GET: PhieuDatPhong/Delete/5
        public ActionResult XoaPhieuDatPhong(int?id)
        {
            tblKhachHang kh = new tblKhachHang();

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

            tblPhieuDatPhong tblPhieuDatPhong = db.tblPhieuDatPhongs.Find(id);

            if (tblPhieuDatPhong == null)
            {
                return(HttpNotFound());
            }
            if (tblPhieuDatPhong.ma_kh != kh.ma_kh)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View(tblPhieuDatPhong));
        }
コード例 #6
0
ファイル: HoaDonController.cs プロジェクト: Shiba22222/QLKS
        public ActionResult GiaHanPhong(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblHoaDon tblHoaDon = db.tblHoaDons.Find(id);

            if (tblHoaDon == null)
            {
                return(HttpNotFound());
            }
            tblPhieuDatPhong pdp = db.tblPhieuDatPhongs.Find(tblHoaDon.ma_pdp);
            String           dt  = null;

            try
            {
                DateTime d = (DateTime)db.tblPhieuDatPhongs.Where(t => t.ma_tinh_trang == 1 && t.ma_phong == pdp.tblPhong.ma_phong).Select(t => t.ngay_vao).OrderBy(t => t.Value).First();
                dt = d.ToString();
            }
            catch
            {
            }
            ViewBag.dateMax = dt;
            return(View(pdp));
        }
コード例 #7
0
ファイル: HomeController.cs プロジェクト: Shiba22222/QLKS
 public ActionResult Result(String ma_kh, String ngay_vao, String ngay_ra, String ma_phong)
 {
     if (ma_kh == null || ngay_vao == null || ngay_ra == null || ma_phong == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         tblPhieuDatPhong tgd = new tblPhieuDatPhong();
         List <int>       ds  = JsonConvert.DeserializeObject <List <int> >(ma_phong);
         tgd.ma_kh         = ma_kh;
         tgd.ma_tinh_trang = 1;
         tgd.ngay_dat      = DateTime.Now;
         tgd.ngay_vao      = (DateTime.ParseExact(ngay_vao, "dd/MM/yyyy", CultureInfo.InvariantCulture)).AddHours(12);
         tgd.ngay_ra       = (DateTime.ParseExact(ngay_ra, "dd/MM/yyyy", CultureInfo.InvariantCulture)).AddHours(12);
         try
         {
             for (int i = 0; i < ds.Count; i++)
             {
                 tgd.ma_phong = ds[i];
                 db.tblPhieuDatPhongs.Add(tgd);
                 db.SaveChanges();
                 ViewBag.Result = "success";
             }
             ViewBag.ngay_vao = tgd.ngay_vao;
             setNull();
         }
         catch
         {
             ViewBag.Result = "error";
         }
     }
     return(View());
 }
コード例 #8
0
        public ActionResult ConfirmXoaPhieuDatPhong(int id)
        {
            tblPhieuDatPhong tblPhieuDatPhong = db.tblPhieuDatPhongs.Find(id);

            tblPhieuDatPhong.ma_tinh_trang   = 3;
            db.Entry(tblPhieuDatPhong).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("BookRoom", "Home"));
        }
コード例 #9
0
 public ActionResult Edit([Bind(Include = "ma_pdp,ma_kh,ngay_dat,ngay_vao,ngay_ra,ma_phong,ma_tinh_trang")] tblPhieuDatPhong tblPhieuDatPhong)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblPhieuDatPhong).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ma_kh         = new SelectList(db.tblKhachHangs, "ma_kh", "mat_khau", tblPhieuDatPhong.ma_kh);
     ViewBag.ma_phong      = new SelectList(db.tblPhongs, "ma_phong", "so_phong", tblPhieuDatPhong.ma_phong);
     ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
     return(View(tblPhieuDatPhong));
 }
コード例 #10
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         tblPhieuDatPhong tblPhieuDatPhong = db.tblPhieuDatPhongs.Find(id);
         db.tblPhieuDatPhongs.Remove(tblPhieuDatPhong);
         db.SaveChanges();
     }
     catch
     {
     }
     return(RedirectToAction("Index"));
 }
コード例 #11
0
ファイル: HoaDonController.cs プロジェクト: Shiba22222/QLKS
        public ActionResult Add(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblPhieuDatPhong tblPhieuDatPhong = db.tblPhieuDatPhongs.Find(id);

            if (tblPhieuDatPhong == null)
            {
                return(HttpNotFound());
            }
            return(View(tblPhieuDatPhong));
        }
コード例 #12
0
        public ActionResult TraPhong(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblPhieuDatPhong phieudatphong = new tblPhieuDatPhong();

            phieudatphong = db.tblPhieuDatPhongs.Where(x => x.ma_phong == id && x.ma_tinh_trang == 2).SingleOrDefault();

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

            return(RedirectToAction("ThanhToan", "HoaDon", new { id = MaHoaDon.ma_hd }));
        }
コード例 #13
0
        // GET: PhieuDatPhong/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblPhieuDatPhong tblPhieuDatPhong = db.tblPhieuDatPhongs.Find(id);

            if (tblPhieuDatPhong == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ma_kh         = new SelectList(db.tblKhachHangs, "ma_kh", "mat_khau", tblPhieuDatPhong.ma_kh);
            ViewBag.ma_phong      = new SelectList(db.tblPhongs, "ma_phong", "so_phong", tblPhieuDatPhong.ma_phong);
            ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
            return(View(tblPhieuDatPhong));
        }
コード例 #14
0
        public ActionResult Create([Bind(Include = "ma_tgd,ma_kh,ngay_dat,ngay_vao,ngay_ra,ma_phong,ma_tinh_trang")] tblPhieuDatPhong tblPhieuDatPhong)
        {
            if (ModelState.IsValid)
            {
                tblPhieuDatPhong.ma_tinh_trang = 1;
                DateTime ngay_vao = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                tblPhieuDatPhong.ngay_vao = ngay_vao;
                db.tblPhieuDatPhongs.Add(tblPhieuDatPhong);
                db.SaveChanges();
                int ma = tblPhieuDatPhong.ma_tgd;
                return(RedirectToAction("Add", "HoaDon", new { id = ma }));
            }

            ViewBag.ma_kh         = new SelectList(db.tblKhachHangs, "ma_kh", "ma_kh", tblPhieuDatPhong.ma_kh);
            ViewBag.ma_phong      = new SelectList(db.tblPhongs, "ma_phong", "so_phong", tblPhieuDatPhong.ma_phong);
            ViewBag.ma_tinh_trang = new SelectList(db.tblTinhTrangPhieuDatPhongs, "ma_tinh_trang", "tinh_trang", tblPhieuDatPhong.ma_tinh_trang);
            return(View(tblPhieuDatPhong));
        }
コード例 #15
0
ファイル: HoaDonController.cs プロジェクト: Shiba22222/QLKS
        public ActionResult DoiPhong(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblHoaDon tblHoaDon = db.tblHoaDons.Find(id);

            if (tblHoaDon == null)
            {
                return(HttpNotFound());
            }
            tblPhieuDatPhong pdp = db.tblPhieuDatPhongs.Find(tblHoaDon.ma_pdp);

            var li = db.tblPhongs.Where(t => t.ma_tinh_trang == 1 && !(db.tblPhieuDatPhongs.Where(m => (m.ma_tinh_trang == 1 || m.ma_tinh_trang == 2) && m.ngay_ra > DateTime.Now && m.ngay_vao < pdp.ngay_ra)).Select(m => m.ma_phong).ToList().Contains(t.ma_phong));

            ViewBag.ma_phong_moi = new SelectList(li, "ma_phong", "so_phong");
            return(View(pdp));
        }
コード例 #16
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());
        }
コード例 #17
0
ファイル: HoaDonController.cs プロジェクト: Shiba22222/QLKS
 public ActionResult ResultGiaHan(String ma_pdp, String ngay_ra)
 {
     if (ma_pdp == null || ngay_ra == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     try
     {
         tblPhieuDatPhong pdp    = db.tblPhieuDatPhongs.Find(Int32.Parse(ma_pdp));
         DateTime         ngayra = DateTime.Parse(ngay_ra);
         pdp.ngay_ra     = ngayra;
         ViewBag.result  = "success";
         ViewBag.ngay_ra = ngay_ra;
     }
     catch (Exception e)
     {
         ViewBag.result = "error: " + e;
     }
     return(View());
 }
コード例 #18
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 }));
        }
コード例 #19
0
ファイル: HoaDonController.cs プロジェクト: tgiangfc/ghotel
 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());
 }
コード例 #20
0
ファイル: HoaDonController.cs プロジェクト: Shiba22222/QLKS
        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());
        }