Пример #1
0
        public Confirmacion(List<String> detalle, List<int> pasajerosIds, List<int> butacasNumeros, List<int> clientesIds, List<decimal> pesos, Viaje v, Aeronave a, LoginForm loginform)
        {
            this.InitializeComponent();

            this.pasajerosIds = pasajerosIds;
            this.butacasNumeros = butacasNumeros;
            this.clientesIds = clientesIds;
            this.pesos = pesos;
            this.selectedAeronave = a;
            this.selectedViaje = v;

            this.detalleTextbox.Lines = detalle.ToArray();
            this.fillCombos();

            if (loginform == null || loginform.loggedUser == null)
                this.medioDePagoCombo.Enabled = false;
        }
Пример #2
0
        private void guardarButton_Click_1(object sender, EventArgs e)
        {
            int aeronaveId = (int)this.aeronaveCombo.SelectedValue;
            int rutaId = (int)this.rutaCombo.SelectedValue;

            DAO.connect();
            Aeronave aeronave = DAO.selectOne<Aeronave>(new[] { "id = " + aeronaveId });
            Ruta ruta = DAO.selectOne<Ruta>(new[] { "id = " + rutaId });
            DateTime fechaSalida = fechaPicker.Value;

            String error = "";

            if (!this.validarViaje(aeronave, ruta, fechaSalida, ref error)) {
                MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Viaje nuevoViaje = new Viaje();
            nuevoViaje.Aeronave_Id = aeronaveId;
            nuevoViaje.Ruta_Id = rutaId;
            nuevoViaje.Fecha_Salida = fechaSalida;
            nuevoViaje.Fecha_Llegada = fechaSalida; //fecha por default
            nuevoViaje.Fecha_Llegada_Estimada = fechaSalida.AddDays(1);

            int affected = DAO.insert<Viaje>(nuevoViaje);
            DAO.closeConnection();

            if (affected != 0)
                MessageBox.Show("Nuevo viaje creado con exito.", "Nuevo viaje creado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
                MessageBox.Show("Error al crear nuevo viaje.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Пример #3
0
        private void viajesDataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.selectedViaje == null || (int)this.viajesDataGrid.SelectedRows[0].Cells[1].Value != this.selectedViaje.Id) {
                this.paquetesDatatable.Clear();
                this.pasajerosDatatable.Clear();
            }

            DataGridViewRow row = this.viajesDataGrid.SelectedRows[0];
            DAO.connect();
            this.selectedViaje = DAO.selectOne<Viaje>( new[] { "id = " + row.Cells[1].Value });
            this.selectedAeronave = this.selectedViaje.Aeronave;
            String connectionString = DAO.makeConnectionString(DBConfig.direccion, DBConfig.database, DBConfig.username, DBConfig.password);
            String selectCommand = "SELECT id, numero FROM BIEN_MIGRADO_RAFA.Butaca";
            selectCommand += " WHERE aeronave_id = " + row.Cells[0].Value.ToString();
            selectCommand += " AND id NOT IN (SELECT butaca_id FROM BIEN_MIGRADO_RAFA.Pasaje WHERE viaje_id = " + row.Cells[1].Value.ToString() + ")";
            selectCommand += " ORDER BY numero";
            dataAdapter = new SqlDataAdapter(selectCommand, connectionString);

            this.butacasSource = new DataSet();

            dataAdapter.Fill(butacasSource);

            butacaCombo.DisplayMember = "numero";
            butacaCombo.ValueMember = "id";
            butacaCombo.DataSource = butacasSource.Tables[0];

            DAO.closeConnection();
        }