private bool Validar()
        {
            MyErrorProvider.Clear();
            RepositorioBase <Estudiantes> Repositorio = new RepositorioBase <Estudiantes>();
            Estudiantes Estudiante = Repositorio.Buscar(Convert.ToInt32(EstudianteIdNumericUpDown.Value));
            bool        paso       = true;

            if (FechaDeInscripcionDateTimePicker.Value > DateTime.Now)
            {
                MyErrorProvider.SetError(FechaDeInscripcionDateTimePicker, "La fecha de inscripcion no puede ser mayor a la fecha de hoy");
                FechaDeInscripcionDateTimePicker.Focus();
                paso = false;
            }

            if (EstudianteIdNumericUpDown.Value == 0 || NombreTextBox.Text == string.Empty)
            {
                MyErrorProvider.SetError(EstudianteIdNumericUpDown, "Debe seleccionar un estudiante");
                EstudianteIdNumericUpDown.Focus();
                paso = false;
            }

            if (Estudiante == null || Estudiante.Nombre != NombreTextBox.Text)
            {
                MyErrorProvider.SetError(CargarEstudianteButton, "Debe cargar un estudiante");
                CargarEstudianteButton.Focus();
                paso = false;
            }


            if (PrecioCreditosNumericUpDown.Value < 1 || PrecioCreditosNumericUpDown.Value > 5000)
            {
                MyErrorProvider.SetError(PrecioCreditosNumericUpDown, "El precio de los creditos debe estar entre 1 y 5,000");
                PrecioCreditosNumericUpDown.Focus();
                paso = false;
            }
            if (this.Detalle.Count == 0)
            {
                MyErrorProvider.SetError(DetalleDataGridView, "Debe agregar alguna asignatura!!!");
                AsignaturaIdNumericUpDown.Focus();
                paso = false;
            }
            return(paso);
        }
Ejemplo n.º 2
0
        private void EliminarButton_Click(object sender, EventArgs e)
        {
            MyErrorProvider.Clear();
            int id;

            int.TryParse(EstudianteIdNumericUpDown.Text, out id);

            RepositorioBase <Estudiante> repositorio = new RepositorioBase <Estudiante>();

            Limpiar();

            if (repositorio.Buscar(id) != null)
            {
                if (repositorio.Eliminar(id))
                {
                    MessageBox.Show("Eliminado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MyErrorProvider.SetError(EstudianteIdNumericUpDown, "No se puede eliminar un registro que no existe");
                EstudianteIdNumericUpDown.Focus();
            }
        }