Esempio n. 1
0
        private void printReport(string rpt)
        {
            string path         = string.Empty;
            string pathImg      = string.Empty;
            string virtualPath  = string.Empty;
            string RptFileName  = string.Empty;
            string TemplatePath = string.Empty;
            bool   withDet      = true;
            object obj;

            int id = 0;

            dsReport ds = new dsReport();

            switch (rpt)
            {
            case "entradaAlm":
                obj = (Entrada)Session["SEntrada"];
                if (obj == null)
                {
                    id      = Convert.ToInt32(Request["_key"].ToString());
                    withDet = Convert.ToBoolean(Request["_wdet"].ToString());
                    obj     = EntradaCtrl.EntradaGetAllDataById(id);
                }
                RptFileName = ((Entrada)obj).Folio + ((Entrada)obj).Folio_indice + ".pdf";
                path        = HttpContext.Current.Server.MapPath("~/rpt/entradasAlm/") + RptFileName;
                //pathImg = HttpContext.Current.Server.MapPath("~/images/logo.jpg");
                if (((Entrada)obj).IsActive)
                {
                    TemplatePath = HttpContext.Current.Server.MapPath("~/report/Almacen/ealm.rpt");
                }
                else
                {
                    TemplatePath = HttpContext.Current.Server.MapPath("~/report/Almacen/ealmCan.rpt");
                }
                string TemplatePathTarima = HttpContext.Current.Server.MapPath("~/rpt/TemplatePallet.pdf");
                DocEntrada.getEntradaAlm(path, TemplatePath, TemplatePathTarima, (Entrada)obj, ds, withDet);
                //this.getRpt(path, TemplatePath, (Entrada)obj, ds);
                //ReportDocument reporte = new ReportDocument();
                //reporte.Load(HttpContext.Current.Server.MapPath("~/report/Almacen/EntradaAlm.rpt"));
                //reporte.SetParameterValue("direccion_bodega", "Luisa 208, col. Nativitas, Benito Juárez. C.P. 03500. México, CDMX");
                ////reporte.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "Test");
                //reporte.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path);
                ////VisorCR.ReportSource = reporte;
                ShowPdf(path);
                break;

            case "remision":
                id = Convert.ToInt32(Request["_key"].ToString());
                Tarima_almacen_remision o = AlmacenCtrl.tarimaRemisionGetAllInfoById(id);
                RptFileName  = o.Folio + ".pdf";
                path         = HttpContext.Current.Server.MapPath("~/rpt/remisionAlm/") + RptFileName;
                TemplatePath = HttpContext.Current.Server.MapPath("~/report/Almacen/ralm.rpt");
                ControlRptAlmacen.getRemision(path, TemplatePath, ds, o);
                ShowPdf(path);
                break;

            case "carga":
                id = Convert.ToInt32(Request["_key"].ToString());
                Tarima_almacen_carga oTAC = AlmacenCtrl.CargaRpt(id);
                RptFileName  = oTAC.Folio_orden_carga + ".pdf";
                path         = HttpContext.Current.Server.MapPath("~/rpt/cargaAlm/") + RptFileName;
                TemplatePath = HttpContext.Current.Server.MapPath("~/report/Almacen/Carga.rpt");
                ControlRptAlmacen.getCarga(path, TemplatePath, ds, oTAC);
                ShowPdf(path);
                break;

            case "salidaAlm":
                id          = Convert.ToInt32(Request["_key"].ToString());
                obj         = SalidaCtrl.SalidaGetAllDataById(id);
                RptFileName = ((Salida)obj).Folio + ((Salida)obj).Folio_indice + ".pdf";
                path        = HttpContext.Current.Server.MapPath("~/rpt/salidasAlm/") + RptFileName;

                AlmacenCtrl.CargaSetSalida(((Salida)obj));

                //pathImg = HttpContext.Current.Server.MapPath("~/images/logo.jpg");
                if (((Salida)obj).IsActive)
                {
                    TemplatePath = HttpContext.Current.Server.MapPath("~/report/Almacen/salm.rpt");
                }
                else
                {
                    TemplatePath = HttpContext.Current.Server.MapPath("~/report/Almacen/salmCan.rpt");
                }
                DocSalida.getSalidaAlm(path, TemplatePath, (Salida)obj, ds);
                ShowPdf(path);
                break;

            case "salidaAlmXls":
                id          = Convert.ToInt32(Request["_key"].ToString());
                obj         = SalidaCtrl.SalidaGetAllDataById(id);
                RptFileName = ((Salida)obj).Folio + ((Salida)obj).Folio_indice + ".xls";
                path        = HttpContext.Current.Server.MapPath("~/rpt/salidasAlm/") + RptFileName;

                AlmacenCtrl.CargaSetSalida(((Salida)obj));

                if (((Salida)obj).IsActive)
                {
                    TemplatePath = HttpContext.Current.Server.MapPath("~/report/Almacen/salm.rpt");
                    DocSalida.getSalidaAlmXls(path, TemplatePath, (Salida)obj, ds);
                }
                ShowXls(path, RptFileName);

                break;
            }
        }
Esempio n. 2
0
        protected void clickGetRptAsync(object sender, EventArgs args)
        {
            try
            {
                ReportViewer ReportViewer1 = new ReportViewer();
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                //ReportViewer1.Visible = true;
                DateTime fecha = DateTime.Today;

                DateTime periodo_ini = new DateTime();
                DateTime.TryParse(txt_fecha_ini.Text, out fecha);
                periodo_ini = fecha;

                DateTime periodo_fin = new DateTime();
                DateTime.TryParse(txt_fecha_fin.Text, out fecha);
                periodo_fin = fecha;

                ReportViewer1.Reset();

                string           rptSelected = ddl_reporte.SelectedValue;
                ReportDataSource rptSource   = null;
                switch (ddl_reporte.SelectedValue)
                {
                case "InvTotDia":
                    rptSource = new ReportDataSource("ds" + rptSelected, ControlRptAlmacen.RelInvTotDiaGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear));
                    break;

                case "RelDiaEnt":
                    rptSource = new ReportDataSource("ds" + rptSelected, ControlRptAlmacen.RelDiaEntGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear));
                    break;

                case "RelDiaSal":
                    rptSource = new ReportDataSource("ds" + rptSelected, ControlRptAlmacen.RelDiaSalGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear));
                    break;
                }

                ReportViewer1.LocalReport.DataSources.Add(rptSource);
                ReportViewer1.LocalReport.ReportPath = HttpContext.Current.Server.MapPath("~/report/Almacen/") + "rpt" + rptSelected + ".rdlc";

                Warning[] warnings;
                string[]  streamIds;
                string    mimeType  = string.Empty;
                string    encoding  = string.Empty;
                string    extension = string.Empty;
                byte[]    bytes     = ReportViewer1.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamIds, out warnings);

                //ReportViewer1.LocalReport.Refresh();


                Response.Buffer = true;
                Response.Clear();
                Response.ContentType = mimeType;
                Response.AddHeader("content-disposition", "attachment; filename=" + ddl_reporte.SelectedValue + ".xls");
                Response.BinaryWrite(bytes); // create the file
                Response.Flush();            // send it to the client to download
            }
            catch (Exception e)
            {
                throw e;
            }
        }