private bool esValido() { Negocio.Profesores oProfesores = new Negocio.Profesores(); string errores = ""; if (tipoOperacion != General.TipoOperacion.Alta) { if ((txtLegajo.Text == "") || (!oProfesores.ExisteLegajo(Convert.ToInt32(txtLegajo.Text) - 90000))) { errores += "-Nº de legajo incorrecto.\n"; } } if (!((Utilidades.Validaciones.validarNumero(txtNroDoc.Text)) && (txtNroDoc.Text.Length <= 8))) { errores += "-El Nº de documento no es válido.\n"; } if (txtDireccion.Text == "") { errores += "-La dirección no es válida.\n"; } if (txtApellido.Text == "") { errores += "-El apellido no es válido.\n"; } if (txtNombre.Text == "") { errores += "-El nombre no es válido.\n"; } if (!Utilidades.Validaciones.validarEmail(txtEmail.Text)) { errores += "-El email no es válido.\n"; } if (!fechaNacValida) { errores += "-La fecha de nacimiento no es válida.\n"; } if (!fechaInicioValida) { errores += "-La fecha de inicio no es válida.\n"; } if (txtTelefono.Text == "") { errores += "-El teléfono no es válido.\n"; } if (txtCelular.Text == "") { errores += "-El celular no es válido.\n"; } if ((txtUsuario.Text.Length < 5) || (txtUsuario.Text.Length > 30)) { errores += "-El nombre de usuario debe tener entre 5 y 30 caracteres.\n"; } //Verificar si se cambio el nombre de usuario else if ((oProfesores.ExisteNombreUsuario(txtUsuario.Text)) && (this.nombreUsuario != this.txtUsuario.Text)) { errores += "-El nombre de usuario ya existe.\n"; } if (this.tipoOperacion == General.TipoOperacion.Alta) { if (txtContrasenia.Text == txtRepetirContrasenia.Text) { if (txtContrasenia.Text.Length < 5) { errores += "-La contraseña debe tener por lo menos 5 caracteres.\n"; } } else { errores += "-Las contraseñas no coinciden.\n"; } } else { if (!((txtContrasenia.Text == "") && (txtRepetirContrasenia.Text == ""))) { if (txtContrasenia.Text == txtRepetirContrasenia.Text) { if (txtContrasenia.Text.Length < 5) { errores += "-La contraseña debe tener por lo menos 5 caracteres.\n"; } } else { errores += "-Las contraseñas no coinciden.\n"; } } } if (errores == "") { return true; } else { MessageBox.Show(errores, "Error"); return false; } }
private void buscarProfesor() { Negocio.Profesores oProfesores = new Negocio.Profesores(); if ((txtLegajo.Text != "") && (oProfesores.ExisteLegajo(Convert.ToInt32(txtLegajo.Text) - 90000))) { try { Entidades.Profesor oProfesor = oProfesores.RecuperarUno(int.Parse(txtLegajo.Text) - 90000)[0]; cbxTipoDoc.SelectedItem = oProfesor.TipoDoc; txtNroDoc.Text = oProfesor.NroDoc.ToString(); txtApellido.Text = oProfesor.Apellido; txtDireccion.Text = oProfesor.Direccion; txtNombre.Text = oProfesor.Nombre; txtEmail.Text = oProfesor.Email; txtNacimiento.Text = oProfesor.FechaNacimiento.ToShortDateString(); txtTelefono.Text = oProfesor.TelefonoFijo; txtCelular.Text = oProfesor.TelefonoCelular; chbActivo.Checked = oProfesor.Activo; txtTitulo.Text = oProfesor.Titulo; txtFechaInicio.Text = oProfesor.FechaInicio.ToShortDateString(); txtUsuario.Text = oProfesor.usuario.NombreUsuario; this.nombreUsuario = oProfesor.usuario.NombreUsuario; this.fechaNacValida = true; this.fechaInicioValida = true; this.legajo_buscado = txtLegajo.Text; } finally { oProfesores = null; } } else { MessageBox.Show("Legajo incorrecto", "Error"); } }