private void btnThem_Click(object sender, EventArgs e) { try { string gt; if (txtMaNV.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaNV.Focus(); return; } if (txtTenNV.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tên nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenNV.Focus(); return; } if (txtDiaChi.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtDiaChi.Focus(); return; } if (txtDienThoai.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtDienThoai.Focus(); return; } if (string.IsNullOrEmpty(txtLuongThang.Text)) { MessageBox.Show("Bạn phải nhập lương tháng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtLuongThang.Focus(); return; } if (BLL.testNV(txtMaNV.Text)) { MessageBox.Show("Mã nhân viên này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaNV.Focus(); txtMaNV.Text = ""; return; } gt = chkNam.Checked ? "Nam" : "Nữ"; BLL.insertNV(txtTenNV.Text, gt, dtpNgaySinh.Value.Date, txtDiaChi.Text, txtDienThoai.Text, float.Parse(txtLuongThang.Text), cbxChucVu.Text); hienThi(); resetValue(); } catch (FormatException ex) { MessageBox.Show("Lỗi nhập không đúng kiểu " + ex.Message); } }