//ok private void bt_save_Click(object sender, EventArgs e) { NHANVIEN nv = new NHANVIEN(); NhanVienBus nvBus = new NhanVienBus(); nv.MANV = Int32.Parse(txt_manv.Text); nv.NGAYSINH = txt_ngaysinh.Value; if (rd_nam.Checked == true) { nv.PHAI = "Nam"; } else { nv.PHAI = "Nu"; } if (!string.IsNullOrEmpty(txt_DiaChi.Text)) { nv.QUEQUAN = txt_DiaChi.Text; } if (!string.IsNullOrEmpty(txt_Sdt.Text)) { nv.SDT = txt_Sdt.Text; } nv.TENNV = txt_hoten.Text; if (!String.IsNullOrEmpty(txt_CMND.Text)) { nv.CMT = txt_CMND.Text; } nv.NGAYVAOLAM = txt_ngayLam.Value; ChucVuBus cvbus = new ChucVuBus(); nv.MACV = cvbus.GetCVbyName(cb_loaiNV.Text).MACV; try { if (!string.IsNullOrEmpty(nv.CMT) && !string.IsNullOrEmpty(nv.QUEQUAN) && !string.IsNullOrEmpty(nv.SDT) && !string.IsNullOrEmpty(nv.TENNV)) { if (nvBus.editNV(nv)) { MessageBox.Show("Edit successted !"); loadDSNhanVien(); } else { MessageBox.Show("Edit not successted !"); } resettext(); } else { MessageBox.Show("Điền đầy đủ thông tin trước khi cập nhật nhân viên !"); } } catch (Exception ex) { MessageBox.Show("Edit not successted !"); } }
public void loadCbBx() { ChucVuBus cvBus = new ChucVuBus(); int a = cvBus.DSCHUCVU().Count; for (int i = 0; i < a; i++) { CHUCVU cv = new CHUCVU(); cv = cvBus.DSCHUCVU()[i]; cb_loaiNV.Items.Add(cv); } cb_loaiNV.DisplayMember = "TENCV"; cb_loaiNV.ValueMember = "MACV"; }
private void frmThemNhanSu_Load(object sender, EventArgs e) { PhongBanBus pb = new PhongBanBus(); cboPhongBan.DataSource = pb.HienThi(""); cboPhongBan.DisplayMember = "TenPB"; cboPhongBan.ValueMember = "MaPB"; ChucVuBus cv = new ChucVuBus(); cboChucVu.DataSource = cv.HienThi(""); cboChucVu.DisplayMember = "TenChucVu"; cboChucVu.ValueMember = "MaChucVu"; ChuyenMonBus cm = new ChuyenMonBus(); cboChuyenMon.DataSource = cm.HienThi(""); cboChuyenMon.DisplayMember = "TenChuyenMon"; cboChuyenMon.ValueMember = "MaChuyenMon"; }
//ok private void tbl_NhanVien_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { ResetMouseEventArgs(); bt_them.Visible = false; ChucVuBus cvbus = new ChucVuBus(); txt_manv.Text = tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[0].Value.ToString(); //!=null? tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[0].Value.ToString():""; txt_hoten.Text = tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[1].Value.ToString(); // != null ? tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[1].Value.ToString() : ""; txt_Sdt.Text = tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[2].Value.ToString(); //!= null ? tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[2].Value.ToString() : ""; txt_DiaChi.Text = tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[3].Value.ToString(); //!= null ? tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[3].Value.ToString() : ""; string phai = tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[4].Value.ToString(); // != null ? tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[4].Value.ToString() : ""; if (phai == "Nam") { rd_nam.Checked = true; } else { rd_nu.Checked = true; } txt_CMND.Text = tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[5].Value.ToString(); // != null ? tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[5].Value.ToString() : "123456789"; txt_ngaysinh.Value = (DateTime)(tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[6].Value); // != null ? (DateTime)(tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[6].Value) : DateTime.Parse("12/31/1998"); txt_ngayLam.Value = (DateTime)(tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[7].Value); // != null ? (DateTime)(tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[7].Value) : DateTime.Now; string tenCV = cvbus.CHUCVUByID(tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[8].Value.ToString()).TENCV; //!= null ? cvbus.CHUCVUByID(tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[8].Value.ToString()).TENCV : "NVTV"; cb_loaiNV.ResetText(); cb_loaiNV.SelectedText = tenCV; string macv = cvbus.GetCVbyName(cb_loaiNV.Text).MACV; if (macv.Equals("AD") || macv.Equals("NVBH")) { AccountBus acBus = new AccountBus(); txt_user.Text = acBus.ACCOUNTByID(Int32.Parse(txt_manv.Text)).USERNAME; visiable_user(true); visiable_pass(false); } Enable(true); }
//ok private void bt_them_Click(object sender, EventArgs e) { NHANVIEN nv = new NHANVIEN(); NhanVienBus nvBus = new NhanVienBus(); ACCOUNT ac = new ACCOUNT(); AccountBus acBus = new AccountBus(); if (!string.IsNullOrEmpty(txt_manv.Text)) { nv.MANV = Int32.Parse(txt_manv.Text); } if (rd_nam.Checked == true) { nv.PHAI = "Nam"; } else { nv.PHAI = "Nu"; } if (!string.IsNullOrEmpty(txt_DiaChi.Text)) { nv.QUEQUAN = txt_DiaChi.Text; } nv.NGAYVAOLAM = txt_ngayLam.Value; ChucVuBus cvbus = new ChucVuBus(); nv.MACV = cvbus.GetCVbyName(cb_loaiNV.Text).MACV; if (!string.IsNullOrEmpty(txt_Sdt.Text)) { nv.SDT = txt_Sdt.Text; } if (!string.IsNullOrEmpty(txt_hoten.Text)) { nv.TENNV = txt_hoten.Text; } if (!string.IsNullOrEmpty(txt_CMND.Text)) { nv.CMT = txt_CMND.Text; } nv.NGAYSINH = txt_ngaysinh.Value; if (!string.IsNullOrEmpty(txt_user.Text)) { ac.ID = nv.MANV; ac.USERNAME = txt_user.Text; ac.PASS = txt_pass.Text; if (!string.IsNullOrEmpty(nv.CMT) && !string.IsNullOrEmpty(nv.QUEQUAN) && !string.IsNullOrEmpty(nv.SDT) && !string.IsNullOrEmpty(nv.TENNV)) { if (nvBus.add(nv, ac)) { MessageBox.Show("Add successted !"); resettext(); visiable_pass(false); loadDSNhanVien(); } else { MessageBox.Show("Add not successted !"); } } else { MessageBox.Show("Điền đầy đủ thông tin trước khi thêm nhân viên !"); return; } } else { if (nvBus.AddNV(nv)) { MessageBox.Show("Add successted !"); loadDSNhanVien(); resettext(); visiable_pass(false); return; } else { MessageBox.Show("Add not successted !"); } } }