Esempio n. 1
0
        private void buttonAgregarUsuario_Click(object sender, EventArgs e)
        {
            BaseDatos db = new BaseDatos();

            if (textNuevoPassword.Text.Trim() == textNuevoPassword2.Text.Trim())
            {
                if (textNuevoUsuario.Text.Trim().Length > 0)
                {
                    db.EjecutarComando("insert into usuario(nombre, usuario, password) values ('" + textNombre.Text.Trim() + "','" + textNuevoUsuario.Text.Trim() + "','" + textNuevoPassword.Text.Trim() + "')");
                    panelRegistro.Visible = false;
                    panelIngreso.Visible  = true;
                    textUsuario.Text      = "";
                    textPassword.Text     = "";
                    changeSize();
                    MessageBox.Show("Usuario registrado con exito");
                }
                else
                {
                    MessageBox.Show("Debe de ingresar un usuario");
                }
            }
            else
            {
                textNuevoPassword.Text  = "";
                textNuevoPassword2.Text = "";
                MessageBox.Show("Las contraseñas no coinciden");
            }
        }
Esempio n. 2
0
        private void buttonCrearVuelo_Click(object sender, EventArgs e)
        {
            ChangeSize();
            BaseDatos db = new BaseDatos();

            if (db.EjecutarComando("INSERT INTO vuelo (avion_id,fecha_salida,hora_salida,origen,destino,aerolinea) " +
                                   "VALUES (" + comboAvionAdmin.SelectedValue + ",'" + dateFechaIdaAdmin.Value.Date.ToString("MM/dd/yyyy") + "','" + dateHoraAdmin.Value.ToShortTimeString().Split(new char[] { ' ' })[0] + "'," + combociudadorigenAdmin.SelectedValue + "," + combociudaddestinoAdmin.SelectedValue + "," + comboAerolineaAdmin.SelectedValue + ")"))
            {
                MessageBox.Show("Registro creado con exito");
            }
            else
            {
                MessageBox.Show("Se presento un error al crear el registro");
            }
        }
Esempio n. 3
0
        private void buttonAdminCiudad_Click(object sender, EventArgs e)
        {
            BaseDatos db = new BaseDatos();

            if (textAdminCiudad.Text.Trim() != "")
            {
                db.EjecutarComando("insert into ciudad(nombre) values ('" + textAdminCiudad.Text + "')");
                dataAdminCiudad.DataSource = db.RetornarTabla("select nombre from ciudad");
                textAdminCiudad.Text       = "";
                llenarCombos();
            }
            else
            {
                MessageBox.Show("Se presento un error al crear la ciudad");
            }
        }
Esempio n. 4
0
        private void button4_Click(object sender, EventArgs e)
        {
            BaseDatos db = new BaseDatos();

            if (textAdminAvion.Text.Trim() != "" && textAdminCapacidad.Text != "")
            {
                db.EjecutarComando("insert into avion(tipo,capacidad) values ('" + textAdminAvion.Text + "'," + textAdminCapacidad.Text + ")");
                dataAdminAvion.DataSource = db.RetornarTabla("select tipo,capacidad from avion");
                textAdminAvion.Text       = "";
                textAdminCapacidad.Text   = "";
                llenarCombos();
            }
            else
            {
                MessageBox.Show("Se presento un error al crear el avión");
            }
        }
Esempio n. 5
0
        private void buttonFinalizar_Click(object sender, EventArgs e)
        {
            bool error = false;

            if (groupBoxIda.Visible)
            {
                for (int i = 0; i < dataVuelos.Rows.Count; i++)
                {
                    if ((bool)dataVuelos.Rows[i].Cells["Selecciona"].Value)
                    {
                        BaseDatos db   = new BaseDatos();
                        DataTable temp = db.RetornarTabla("select * from cliente where documento = " + textIdentificacion.Text);
                        if (temp == null || temp.Rows.Count == 0)
                        {
                            string tipo_tarjeta = string.Empty;
                            if (radioMaster.Checked)
                            {
                                tipo_tarjeta = "Master";
                            }
                            else
                            {
                                tipo_tarjeta = "Visa";
                            }
                            db.EjecutarComando("INSERT INTO cliente (nombre,apellidos,genero,email,telefono,documento,tipo_documento,tipo_tarjeta,numero_tarjeta) VALUES ('" + textNombre.Text +
                                               "','" + txtApellidos.Text + "'," +
                                               "'" + comboGenero.SelectedItem + "'," +
                                               "'" + txtMail.Text + "'," +
                                               "" + txtTelefono.Text + "," +
                                               "'" + textIdentificacion.Text + "'," +
                                               "'" + comboTipoIdentificacion.SelectedItem + "'," +
                                               "'" + tipo_tarjeta + "'," +
                                               "" + textNumero.Text + ")");
                        }

                        int reservas_vuelo = Convert.ToInt16(db.EjecutarEscalar("select count(vuelo_ida_id) from reservas where vuelo_ida_id = " + dataVuelos.Rows[i].Cells["id"].Value.ToString()));

                        if (reservas_vuelo >= Convert.ToInt16(dataVuelos.Rows[i].Cells["capacidad"].Value))
                        {
                            MessageBox.Show("El vuelo de ida no cuenta con asientos disponibles, lo invitamos a realizar nuevamente otra busqueda en nuestro sistema");
                            buttonBuscarVuelos.Visible = true;
                            error = true;
                        }
                        else
                        {
                            db.EjecutarComando("INSERT INTO reservas (vuelo_ida_id,cliente) " + "VALUES (" + dataVuelos.Rows[i].Cells["id"].Value.ToString() + "," + textIdentificacion.Text + ")");
                        }
                        break;
                    }
                }
            }
            if (groupBoxRegreso.Visible)
            {
                for (int i = 0; i < dataVuelosRegreso.Rows.Count; i++)
                {
                    if ((bool)dataVuelosRegreso.Rows[i].Cells["Seleccionar"].Value)
                    {
                        BaseDatos db   = new BaseDatos();
                        DataTable temp = db.RetornarTabla("select * from cliente where documento = " + textIdentificacion.Text);
                        if (temp == null || temp.Rows.Count == 0)
                        {
                            string tipo_tarjeta = string.Empty;
                            if (radioMaster.Checked)
                            {
                                tipo_tarjeta = "Master";
                            }
                            else
                            {
                                tipo_tarjeta = "Visa";
                            }
                            db.EjecutarComando("INSERT INTO cliente (nombre,apellidos,genero,email,telefono,documento,tipo_documento,tipo_tarjeta,numero_tarjeta) VALUES ('" + textNombre.Text +
                                               "','" + txtApellidos.Text + "'," +
                                               "'" + comboGenero.SelectedItem + "'," +
                                               "'" + txtMail.Text + "'," +
                                               "" + txtTelefono.Text + "," +
                                               "'" + textIdentificacion.Text + "'," +
                                               "'" + comboTipoIdentificacion.SelectedItem + "'," +
                                               "'" + tipo_tarjeta + "'," +
                                               "" + textNumero.Text + ")");
                        }

                        int reservas_vuelo = Convert.ToInt16(db.EjecutarEscalar("select count(vuelo_regreso_id) from reservas where vuelo_ida_id = " + dataVuelosRegreso.Rows[i].Cells["id"].Value.ToString()));

                        if (reservas_vuelo >= Convert.ToInt16(dataVuelosRegreso.Rows[i].Cells["capacidad"].Value))
                        {
                            MessageBox.Show("El vuelo de regreso no cuenta con asientos disponibles, lo invitamos a realizar nuevamente otra busqueda en nuestro sistema");
                            buttonBuscarVuelos.Visible = true;
                            error = true;
                        }
                        else
                        {
                            db.EjecutarComando("INSERT INTO reservas (vuelo_regreso_id,cliente) " +
                                               "VALUES (" + dataVuelosRegreso.Rows[i].Cells["id"].Value.ToString() + "," + textIdentificacion.Text + ")");
                        }
                        break;
                    }
                }
            }
            groupBoxIda.Visible     = false;
            groupBoxRegreso.Visible = false;
            groupCliente.Visible    = false;
            buttonReservar.Visible  = false;
            dataVuelos.DataSource   = null;
            dataVuelos.DataSource   = null;
            groupReserva.Visible    = true;
            limpiarControles();
            if (!error)
            {
                limpiarControles();
                MessageBox.Show("Reserva realizada con exito!!!");
            }
        }