Example #1
0
        } //Fin de formEdicionVuelos

        private void button1_Click(object sender, EventArgs e)
        {
            //Se declaran las variables
            int     id;
            int     idAvion;
            int     millas;
            string  origenVuelo;
            string  destinoVuelo;
            string  fechaHora;
            Decimal precioDolares;

            //Try para la captura de excepciones
            try
            {
                //No permite que los campos esten vacios
                if (txtIdVuelo.Text == "" || cbAvion.Text == "" || txtMillasVuelo.Text == "" || txtPrecio.Text == "")
                {
                    throw new Exception("Ingrese los campos necesarios.");
                }

                //Si no permite el ingreso de los datos que estan llenos
                else
                {
                    id            = Convert.ToInt32(txtIdVuelo.Text);
                    idAvion       = Convert.ToInt32(cbAvion.Text);
                    millas        = int.Parse(txtMillasVuelo.Text);
                    origenVuelo   = cbOrigenVuelo.Text;
                    destinoVuelo  = cbDestinoVuelo.Text;
                    fechaHora     = cbFecha.Value.ToShortDateString() + "---" + cbHora.Value.ToShortTimeString();
                    precioDolares = Decimal.Parse(txtPrecio.Text);
                }
                //Si el origen del vuelo es igual a el destino muestra el mensaje
                if (cbOrigenVuelo.Text == cbDestinoVuelo.Text)
                {
                    throw new Exception("Seleccione un destino diferente al de origen de vuelo.");
                }

                //Si la fecha es igual
                if (!validarFecha())
                {
                    throw new Exception("Seleccione una fecha futura.");
                }


                //Vuelo vuelo = new Vuelo(id, idAvion, millas, origenVuelo, destinoVuelo, fechaHora,precioDolares);

                Vuelo.Agregar(id, origenVuelo, destinoVuelo, millas, fechaHora, idAvion, precioDolares);
                MessageBox.Show("Vuelo ingresado");
                asignarVueloEnAsientos(idAvion, id);
                avion.cambiarEstado(idAvion);
                limpiarComponentes();
            } //Fin del try

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            } //Fin del catch
        }     //Fin del boton button1_Click (Ingresar vuelo)
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Se declaran las variables
            int id;
            int idAvion;
            int millas;
            string origenVuelo;
            string destinoVuelo;
            string fechaHora;
            float precioDolares;

            //Try para la captura de excepciones
            try
            {
                //No permite que los campos esten vacios
                if (txtIdVuelo.Text == "" || cbAvion.Text == "" || txtMillasVuelo.Text == "" || txtPrecio.Text == "")
                {
                    throw new Exception("Ingrese los campos necesarios.");
                }

                //Si no permite el ingreso de los datos que estan llenos
                else
                {
                    id = Convert.ToInt32(txtIdVuelo.Text);
                    idAvion = Convert.ToInt32(cbAvion.Text);
                    millas = Convert.ToInt32(txtMillasVuelo.Text);
                    origenVuelo = cbOrigenVuelo.Text;
                    destinoVuelo = cbDestinoVuelo.Text;
                    fechaHora = cbFecha.Value.ToShortDateString() + "---" + cbHora.Value.ToShortTimeString();
                    precioDolares = float.Parse(txtPrecio.Text);
                }
                //Si el origen del vuelo es igual a el destino muestra el mensaje
                if (cbOrigenVuelo.Text == cbDestinoVuelo.Text)
                {
                   throw new Exception("Seleccione un destino diferente al de origen de vuelo.");
                }

                //Si la fecha es igual
                if (!validarFecha())
                {
                    throw new Exception("Seleccione una fecha futura.");
                }
                Vuelo vuelo = new Vuelo(id, idAvion, millas, origenVuelo, destinoVuelo, fechaHora,precioDolares);
                vuelo.Agregar(vuelo);
                asignarVueloEnAsientos(idAvion,id);
                avion.cambiarEstado(idAvion);
                actualizarDataGrid();
            } //Fin del try

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }//Fin del catch
        }