/////////////////////////////////////////////// /// thêm hợp đồng public bool themhd(String mahd, String tenhd, DateTime ngaythue, DateTime ngaytra, String diadiem, float tienthue, String matx, String maoto, String makh, String manv) { HOPDONG hd = new HOPDONG(); hd.MAHD = mahd; hd.NGAYTHUE = ngaythue; hd.TENHD = tenhd; hd.NGAYTRA = ngaytra; hd.TIENTHUE = tienthue; hd.DIADIEM = diadiem; hd.MAKH_F = makh; hd.MANV_F = manv; hd.MAOTO_F = maoto; hd.MATX_F = matx; db.HOPDONGs.InsertOnSubmit(hd); try { db.SubmitChanges(); } catch { return(false); } return(true); }
public void GiaHanHopDong(NHANVIEN nhanvien) { Global.Ins.isValid = false; if (SelectedLoaiHD == null) { MessageBox.Show("Bạn chưa chọn loại hợp đồng"); return; } if (NgayBD < DateTime.Now) { MessageBox.Show("Không được chọn ngày trước đó"); return; } Global.Ins.deleteHopDong(nhanvien.id); LOAIHOPDONG lhd = Global.Ins.getLHDbyTenLHD(SelectedLoaiHD); HOPDONG hd = new HOPDONG() { id = Global.Ins.autoGenerateHopDong(), MaLoaiHD = lhd.id, MaNV = nhanvien.id, NgayHD = NgayBD, NgayKT = NgayBD.AddMonths(lhd.ThoiHan ?? 0), isDeleted = false, }; DataProvider.Ins.DB.HOPDONGs.Add(hd); DataProvider.Ins.DB.SaveChanges(); Global.Ins.isValid = true; }
public ActionResult Edit([Bind(Include = "MaHD,NgayLap,GiaThoaThuan,MaTram,ThoiHanThue,MaDT,NguoiLap,MoTa,createUser,lastupdateUser,createDate,lastupdateDate,isDeleted")] HOPDONG hOPDONG) { string nguoiLap = Request.Form["nhanVienDropList"].ToString(); string doiTac = Request.Form["doiTacDropList"].ToString(); string tramXe = Request.Form["tramXeDropList"].ToString(); if (ModelState.IsValid) { INhanVienService nhanVienService = new NhanVienService(); NHANVIEN nv = nhanVienService.Detail(Int32.Parse(nguoiLap)); IDoiTacService doiTacService = new DoiTacService(); DOITAC dtac = doiTacService.Detail(Int32.Parse(doiTac)); ITramXeService tramXeService = new TramXeService(); TRAMXE tx = tramXeService.Detail(Int32.Parse(tramXe))[0]; IList <HOPDONG> hd = service.Detail(hOPDONG.MaHD); hd[0].NgayLap = hOPDONG.NgayLap; hd[0].GiaThoaThuan = hOPDONG.GiaThoaThuan; hd[0].MaTram = Int32.Parse(tramXe); hd[0].ThoiHanThue = hOPDONG.ThoiHanThue; hd[0].MaDT = Int32.Parse(doiTac); hd[0].NguoiLap = Int32.Parse(nguoiLap); hd[0].MoTa = hOPDONG.MoTa; hd[0].NHANVIEN = nv; hd[0].DOITAC = dtac; hd[0].TRAMXE = tx; service.Update(hd[0]); return(RedirectToAction("Index")); } return(View(hOPDONG)); }
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)); }
//===========================Thêm mới khách hàng================================== private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (txtMaKH.Text == "" || txtHoten.Text == "" || dtpNamSinh.Value == null || dtpNamSinh.Value == DateTime.Now || txtSDT.Text == "" || txtQueQuan.Text == "" || txtCMND.Text == "") { MessageBox.Show("Vui lòng điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { checkCharMaKhach(); checkCharSDT(); checkCharCMND(); //set cho kí tự đầu tiên của chuỗi tên viết hoa(dùng thư viện System.Globalization để sử dụng) txtHoten.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(txtHoten.Text.ToLower()); txtQueQuan.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(txtQueQuan.Text.ToLower()); string ma = txtMaKH.Text; string hoten = txtHoten.Text; string ngaysinh = dtpNamSinh.Value.ToString(); string sdt = txtSDT.Text; string quenquan = txtQueQuan.Text; string cmnd = txtCMND.Text; string maphong = cbPhong.SelectedValue.ToString(); string tenphong = cbPhong.Text; Khách_hàng khachhang = DB.Khách_hàng.FirstOrDefault(p => p.Mã_KH == ma); if (khachhang != null) { MessageBox.Show("Trùng mã"); } else { try { //Tạo 1 đối tượng mới rồi thêm vào DB Khách_hàng khachhang1 = new Khách_hàng(); khachhang1.Mã_KH = ma; khachhang1.Tên_KH = hoten; khachhang1.Năm_sinh = DateTime.Parse(ngaysinh); khachhang1.Giới_tính = rbtnNam.Checked ? "Nam" : "Nữ"; khachhang1.Sđt = sdt; khachhang1.Quê_quán = quenquan; khachhang1.CMND = cmnd; khachhang1.Mã_phòng = cbPhong.Text; DB.Khách_hàng.Add(khachhang1); HOPDONG hopdong1 = new HOPDONG(); hopdong1.Mã_KH = khachhang1.Mã_KH; hopdong1.Mã_phòng = khachhang1.Mã_phòng; DB.HOPDONGs.Add(hopdong1); DB.SaveChanges();//Lưu lại DB sau khi thêm dgvTrangChu.Rows.Clear(); updateGridView(); MessageBox.Show("Thêm thông tin thành công", "Thông báo"); } catch { MessageBox.Show("Không thể thêm thông tin khách"); } } } }
public void them(HOPDONG k) { k.mahd = k.mahd.ToUpper(); k.manv = k.manv.ToUpper(); k.masv = k.masv.ToUpper(); dshd.InsertOnSubmit(k); tc.capnhat(); }
public ActionResult DeleteConfirmed(int id) { HOPDONG hOPDONG = db.HOPDONGs.Find(id); db.HOPDONGs.Remove(hOPDONG); db.SaveChanges(); return(RedirectToAction("Index")); }
private void btn_xacnhan_Click(object sender, EventArgs e) { DialogResult res; res = MessageBox.Show("Xác nhận trả phòng!", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (res == DialogResult.Yes) { try { int position = gridView_traphong.FocusedRowHandle; string m = gridView_traphong.GetRowCellValue(position, "Makt").ToString(); string n = gridView_traphong.GetRowCellValue(position, "Mahd").ToString(); HOPDONG hd = new HOPDONG(); hd.MAHD = n; hd.TINHTRANG = false; KHACHTHUE kt = new KHACHTHUE(); kt.MAKT = m; kt.TINHTRANG = false; if (hopdong.sua_tinhtrangHopDong(hd) == true) { dal_sm.updatetinhtrangKT(hd.MAHD); grv_traphong.DataSource = traphong.LoadTraPhong(); } else { MessageBox.Show("Thất bại"); } PHONG p = new PHONG(); p.MAPHONG = txt_maphong.Text; p.TINHTRANG = false; p.SOLUONG_HT = 0; if (phong.sua_slhientai(p) == true) { MessageBox.Show(" thành công"); } else { MessageBox.Show("Sữa slht thất bại"); } } catch { MessageBox.Show("Lỗi !!!"); } frm_traphong_Load(sender, e); txt_slhientai.Text = "0"; } else { return; } }
// GET: Student/HOPDONGs/Create public ActionResult Create() { HOPDONG hd = new HOPDONG(); ViewBag.MAPHONG = new SelectList(db.PHONGs, "MAPHONG", "MAKHU"); ViewBag.MASV = new SelectList(db.SINHVIENs, "MASV", "MATKHAU"); return(View()); }
public ActionResult Edit([Bind(Include = "MaHD,NgayLap,GiaThoaThuan,MaTram,ThoiHanThue,MaDT,NguoiLap,MoTa,createUser,lastupdateUser,createDate,lastupdateDate,isDeleted")] HOPDONG hOPDONG) { if (ModelState.IsValid) { db.Entry(hOPDONG).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hOPDONG)); }
public void kiemtra() { foreach (SINHVIEN a in dssv) { HOPDONG hd = tim_hd(a.masv); if (hd == null) { delete(a); } } }
public ActionResult Edit([Bind(Include = "MAHOPDONG,MASV,MAPHONG,NGAYLAP,NGAYBATDAU,NGAYKETTHUC,HIEULUCHD")] HOPDONG hOPDONG) { if (ModelState.IsValid) { db.Entry(hOPDONG).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MAPHONG = new SelectList(db.PHONGs, "MAPHONG", "MAKHU", hOPDONG.MAPHONG); ViewBag.MASV = new SelectList(db.SINHVIENs, "MASV", "MATKHAU", hOPDONG.MASV); return(View(hOPDONG)); }
//Thêm public bool them_HopDong(HOPDONG hd) { //try //{ data.HOPDONGs.InsertOnSubmit(hd); data.SubmitChanges(); return(true); //} //catch //{ // return false; //} }
//===============================================================Sửa khách trọ==================================================================== private void BarButtonItem5_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { if (txtMaKH.Text == "" || txtHoten.Text == "" || dtpNamSinh.Value == null || dtpNamSinh.Value == DateTime.Now || txtSDT.Text == "" || txtQueQuan.Text == "" || txtCMND.Text == "") { MessageBox.Show("Vui lòng điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string ma = txtMaKH.Text; string hoten = txtHoten.Text; string ngaysinh = dtpNamSinh.Value.ToString(); string sdt = txtSDT.Text; string quenquan = txtQueQuan.Text; string cmnd = txtCMND.Text; string maphong = cbPhong.SelectedValue.ToString(); string tenphong = cbPhong.Text; Phòng phong = new Phòng(); maphong = phong.Mã_phòng; tenphong = phong.Mã_phòng; Khách_hàng khachhang = DB.Khách_hàng.FirstOrDefault(p => p.Mã_KH == ma); if (khachhang != null) { //khachhang.Mã_KH = ma; Không được sửa mã vì mã là khóa chính ở DB khachhang.Tên_KH = hoten; khachhang.Năm_sinh = DateTime.Parse(ngaysinh); khachhang.Giới_tính = rbtnNam.Checked ? "Nam" : "Nữ"; khachhang.Sđt = sdt; khachhang.Quê_quán = quenquan; khachhang.CMND = cmnd; khachhang.Mã_phòng = cbPhong.Text; HOPDONG hopdong1 = new HOPDONG(); hopdong1.Mã_KH = khachhang.Mã_KH; hopdong1.Mã_phòng = khachhang.Mã_phòng; DB.SaveChanges(); MessageBox.Show("Đã cập nhật thông tin khách trọ", "Thông báo", MessageBoxButtons.OK); dgvTrangChu.Rows.Clear(); updateGridView(); } else { MessageBox.Show("Không tìm thấy thông tin khách hàng"); } } } catch { MessageBox.Show("Không thể cập nhật thông tin", "Lỗi", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }
// GET: HOPDONGs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HOPDONG hOPDONG = db.HOPDONGs.Find(id); if (hOPDONG == null) { return(HttpNotFound()); } return(View(hOPDONG)); }
public void sua(HOPDONG a) { HOPDONG x = tim(a.mahd); if (x != null) { x.masv = a.masv; x.manv = a.manv; x.ngaybd = a.ngaybd; x.ngaykt = a.ngaykt; tc.capnhat(); } }
//Xóa public bool xoa_HopDong(string pMaHD) { try { HOPDONG hd = data.HOPDONGs.Where(t => t.MAHD == pMaHD).FirstOrDefault(); data.HOPDONGs.DeleteOnSubmit(hd); data.SubmitChanges(); return(true); } catch { return(false); } }
private void CommandBinding_Executed_themHD(object sender, ExecutedRoutedEventArgs e) { NHANVIEN nv = (NHANVIEN)cmbManv.SelectedItem; HOPDONG hd = new HOPDONG(); hd.mahd = txtMahd.Text; hd.masv = txtMasv.Text; hd.manv = nv.manv; hd.ngaybd = dpNgaybatdau.SelectedDate; hd.ngaykt = dpNgayketthuc.SelectedDate; xl.them(hd); dgHopdong.ItemsSource = xl.getDSHopdong(); }
/// xóa hợp đồng public bool xoahd(String mahd) { HOPDONG hd = db.HOPDONGs.Where(h => h.MAHD == mahd).FirstOrDefault(); db.HOPDONGs.DeleteOnSubmit(hd); try { db.SubmitChanges(); } catch { return(false); } return(true); }
public ActionResult Suahopdong(int id) { HOPDONG hopdong = db.HOPDONGs.SingleOrDefault(n => n.MaHD == id); if (hopdong == null) { Response.StatusCode = 404; return(null); } ViewBag.NgayLap = new SelectList(db.HOPDONGs.ToList().OrderBy(n => n.NgayLap), "NgayLap", "NgayLap"); ViewBag.TienCoc = new SelectList(db.HOPDONGs.ToList().OrderBy(n => n.TienCoc), "TienCoc", "TienCoc"); return(View(hopdong)); }
public ActionResult Suahopdong(HOPDONG hopdong) { ViewBag.NgayLap = new SelectList(db.HOPDONGs.ToList().OrderBy(n => n.NgayLap), "NgayLap", "NgayLap"); ViewBag.TienCoc = new SelectList(db.HOPDONGs.ToList().OrderBy(n => n.TienCoc), "TienCoc", "TienCoc"); if (ModelState.IsValid) { HOPDONG hd = db.HOPDONGs.Where(x => x.MaHD == hopdong.MaHD).Single <HOPDONG>(); hd.NgayLap = hopdong.NgayLap; hd.TienCoc = hopdong.TienCoc; db.SaveChanges(); } return(RedirectToAction("Index")); }
private void AddTenancy() { string listIDservice = getIDservice(); connectDBEntity mod1 = new connectDBEntity(); var Tenancy = new HOPDONG { MaHopDong = txtTenacyID.Text, MaPhong = cboRoomName.SelectedValue.ToString(), MaNhanVien = txtIDofStaff.Text, MaDichVu = listIDservice, MaKhachHang = txtIDofCus.Text }; mod1.HOPDONG.Add(Tenancy); mod1.SaveChanges(); }
// GET: Admin/HOPDONGs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HOPDONG hOPDONG = db.HOPDONGs.Find(id); if (hOPDONG == null) { return(HttpNotFound()); } ViewBag.MAPHONG = new SelectList(db.PHONGs, "MAPHONG", "MAKHU", hOPDONG.MAPHONG); ViewBag.MASV = new SelectList(db.SINHVIENs, "MASV", "MATKHAU", hOPDONG.MASV); return(View(hOPDONG)); }
public ActionResult Create([Bind(Include = "MaHD,NgayLap,GiaThoaThuan,MaTram,ThoiHanThue,MaDT,NguoiLap,MoTa,createUser,lastupdateUser,createDate,lastupdateDate,isDeleted")] HOPDONG hOPDONG) { string nguoiLap = Request.Form["nhanVienDropList"].ToString(); string doiTac = Request.Form["doiTacDropList"].ToString(); string tramXe = Request.Form["tramXeDropList"].ToString(); if (ModelState.IsValid) { hOPDONG.isDeleted = 0; hOPDONG.NguoiLap = Int32.Parse(nguoiLap); hOPDONG.MaDT = Int32.Parse(doiTac); hOPDONG.MaTram = Int32.Parse(tramXe); service.Add(hOPDONG); return(RedirectToAction("Index")); } return(View(hOPDONG)); }
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)); }
public bool suahopdong(HOPDONG phd) { try { HOPDONG nv = data.HOPDONGs.Where(t => t.MAHD == phd.MAHD).FirstOrDefault(); if (nv != null) { nv.TINHTRANG = phd.TINHTRANG; data.SubmitChanges(); } return(true); } catch { return(false); } }
public bool sua_TinhtrangHopDong(HOPDONG pHopDong) { try { HOPDONG hd = data.HOPDONGs.Where(t => t.MAHD == pHopDong.MAHD).FirstOrDefault(); if (hd != null) { hd.TINHTRANG = pHopDong.TINHTRANG; data.SubmitChanges(); } return(true); } catch { return(false); } }
//Sửa public bool sua_HopDong(HOPDONG pHopDong) { try { HOPDONG hd = data.HOPDONGs.Where(t => t.MAHD == pHopDong.MAHD).FirstOrDefault(); if (hd != null) { hd.TIENCOC = pHopDong.TIENCOC; hd.NGAYTRA = pHopDong.NGAYTRA; data.SubmitChanges(); } return(true); } catch { return(false); } }
public void Delete(HOPDONG hd) { var user = HttpContext.Current.Session[GlobalConstant.USER]; if (user != null) { NHANVIEN currentUser = (NHANVIEN)user; hd.lastupdateUser = currentUser.MaNV; } DateTime current = DateTime.Now; hd.lastupdateDate = current; using (QLXeKhachEntities context = new QLXeKhachEntities()) { context.Entry(hd).State = EntityState.Modified; context.SaveChanges(); } }
public bool suatinhtranghopdong(HOPDONG kt) { try { HOPDONG hd = data.HOPDONGs.Where(t => t.MAHD == kt.MAHD).FirstOrDefault(); if (hd != null) { //hd.SOLAN = pvipham.SOLAN; hd.TINHTRANG = kt.TINHTRANG; data.SubmitChanges(); } return(true); } catch { return(false); } }