private void btn_modificar_Click(object sender, EventArgs e)
        {
            Aeronave aeronave_seleccionada = new Aeronave();
            aeronave_seleccionada.Modelo = txt_modelo.Text;
            aeronave_seleccionada.Matricula = txt_matricula.Text;
            aeronave_seleccionada.Kg_disponibles = Convert.ToInt32(txt_kgs_disp.Text);
            aeronave_seleccionada.Cantidad_Asientos = Convert.ToInt32(txt_cant_asientos.Text);
            Fabricante fabricant = (Fabricante)cmb_fabricante.SelectedItem;
            Servicio service = (Servicio)cmb_servicio.SelectedItem;
            aeronave_seleccionada.Servicio = service;
            aeronave_seleccionada.Fabricante = fabricant;

            new AeronaveDAO().Guardar(aeronave_seleccionada);
            Abm_Aeronave.abm_aeronave form = new Abm_Aeronave.abm_aeronave();
            this.Close();
            form.Show();
        }
 private void btn_volver_Click(object sender, EventArgs e)
 {
     Abm_Aeronave.abm_aeronave form = new Abm_Aeronave.abm_aeronave();
     this.Close();
     form.Show();
 }
Ejemplo n.º 3
0
        private void btn_baja_Click(object sender, EventArgs e)
        {
            if (cmb_tipo_baja.SelectedItem == null)
            {
                MessageBox.Show("Debe indicar el tipo de baja");
                return;
            }

            if (btn_select.Visible==true)
            {
                MessageBox.Show("Debe confirmar la fecha");
                return;
            }

            DialogResult result = MessageBox.Show("Seguro que desea realizar dicha baja?", "Baja", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                string nombre = (string)cmb_tipo_baja.SelectedItem;

                if (nombre == "Baja por fuera de servicio")
                {
                    if (pn_accion.Visible)
                    {
                        if (cmb_accion.SelectedItem.Equals("Cancelar pasajes/encomiendas"))
                        {
                             Random rnd = new Random();
                             int codigo = rnd.Next(10000000, 99999999); // creates a 8 digit random no.
                             new AeronaveDAO().Aeronaves_Cancelar_Pasajes(aeronave.Id, codigo);
                             new AeronaveDAO().Eliminar(aeronave.Id, -1, Convert.ToDateTime(dateTimePicker_fecha_reinicio.Text), 0,0);
                             MessageBox.Show("Se cancelaron los pasajes");
                        }
                        else
                        {

                            Aeronave seleccionado = new AeronaveDAO().FindById(Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString()));
                            new AeronaveDAO().Eliminar(aeronave.Id, seleccionado.Id, Convert.ToDateTime(dateTimePicker_fecha_reinicio.Text), 0,1);
                            MessageBox.Show("Se reemplazo la aeronave");
                        }
                    }else{
                     new AeronaveDAO().Eliminar(aeronave.Id, -1, Convert.ToDateTime(dateTimePicker_fecha_reinicio.Text), 0,0);
                    }
                }

                if (nombre == "Baja definitiva")
                {
                    if(pn_accion.Visible){
                        if (cmb_accion.SelectedItem.Equals("Cancelar pasajes/encomiendas"))
                       {
                           Random rnd = new Random();
                           int codigo = rnd.Next(10000000, 99999999); // creates a 8 digit random no.
                           new AeronaveDAO().Aeronaves_Cancelar_Pasajes(aeronave.Id, codigo);
                           new AeronaveDAO().Eliminar(aeronave.Id, -1, Convert.ToDateTime(dateTimePicker_fecha_definitiva.Text), 1,0);
                           MessageBox.Show("Se cancelaron los pasajes");

                        }else{
                         Aeronave seleccionado = new AeronaveDAO().FindById(Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString()));
                         new AeronaveDAO().Eliminar(aeronave.Id,seleccionado.Id,Convert.ToDateTime(dateTimePicker_fecha_definitiva.Text), 1,1);
                         MessageBox.Show("Se reemplazo la aeronave");
                        }

                    }else{
                        new AeronaveDAO().Eliminar(aeronave.Id, -1, Convert.ToDateTime(dateTimePicker_fecha_definitiva.Text), 1,0);
                    }
                }
                Abm_Aeronave.abm_aeronave form = new Abm_Aeronave.abm_aeronave();
                this.Hide();
                form.Show();

            }
        }
Ejemplo n.º 4
0
        private void btn_ingresar_Click(object sender, EventArgs e)
        {
            var aeronavesActuales = new AeronaveDAO().Obtener_Todas(0);
            var matriculasActuales = aeronavesActuales.Select(x => x.Matricula);
            if (matriculasActuales.Contains(txt_matricula.Text))
            {
                MessageBox.Show("Matricula existente");
            }
            else
            {
                Aeronave aeronave_seleccionada = new Aeronave();

                aeronave_seleccionada.Modelo = txt_modelo.Text;
                aeronave_seleccionada.Matricula = txt_matricula.Text;
                Fabricante fabricant = (Fabricante)cmb_fabricante.SelectedItem;
                Servicio service = (Servicio)cmb_servicio.SelectedItem;
                aeronave_seleccionada.Servicio = service;
                aeronave_seleccionada.Fabricante = fabricant;
                aeronave_seleccionada.Kg_disponibles = Convert.ToInt32(txt_kgs_disp.Text);
                aeronave_seleccionada.Cantidad_Asientos = Convert.ToInt32(txt_cant_asientos.Text);
                aeronave_seleccionada.Fecha_Alta = Convert.ToDateTime(clk_fecha_alta.Text);

                new AeronaveDAO().Guardar(aeronave_seleccionada);

                if (retorno == 0)
                {
                    Abm_Aeronave.abm_aeronave form = new Abm_Aeronave.abm_aeronave();
                    this.Close();
                    form.Show();
                }
                else
                {
                    this.Close();
                }
            }
        }
Ejemplo n.º 5
0
 private void btn_cancelar_Click(object sender, EventArgs e)
 {
     Abm_Aeronave.abm_aeronave form = new Abm_Aeronave.abm_aeronave();
     this.Hide();
     form.Show();
 }