Ejemplo n.º 1
0
        public Pasaje obtenerPorId(int id)
        {
            Pasaje p = new Pasaje();
            DatosSistema datos = new DatosSistema();
            string[] param = { "@id" };
            DataTable dt = datos.getDatosTabla("[INFONIONIOS].[spObtenerPasajePorId]", param, id);
            if (dt.Rows.Count != 0)
            {
                p.idPasaje = Int32.Parse(dt.Rows[0]["PASAJE_ID"].ToString());
                p.codigoPasaje = Decimal.Parse(dt.Rows[0]["PASAJE_CODIGO"].ToString());
                p.precioPasaje = Decimal.Parse(dt.Rows[0]["PASAJE_PRECIO"].ToString());
                p.idViaje = Int32.Parse(dt.Rows[0]["VIAJE_ID"].ToString());
                p.idCliente = Int32.Parse(dt.Rows[0]["CLIENTE_ID"].ToString());
                p.idCompra = Int32.Parse(dt.Rows[0]["COMPRA_ID"].ToString());
                p.idButaca = Int32.Parse(dt.Rows[0]["BUTACA_ID"].ToString());
                p.idCancelacion = mapearCancelacion(dt.Rows[0]["CANCELACION_ID"].ToString());
            }
            else
            {
                return null;
            }

            return p;
        }
Ejemplo n.º 2
0
        private void dgvPasajes_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
                return;

            Pasaje pasaje = new Pasaje().obtenerPorId((int)dgvPasajes.Rows[e.RowIndex].Cells[0].Value);

            if (e.ColumnIndex == 8)
            {
                var msg = MessageBox.Show("¿Está seguro que desea cancelar el pasaje?", "Atención", MessageBoxButtons.YesNo);
                if (msg == DialogResult.Yes)
                {
                    frmMotivo frmMotivoP = new frmMotivo();
                    frmMotivoP.ShowDialog();
                    try
                    {
                        new Pasaje().cancelarPasaje(pasaje.idPasaje, UsuarioLogueado.usuario.idUsuario, frmMotivoP.motivo);
                        MessageBox.Show("El pasaje ha sido cancelado.", "Atención");
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Hubo un problema al devolver el pasaje");
                    }
                    cargarDGVs();
                    dgvPasajes.Columns[0].Visible = false;
                    dgvEncomiendas.Columns[0].Visible = false;
                }
            }
        }