private void btnConsultarClientes_Click(object sender, EventArgs e) { BaseDatos db = new BaseDatos(); dataClientesRegistrados.DataSource = db.RetornarTabla("select nombre, apellidos, tipo_documento, documento, genero, email, telefono from cliente "); }
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!!!"); } }