private void btnThemNV_Click(object sender, EventArgs e) { string errorS = ""; try { NhanVien_DTO nvDTO = new NhanVien_DTO(); if (txtMaNV.Text.Trim() != "") { if (NhanVien_BLL.KiemTraMa(txtMaNV.Text) == 1) { errorS += "Mã nhân viên bị trùng!!\n"; } else { nvDTO.MaNV = txtMaNV.Text; } } else { errorS += "Chưa nhập mã nhân viên!!\n"; } if (txtTenNV.Text.Trim() != "") { nvDTO.TenNhanVien = txtTenNV.Text; } else { errorS += "Chưa nhập tên nhân viên!!\n"; } if (dtpNgaySinh.Text.Trim() != "") { nvDTO.NgaySinh = Convert.ToDateTime(dtpNgaySinh.Text); } else { errorS += "Chưa nhập ngày sinh nhân viên!!\n"; } if (txtDiaChi.Text.Trim() != "") { nvDTO.DiaChi = txtDiaChi.Text; } else { errorS += "Chưa nhập địa chỉ nhân viên!!\n"; } if (txtCMND.Text.Trim() != "") { if (IsNumber(txtCMND.Text) == true) { nvDTO.CMND = txtCMND.Text; } else { errorS += "CMND không hợp lệ!!\n"; } } else { errorS += "Chưa nhập CMND nhân viên!!\n"; } if (rdbNam.Checked) { nvDTO.GioiTinh = "Nam"; } else { nvDTO.GioiTinh = "Nữ"; } if (txtSDT.Text.Trim() != "") { if (IsNumber(txtSDT.Text) == true) { nvDTO.SDT = txtSDT.Text; } else { errorS += "Số điện thoại không hợp lệ!!\n"; } } else { errorS += "Chưa nhập SDT nhân viên!!\n"; } if (cmbMaChucVu.SelectedValue != null) { nvDTO.MaChucVu = (string)cmbMaChucVu.SelectedValue; } else { errorS += "Chưa chọn chức vụ nhân viên!!\n"; } if (errorS != "") { MessageBox.Show(errorS, "Thông báo lỗi"); return; } int check = NhanVien_BLL.ThemNhanVien(nvDTO); if (check > 0) { HienThiDanhSachCacNhanVien(pos); XtraMessageBox.Show("Thêm 1 nhân viên thành công!", "Thông báo"); } else { XtraMessageBox.Show("Thêm 1 nhân viên thất bại!", "Thông báo"); return; } } catch (Exception ex) { XtraMessageBox.Show("Error : " + ex.Message); } }