public ActionResult Descargar()
 {
     if (Request.Cookies[cookie_name] != null)
     {
         if (funcion.valid_cookie(Request.Cookies[cookie_name].Value))
         {
             CrystalDecisions.CrystalReports.Engine.ReportDocument reporte = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
             reporte.Load(Server.MapPath("~/Reports/Reporte.rpt"));
             reporte.SetDatabaseLogon("admin", "123456", "SINDECIDIR-PC", "sistemaV2");
             reporte.Refresh();
             try
             {
                 Stream stream = reporte.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                 stream.Seek(0, SeekOrigin.Begin);
                 return(File(stream, "application/pdf", "Sistema_Reporte.pdf"));
             }
             catch
             {
                 throw;
             }
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Beispiel #2
0
        public void ViewReport(CrystalDecisions.Windows.Forms.CrystalReportViewer CrViewer, string Reportname, string rsSelectionformula, string paraname1, string paraname2, string paraname3, string paraname4, string paraname5, string paraname6, string paraname7, string paravalue1, string paravalue2, string paravalue3, string paravalue4, string paravalue5, string paravalue6, string paravalue7, int SendToPrinter, Form frm)
        {
            rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string REPORTSPATH = Application.StartupPath + ConfigurationManager.AppSettings["ShareFolder"];

            rpt.Load((REPORTSPATH + ("\\" + Reportname)));
            rpt.SetParameterValue(paraname1, paravalue1);
            rpt.SetParameterValue(paraname2, paravalue2);
            rpt.SetParameterValue(paraname3, paravalue3);
            rpt.SetParameterValue(paraname4, paravalue4);
            rpt.SetParameterValue(paraname5, paravalue5);
            rpt.SetParameterValue(paraname6, paravalue6);
            rpt.SetParameterValue(paraname7, paravalue7);
            //  CrystalDecisions.CrystalReports.Engine.Table tdCurr;

            foreach (CrystalDecisions.CrystalReports.Engine.Table tdCurr in rpt.Database.Tables)
            {
                rptTLInfo = new CrystalDecisions.Shared.TableLogOnInfo();
                rptTLInfo = tdCurr.LogOnInfo;
                // With...
                //SERVERNAME.Password = "******";
                //dataBaseName.ServerName = "SA";
                rptTLInfo.ConnectionInfo.DatabaseName = "IMS";
                tdCurr.ApplyLogOnInfo(rptTLInfo);
            }
            rpt.SetDatabaseLogon("", "", ".", "IMS");
            rpt.SummaryInfo.ReportAuthor = RptAuthor;
            if ((rsSelectionformula != ""))
            {
                rpt.RecordSelectionFormula = rsSelectionformula;
            }

            if ((SendToPrinter == 1))
            {
                try
                {
                    rpt.PrintToPrinter(1, true, 1, 1);
                }
                catch (Exception ex)
                {
                    //  MsgBox(ex.Message);
                }
            }
            else
            {
                //if (((Para1 == null)
                //            == false)) {
                //    CrViewer.ParameterFieldInfo = parameters;
                //}

                CrViewer.ReportSource = rpt;
                CrViewer.Refresh();
                if ((frm.Tag != "ALL BILL REPORT"))
                {
                    //    frm.Show();
                    //   SHOW_PLEASE_WAIT(false);
                }
            }
        }
Beispiel #3
0
        // Reportes
        public ActionResult DescargarReporte()
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument reporte = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            reporte.Load(Server.MapPath("~/Reportes/Reporte.rpt"));
            reporte.SetDatabaseLogon("admin", "123456", "localhost\\SQLEXPRESS", "sistema");
            reporte.Refresh();

            try
            {
                Stream stream = reporte.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf", "Sistema_Reporte.pdf"));
            }
            catch (Exception ex)
            {
                throw;
            }
        }