Example #1
0
        private void printItextSharp()
        {
            string     path             = string.Empty;
            string     pathImg          = string.Empty;
            string     virtualPath      = string.Empty;
            string     rpt              = string.Empty;
            string     RptFileName      = string.Empty;
            string     TemplatePath     = string.Empty;
            string     TemplatePathCond = string.Empty;
            string     key;
            object     obj;
            dsFormatos ds = new dsFormatos();

            try
            {
                rpt = Request["rpt"].ToString();

                switch (rpt)
                {
                case "entrada":
                    obj         = (Entrada)Session["SEntrada"];
                    RptFileName = ((Entrada)obj).Folio + ((Entrada)obj).Folio_indice + ".pdf";
                    path        = HttpContext.Current.Server.MapPath("~/rpt/entradas/") + RptFileName;

                    switch (((Entrada)obj).Id_cliente)
                    {
                    case 1:
                    case 9:
                    case 11:
                    case 12:
                    case 13:
                    case 14:
                    case 15:
                    case 25:
                    case 30:
                    case 32:
                        TemplatePath = HttpContext.Current.Server.MapPath("~/report/Formatos/entrada.rpt");
                        DocEntrada.getEntrada(path, TemplatePath, (Entrada)obj, ds);
                        break;

                    default:
                        pathImg      = HttpContext.Current.Server.MapPath("~/images/logo.jpg");
                        TemplatePath = HttpContext.Current.Server.MapPath("~/rpt/TemplateEntrada.pdf");
                        DocEntrada.getEntrada(path, TemplatePath, (Entrada)obj);
                        break;
                    }

                    //obj = (Entrada)Session["SEntrada"];
                    //RptFileName = ((Entrada)obj).Folio + ((Entrada)obj).Folio_indice + ".pdf";
                    //path = HttpContext.Current.Server.MapPath("~/rpt/entradas/") + RptFileName;
                    //pathImg = HttpContext.Current.Server.MapPath("~/images/logo.jpg");
                    //TemplatePath = HttpContext.Current.Server.MapPath("~/rpt/TemplateEntrada.pdf");
                    //DocEntrada.getEntrada(path, TemplatePath, (Entrada)obj);
                    //ShowPdf(path);
                    //HTMLToPdf(getHtmlPdf(((Entrada)obj)), path);

                    ShowPdf(path);

                    break;

                case "salida":
                    obj         = (Salida)Session["SSalida"];
                    RptFileName = ((Salida)obj).Folio + ((Salida)obj).Folio_indice + ".pdf";
                    path        = HttpContext.Current.Server.MapPath("~/rpt/salidas/") + RptFileName;

                    switch (((Salida)obj).Id_cliente)
                    {
                    case 1:
                    case 9:
                    case 11:
                    case 12:
                    case 13:
                    case 14:
                    case 15:
                    case 25:
                    case 30:
                    case 32:
                        TemplatePath = HttpContext.Current.Server.MapPath("~/report/Formatos/salida.rpt");
                        DocSalida.getSalida(path, TemplatePath, (Salida)obj, ds);
                        break;

                    default:
                        pathImg      = HttpContext.Current.Server.MapPath("~/images/logo.jpg");
                        TemplatePath = HttpContext.Current.Server.MapPath("~/rpt/TemplateSalida.pdf");
                        DocSalida.getSalida(path, TemplatePath, (Salida)obj);
                        break;
                    }


                    ShowPdf(path);
                    break;

                case "remision":
                    obj          = (Salida_remision)Session["SSalida_remision"];
                    RptFileName  = ((Salida_remision)obj).Folio_remision + ".pdf";
                    path         = HttpContext.Current.Server.MapPath("~/rpt/remisiones/") + RptFileName;
                    pathImg      = HttpContext.Current.Server.MapPath("~/images/logo.jpg");
                    TemplatePath = HttpContext.Current.Server.MapPath("~/rpt/TemplateRemision.pdf");
                    DocRemision.getRemision(path, TemplatePath, (Salida_remision)obj);
                    ShowPdf(path);
                    break;

                case "ordcarga":
                    //obj = (Salida_orden_carga)Session["SSalida_ord_carga"];
                    obj          = SalidaCtrl.OrdenCargaGetById(Convert.ToInt32(Request["id"].ToString()), false);
                    RptFileName  = ((Salida_orden_carga)obj).Folio_orden_carga + ".pdf";
                    path         = HttpContext.Current.Server.MapPath("~/rpt/ordencarga/") + RptFileName;
                    pathImg      = HttpContext.Current.Server.MapPath("~/images/logo.jpg");
                    TemplatePath = HttpContext.Current.Server.MapPath("~/rpt/TemplateOrdenCarga.pdf");
                    DocOrdenCarga.getOrdenCarga(path, TemplatePath, (Salida_orden_carga)obj);
                    ShowPdf(path);
                    break;

                case "ordCargaSal":
                    obj              = SalidaCtrl.OrdenCargaGetById(Convert.ToInt32(((Usuario)Session["userCasc"]).Id_print), false);
                    RptFileName      = ((Salida_orden_carga)obj).Folio_orden_carga + "_S.pdf";
                    path             = HttpContext.Current.Server.MapPath("~/rpt/ordencarga/") + RptFileName;
                    TemplatePath     = HttpContext.Current.Server.MapPath("~/report/Formatos/salida.rpt");
                    TemplatePathCond = HttpContext.Current.Server.MapPath("~/report/Formatos/auduniemb.rpt");
                    DocSalida.getSalidaOC(path, new string[] { TemplatePath, TemplatePathCond }, (Salida_orden_carga)obj, ds);
                    ShowPdf(path);
                    break;

                case "rptAlmRes":
                    int anio = Convert.ToInt32(Request["anio"]);
                    int mes  = Convert.ToInt32(Request["mes"]);
                    RptFileName  = "Resumen_" + anio.ToString() + "_" + mes.ToString() + ".pdf";
                    TemplatePath = HttpContext.Current.Server.MapPath("~/rpt/TemplateResAlm.pdf");
                    path         = HttpContext.Current.Server.MapPath("~/rpt/rptAlm/") + RptFileName;
                    DocAlmacenResumen.getAlmResumen(path, TemplatePath, anio, mes);
                    ShowPdf(path);
                    break;

                case "ordCargaSalTra":
                    obj = SalidaCtrl.OrdenCargaGetById(Convert.ToInt32(((Usuario)Session["userCasc"]).Id_print), false);
                    ((Salida_orden_carga)obj).LstSalida = ((Salida_orden_carga)Session["SSalida_ord_carga"]).LstSalida;
                    foreach (Salida_orden_carga_tc itemTC in ((Salida_orden_carga)obj).PLstSalOCTransCond)
                    {
                        itemTC.Si_no = ((Salida_orden_carga)Session["SSalida_ord_carga"]).PLstSalOCTransCond.Find(p => p.Id_transporte_condicion == itemTC.Id_transporte_condicion).Si_no;
                    }
                    RptFileName      = ((Salida_orden_carga)obj).Folio_orden_carga + "_S.pdf";
                    path             = HttpContext.Current.Server.MapPath("~/rpt/ordencarga/") + RptFileName;
                    TemplatePathCond = HttpContext.Current.Server.MapPath("~/report/Formatos/auduniemb.rpt");
                    DocSalida.getSalidaOCTransCondicion(path, TemplatePathCond, (Salida_orden_carga)obj, ((Salida_orden_carga)obj).LstSalida.First(), ds);
                    Session.Remove("SSalida_ord_carga");
                    ShowPdf(path);
                    break;

                case "maqpso":
                    obj          = (Orden_trabajo_servicio)Session["SOrdTbjSer"];
                    RptFileName  = ((Orden_trabajo_servicio)obj).Ref1 + ".pdf";
                    path         = HttpContext.Current.Server.MapPath("~/rpt/maqpas/") + RptFileName;
                    TemplatePath = HttpContext.Current.Server.MapPath("~/report/Formatos/maqpso.rpt");
                    DocOdnTbj.getOdnTbjSrv(path, TemplatePath, (Orden_trabajo_servicio)obj, ds);
                    //DocEntrada.getEntrada(path, TemplatePath, (Entrada)obj, ds);
                    Session.Remove("SOrdTbjSer");
                    ShowPdf(path);
                    break;

                case "SalAud":
                    key = Request["_key"].ToString();
                    Salida_transporte_auditoria sTA = SalidaCtrl.SalidaTransporteAuditoriaGet(Convert.ToInt32(key));
                    RptFileName  = sTA.Folio + ".pdf";
                    path         = HttpContext.Current.Server.MapPath("~/rpt/salaudtrans/") + RptFileName;
                    TemplatePath = HttpContext.Current.Server.MapPath("~/report/Formatos/auduniemb.rpt");
                    DocSalida.getSalidaAudUni(path, TemplatePath, sTA, ds);
                    ShowPdf(path);
                    break;

                default:
                    break;
                }
            }
            catch
            {
                throw;
            }
        }
Example #2
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;
            }
        }