Example #1
0
 public ActionResult Edit([Bind(Include = "MaKH,HoTen,CMND,NgheNghiep,QueQuan,NgaySinh,MaPhong")] KhachHang khachHang)
 {
     if (ModelState.IsValid)
     {
         db.Entry(khachHang).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaPhong = new SelectList(db.DSPhongs, "MaPhong", "TenPhong", khachHang.MaPhong);
     return(View(khachHang));
 }
 public ActionResult Edit([Bind(Include = "MaPhong,TenPhong,TinhTrangPhong,GiaTienPhong,HinhPhong,ThongTinChiTietPhong")] DSPhong dSPhong)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dSPhong).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dSPhong));
 }
 public ActionResult Edit([Bind(Include = "MaHD,MaKH,MaPhong,NgayLapHD")] HoaDon hoaDon)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hoaDon).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaPhong = new SelectList(db.DSPhongs, "MaPhong", "TenPhong", hoaDon.MaPhong);
     return(View(hoaDon));
 }
Example #4
0
 public ActionResult Edit([Bind(Include = "MaKH,MaHD,SoDien,SoNuoc,GiaDien,GiaNuoc")] CTHD cTHD)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cTHD).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaHD = new SelectList(db.HoaDons, "MaHD", "MaKH", cTHD.MaHD);
     ViewBag.MaKH = new SelectList(db.KhachHangs, "MaKH", "HoTen", cTHD.MaKH);
     return(View(cTHD));
 }
Example #5
0
        public ActionResult Index(ListPhongTrong l, FormCollection f)
        {
            var      MaPhong      = f["DropDownList"].ToString();
            var      Makh         = "KH00" + (db.KhachHangs.Count() + 1).ToString();
            var      HoTenKH      = f.Get("txtHoTen");
            var      CMNDKH       = f.Get("txtCMND");
            var      ngheNghiepKH = f.Get("txtNgheNghiep");
            var      queQuanKH    = f.Get("txtQueQuan");
            var      ngaySinhKH   = f.Get("txtNgaySinh");
            DateTime oDate        = Convert.ToDateTime(ngaySinhKH);

            KhachHang kh = new KhachHang();

            kh.MaKH       = Makh;
            kh.HoTen      = HoTenKH;
            kh.CMND       = CMNDKH;
            kh.NgheNghiep = ngheNghiepKH;
            kh.QueQuan    = queQuanKH;
            kh.NgaySinh   = oDate;
            kh.MaPhong    = MaPhong;

            HoaDon hd = new HoaDon();

            hd.MaHD      = "HD00" + (db.HoaDons.Count() + 1).ToString();
            hd.MaKH      = kh.MaKH;
            hd.MaPhong   = kh.MaPhong;
            hd.NgayLapHD = DateTime.Now;

            var phong = db.DSPhongs.Where(c => c.MaPhong == MaPhong).SingleOrDefault();

            if (ModelState.IsValid)
            {
                //cap nhat tinh trang phong
                phong.TinhTrangPhong  = false;
                db.Entry(phong).State = EntityState.Modified;
                //them khach hang
                db.KhachHangs.Add(kh);
                db.SaveChanges();
                //them 1 hoa don moi
                db.HoaDons.Add(hd);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }