private void but_CreateJobtitle_Click(object sender, EventArgs e) { ChucVuDto _cvdDTO = new ChucVuDto(); _cvdDTO.TenChucVu = txt_JobtitleName.Text; _cvdDTO.TrangThai = true; NhanVienBus _nvBUS = new NhanVienBus(); string _qgdMessage = string.Empty; if (!_nvBUS.CreateJobtitle(_cvdDTO, out _qgdMessage)) { MessageBox.Show(_qgdMessage, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult dialogResult = MessageBox.Show(_qgdMessage + "\nBạn có tiếp tục tạo chức vụ", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { txt_JobtitleName.Text = ""; } else if (dialogResult == DialogResult.No) { RenderForm(); HideControlSupportJobtitle(); but_CreateStaff.Enabled = true; but_CreatePermission.Enabled = false; but_CreatePaymentStore.Enabled = false; but_CreateJobtitle.Enabled = false; this.ClientSize = new System.Drawing.Size(500, 240); } } }
private void txtLuu_Click(object sender, EventArgs e) { if (txtTenNv.Text.Length == 0) { errTenNV.SetError(txtTenNv, "Không được để trống"); } else { errTenNV.SetError(txtTenNv, ""); } if (errTenNV.GetError(txtTenNv).Length == 0) { nv.TenNV = txtTenNv.Text; nv.MoTaKhac = txtMoTa.Text ?? ""; nv.DienThoaiLH = txtDT.Text ?? ""; if (NhanVienBus.UpdateNhanVien(nv)) { MessageBox.Show("Cập nhật thánh công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); _frmNV.data = NhanVienBus.GetListNhanVien(); _frmNV.dgvNhanVien.DataSource = _frmNV.data; this.Close(); } else { MessageBox.Show("Cập nhật thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
// Ok ! private void bt_Xoa_Click(object sender, EventArgs e) { NhanVienBus nvBus = new NhanVienBus(); int manv = Int32.Parse(tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[0].Value.ToString()); if (manv != 3114100) { if (DialogResult.Yes == MessageBox.Show("Bạn Muốn xóa nhân viên ?" + tbl_NhanVien.Rows[tbl_NhanVien.CurrentCell.RowIndex].Cells[1].Value.ToString(), "Comfirm", MessageBoxButtons.YesNo)) { if (nvBus.deleteNV(manv)) { MessageBox.Show("Delete Successed !"); } else { MessageBox.Show("Delete not Successed !"); return; } } resettext(); tbl_NhanVien.ClearSelection(); loadDSNhanVien(); } else { MessageBox.Show("Không thể xoá chính bạn !"); return; } }
private void RenderForm() { List <PaymentStoreResult> lstPaymentStore = new List <PaymentStoreResult>(); lstPaymentStore = QuayGiaoDichBUS.getDataSourcePaymentCombo(); gridLook_PaymentStore.Properties.DataSource = lstPaymentStore; gridLook_PaymentStore.Properties.DisplayMember = "PaymentStoreName"; gridLook_PaymentStore.Properties.ValueMember = "PaymentStoreCode"; List <PermissionResult> lstPermission = new List <PermissionResult>(); lstPermission = NhomTaiKhoanBus.Instance.GetAllPermission(); gridLook_Permission.Properties.DataSource = lstPermission; gridLook_Permission.Properties.DisplayMember = "PermissionName"; gridLook_Permission.Properties.ValueMember = "PermissionCode"; List <GenderResult> lstGender = new List <GenderResult>(); lstGender = NhomTaiKhoanBus.Instance.GetAllGender(); cbo_StaffGender.Properties.DataSource = lstGender; cbo_StaffGender.Properties.DisplayMember = "GenderName"; cbo_StaffGender.Properties.ValueMember = "GenderCode"; List <ChucVuDto> lstJobtitle = new List <ChucVuDto>(); NhanVienBus _nvBUS = new NhanVienBus(); lstJobtitle = _nvBUS.GetAllJobtitle(); cbo_StaffJobtitle.Properties.DataSource = lstJobtitle; cbo_StaffJobtitle.Properties.DisplayMember = "TenChucVu"; cbo_StaffJobtitle.Properties.ValueMember = "MaChucVu"; }
//Main function private void Search() { string _tenNhanVien = txt_StaffName.Text; string _email = txt_StaffEmail.Text; bool _gender = cbo_StaffGender.EditValue != null?Convert.ToBoolean(cbo_StaffGender.EditValue) : false; DateTime _birthday = DateTime.ParseExact(dtm_StaffBirthday.DateTime.ToString("yyyy-MM-dd"), "yyyy-MM-dd", CultureInfo.InvariantCulture); DateTime _birthdayT = DateTime.ParseExact(dtm_StaffBirthdayT.DateTime.ToString("yyyy-MM-dd"), "yyyy-MM-dd", CultureInfo.InvariantCulture); string _phoneNumber = txt_StaffPhoneNumber.Text; int _quayGiaoDich = int.TryParse(cbo_PaymentStore.EditValue.ToString(), out _quayGiaoDich) ? _quayGiaoDich : 0; NhanVienBus _nv_BUS = new NhanVienBus(); List <StaffManager_DTO> _lstStaffManager = new List <StaffManager_DTO>(); _lstStaffManager = _nv_BUS.ReadListStaff(_tenNhanVien, _email, _gender, _birthday, _birthdayT, _phoneNumber, _quayGiaoDich); if (_lstStaffManager == null) { MessageBox.Show("Không tìm thấy nhân viên nào thõa điều kiện tìm kiếm!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Tìm thấy " + _lstStaffManager.Count.ToString() + " kết quả", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); gridControl_StaffInfo.DataSource = _lstStaffManager; BindingGrid(); } }
//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 !"); } }
private void LoadThongTinNhanVien() { NhanVienBus nv = new NhanVienBus(); DataTable dt = nv.LayTenPBTheoNV(MaNVien); txtMaNV.Text = dt.Rows[0][0].ToString(); txtTen.Text = dt.Rows[0][1].ToString(); txtPhongBan.Text = dt.Rows[0][2].ToString(); txtChucVu.Text = dt.Rows[0][3].ToString(); }
private void frm_ThongTin_Load(object sender, EventArgs e) { _loginTaiKhoan = getDataChangePasswordFormFromMainForm(); NhanVienDto _nvDTO = new NhanVienDto(); NhanVienBus _nvBUS = new NhanVienBus(); _nvDTO = _nvBUS.ReadStaff(_loginTaiKhoan.MaNhanVien); txt_HoTen.Text = _nvDTO.TenNhanVien; txt_MaNhanVien.Text = _nvDTO.MaNV.ToString(); txt_ChucVu.Text = _nvDTO.ChucVu.ToString(); txt_NgaySinh.Text = _nvDTO.NgaySinh.ToString("dd/MM/yyyy hh:mm:ss"); txt_Email.Text = _nvDTO.Email; txt_DiaChi.Text = _nvDTO.DiaChi; }
private void but_StaffUpdate_Click(object sender, EventArgs e) { string Message = string.Empty; if (!isValidateUpdateStaff(out Message)) { MessageBox.Show(Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { StaffUpdateModel _staffUpdateInfo = new StaffUpdateModel(); List <StaffUpdateModel> _lstStaffUpdateInfo = new List <StaffUpdateModel>(); for (int i = 0; i < gridView_StaffInfo.SelectedRowsCount; i++) { int handle = Convert.ToInt32(gridView_StaffInfo.GetRowHandle(gridView_StaffInfo.GetSelectedRows()[i])); _staffUpdateInfo.StaffCode = gridView_StaffInfo.GetRowCellValue(handle, "StaffCode") != null?Convert.ToInt32(gridView_StaffInfo.GetRowCellValue(handle, "StaffCode").ToString()) : 0; _staffUpdateInfo.StaffName = gridView_StaffInfo.GetRowCellValue(handle, "StaffName") != null?gridView_StaffInfo.GetRowCellValue(handle, "StaffName").ToString() : ""; _staffUpdateInfo.StaffGender = gridView_StaffInfo.GetRowCellValue(handle, "StaffGender") != null?Convert.ToBoolean(gridView_StaffInfo.GetRowCellValue(handle, "StaffGender").ToString()) : false; _staffUpdateInfo.StaffBirthday = gridView_StaffInfo.GetRowCellValue(handle, "StaffBirthday") != null?Convert.ToDateTime(gridView_StaffInfo.GetRowCellValue(handle, "StaffBirthday").ToString()) : DateTime.Now; _staffUpdateInfo.StaffEmail = gridView_StaffInfo.GetRowCellValue(handle, "StaffEmail") != null?gridView_StaffInfo.GetRowCellValue(handle, "StaffEmail").ToString() : ""; _staffUpdateInfo.StaffPhoneNumber = gridView_StaffInfo.GetRowCellValue(handle, "StaffPhoneNumber") != null?gridView_StaffInfo.GetRowCellValue(handle, "StaffPhoneNumber").ToString() : ""; _staffUpdateInfo.StaffAddress = gridView_StaffInfo.GetRowCellValue(handle, "StaffAddress") != null?gridView_StaffInfo.GetRowCellValue(handle, "StaffAddress").ToString() : ""; _staffUpdateInfo.StaffJobtitle = gridView_StaffInfo.GetRowCellValue(handle, "StaffJobtitle") != null?Convert.ToInt32(gridView_StaffInfo.GetRowCellValue(handle, "StaffJobtitle").ToString()) : 0; _staffUpdateInfo.StaffPaymentStore = gridView_StaffInfo.GetRowCellValue(handle, "StaffPaymentStore") != null?Convert.ToInt32(gridView_StaffInfo.GetRowCellValue(handle, "StaffPaymentStore").ToString()) : 0; _staffUpdateInfo.StaffPermission = gridView_StaffInfo.GetRowCellValue(handle, "StaffPermission") != null?Convert.ToInt32(gridView_StaffInfo.GetRowCellValue(handle, "StaffPermission").ToString()) : 0; _lstStaffUpdateInfo.Add(_staffUpdateInfo); } NhanVienBus _nhaVienBUS = new NhanVienBus(); string updateMessage = string.Empty; if (!_nhaVienBUS.UpdateStaff(_lstStaffUpdateInfo, out updateMessage)) { MessageBox.Show(updateMessage, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(updateMessage, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //Search(); } } }
private void loadDSNhanVien() { NhanVienBus nvBus = new NhanVienBus(); tbl_NhanVien.DataSource = nvBus.DSNhanVien(); //for (int i = 0; i < tbl_NhanVien.Columns.Count; i++) //{ // //if ((tbl_NhanVien.Columns[i].HeaderText == "CHUCVU" && tbl_NhanVien.Columns[8].Visible == true) || // // (tbl_NhanVien.Columns[i].HeaderText == "HOADONs" && tbl_NhanVien.Columns[9].Visible == true) || // // (tbl_NhanVien.Columns[i].HeaderText == "ACCOUNT" && tbl_NhanVien.Columns[10].Visible == true) || // // (tbl_NhanVien.Columns[i].HeaderText == "NHAPKHOes" && tbl_NhanVien.Columns[11].Visible == true)) // //{ // // tbl_NhanVien.Columns.RemoveAt(i); // //} //} }
private void BT_Login_Click(object sender, EventArgs e) { var manv = TB_TenDangNhap.Text; var mk = CalculateMD5Hash(TB_MatKhau.Text); //Console.WriteLine(mk); NhanVienBus nvbus = new NhanVienBus(); if (nvbus.KiemTraTaiKhoan(manv, mk)) { MessageBox.Show("Đã đăng nhập thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } else { MessageBox.Show("Vui lòng kiểm tra lại mã nhân viên và mật khẩu", "Không thể đăng nhập được", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnDelete_Click(object sender, EventArgs e) { var nv = dgvNhanVien.CurrentRow.DataBoundItem as NhanVien; DialogResult result = MessageBox.Show("Bạn có chắc chắn xóa", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { if (NhanVienBus.DeleteNhanVien(nv.MaNV)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); data = NhanVienBus.GetListNhanVien(); dgvNhanVien.DataSource = data; } else { MessageBox.Show("Xóa thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void but_CreateStaff_Click(object sender, EventArgs e) { string out_Message = string.Empty; if (!isValidateCreateForm(out out_Message)) { MessageBox.Show(out_Message, "Lỗi tạo nhân viên", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Get data from form string nameStaff = txt_StaffName.Text; int jobtitleStaff = int.TryParse(cbo_StaffJobtitle.EditValue.ToString(), out jobtitleStaff) ? jobtitleStaff : 0; DateTime birthdayStaff = dtm_StaffBirthday.DateTime; bool genderStaff = bool.TryParse(cbo_StaffGender.EditValue.ToString(), out genderStaff) ? genderStaff : false; int permissionStaff = int.TryParse(gridLook_Permission.EditValue.ToString(), out permissionStaff) ? permissionStaff : 0; int paymentStoreStaff = int.TryParse(gridLook_PaymentStore.EditValue.ToString(), out paymentStoreStaff) ? paymentStoreStaff : 0; string shortNameStaff = Extensions.ConvertToUnSign(Extensions.GetShortName(nameStaff)).ToLower(); string addressStaff = txt_StaffAddress.Text; string emailStaff = txt_StaffEmail.Text; string phoneNumberStaff = txt_StaffPhoneNumber.Text; //Call function create staff string msg_CreateStaff = string.Empty; NhanVienBus _nvBus = new NhanVienBus(); if (!_nvBus.CreateStaffAndAccount(nameStaff, shortNameStaff, genderStaff, birthdayStaff, jobtitleStaff, paymentStoreStaff, permissionStaff, addressStaff, emailStaff, phoneNumberStaff, out msg_CreateStaff)) { MessageBox.Show(msg_CreateStaff, "Lỗi tạo nhân viên", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult dialogResult = MessageBox.Show(msg_CreateStaff + "\nBạn có muốn tạo tiếp nhân viên?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { RefreshForm(); } else { this.Close(); } } } }
private void bt_moi_Click(object sender, EventArgs e) { resettext(); Enable(true); cb_loaiNV.Refresh(); cb_loaiNV.SelectedIndex = 2; tbl_NhanVien.ClearSelection(); NhanVienBus nvBus = new NhanVienBus(); txt_manv.Text = (nvBus.MaNVNow() + 1).ToString(); txt_manv.Enabled = false; txt_ngayLam.Value = DateTime.Now; txt_ngaysinh.Value = DateTime.Parse("12/31/1996"); cb_loaiNV.Focus(); bt_them.Visible = true; bt_Luu.Visible = false; txt_pass.ReadOnly = true; txt_user.ReadOnly = false; visiable_user(false); visiable_pass(false); }
private void ThongTinNv_Load(object sender, EventArgs e) { int id; string name = UserName_infor; AccountBus acbus = new AccountBus(); ACCOUNT ac = new ACCOUNT(); ac = acbus.ACCOUNTByName(name); id = ac.ID; NhanVienBus nvbus = new NhanVienBus(); NHANVIEN nv = new NHANVIEN(); nv = nvbus.NhanVienByID(id); txt_manv.Text = nv.MANV.ToString(); if (nv.PHAI == "Nam") { rd_nam.Checked = true; rd_nu.Enabled = false; } else { rd_nu.Checked = true; rd_nam.Enabled = false; } txt_CMND.Text = nv.CMT; txt_DiaChi.Text = nv.QUEQUAN; txt_hoten.Text = nv.TENNV; txt_NgayLam.Text = nv.NGAYVAOLAM.ToString(); DateTime d = Convert.ToDateTime(txt_NgayLam.Text); txt_NgayLam.Text = d.ToString("MM/dd/yyyy"); txt_ngaysinh.Text = nv.NGAYSINH.ToString(); DateTime dm = Convert.ToDateTime(txt_ngaysinh.Text); txt_ngaysinh.Text = dm.ToString("MM/dd/yyyy"); txt_Sdt.Text = nv.SDT; txt_user.Text = ac.USERNAME; Show_Hide(false); }
private void Them() { NhanVienEntity nv = new NhanVienEntity(); nv.HoTen = txtTen.Text; nv.DiaChi = txtDiaChi.Text; nv.GhiChu = txtGhiChu.Text; nv.MaChucVu = cboChucVu.SelectedValue.ToString(); nv.MaPB = cboPhongBan.SelectedValue.ToString(); nv.MaChuyenMon = cboChuyenMon.SelectedValue.ToString(); nv.NgaySinh = dtNgaySinh.Value.ToString(); if (ckNam.Checked == true) { nv.GioiTinh = "Nam"; } else { nv.GioiTinh = "Nữ"; } NhanVienBus nhanv = new NhanVienBus(); nhanv.Them(nv); }
private void but_DeleteStaff_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { string Message = string.Empty; if (!isValidateDeleteStaff(out Message)) { MessageBox.Show(Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int handle = Convert.ToInt32(gridView_StaffInfo.GetFocusedRowCellValue("StaffCode")); NhanVienBus _nhaVienBUS = new NhanVienBus(); string deleteMessage = string.Empty; if (!_nhaVienBUS.DeleteStaff(handle, out deleteMessage)) { MessageBox.Show(deleteMessage, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(deleteMessage, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Search(); } } }
private void Login() { string l_UserName = txt_UserName.Text.Trim(); string en_Password = string.Empty; if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.userName) && Properties.Settings.Default.passWord == txt_Password.Text) { en_Password = Extensions.DecryptMD5(Properties.Settings.Default.passWord, true); } string l_Password = string.IsNullOrEmpty(en_Password) ? Extensions.EncryptMD5(txt_Password.Text, true).Trim(): Extensions.EncryptMD5(en_Password, true).Trim(); if (string.IsNullOrEmpty(l_UserName) || string.IsNullOrEmpty(l_Password)) { DialogResult dialogResult = MessageBox.Show("Tên đăng nhập hoặc mật khẩu không được trống!!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); if (dialogResult == DialogResult.OK) { if (string.IsNullOrEmpty(l_UserName)) { txt_UserName.Focus(); } if (string.IsNullOrEmpty(l_Password)) { txt_Password.Focus(); } if (string.IsNullOrEmpty(l_UserName) && string.IsNullOrEmpty(l_Password)) { txt_UserName.Focus(); } } } else { try { TaiKhoanBus _tk = new TaiKhoanBus(); var _login = _tk.Login(l_UserName, l_Password); if (_login == null) { DialogResult dialogResult = MessageBox.Show("Không lấy được thông tin đăng nhập!!!", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { if (string.IsNullOrEmpty(l_UserName)) { txt_UserName.Focus(); } if (string.IsNullOrEmpty(l_Password)) { txt_Password.Focus(); } if (string.IsNullOrEmpty(l_UserName) && string.IsNullOrEmpty(l_Password)) { txt_UserName.Focus(); } } else if (dialogResult == DialogResult.No) { Application.Exit(); } } else { _tkDto = _login; NhanVienDto _nvDTO = new NhanVienDto(); NhanVienBus _nvBUS = new NhanVienBus(); _nvDTO = _nvBUS.ReadStaff(_tkDto.MaNhanVien); if (_nvDTO != null) { if (!_nvDTO.DoiMatKhau) { DialogResult dialogResult = MessageBox.Show("Vui lòng đổi mật khẩu cho lần đầu tiên đăng nhập", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { this.Hide(); frm_DoiMatKhau_HeThong _frmChangPass = new frm_DoiMatKhau_HeThong(); _frmChangPass.getDataChangePasswordFormFromLoginForm += delegate { return(_login); };//set data from login form _frmChangPass.Show(); } else if (dialogResult == DialogResult.No) { Application.Exit(); } } else { this.Hide(); if (chkRememberUser.Checked) { if (Properties.Settings.Default.userName != string.Empty) { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.userName = l_UserName; Properties.Settings.Default.passWord = l_Password; Properties.Settings.Default.is_Check = chkRememberUser.Checked; Properties.Settings.Default.Save(); } else { Properties.Settings.Default.userName = l_UserName; Properties.Settings.Default.passWord = l_Password; Properties.Settings.Default.is_Check = chkRememberUser.Checked; Properties.Settings.Default.Save(); } } else { Properties.Settings.Default.Reset(); Properties.Settings.Default.Save(); } frm_main _frmMain = new frm_main(); _frmMain.accountLoginOrchangePasswordDelegate += delegate { return(_login); };//Set data from form login _frmMain.Show(); } } else { DialogResult dialogResult = MessageBox.Show("Vui lòng kiểm tra trạng thái nhân viên", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { if (string.IsNullOrEmpty(l_UserName)) { txt_UserName.Focus(); } if (string.IsNullOrEmpty(l_Password)) { txt_Password.Focus(); } if (string.IsNullOrEmpty(l_UserName) && string.IsNullOrEmpty(l_Password)) { txt_UserName.Focus(); } } else if (dialogResult == DialogResult.No) { Application.Exit(); } } } } catch (Exception ex) { Logger.WriteLogError("Login Login", ex.ToString()); DialogResult dialogResult = MessageBox.Show("Vui lòng kiểm tra trạng thái nhận viên", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }
public FrmNhanVien() { InitializeComponent(); data = NhanVienBus.GetListNhanVien(); dataFilter = data; }
//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 !"); } } }
private void FrmCreateNhanVien_Load(object sender, EventArgs e) { txtMaNV.Text = NhanVienBus.GetMaNVNext().ToString(); }