private void btnSearchEmployee_Click(object sender, EventArgs e) { if (!filledValues()) { //MessageBox.Show("Complete la información"); } else { Cursor.Current = Cursors.WaitCursor; //dgvEmployee.Rows.Clear(); serviceDAA = new DBControllerWSClient(); empleado = (serviceDAA.queryEmployeeByDNI(txtDNI.Text)); Cursor.Current = Cursors.Arrow; if (empleado.idEmployee != null) { ModifyEmployeeForm modifyEmployeeForm = new ModifyEmployeeForm(); modifyEmployeeForm.currentEmployee = new employee(); //employee e1 = new employee(); serviceDAA = new DBControllerWSClient(); //e1 = serviceDAA.queryEmployeeByDNI(dgvEmployee.Rows[i].Cells[0].Value.ToString()); modifyEmployeeForm.currentEmployee = empleado; modifyEmployeeForm.SetParent(this); modifyEmployeeForm.ShowDialog(); updateDataGridView(); } else { MessageBox.Show("Empleado no encontrado"); } //dgvEmployee.Rows.Add(new String[] { //empleado.dni,empleado.name,empleado.lastName,empleado.phone,empleado.email,empleado.role }); } }
private bool filledValues() { if (txtEmployeeDNI.Text == "" || txtEmployeeDNI.Text.Length < 8) { MessageBox.Show("Ingrese un DNI válido"); return(false); } if (txtEmployeeDNI.Text.Length == 8) { int result = 0; if (!int.TryParse(txtEmployeeDNI.Text, out result)) { MessageBox.Show("Ha ingresado caracteres no numericos en el campo DNI, porfavor ingresar 8 dígitos "); return(false); } } if (txtEmployeeName.Text == "" || txtEmployeeName.Text.Length < 2) { MessageBox.Show("Ingrese un nombre válido"); return(false); } if (txtEmployeeFirstLastName.Text == "" || txtEmployeeFirstLastName.Text.Length < 2) { MessageBox.Show("Ingrese un apellido paterno válido"); return(false); } if (txtEmployeeSecondLastName.Text == "" || txtEmployeeSecondLastName.Text.Length < 2) { MessageBox.Show("Ingrese un apellido materno válido"); return(false); } if (txtEmployeePhone.Text == "" || txtEmployeePhone.Text.Length < 3) { MessageBox.Show("Ingrese un teléfono válido"); return(false); } if (txtEmployeePhone.Text.Length >= 3) { int result = 0; if (!Regex.Match(txtEmployeePhone.Text, @"([0-9]{3,})").Success) { MessageBox.Show("Ha ingresado caracteres no numericos en el campo Telefono, ingrese de 3 a 15 digitos"); return(false); } } if (txtEmployeeEmail.Text == "" || !txtEmployeeEmail.Text.Contains("@")) { MessageBox.Show("Ingrese un correo válido"); return(false); } if (dtpEmployeeBorn.Value.Date > DateTime.Now) { MessageBox.Show("Ingrese una fecha válida de nacimiento"); return(false); } if (dtpEmployeeStartDate.Value.Date > dtpEmployeeEndDate.Value.Date) { MessageBox.Show("Ingrese fechas de contratos válidas"); return(false); } if (cbArea.Text == "") { MessageBox.Show("Ingrese el área del empleado"); return(false); } if (cbRole.Text == "") { MessageBox.Show("Ingrese el cargo del empleado"); return(false); } Cursor.Current = Cursors.WaitCursor; serviceDA = new DBControllerWSClient(); employee c = serviceDA.queryEmployeeByDNI(txtEmployeeDNI.Text); Cursor.Current = Cursors.Arrow; if (c.email != null) { MessageBox.Show("Ya existe un empleado con ese DNI"); return(false); } return(true); }