Skip to content

Instantly share code, notes, and snippets.

@jofese
Created July 6, 2017 21:29
Show Gist options
  • Save jofese/9f690347e8169acd5712a923259ae640 to your computer and use it in GitHub Desktop.
Save jofese/9f690347e8169acd5712a923259ae640 to your computer and use it in GitHub Desktop.
generar un reporte en c#
try
{
ReportDocument objReporte = new ReportDocument();
objReporte.Load(Application.StartupPath.ToString() + "\\Crystal Report\\rptRecalculo.rpt");
OracleConnection _conexion = new OracleConnection(cls_DatosOracle.cadenaconexion);
OracleDataAdapter _comando = new OracleDataAdapter(string.Format(@"SELECT PRFNUM AS PREFACTURA,
USUARIO,
NOMBRECOMPLETO,
REGRECALCULO,
CODMOTIVO,
MOTIVO,
FECCREPREFACTURA,
'{2}' as INICIO,
'{3}' as FIN
FROM (SELECT pr.prfnum,
(SELECT usenam
FROM prefacturas
WHERE prfnum = pr.prfnum)
AS Usuario,
(SELECT usenam
FROM usuarios
WHERE useusr = (SELECT usenam
FROM prefacturas
WHERE prfnum = pr.prfnum))
AS NombreCompleto,
PR.FECREC AS RegRecalculo,
pr.motrec AS CodMotivo,
M.MOT AS Motivo,
(SELECT feccre
FROM prefacturas
WHERE prfnum = pr.prfnum)
AS FecCrePrefactura
FROM prefacturas_recalculo pr
LEFT JOIN sia_motivos m ON m.motnum = pr.motrec) Q1
WHERE Usuario LIKE '%{0}%'
AND CODMOTIVO LIKE '{1}'
AND RegRecalculo BETWEEN TO_DATE ('{2}', 'dd/mm/yyyy')
AND TO_DATE ('{3}', 'dd/mm/yyyy') ",usuario, codmotivo,inicio,fin), _conexion);
/*REEMPLAZA ESTOS "", "%%" POR TUS VARIABLES, LAS FECHAS TAMBIÉN AGREGALAS COMO PARÁMETROS SERÍAN LOS ÍNDICES {2} Y {3}
CAMBIA EL LLENADO DEL COMBO POR UNA LISTA, GUÍATE DE LO DE TICKETS SI NECESITAS EJEMPLO
*/
DataSet DS = new DataSet();
_comando.Fill(DS, "RepRecalculo");
objReporte.SetDataSource(DS);
FrmReportes FormReportes = new FrmReportes();
FormReportes.CrReportes.ReportSource = objReporte;
FormReportes.Show();
}
catch (Exception ex)
{
throw;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment