Beispiel #1
0
        public static int Agregar(_destino pDestino)
        {
            int          retorno = 0;
            MySqlCommand comando = new MySqlCommand(String.Format("Insert into destino(dest_nom) values('{0}')", pDestino.dest_nom), BdConexion.ObtenerConexion());

            retorno = comando.ExecuteNonQuery();
            return(retorno);
        }
Beispiel #2
0
        public static int Actualizar(_destino pDestino)
        {
            int             retorno  = 0;
            MySqlConnection conexion = BdConexion.ObtenerConexion();
            MySqlCommand    comando  = new MySqlCommand(String.Format("Update destino set dest_nom='{1}' where dest_id = '{0}'", pDestino.dest_id, pDestino.dest_nom), conexion);

            retorno = comando.ExecuteNonQuery();
            return(retorno);
        }
Beispiel #3
0
 private void agregarbtn_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         int linea = Convert.ToInt16(dataGridView1.CurrentRow.Cells[0].Value);
         destinoSeleccionado = destBD.obtenerDestino(linea);
         this.Close();
     }
 }
        private void consultarbtn_Click(object sender, EventArgs e)
        {
            error.Clear();
            buscarDestino buscar = new buscarDestino();

            buscar.ShowDialog();
            if (buscar.destinoSeleccionado != null)
            {
                VueloActual  = buscar.destinoSeleccionado;
                destNom.Text = buscar.destinoSeleccionado.dest_nom;

                ingresarbtn.Hide();
            }
        }
Beispiel #5
0
        public static _destino buscarDestino(string dest_nom)
        {
            _destino        pDestino = new _destino();
            MySqlConnection conexion = BdConexion.ObtenerConexion();
            MySqlCommand    _comando = new MySqlCommand(String.Format("select * from destino where dest_nom ='{0}'", dest_nom), conexion);
            MySqlDataReader _reader  = _comando.ExecuteReader();

            while (_reader.Read())
            {
                pDestino.dest_id  = _reader.GetInt16(0);
                pDestino.dest_nom = _reader.GetString(1);
            }
            conexion.Close();
            return(pDestino);
        }
Beispiel #6
0
        public static List <_destino> BuscarT()
        {
            List <_destino> _lista   = new List <_destino>();
            MySqlCommand    _comando = new MySqlCommand(String.Format("Select dest_id as 'ID', dest_nom as 'Nombre del destino' from destino;"), BdConexion.ObtenerConexion());
            MySqlDataReader _reader  = _comando.ExecuteReader();

            while (_reader.Read())
            {
                _destino pDestino = new _destino();
                pDestino.dest_id  = _reader.GetInt16(0);
                pDestino.dest_nom = _reader.GetString(1);
                _lista.Add(pDestino);
            }
            return(_lista);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (validar())
            {
                _destino pDestino = new _destino();
                pDestino.dest_nom = destNom.Text.Trim();

                int resultado = destBD.Agregar(pDestino);
                if (resultado > 0)
                {
                    MessageBox.Show("Destino Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    error.Clear();
                    limpiar();
                }
                else
                {
                    MessageBox.Show("No se pudo guardar el destino", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        private void modificarbtn_Click(object sender, EventArgs e)
        {
            if (validar())
            {
                _destino pDestino = new _destino();
                pDestino.dest_id  = VueloActual.dest_id;
                pDestino.dest_nom = destNom.Text.Trim();

                if (destBD.Actualizar(pDestino) > 0)
                {
                    MessageBox.Show("Los datos del destino 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);
                }
            }
        }
        private void cmbDestino_SelectedValueChanged(object sender, EventArgs e)
        {
            _destino dest = destBD.buscarDestino(cmbDestino.Text);

            idDestino.Text = Convert.ToString(dest.dest_id);
        }