Esempio n. 1
0
        public ActionResult Chitiethopdong(int id, int id2)
        {
            HOPDONG        hopdong   = db.HOPDONGs.SingleOrDefault(n => n.MaHD == id);
            CHITIETHOPDONG cthopdong = db.CHITIETHOPDONGs.SingleOrDefault(n => n.MaHD == id);
            PHONG          phong     = db.PHONGs.SingleOrDefault(n => n.MaPHG == id);
            CONGTY         cty       = db.CONGTies.SingleOrDefault(n => n.MaCongTy == id2);


            ViewBag.MaHD         = hopdong.MaHD;
            ViewBag.MaPHG        = cthopdong.MaPHG;
            ViewBag.TenPHG       = phong.TenPHG;
            ViewBag.Tang         = phong.Tang;
            ViewBag.DienTich     = phong.DienTich;
            ViewBag.ThoiGianThue = cthopdong.ThoiGianThue;

            ViewBag.MaCongTy = cty.MaCongTy;
            ViewBag.TenCT    = cty.TenCT;

            if (hopdong == null)
            {
                Response.StatusCode = 404;
                return(null);
            }

            return(View(hopdong));
        }
Esempio n. 2
0
        public bool ThemChiTietHopDong(CHITIETHOPDONG p)
        {
            linQDataContext chitiet1 = new linQDataContext();

            chitiet1.CHITIETHOPDONGs.InsertOnSubmit(p);
            chitiet1.SubmitChanges();
            return(true);
        }
Esempio n. 3
0
        public ActionResult Suathongtinhopdong(int id1, int id2)
        {
            CHITIETHOPDONG cthopdong = db.CHITIETHOPDONGs.Find(id1, id2);

            if (cthopdong == null)
            {
                Response.StatusCode = 404;
                return(null);
            }

            ViewBag.MaPHG = new SelectList(db.CHITIETHOPDONGs.ToList().OrderBy(n => n.MaPHG), "MaPHG", "MaPHG");

            ViewBag.ThoiGianThue = new SelectList(db.CHITIETHOPDONGs.ToList().OrderBy(n => n.ThoiGianThue), "ThoiGianThue", "ThoiGianThue");

            return(View(cthopdong));
        }
Esempio n. 4
0
        public ActionResult Suathongtinhopdong(CHITIETHOPDONG cthopdong, int id1, int id2)
        {
            ViewBag.MaPHG = new SelectList(db.CHITIETHOPDONGs.ToList().OrderBy(n => n.MaPHG), "MaPHG", "MaPHG");

            ViewBag.ThoiGianThue = new SelectList(db.CHITIETHOPDONGs.ToList().OrderBy(n => n.ThoiGianThue), "ThoiGianThue", "ThoiGianThue");


            if (ModelState.IsValid)
            {
                CHITIETHOPDONG cthd = db.CHITIETHOPDONGs.Find(id1, id2);
                cthd.MaPHG        = cthopdong.MaPHG;
                cthd.ThoiGianThue = cthopdong.ThoiGianThue;
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
        public ActionResult Xoahopdong(int id)
        {
            HOPDONG        hopdong   = db.HOPDONGs.SingleOrDefault(n => n.MaHD == id);
            CHITIETHOPDONG cthopdong = db.CHITIETHOPDONGs.SingleOrDefault(n => n.MaHD == id);


            ViewBag.MaHD         = hopdong.MaHD;
            ViewBag.MaPHG        = cthopdong.MaPHG;
            ViewBag.ThoiGianThue = cthopdong.ThoiGianThue;

            if (hopdong == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(hopdong));
        }
Esempio n. 6
0
 private void addTenancyinfo()
 {
     try
     {
         connectDBEntity mod1        = new connectDBEntity();
         double          deposit     = double.Parse(txtDeposits.Text);
         var             Tenancyinfo = new CHITIETHOPDONG
         {
             MaHopDong      = txtTenacyID.Text,
             NgayLapHopDong = dtpDate.Value,
             TenPhong       = getRoomname(),
             TenDichVu      = getSer(lsvService, 1),
             GiaDichVu      = getSer(lsvService, 2),
             DonViTinh      = getSer(lsvService, 3),
             TienDatCoc     = deposit,
             NgayBatDau     = dtpStart.Value,
             NgayKetThuc    = dtpEnd.Value
         };
         mod1.CHITIETHOPDONG.Add(Tenancyinfo);
         mod1.SaveChanges();
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
     {
         Exception raise = dbEx;
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 string message = string.Format("{0}:{1}",
                                                validationErrors.Entry.Entity.ToString(),
                                                validationError.ErrorMessage);
                 // raise a new exception nesting
                 // the current instance as InnerException
                 raise = new InvalidOperationException(message, raise);
             }
         }
         throw raise;
     }
 }
Esempio n. 7
0
        public ActionResult Xacnhanxoa(int id)
        {
            HOPDONG        hopdong   = db.HOPDONGs.SingleOrDefault(n => n.MaHD == id);
            CHITIETHOPDONG cthopdong = db.CHITIETHOPDONGs.SingleOrDefault(n => n.MaHD == id);


            ViewBag.MaHD         = hopdong.MaHD;
            ViewBag.MaPHG        = cthopdong.MaPHG;
            ViewBag.ThoiGianThue = cthopdong.ThoiGianThue;
            if (hopdong == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            db.HOPDONGs.Remove(hopdong);
            db.CHITIETHOPDONGs.Remove(cthopdong);


            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 8
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (txtHoTen.Text.Length > 0 && txtMaHopDong.Text.Length > 0 && spinEditKyLanThu.Text.Length > 0 && txtMaNV.Text.Length > 0 && dateEditNgayBatDau.DateTime.ToString() != "1/1/0001 12:00:00 AM" && dateEditNgayKetThuc.DateTime.ToString() != "1/1/0001 12:00:00 AM" && dateEditNgayKy.DateTime.ToString() != "1/1/0001 12:00:00 AM")
     {
         CHITIETHOPDONG cHITIETHOPDONG = new CHITIETHOPDONG();
         cHITIETHOPDONG.MACTHD         = txtMaHopDong.Text;
         cHITIETHOPDONG.MAHOPDONG      = cboLoaiHopDong.SelectedValue.ToString();
         cHITIETHOPDONG.MANV           = NV;
         cHITIETHOPDONG.NGAYKY         = dateEditNgayKy.DateTime;
         cHITIETHOPDONG.NGAYBD         = dateEditNgayBatDau.DateTime;
         cHITIETHOPDONG.NGAYKT         = dateEditNgayKetThuc.DateTime;
         cHITIETHOPDONG.LUONGTHOATHUAN = decimal.Parse(txtLuong.Text);
         cHITIETHOPDONG.KYLANTHU       = int.Parse(spinEditKyLanThu.Text);
         if (bLL_nhanvien.BLL_ThemChiTietHopDong(cHITIETHOPDONG))
         {
             MessageBox.Show("Thành công"); return;
         }
         MessageBox.Show("Trùng khóa");
     }
     else
     {
         MessageBox.Show("Vui lòng nhập đủ dữ liệu");
     }
 }
Esempio n. 9
0
 public bool BLL_ThemChiTietHopDong(CHITIETHOPDONG p)
 {
     return(dAL_NhanVien.ThemChiTietHopDong(p));
 }
Esempio n. 10
0
        public ActionResult Themhopdong(FormCollection collection, ContractViewModel model)
        {
            ViewBag.MaPHG = new SelectList(db.PHONGs.ToList().OrderBy(n => n.MaPHG), "MaPHG");

            ViewBag.ThoiGianThue = new SelectList(db.CHITIETHOPDONGs, "ThoiGianThue");
            ViewBag.MaCongTy     = new SelectList(db.CONGTies.ToList().OrderBy(n => n.MaCongTy), "MaCongTy", "TenCT");
            ViewBag.TenNV        = new SelectList(db.NHANVIENs.ToList().OrderBy(n => n.TenNV), "TenNV", "TenNV");
            ViewBag.DiaChiNV     = new SelectList(db.NHANVIENs.ToList().OrderBy(n => n.DiaChiNV), "DiaChiNV", "DiaChiNV");
            ViewBag.SDTNV        = new SelectList(db.NHANVIENs.ToList().OrderBy(n => n.SDTNV), "SDTNV", "SDTNV");
            ViewBag.ChucVu       = new SelectList(db.NHANVIENs.ToList().OrderBy(n => n.ChucVu), "ChucVu", "ChucVu");



            var NgayLap      = collection["NgayLap"];
            var TienCoc      = collection["TienCoc"];
            var ThoiGianThue = collection["ThoiGianThue"];
            var MaPHG        = collection["MaPHG"];
            var MaCongTy     = collection["MaCongTy"];
            var TenNV        = collection["TenNV"];
            var DiaChiNV     = collection["DiaChiNV"];
            var SDTNV        = collection["SDTNV"];
            var ChucVu       = collection["ChucVu"];

            if (String.IsNullOrEmpty(NgayLap))
            {
                ViewData["Loi1"] = "Ngày lập không được bỏ trống!";
            }
            else if (String.IsNullOrEmpty(TienCoc))
            {
                ViewData["Loi2"] = "Tiền cọc không đucợ bỏ trống!";
            }
            else if (String.IsNullOrEmpty(ThoiGianThue))
            {
                ViewData["Loi3"] = "Thời gian thuê không được bỏ trống!";
            }
            else if (String.IsNullOrEmpty(MaPHG))
            {
                ViewData["Loi4"] = "Mã phòng không được bỏ trống!";
            }
            else if (String.IsNullOrEmpty(MaCongTy))
            {
                ViewData["Loi5"] = "Mã công ty không được bỏ trống!";
            }
            else if (String.IsNullOrEmpty(TenNV))
            {
                ViewData["Loi6"] = "Tên khách hàng không được bỏ trống!";
            }
            else if (String.IsNullOrEmpty(DiaChiNV))
            {
                ViewData["Loi7"] = "Địa chỉ khách hàng không được bỏ trống!";
            }
            else if (String.IsNullOrEmpty(SDTNV))
            {
                ViewData["Loi8"] = "SĐT khách hàng không được bỏ trống!";
            }
            else if (String.IsNullOrEmpty(ChucVu))
            {
                ViewData["Loi9"] = "Chức vụ không được bỏ trống!";
            }



            HOPDONG hopdong = new HOPDONG();

            hopdong.MaHD     = model.MaHD;
            hopdong.NgayLap  = model.NgayLap;
            hopdong.TienCoc  = model.TienCoc;
            hopdong.MaCongTy = model.MaCongTy;
            db.HOPDONGs.Add(hopdong);

            int mahd = hopdong.MaHD;

            CHITIETHOPDONG cthd = new CHITIETHOPDONG();

            cthd.MaHD         = model.MaHD;
            cthd.MaPHG        = model.MaPHG;
            cthd.ThoiGianThue = model.ThoiGianThue;
            db.CHITIETHOPDONGs.Add(cthd);

            NHANVIEN nv = new NHANVIEN();

            nv.MaPHG    = model.MaPHG;
            nv.MaCongTy = model.MaCongTy;
            nv.TenNV    = model.TenNV;
            nv.DiaChiNV = model.DiaChiNV;
            nv.SDTNV    = model.SDTNV;
            nv.ChucVu   = model.ChucVu;
            db.NHANVIENs.Add(nv);

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }