Example #1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            List <string> errores = ValidarAeronave();

            string erroresAMostrar = "Se encontraron los siguientes errores en la aeronave a ingresar:" + System.Environment.NewLine;

            foreach (var item in errores)
            {
                erroresAMostrar = string.Concat(erroresAMostrar + System.Environment.NewLine, item);
            }

            if (errores.Count > 0)
            {
                MessageBox.Show(erroresAMostrar, "Error.");
                return;
            }
            string   matricula       = MatriculaNaveRegistrar.Text;
            int      horas           = int.Parse(HorasVueloNaveRegistrar.Text);
            string   tipo            = TipoNaveRegistrar.Text;
            DateTime fecha           = (DateTime)FechaAeronavegabilidad.SelectedDate;
            DateTime fechaInspeccion = (DateTime)FechaInspección.SelectedDate;
            DateTime ano             = new DateTime(int.Parse(AnoFabricacion.Text), 1, 1);
            Aeronave a = new Aeronave(matricula, tipo, horas, fechaInspeccion, fecha, ano, "A");

            if (a.GuardarEnBD() > 0)
            {
                MessageBox.Show("La nave se ha registrado correctamente.");
            }
        }