예제 #1
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(cboNumeroVuelo.Text) || string.IsNullOrEmpty(txtaerolinea.Text) || string.IsNullOrEmpty(txtDuracionVuelo.Text) || string.IsNullOrEmpty(txtpuertaEmbargue.Text))
                {
                    MessageBox.Show("Los campos deben de estar lleno", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    piloGlobal = Singleton.opPiloto.buscarPilotoPorNombre(cbo_nombrePiloto.Text);
                    var idpiloto = piloGlobal.idPiloto.ToString();
                    TipovueloGlobal = Singleton.optipovuelo.BuscarTipoVueloDescripcion(cbo_tipovuelo.Text);
                    var idtipovuelo = TipovueloGlobal.IDTIPOVUELO.ToString();
                    avionGlobal = Singleton.opavion.BuscarAvionPorModelo(cbo_modeloAvion.Text);
                    var idavion = avionGlobal.IDAVION.ToString();



                    Vuelos.DATA.Vuelos vuelos = new Vuelos.DATA.Vuelos
                    {
                        NroVuelo       = cboNumeroVuelo.Text,
                        idPiloto       = Convert.ToInt32(idpiloto),
                        idTipoVuelo    = Convert.ToInt32(idtipovuelo),
                        idAvion        = Convert.ToInt32(idavion),
                        Duracion_Vuelo = txtDuracionVuelo.Text,
                        Aerolinea      = txtaerolinea.Text,
                        Fecha_Vuelo    = Convert.ToDateTime(dtp_fechaVuelo.Value),
                        Hora_Salida    = Convert.ToDateTime(dtp_horaSalida.Value),
                        Hora_llegada   = Convert.ToDateTime(dtp_horaLlegada.Value),
                        Puerta_embarge = txtpuertaEmbargue.Text
                    };
                    Singleton.opVuelos.insertarVuelos(vuelos);
                    MessageBox.Show("Vuelo insertado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LimpiarCampos();
                    DisplayData();
                }
            }
            catch
            {
                MessageBox.Show("Hubo un error", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            try
            {
                PilotoGlobal = Singleton.opPiloto.buscarPilotoPorNombre(cbonombrepiloto.Text); //Esta linea agarra el nombre del piloto y lo guarda en la variable
                var numeropiloto = PilotoGlobal.idPiloto.ToString();                           //esta linea convierte la variable con el nombre y lo convierte en el id correspondiente

                TipoVueloGlobal = Singleton.optipovuelo.BuscarTipoVueloDescripcion(cbo_tipoVuelo.Text);
                var numerotipoVuelo = TipoVueloGlobal.IDTIPOVUELO.ToString();

                AvionGlobal = Singleton.opavion.BuscarAvionPorModelo(cbomodeloavion.Text);
                var numeroavion = AvionGlobal.IDAVION.ToString();

                Vuelos.DATA.Vuelos vuelo = new Vuelos.DATA.Vuelos()
                {
                    idPiloto       = Convert.ToInt32(numeropiloto),
                    idTipoVuelo    = Convert.ToInt32(numerotipoVuelo),
                    idAvion        = Convert.ToInt32(numeroavion),
                    Duracion_Vuelo = txttiempo.Text,
                    Aerolinea      = txtaerolinea.Text,
                    Fecha_Vuelo    = dtp_fechaVuelo.Value,
                    Hora_Salida    = dtp_horasalida.Value,
                    Hora_llegada   = dtp_horasalida.Value,
                    Puerta_embarge = txtPuerta.Text,
                    NroVuelo       = cbo_nroVuelo.Text
                };
                var mensaje = MessageBox.Show("Desea actualizar los datos? ", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (mensaje == DialogResult.Yes)
                {
                    Singleton.opVuelos.ActualizarVuelos(vuelo);
                    MessageBox.Show("Vuelo actualizado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DisplayData();
                    limpiar();
                }
            }
            catch
            {
                MessageBox.Show("hubo un error", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
 public void insertarTipoVuelo(TipoVuelo tp)
 {
     _db.Insert(tp);
 }
예제 #4
0
 public void ActualizarTipoVuelo(TipoVuelo tp)
 {
     _db.Update(tp);
 }