Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "MaNV,TenNV,MaCV,SDTNV,DCNV")] NV nV)
        {
            List <SelectListItem> selectList = new List <SelectListItem>();

            foreach (var item in db.ChucVu)
            {
                if (item.MaCV != 1 && item.MaCV != 2 && item.MaCV != 3)
                {
                    selectList.Add(new SelectListItem
                    {
                        Text  = item.TenCV,
                        Value = item.MaCV.ToString()
                    });
                }
            }
            ViewBag.TenCV = /*new SelectList(db.ChucVus, "MaCV", "TenCV")*/ selectList;
            try
            {
                if (ModelState.IsValid)
                {
                    db.NV.Add(nV);
                    db.SaveChanges();
                    return(RedirectToAction("ThêmNhânViênTC", new { id = Encryption.encrypt(nV.MaNV.ToString()) }));
                }
            }
            catch
            {
                return(View("LỗiTạoNhânViên"));
            }
            return(View(nV));
        }
Ejemplo n.º 2
0
        public ActionResult CreateChiTietDoanhThu([Bind(Include = "MaDoanhThu,MaLoai")] ChiTietDoanhThu chiTietDoanhThu)
        {
            List <SelectListItem> maDoanhThu = new List <SelectListItem>();

            foreach (var item in db.DoanhThu)
            {
                maDoanhThu.Add(new SelectListItem
                {
                    Text  = item.MaDoanhThu.ToString(),
                    Value = item.MaDoanhThu.ToString()
                });
            }
            ViewBag.MaDoanhThu = maDoanhThu;
            ViewBag.TenLoai    = new SelectList(db.LoaiPhong, "MaLoai", "TenLoai");
            try
            {
                if (ModelState.IsValid)
                {
                    db.ChiTietDoanhThu.Add(chiTietDoanhThu);
                    db.SaveChanges();
                    return(RedirectToAction("QuảnLýDoanhThu"));
                }
            }
            catch
            {
                return(View("LỗiThêmDoanhThu"));
            }

            return(View(chiTietDoanhThu));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "MaPhong,TenPhong,MaLoai,GhiChu,TinhTrang")] Phong phong)
        {
            List <SelectListItem> loaiPhong = new List <SelectListItem>();

            foreach (var item in db.LoaiPhong)
            {
                loaiPhong.Add(new SelectListItem
                {
                    Text  = item.TenLoai,
                    Value = Convert.ToString(item.MaLoai)
                });
            }
            ViewBag.LoaiPhong = loaiPhong;
            try
            {
                if (ModelState.IsValid)
                {
                    db.Phong.Add(phong);
                    db.SaveChanges();
                    return(RedirectToAction("TạoPhòngTC", new { id = Encryption.encrypt(phong.MaPhong.ToString()) }));
                }
            }
            catch
            {
                return(View("LỗiTạoPhòng"));
            }
            return(View(phong));
        }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "Email,Pass,MaNV,Roles,NV")] TaiKhoan userprofile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userprofile).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ThôngTinTàiKhoản", new { id = Encryption.encrypt(userprofile.MaNV.ToString()) }));
     }
     return(View(userprofile));
 }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "MaKhachHang,TenKhachHang,MaLoaiKhach,DiaChi,CMND")] KhachHang khachHang)
        {
            if (ModelState.IsValid)
            {
                db.KhachHang.Add(khachHang);
                db.SaveChanges();
                return(RedirectToAction("ThôngTinKháchHàng", new { id = Encryption.encrypt(khachHang.MaKhachHang.ToString()) }));
            }

            ViewBag.MaLoaiKhach = new SelectList(db.LoaiKhach, "MaLoaiKhach", "TenLoaiKhach", khachHang.MaLoaiKhach);
            return(View(khachHang));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "MaThuePhong,MaKhachHang,SoLuongKhach")] ChiTietThuePhong chiTietThuePhong)
        {
            if (ModelState.IsValid)
            {
                db.ChiTietThuePhong.Add(chiTietThuePhong);
                db.SaveChanges();
                return(RedirectToAction("ChiTiết", new { id = chiTietThuePhong.MaThuePhong, khachHang = chiTietThuePhong.MaKhachHang }));
            }

            ViewBag.MaKhachHang = new SelectList(db.KhachHang, "MaKhachHang", "TenKhachHang", chiTietThuePhong.MaKhachHang);
            ViewBag.MaThuePhong = new SelectList(db.ThuePhong, "MaThuePhong", "MaThuePhong", chiTietThuePhong.MaThuePhong);
            return(View(chiTietThuePhong));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "MaHD,MaThuePhong,NgayThanhToan,SoNgayThue,ThanhTien")] ChiTietHoaDon chiTietHoaDon)
        {
            if (ModelState.IsValid)
            {
                db.ChiTietHoaDon.Add(chiTietHoaDon);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaHD        = new SelectList(db.HD, "MaHD", "MaHD", chiTietHoaDon.MaHD);
            ViewBag.MaThuePhong = new SelectList(db.ThuePhong, "MaThuePhong", "MaThuePhong", chiTietHoaDon.MaThuePhong);
            return(View(chiTietHoaDon));
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Email,Pass,MaNV,Roles")] TaiKhoan taiKhoan)
        {
            if (ModelState.IsValid)
            {
                db.TaiKhoan.Add(taiKhoan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }



            ViewBag.MaNV = new SelectList(db.NV, "MaNV", "TenNV", taiKhoan.MaNV);
            return(View(taiKhoan));
        }
Ejemplo n.º 9
0
 public ActionResult Create([Bind(Include = "MaQuiDinh,TenQuiDinh,MoTa,ThamSo,ThamSoTien")] QuiDinh quiDinh)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.QuiDinh.Add(quiDinh);
             db.SaveChanges();
             return(RedirectToAction("ThôngTinQuiĐịnh", new { id = Encryption.encrypt(quiDinh.MaQuiDinh.ToString()) }));
         }
     }
     catch
     {
         return(View("LỗiQuiĐịnh"));
     }
     return(View(quiDinh));
 }
Ejemplo n.º 10
0
 public ActionResult Create([Bind(Include = "MaCV,TenCV")] ChucVu chucVu)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.ChucVu.Add(chucVu);
             db.SaveChanges();
             return(View("ThêmChứcVụThànhCông"));
         }
     }
     catch
     {
         return(View("LỗiChứcVụ"));
     }
     return(View(chucVu));
 }
Ejemplo n.º 11
0
        public ActionResult Create([Bind(Include = "MaDoanhThu,LoaiPhong,Thang")] ChiTietDoanhThu chiTietDoanhThu)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.ChiTietDoanhThu.Add(chiTietDoanhThu);
                    db.SaveChanges();
                    return(RedirectToAction("ThêmDoanhThuTC", new { id = Encryption.encrypt(chiTietDoanhThu.MaDoanhThu.ToString()) }));
                }
            }
            catch
            {
                return(View("LỗiThêmDoanhThu"));
            }

            return(View(chiTietDoanhThu));
        }
Ejemplo n.º 12
0
        public ActionResult Create([Bind(Include = "MaLoai,TenLoai,Dongia")] LoaiPhong loaiPhong)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.LoaiPhong.Add(loaiPhong);
                    db.SaveChanges();
                    return(RedirectToAction("ThêmLoạiPhòngTC", new { id = Encryption.encrypt(loaiPhong.MaLoai.ToString()) }));
                }
            }
            catch
            {
                return(View("LỗiLoạiPhòng"));
            }


            return(View(loaiPhong));
        }
Ejemplo n.º 13
0
        public ActionResult Create([Bind(Include = "MaPhong,NgayBatDauThue")] ThuePhong thuePhong)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    {
                        db.ThuePhong.Add(thuePhong);
                        db.SaveChanges();
                        return(RedirectToAction("ThànhCông", new { id = Encryption.encrypt(thuePhong.MaThuePhong.ToString()) }));
                    }
                }
            }
            catch
            {
                return(View("LỗiThuêPhòng"));
            }
            List <SelectListItem> tenPhong = new List <SelectListItem>();

            foreach (var item in db.Phong)
            {
                if (item.TinhTrang == false)
                {
                    tenPhong.Add(new SelectListItem
                    {
                        Text  = item.TenPhong,
                        Value = item.MaPhong.ToString()
                    });
                }
            }
            ViewBag.MaPhong = tenPhong;
            return(View(thuePhong));
        }
Ejemplo n.º 14
0
        public ActionResult Index([Bind(Include = "MaPhong,NgayBatDauThue")] ThuePhong thuePhong)
        {
            List <SelectListItem> tenPhong = new List <SelectListItem>();

            foreach (var item in db.Phong)
            {
                if (item.TinhTrang == false)
                {
                    tenPhong.Add(new SelectListItem
                    {
                        Text  = item.TenPhong,
                        Value = item.MaPhong.ToString()
                    });
                }
            }
            ViewBag.MaPhong = /*new SelectList(db.Phongs, "MaPhong", "MaPhong")*/ tenPhong;
            var tinhTrang = phong.TinhTrang.HasValue;

            try
            {
                if (ModelState.IsValid)
                {
                    if (tinhTrang == false)
                    {
                        db.ThuePhong.Add(thuePhong);
                        db.SaveChanges();
                        return(View("DatPhong"));
                    }
                }
            }
            catch
            {
                return(View("CreateError"));
            }
            return(View("TrangChủ", thuePhong));
        }
Ejemplo n.º 15
0
        public ActionResult Create([Bind(Include = "MaKhachHang,MaNV,TongTien")] HD hD)
        {
            List <SelectListItem> tenKH = new List <SelectListItem>();

            foreach (var item in db.KhachHang)
            {
                tenKH.Add(new SelectListItem
                {
                    Text  = item.TenKhachHang,
                    Value = Convert.ToString(item.MaKhachHang)
                });
            }
            ViewBag.MaKH = /*new SelectList(db.KhachHangs, "MaKhachHang", "TenKhachHang")*/ tenKH;
            List <SelectListItem> tenNV = new List <SelectListItem>();

            foreach (var item in db.NV)
            {
                if (item.ChucVu.TenCV == "Ke Toan" || item.ChucVu.TenCV == "Ke Toan Truong")
                {
                    tenNV.Add(new SelectListItem
                    {
                        Text  = item.TenNV,
                        Value = Convert.ToString(item.MaNV)
                    });
                }
            }
            ViewBag.MaNV = tenNV;
            if (ModelState.IsValid)
            {
                db.HD.Add(hD);
                db.SaveChanges();
                return(View("ThanhToánHoáTC"));
            }

            return(View(hD));
        }