private void btnAddSub_Click(object sender, EventArgs e) { try { this.chucVu.insert(this.txtMaCV.Text, this.txtTenCV.Text); ShowMessageBox.information("Thêm thành công"); loadTableChucVu();//Load lai bang chuc vu } catch (InsertException CVEx) { ShowMessageBox.erorr(CVEx.Message, "Lỗi"); } catch (Exception ex) { ShowMessageBox.erorr(ex.Message, "Lỗi"); } //Reload table ChucVu loadTableChucVu(); //Remove btnCancelAdd and after that add btnAdd this.btnCancelAdd.Visible = false; this.btnAddSub.Visible = false; //Turn on comeback restartAllBtnFunctuinMain(); }
/* * ________________ EVENT CLICK ________________ */ private void btnSubmit_Click(object sender, EventArgs e) { try { this.adminM.drAdmin = adminM.login(txtUsername.Text, txtPassword.Text); ShowMessageBox.information("Đăng nhập thành công", "Xin chào"); this.Close(); } catch (FindException findEx) { ShowMessageBox.erorr(findEx.Message, "Đăng nhập thất bại"); } }
private void btnSubUpdate_Click(object sender, EventArgs e) { if (inputAllNotEmpty()) //Kiem tra tat ca thong tin nhan vien muon cap nhat da nhap day du { this.AcceptButton = btnSubUpdate; //set acceptButton int maGioiTinh = int.Parse((cbGioTinh.SelectedItem as ComboboxItem).Value.ToString()); string maPB = (cbPhongBan.SelectedItem as ComboboxItem).Value.ToString(); string maCV = (cbChucVu.SelectedItem as ComboboxItem).Value.ToString(); string maTDHV = (cbTrinhDoHocVan.SelectedItem as ComboboxItem).Value.ToString(); int bacLuong = int.Parse((cbLuong.SelectedItem as ComboboxItem).Value.ToString()); string maHD = (cbLoaiHopDong.SelectedItem as ComboboxItem).Value.ToString(); string ngaySinh = dtpNgaySinh.Value.ToString("yyyy-MM-dd");; try { //Insert this.nhanVienM.update(txtMaNV.Text, txtHoTen.Text, txtSDT.Text, maGioiTinh, ngaySinh, txtDanToc.Text, txtQueQuan.Text, txtDiaChi.Text, txtCMND.Text, maPB, maCV, maTDHV, bacLuong, maHD); ShowMessageBox.information("Cập nhật thông tin nhân viên có mã là " + txtMaNV.Text + " thành công", "Thông báo"); //Reset table NhanVien loadTableNhanVien(); //reset all button function main resetAllButton(); //clear clearAllInput(); txtMaNV.Enabled = true; //visible btnSubUpdate.Visible = false; btnCancelUpdate.Visible = false; } catch (InsertException insertEx) { ShowMessageBox.erorr(insertEx.Message); } catch (Exception ex) { ShowMessageBox.erorr(ex.Message); } } else { ShowMessageBox.erorr("ComboBox dữ liệu chưa được bạn chọn \nHoặc còn thiếu một số thông tin", "Lỗi"); } }
private void btnDelete_Click(object sender, EventArgs e) { if (!isTxtEmpty()) { DialogResult result = new DialogResult(); result = MessageBox.Show( "Bạn có chắc chắn muốn xoá Chức Vụ " + txtTenCV.Text + " không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { try { //Thuc thu xoa chuc vu this.chucVu.delete(txtMaCV.Text); //reload table chuc vu loadTableChucVu(); ShowMessageBox.information("Xoá thành công"); clearTxtInput(); } catch (DeleteException cvDelEx) { ShowMessageBox.erorr(cvDelEx.Message); } catch (Exception ex) { ShowMessageBox.erorr(ex.Message); } } } else { MessageBox.Show("Dữ liệu Mã Chức Vụ đang còn trống", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnDelete_Click(object sender, EventArgs e) { if (txtMaNV.Text != string.Empty) { DialogResult result = new DialogResult(); result = MessageBox.Show("Bạn có muốn xoá nhân viên có mã là " + txtMaNV.Text + " không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result != DialogResult.No) { try { nhanVienM.delete(txtMaNV.Text); //Thong bao ShowMessageBox.information("Xoá thông tin của nhân viên thông"); //reload table NhanVien loadTableNhanVien(); //Clear clearAllInput(); } catch (DeleteException delEx) { ShowMessageBox.erorr(delEx.Message); } catch (Exception ex) { ShowMessageBox.erorr(ex.Message); } } } else { ShowMessageBox.erorr("Vui lòng nhập thông tin mã Nhân Viên muốn xoá", "Thông tin thiếu"); } }