Ejemplo n.º 1
0
        private void bajaAeronave_Click(object sender, EventArgs e)
        {
            if (this.aeronaveDataGrid.SelectedRows.Count == 0)
            {
                MessageBox.Show("Debe elegir una aeronave para dar de baja", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (this.aeronaveDataGrid.SelectedRows.Count > 1)
            {
                MessageBox.Show("Solo puede elegir una aeronave para dar de baja a la vez", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            DataGridViewRow row = this.aeronaveDataGrid.SelectedRows[0];

            String  matricula     = (String)row.Cells[0].Value;
            String  modelo        = (String)row.Cells[1].Value;
            decimal kgDisponibles = Convert.ToDecimal(row.Cells[2].Value);
            String  fabricante    = (String)row.Cells[3].Value;

            AeronaveBaja aeronaveBaja = new AeronaveBaja(matricula);
            var          dr           = aeronaveBaja.ShowDialog();

            if (aeronaveBaja.dr == DialogResult.Cancel)
            {
                return;
            }

            DAO.connect();

            Aeronave aeronave = DAO.selectOne <Aeronave>(new[] { "matricula = '" + matricula + "' " });

            BajaAeronave bajaAeronave = new BajaAeronave();

            bajaAeronave.Aeronave_Id  = aeronave.Id;
            bajaAeronave.Tipo_Baja_Id = aeronaveBaja.tipoBajaId;
            bajaAeronave.Fecha_Baja   = Config.SystemConfig.systemDate;
            int idInsertado = DAO.insert <BajaAeronave>(bajaAeronave);

            DAO.closeConnection();

            string query = obtenerQueryBase();

            query = query.Substring(0, query.Length - 5);

            GetData(query);
        }
 private void dataGridRol1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     // Ignore clicks that are not in our
     if (e.ColumnIndex == dataGridRol1.Columns["buttonEliminar"].Index && e.RowIndex >= 0)
     {
         Aeronave aeronaveSel = new Aeronave(Convert.ToInt32(dataGridRol1.Rows[e.RowIndex].Cells["Id"].Value), Convert.ToString(dataGridRol1.Rows[e.RowIndex].Cells["Matricula"].Value), Convert.ToString(dataGridRol1.Rows[e.RowIndex].Cells["Modelo"].Value), Convert.ToDecimal(dataGridRol1.Rows[e.RowIndex].Cells["KG_Disponibles"].Value), Convert.ToString(dataGridRol1.Rows[e.RowIndex].Cells["Fabricante"].Value), Convert.ToInt32(dataGridRol1.Rows[e.RowIndex].Cells["Cant_Butacas_Ventanilla"].Value), Convert.ToInt32(dataGridRol1.Rows[e.RowIndex].Cells["Cant_Butacas_Pasillo"].Value), Convert.ToString(dataGridRol1.Rows[e.RowIndex].Cells["Tipo_Servicio"].Value));
         Form frm = new BajaAeronave(aeronaveSel);
         frm.Show(this);
     }
 }
Ejemplo n.º 3
0
        private void boton_Eliminar_Aeronave_Click(object sender, EventArgs e)
        {
            try
             {
                 SqlCommand sqlCmd = new SqlCommand("SELECT THE_CVENGERS.aeronaveEnElAire (" + dameIdAeronave(((Avion)listBox1.SelectedItem).getMatricula()) + ")", Conexion.getConexion());

                 if ((int)sqlCmd.ExecuteScalar() == 1)
                {
                     MessageBox.Show("No se puede dar de baja, la aeronave se encuentra en viaje", "Error",MessageBoxButtons.OK);
                }
                else {

                    BajaAeronave ventana = new BajaAeronave(((Avion)listBox1.SelectedItem).getMatricula());
                    ventana.Show();
                }

            }
            catch(Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK);
            }
        }