예제 #1
0
        public ActionResult Create([Bind(Include = "MaPhong,TenPhong,TinhTrangPhong,GiaTienPhong,HinhPhong,ThongTinChiTietPhong")] DSPhong dSPhong)
        {
            if (ModelState.IsValid)
            {
                db.DSPhongs.Add(dSPhong);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dSPhong));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "MaKH,HoTen,CMND,NgheNghiep,QueQuan,NgaySinh,MaPhong")] KhachHang khachHang)
        {
            if (ModelState.IsValid)
            {
                db.KhachHangs.Add(khachHang);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaPhong = new SelectList(db.DSPhongs, "MaPhong", "TenPhong", khachHang.MaPhong);
            return(View(khachHang));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "MaHD,MaKH,MaPhong,NgayLapHD")] HoaDon hoaDon)
        {
            if (ModelState.IsValid)
            {
                db.HoaDons.Add(hoaDon);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaPhong = new SelectList(db.DSPhongs, "MaPhong", "TenPhong", hoaDon.MaPhong);
            return(View(hoaDon));
        }
예제 #4
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"));
        }
예제 #5
0
        public ActionResult New(string id)
        {
            CTHD   cthd = new CTHD();
            HoaDon hd   = db.HoaDons.Where(x => x.MaHD == id).SingleOrDefault();

            cthd.MaHD = id;
            cthd.MaKH = hd.MaKH;
            var SoDien  = Request["txtSD"];
            var SoNuoc  = Request["txtSN"];
            var GiaDien = Request["txtGiaDien"];
            var GiaNuoc = Request["txtGiaNuoc"];

            cthd.SoDien  = Int32.Parse(SoDien);
            cthd.SoNuoc  = Int32.Parse(SoNuoc);
            cthd.GiaDien = Int32.Parse(GiaDien);
            cthd.GiaNuoc = Int32.Parse(GiaNuoc);

            db.CTHDs.Add(cthd);
            db.SaveChanges();

            return(RedirectToActionPermanent("Index", "HoaDons"));
        }