private void btnSua_Click(object sender, EventArgs e) { thongTinUpdate.hoTenDD = txtTenNguoiKy.Text.Trim(); thongTinUpdate.namThucHien = datetimeNamThucHien.Value; thongTinUpdate.ngayHieuLuc = dateTimeNgayHieuLuc.Value; thongTinUpdate.ngayKyQD = dateTimeNgayKy.Value; thongTinUpdate.noiDung = txtNoiDung.Text.Trim(); thongTinUpdate.soQuyetDinh = txtSoQuyetDinh.Text.Trim(); thongTinUpdate.viTriCu = txtViTriCu.Text.Trim(); thongTinUpdate.viTriMoi = txtViTriMoi.Text.Trim(); if (thongTinServices.UpdateThongTin(thongTinUpdate)) { MessageBox.Show("Đã Sửa Thông Tin Thành Công!", "Thông Báo", MessageBoxButtons.OK); InitGridView(); dataGridThongTin.Refresh(); txtHoTen.ReadOnly = false; txtMaNv.ReadOnly = false; ClearAllText(this); txtNoiDung.Text = loaiThongTin; thongTinUpdate = null; btnSua.Enabled = false; btnThem.Enabled = true; } else { MessageBox.Show("Lỗi! Vui Lòng Kiểm Tra Lại Thông Tin Đầu Vào!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void InitThoiViec(TD_DD_BN_TV thongTin) { if (thongTin != null) { lblNamTV.Text = thongTin.namThucHien.ToString("yyyy"); lblSoQDTV.Text = thongTin.soQuyetDinh; lblNgayHieuLucTV.Text = Convert.ToDateTime(thongTin.ngayHieuLuc).ToString("dd/MM/yyyy"); } else { lblNamTV.Text = "Chưa Cập Nhật"; lblSoQDTV.Text = "Chưa Cập Nhật"; lblNgayHieuLucTV.Text = "Chưa Cập Nhật"; } }
private void InitDieuDong(TD_DD_BN_TV thongTin) { if (thongTin != null) { lblNamDD.Text = thongTin.namThucHien.ToString("yyyy"); lblViTriCuDD.Text = thongTin.viTriCu; lblViTriMoiDD.Text = thongTin.viTriMoi; lblSoQDDD.Text = thongTin.soQuyetDinh; lblNgayHieuLucDD.Text = Convert.ToDateTime(thongTin.ngayHieuLuc).ToString("dd/MM/yyyy"); } else { lblNamDD.Text = "Chưa Cập Nhật"; lblViTriCuDD.Text = "Chưa Cập Nhật"; lblViTriMoiDD.Text = "Chưa Cập Nhật"; lblSoQDDD.Text = "Chưa Cập Nhật"; lblNgayHieuLucDD.Text = "Chưa Cập Nhật"; } }
private void dataGridThongTin_CellClick(object sender, DataGridViewCellEventArgs e) { thongTinUpdate = thongTinServices.GetThongTinById(Convert.ToInt32(dataGridThongTin.CurrentRow.Cells[0].Value.ToString())); txtMaNv.Text = thongTinUpdate.ThongTinNhanVIen.MaNV; txtHoTen.Text = thongTinUpdate.ThongTinNhanVIen.hoTen; txtHoTen.ReadOnly = true; txtMaNv.ReadOnly = true; txtNoiDung.Text = thongTinUpdate.noiDung; txtTenNguoiKy.Text = thongTinUpdate.hoTenDD; txtSoQuyetDinh.Text = thongTinUpdate.soQuyetDinh; datetimeNamThucHien.Value = thongTinUpdate.namThucHien; dateTimeNgayHieuLuc.Value = Convert.ToDateTime(thongTinUpdate.ngayHieuLuc); dateTimeNgayKy.Value = Convert.ToDateTime(thongTinUpdate.ngayKyQD); txtViTriCu.Text = thongTinUpdate.viTriCu; txtViTriMoi.Text = thongTinUpdate.viTriMoi; txtDienLaoDong.Text = thongTinUpdate.dienLaoDong; txtDienHuongLuong.Text = thongTinUpdate.dienHuongLuong; txtGhiChu.Text = thongTinUpdate.ghiChu; btnThem.Enabled = false; btnSua.Enabled = true; }
private void btnThem_Click(object sender, EventArgs e) { string maNV = txtMaNv.Text.Trim(); var emp = nhanVienServices.GetEmpByMaNV(maNV); if (emp != null) { TD_DD_BN_TV thongTin = new TD_DD_BN_TV { idNhanVien = emp.idNhanVien, hoTenDD = txtTenNguoiKy.Text.Trim(), noiDung = txtNoiDung.Text.Trim(), namThucHien = datetimeNamThucHien.Value, viTriCu = txtViTriCu.Text.Trim(), viTriMoi = txtViTriMoi.Text.Trim(), dienLaoDong = txtDienLaoDong.Text.Trim(), dienHuongLuong = txtDienHuongLuong.Text.Trim(), soQuyetDinh = txtSoQuyetDinh.Text.Trim(), ngayKyQD = dateTimeNgayKy.Value, ngayHieuLuc = dateTimeNgayHieuLuc.Value, ghiChu = txtGhiChu.Text }; if (thongTinServices.AddThongTin(thongTin)) { MessageBox.Show("Đã Thêm Thành Công!", "Thông Báo!", MessageBoxButtons.OK); ClearAllText(this); InitGridView(); dataGridThongTin.Refresh(); } else { MessageBox.Show("Vui Lòng Kiểm Tra Lại Thông Tin Nhập Vào!", "Lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Không Tồn Tại Mã Nhân Viên Trong Dữ Liệu!", "Lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }