private void btCapnhat_Click(object sender, EventArgs e) { DTO.DMHopdong hopdong = new DTO.DMHopdong(); hopdong.Manv = HD.Manv; hopdong.Sohd = sohdTextEdit.Text; hopdong.Loaihd = loaihdTextEdit.Text; hopdong.Ngaykihd = ngaykihdDateEdit.Text; hopdong.Ngayhd = ngayhdDateEdit.Text; hopdong.Ngayhh = ngayhhDateEdit.Text; hopdong.Dieukhoan = dieukhoanTextEdit.Text; hopdong.Kilanthu = combKilanthu.Text; if (clConver.KT(hopdong)) { if (BUS.BUS_DMHopdong.UpdatetHopDong(hopdong) == "true") { MessageBox.Show("Sửa thành công hợp đồng " + HD.Sohd + " cho nhân viên " + hoten + "! ", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); Mygetvalue(); this.Close(); } else { MessageBox.Show("Lỗi update từ hệ thống!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Lỗi update từ hệ thống!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void InsertHD() { DTO.DMHopdong hd = new DTO.DMHopdong(); hd.Sohd = sohdTextEdit.Text; hd.Manv = manv; hd.Loaihd = loaihdTextEdit.Text; hd.Ngaykihd = ngaykihdDateEdit.Text; hd.Ngayhd = ngayhdDateEdit.Text; hd.Ngayhh = ngayhhDateEdit.Text; hd.Kilanthu = combKilanthu.Text; hd.Dieukhoan = dieukhoanTextEdit.Text; if (clConver.KT(hd)) { if (BUS.BUS_DMHopdong.InsertHopDong(hd) == "true") { MessageBox.Show("Thêm hợp đồng thành công cho nhân viên " + hoten + " ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); BUS.BUS_DMHopdong.UpdateSoIdHD(); Mygetstring(); this.Close(); } else { MessageBox.Show("Thêm hợp đồng cho nhân viên " + hoten + " thất bại do hệ thống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { } }
public static bool KT(DTO.DMHopdong hd) { if (hd.Loaihd == "") { MessageBox.Show("Lỗi !!! Bạn vẫn chưa chọn loại hợp đồng", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (hd.Kilanthu == "") { MessageBox.Show("Lỗi !!! Bạn vẫn chưa chọn Lần ký", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (hd.Ngaykihd == "" || hd.Ngayhd == "") { MessageBox.Show("Lỗi !!! bạn chưa chọn ngày hợp đồng hoặc ngày ký", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } DateTime dt = DateTime.Parse(hd.Ngaykihd); if (dt > DateTime.Now) { MessageBox.Show("Lỗi !!! Ngày kí phải nhỏ hơn ngày hiện tại", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (DateTime.Parse(hd.Ngayhd) < DateTime.Parse(hd.Ngaykihd)) { MessageBox.Show("Lỗi !!! Ngày hợp đồng không được nhỏ hơn ngày ký hợp đồng", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { if (BUS.BUS_DMHopdong.NgayHopDong(hd.Ngayhd, hd.Manv, hd.Sohd) == 0) { MessageBox.Show("Lỗi !!! Có 1 hợp đồng của nhân viên " + hd.Manv + " đang còn hiệu lực trong thời gian này", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } return(true); }
public frmSuaHopDong(DTO.DMHopdong HD, string hoten) { this.hoten = hoten; this.HD = HD; InitializeComponent(); }