示例#1
0
 public static int Agregar(_boleto pBoleto)
 {
     int retorno = 0;
     MySqlCommand comando = new MySqlCommand(String.Format("Insert into boleto(pas_id, bol_fecha, dest_id, vue_id, bol_costo) values('{0}','{1}','{2}','{3}','{4}')", pBoleto.pas_id, pBoleto.bol_fecha, pBoleto.dest_id, pBoleto.vue_id, pBoleto.bol_costo), BdConexion.ObtenerConexion());
     retorno = comando.ExecuteNonQuery();
     return retorno;
 }
        private void modificarbtn_Click(object sender, EventArgs e)
        {
            if (validar())
            {
                _boleto pBoleto = new _boleto();
                pBoleto.bol_id    = BoletoActual.bol_id;
                pBoleto.bol_fecha = dtp.Value.ToString("yyyy-MM-dd");
                pBoleto.dest_id   = Convert.ToInt16(idDestino.Text);
                pBoleto.pas_id    = Convert.ToInt16(idPasajero.Text);
                pBoleto.vue_id    = Convert.ToInt16(idVuelo.Text);
                pBoleto.bol_costo = Convert.ToInt16(costotxt.Text.Trim());

                if (bolBD.Actualizar(pBoleto) > 0)
                {
                    MessageBox.Show("Los datos del boleto se actualizaron", "Datos Actualizados", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    error.Clear();
                    limpiar();
                    ingresarbtn.Show();
                }
                else
                {
                    MessageBox.Show("No se pudo actualizar", "Error al Actualizar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
示例#3
0
 public static int Actualizar(_boleto pBoleto)
 {
     int retorno = 0;
     MySqlConnection conexion = BdConexion.ObtenerConexion();
     MySqlCommand comando = new MySqlCommand(String.Format("Update boleto set pas_id='{1}',bol_fecha='{2}',dest_id='{3}',vue_id='{4}',bol_costo='{5}' where bol_id = '{0}'", pBoleto.bol_id, pBoleto.pas_id, pBoleto.bol_fecha, pBoleto.dest_id, pBoleto.vue_id, pBoleto.bol_costo), conexion);
     retorno = comando.ExecuteNonQuery();
     return retorno;
 }
 private void agregarbtn_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         int linea = Convert.ToInt16(dataGridView1.CurrentRow.Cells[0].Value);
         boletoSeleccionado = bolBD.obtenerBoleto(linea);
         this.Close();
     }
 }
示例#5
0
 public static List<_boleto> Buscar(string pDestino)
 {
     List<_boleto> _lista = new List<_boleto>();
     MySqlCommand _comando = new MySqlCommand(String.Format("Select * from boleto where dest_id like '%{0}%'", pDestino), BdConexion.ObtenerConexion());
     MySqlDataReader _reader = _comando.ExecuteReader();
     while (_reader.Read())
     {
         _boleto pBoleto = new _boleto();
         pBoleto.bol_id = _reader.GetInt16(0);
         pBoleto.pas_id = _reader.GetInt16(1);
         pBoleto.bol_fecha = _reader.GetString(2);
         pBoleto.dest_id = _reader.GetInt16(3);
         pBoleto.vue_id = _reader.GetInt16(4);
         pBoleto.bol_costo = _reader.GetInt16(5);
         _lista.Add(pBoleto);
     }
     return _lista;
 }
示例#6
0
 public static _boleto obtenerBoleto(int bol_id)
 {
     _boleto pBoleto = new _boleto();
     MySqlConnection conexion = BdConexion.ObtenerConexion();
     MySqlCommand _comando = new MySqlCommand(String.Format("select * from boleto where bol_id ='{0}'", bol_id), conexion);
     MySqlDataReader _reader = _comando.ExecuteReader();
     while (_reader.Read())
     {
         pBoleto.bol_id = _reader.GetInt16(0);
         pBoleto.pas_id = _reader.GetInt16(1);
         pBoleto.bol_fecha = _reader.GetString(2);
         pBoleto.dest_id = _reader.GetInt16(3);
         pBoleto.vue_id = _reader.GetInt16(4);
         pBoleto.bol_costo = _reader.GetInt16(5);
     }
     conexion.Close();
     return pBoleto;
 }
示例#7
0
        public static List<_boleto> BuscarT()
        {

            List<_boleto> _lista = new List<_boleto>();
            MySqlCommand _comando = new MySqlCommand(String.Format("Select bol_id as 'ID', pas_id as 'Id Pasajero', bol_fecha as 'Fecha de Boleto', dest_id as 'Id Destino', vue_id as 'Id Vuelo', bol_costo as 'Costo de boleto' from boleto;"), BdConexion.ObtenerConexion());
            MySqlDataReader _reader = _comando.ExecuteReader();
            while (_reader.Read())
            {
                _boleto pBoleto = new _boleto();
                pBoleto.bol_id = _reader.GetInt16(0);
                pBoleto.pas_id = _reader.GetInt16(1);
                pBoleto.bol_fecha = _reader.GetString(2);
                pBoleto.dest_id = _reader.GetInt16(3);
                pBoleto.vue_id = _reader.GetInt16(4);
                pBoleto.bol_costo = _reader.GetInt16(5);
                _lista.Add(pBoleto);
            }
            return _lista;
        }
        private void consultarbtn_Click(object sender, EventArgs e)
        {
            error.Clear();
            buscarBoleto buscar = new buscarBoleto();

            buscar.ShowDialog();
            if (buscar.boletoSeleccionado != null)
            {
                BoletoActual = buscar.boletoSeleccionado;
                //string nombrePasajero = pasBD.obtenerPasajero(buscar.boletoSeleccionado.pas_id).nombre; //utilizar pasBD para obtener el nombre del pasajero seleccionado
                string nombrePasajero = bolBD.nombrePasajero(buscar.boletoSeleccionado.bol_id);
                idPasajero.Text  = Convert.ToString(buscar.boletoSeleccionado.pas_id);
                pasajerotxt.Text = nombrePasajero;
                dtp.Text         = buscar.boletoSeleccionado.bol_fecha;
                idDestino.Text   = Convert.ToString(buscar.boletoSeleccionado.dest_id);
                costotxt.Text    = Convert.ToString(buscar.boletoSeleccionado.bol_costo);

                ingresarbtn.Hide();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (validar())
            {
                _boleto pBoleto = new _boleto();
                pBoleto.bol_fecha = dtp.Value.ToString("yyyy-MM-dd");
                pBoleto.pas_id    = Convert.ToInt16(idPasajero.Text);
                pBoleto.dest_id   = Convert.ToInt16(idDestino.Text);
                pBoleto.vue_id    = Convert.ToInt16(idVuelo.Text);
                pBoleto.bol_costo = Convert.ToInt16(costotxt.Text.Trim());

                int resultado = bolBD.Agregar(pBoleto);
                if (resultado > 0)
                {
                    MessageBox.Show("Boleto Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    error.Clear();
                    limpiar();
                }
                else
                {
                    MessageBox.Show("No se pudo guardar el boleto", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }