예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strFormatoReporte = "PDF";  //PDF, XLS, DOC

            if (Session["FormatoReporte"] != null) strFormatoReporte = Session["FormatoReporte"].ToString();

            MemoryStream stream = new MemoryStream();
            myReportDocument = (CrystalDecisions.CrystalReports.Engine.ReportDocument)Session["ReporteCrystal"];

            switch (strFormatoReporte)
            {
                case "PDF":
                    stream = (MemoryStream)myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    Response.ContentType = "application/pdf";
                    break;
                case "XLS":
                    stream = (MemoryStream)myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                    Response.ContentType = "application/vnd.ms-excel";
                    break;
                case "DOC":
                    stream = (MemoryStream)myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.WordForWindows);
                    Response.ContentType = "application/doc";
                    break;
                default:
                    stream = (MemoryStream)myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    Response.ContentType = "application/pdf";
                    break;
            }

            myReportDocument.Close();
            myReportDocument.Dispose();

            //Escribir PDF
            Response.Clear();
            Response.Buffer = true;
            //Response.ContentType = "application/pdf";

            Response.BinaryWrite(stream.ToArray());
            Response.End();

            stream.Flush();
            stream.Close();
            stream.Dispose();

            //Cerrar Ventana
            //string lstScript = "<script language='JavaScript'>window.close(); </script>";
            //this.ClientScript.RegisterStartupScript(this.GetType(), "s", lstScript);
        }
예제 #2
0
        public ActionResult ExportData_IU(ApplicationHeaderInfo pInfo, App_Detail_PLD01_HDCN_Info pDetail,
                                          List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo)
        {
            try
            {
                string language = AppsCommon.GetCurrentLang();

                // Fill export_header
                string fileName_docx = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VI_" + TradeMarkAppCode.AppCode_TM_4C2_PLD_01_HDCN + ".docx");

                AppsCommon.Prepare_Data_Export_D01(ref pDetail, pInfo, pAppDocumentInfo, pFeeFixInfo);

                List <App_Detail_PLD01_HDCN_Info> _lst = new List <App_Detail_PLD01_HDCN_Info>();
                _lst.Add(pDetail);

                DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_PLD01_HDCN_Info>(_lst, false);
                _ds_all.Tables[0].TableName = "Table_4c2";

                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _tempfile    = "TM_PLD01_HDCN.rpt";
                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf");
                if (language == Language.LangVI)
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf";
                }
                else
                {
                    _tempfile    = "TM_PLD01_HDCN_EN.rpt"; // tiếng anh
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf";
                }
                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));
                //oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), "TM_PLD01_HDCN.rpt"));

                if (_ds_all != null)
                {
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                System.IO.Stream oStream   = oRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[]           byteArray = new byte[oStream.Length];
                oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
                System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
 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"));
     }
 }
예제 #4
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;
            }
        }
예제 #5
0
        public byte[] RunReport(String reportName, String fileName, string travelRequestId)
        {
            byte[]         response         = null;
            ConnectionInfo crConnectionInFo = new ConnectionInfo();

            CrystalDecisions.CrystalReports.Engine.Tables crTables;
            TableLogOnInfo             crTableLogonInfo             = new TableLogOnInfo();
            DiskFileDestinationOptions crDiskFileDestinationOptions = new CrystalDecisions.Shared.DiskFileDestinationOptions();
            ExportOptions crExportOptions = new CrystalDecisions.Shared.ExportOptions();

            CrystalDecisions.CrystalReports.Engine.ReportDocument dReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            String rptPath = System.Web.Hosting.HostingEnvironment.MapPath(System.Configuration.ConfigurationManager.AppSettings["rptPath"]);
            String fName   = fileName;

            dReport.Load(rptPath + reportName);

            dReport.SetParameterValue("p_travelrequestID", travelRequestId);
            if (reportName == "Travel_Business_Expense.rpt")
            {
                dReport.SetParameterValue("p_travelrequestID", travelRequestId);
            }


            string defaultConnectionString = ConfigurationManager.ConnectionStrings["CrystalReport"].ConnectionString;
            var    builder = new DbConnectionStringBuilder();

            builder.ConnectionString = defaultConnectionString;

            crConnectionInFo.DatabaseName = "";
            crConnectionInFo.ServerName   = builder["SERVICE_NAME"].ToString();
            crConnectionInFo.UserID       = builder["User ID"].ToString();
            crConnectionInFo.Password     = builder["Password"].ToString();



            crTables = dReport.Database.Tables;
            crTableLogonInfo.ConnectionInfo = crConnectionInFo;

            foreach (CrystalDecisions.CrystalReports.Engine.Table rTable in crTables)
            {
                rTable.ApplyLogOnInfo(crTableLogonInfo);
            }
            foreach (CrystalDecisions.CrystalReports.Engine.ReportDocument subrpt in dReport.Subreports)
            {
                foreach (CrystalDecisions.CrystalReports.Engine.Table rTable in subrpt.Database.Tables)
                {
                    rTable.ApplyLogOnInfo(crTableLogonInfo);
                }
            }

            try
            {
                var memoryStream = new MemoryStream();
                var data         = dReport.ExportToStream(ExportFormatType.PortableDocFormat);
                data.CopyTo(memoryStream);
                response = memoryStream.ToArray();


                if (File.Exists(rptPath + "Exported/" + fileName + ".pdf"))
                {
                    File.Delete(rptPath + "Exported/" + fileName + ".pdf");
                }
                FileStream file = new FileStream(rptPath + "Exported/" + fileName + ".pdf", FileMode.Create, FileAccess.ReadWrite);
                memoryStream.WriteTo(file);
                file.Close();
                file.Dispose();
                memoryStream.Close();
                memoryStream.Dispose();

                //File.WriteAllBytes(rptPath+"Exported/"+fileName+".pdf", response);
            }
            catch (Exception ex)
            {
                LogMessage.Log("Error generating crystal report : " + ex.Message);
                throw new Exception(ex.Message);
            }
            finally
            {
                dReport.Close();
                dReport.Dispose();
            }
            return(response);
        }
예제 #6
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataSet dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);

        #region 前置檢查與參數過濾

        string par_ProgramID = string.Empty;
        string par_LoginUser = string.Empty;

        string sTemp;
        par_ProgramID = this.PageCode;
        par_LoginUser = Session["UID"].ToString();

        #endregion

        #region 組合查詢條件至Report ArrayList

        report.SetParameterValue("ProgramName", par_ProgramID);
        report.SetParameterValue("UserName", par_LoginUser); //"/"

        report.SetParameterValue("AcceptDate", this.SLP_Accept_Range.RangeStartTextBox.Text + " - " + this.SLP_Accept_Range.RangeEndTextBox.Text);

        if (this.SLP_VENDER_BEGIN.Text == string.Empty && this.SLP_VENDER_END.Text == string.Empty)
            sTemp = string.Empty;
        else if (this.SLP_VENDER_BEGIN.Text == string.Empty)
            sTemp = "          " + " - " + this.SLP_VENDER_END.Text + "" + this.SLP_VENDER_END.Name;
        else if (this.SLP_VENDER_END.Text == string.Empty)
            sTemp = this.SLP_VENDER_BEGIN.Text + "" + this.SLP_VENDER_BEGIN.Name + " - ";
        else
            sTemp = this.SLP_VENDER_BEGIN.Text + "" + this.SLP_VENDER_BEGIN.Name + " - "
                  + this.SLP_VENDER_END.Text + "" + this.SLP_VENDER_END.Name;

        report.SetParameterValue("Vendor", sTemp);

        if (this.SLP_RootNoStart.Text == string.Empty && this.SLP_RootNoEnd.Text == string.Empty)
            sTemp = string.Empty;
        else if (this.SLP_RootNoStart.Text == string.Empty)
            sTemp = "          " + " - " + this.SLP_RootNoEnd.Text + "" + this.SLP_RootNoEnd.Name;
        else if (this.SLP_RootNoEnd.Text == string.Empty)
            sTemp = this.SLP_RootNoStart.Text + "" + this.SLP_RootNoStart.Name + " - ";
        else
            sTemp = this.SLP_RootNoStart.Text + "" + this.SLP_RootNoStart.Name + " - "
                  + this.SLP_RootNoEnd.Text + "" + this.SLP_RootNoEnd.Name;

        report.SetParameterValue("RootNo", sTemp);

        if (this.SLP_PMA_BEGIN.Text == string.Empty && this.SLP_PMA_END.Text == string.Empty)
            sTemp = string.Empty;
        else if (this.SLP_PMA_BEGIN.Text == string.Empty)
            sTemp = "          " + " - " + this.SLP_PMA_END.Text + "" + this.SLP_PMA_END.Name;
        else if (this.SLP_PMA_END.Text == string.Empty)
            sTemp = this.SLP_PMA_BEGIN.Text + "" + this.SLP_PMA_BEGIN.Name + " - ";
        else
            sTemp = this.SLP_PMA_BEGIN.Text + "" + this.SLP_PMA_BEGIN.Name + " - "
                  + this.SLP_PMA_END.Text + "" + this.SLP_PMA_END.Name;

        report.SetParameterValue("PMA", sTemp);

        if (this.SLP_CATEGORY_BEGIN.Text == string.Empty && this.SLP_CATEGORY_END.Text == string.Empty)
            sTemp = string.Empty;
        else if (this.SLP_CATEGORY_BEGIN.Text == string.Empty)
            sTemp = "          " + " - " + this.SLP_CATEGORY_END.Text + "" + this.SLP_CATEGORY_END.Name;
        else if (this.SLP_CATEGORY_END.Text == string.Empty)
            sTemp = this.SLP_CATEGORY_BEGIN.Text + "" + this.SLP_CATEGORY_BEGIN.Name + " - ";
        else
            sTemp = this.SLP_CATEGORY_BEGIN.Text + "" + this.SLP_CATEGORY_BEGIN.Name + " - "
                  + this.SLP_CATEGORY_END.Text + "" + this.SLP_CATEGORY_END.Name;

        report.SetParameterValue("CATEGORY", sTemp);

        report.SetParameterValue("Item", this.SLP_SKU.Text);
        report.SetParameterValue("Period", this.SLP_PERIOD.Text);
        if (this.rdabNormal.Checked == true)
            report.SetParameterValue("Type", this.rdabNormal.Text);
        else if (this.rdNormal.Checked == true)
            report.SetParameterValue("Type", this.rdNormal.Text);

        #endregion

        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/vnd.ms-excel";
                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            case "PDF":


                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";

                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                //Response.OutputStream.Write("AA", 0, 2);

                Response.Flush();
                Response.Close();
                report.Close();

                break;
            default:

                break;
        }

    }
예제 #7
0
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);



        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                Response.ContentType = "application/vnd.ms-excel";


                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();

                break;
            case "PDF":

                string s_par_Program_ID = string.Empty;
                string s_par_LoginUser = string.Empty;

                s_par_Program_ID = this.PageCode;
                s_par_LoginUser = Session["UID"].ToString();


                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                break;
            default:

                break;
        }

    }
예제 #8
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);
        string par_ProgramID = string.Empty;
        string par_LoginUser = string.Empty;
        string par_Chan1 = string.Empty;
        string par_Chan2 = string.Empty;
        string par_Chan3 = string.Empty;

        #region 前置檢查與參數過濾

        string par_PlanAcceptData = this.txtPLAN_ACCEPT_DATE.Text;
        par_ProgramID = this.PageCode;
        string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();

        par_LoginUser = Session["UID"].ToString() + " " + Login_Name;

        if (dt_Source.Rows[0]["No1_Name"] != System.DBNull.Value)
        {
            par_Chan1 = dt_Source.Rows[0]["No1_Name"].ToString();
        }


        if (dt_Source.Rows[0]["No2_Name"] != System.DBNull.Value)
        {
            par_Chan2 = dt_Source.Rows[0]["No2_Name"].ToString();
        }


        if (dt_Source.Rows[0]["No3_Name"] != System.DBNull.Value)
        {
            par_Chan3 = dt_Source.Rows[0]["No3_Name"].ToString();
        }        

        #endregion

        #region 組合查詢條件至ArrayList
        
        report.SetParameterValue("par_ProgramID", par_ProgramID);
        report.SetParameterValue("par_LoginUser", par_LoginUser);
        report.SetParameterValue("par_PlanAcceptDate", GetValueSetParameter(par_PlanAcceptData, "string"));
        report.SetParameterValue("par_Chan1", par_Chan1);
        report.SetParameterValue("par_Chan2", par_Chan2);
        report.SetParameterValue("par_Chan3", par_Chan3);
        #endregion

        #region 判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":
                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名                
                Response.ContentType = "application/vnd.ms-excel";                
                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;

            case "PDF":
                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            default:

                break;
        }
        #endregion

    }
예제 #9
0
    // show報表
    private void ShowReport(DataSet ds)
    {
        try
        {
            string strFileName = "";
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            report.Load(Server.MapPath("./REPORT/MKT05/CRMKT05R01.rpt"));
            strFileName = HttpUtility.UrlEncode("採購卡.PDF", System.Text.Encoding.UTF8);

            report.SetDataSource(ds);

            System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            byte[] bytesPDF = new byte[streamPDF.Length];
            streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
            streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

            //export file  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);//pdf檔名  
            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
            Response.Flush();
            Response.Close();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
            UpdatePanel_ErrMsg.Update();
        }
    }
예제 #10
0
        protected void InicializaPagina()
        {
            int IdOrdenCompra;

            string id = Request.QueryString["id"].ToString();

            IdOrdenCompra = Convert.ToInt32(id);

            OrdenCompraDTO objOrdenCompraDTO = objOrdenCompraDAO.ListarPorClave(IdOrdenCompra);
            ProveedorDTO objProveedorDTO = objProveedorDAO.ListarPorClave(objOrdenCompraDTO.IdProveedor);
            List<OrdenCompraLineaDTO> objOrdenCompraLinea = objOrdenCompraLineaDAO.Listar(IdOrdenCompra);
            ParametroDTO objParametroDTO = objParametroDAO.ListarPorClave(1);
            FormaPagoDTO objFormaPagoDTO = objFormaPagoDAO.ListarPorClave(objOrdenCompraDTO.IdFormaPago);
            MonedaDTO objMonedaDTO = objMonedaDAO.ListarPorClave(objOrdenCompraDTO.CodMoneda);
            CotizacionDTO objCotizacionDTO = objCotizacionDAO.ListarPorClave(objOrdenCompraDTO.IdCotizacion);
            PedidoDTO objPedidoDTO = objPedidoDAO.ListarPorClave(objCotizacionDTO.IdPedido);
            UsuarioDTO objUsuarioDTO = objUsuarioDAO.ListarPorClave(objPedidoDTO.IdSolicitante);
            List<PedidoPresupuestoDTO> ListaPedidoPresupuestoDTO = objPedidoPresupuestoDAO.Listar(objPedidoDTO.IdPedido);

            dsReportes dsReporte = new dsReportes();

            dsReportes.ParametroRow drParametroRow = dsReporte.Parametro.NewParametroRow();
            drParametroRow.id_reporte = 1;
            drParametroRow.empresa = objParametroDTO.RazonSocial;

            if (objOrdenCompraDTO.IdTipoOrdenCompra == 1)
                drParametroRow.titulo1 = "ORDEN DE COMPRA N° " + objOrdenCompraDTO.IdOrdenCompra.ToString();
            else
                if (objOrdenCompraDTO.IdTipoOrdenCompra == 2)
                    drParametroRow.titulo1 = "ORDEN DE SERVICIO N° " + objOrdenCompraDTO.IdOrdenCompra.ToString();
                else
                    drParametroRow.titulo1 = "ORDEN N° " + objOrdenCompraDTO.IdOrdenCompra.ToString();

            dsReporte.Parametro.AddParametroRow(drParametroRow);

            //MONTO DE IGV
            IgvDTO objIGVDTO = objIGVDAO.ListarIGVVigente(objOrdenCompraDTO.FechaOrdenCompra);

            dsReportes.OrdenCompraRow drOrdenCompraRow = dsReporte.OrdenCompra.NewOrdenCompraRow();
            drOrdenCompraRow.IdReporte = 1;
            drOrdenCompraRow.IdOrdenCompra = objOrdenCompraDTO.IdOrdenCompra;

            if (objProveedorDTO != null)
            {
                drOrdenCompraRow.RazonSocial = objProveedorDTO.RazonSocial;
                drOrdenCompraRow.Ruc = objProveedorDTO.Ruc;
                drOrdenCompraRow.Direccion = objProveedorDTO.Direccion;
                drOrdenCompraRow.Contacto = objProveedorDTO.Contacto;
            }

            drOrdenCompraRow.Fecha = objOrdenCompraDTO.FechaOrdenCompra.ToString("dd/MM/yyyy");
            drOrdenCompraRow.Cotizacion = "Estimación N° " + objOrdenCompraDTO.IdCotizacion.ToString();

            if (objMonedaDTO!=null)
                drOrdenCompraRow.Moneda = objMonedaDTO.Simbolo;

            drOrdenCompraRow.Subtotal = objOrdenCompraDTO.ImporteOrdenCompra;

            if (objOrdenCompraDTO.FechaEntrega.Year!=1)
                drOrdenCompraRow.FechaEntrega = objOrdenCompraDTO.FechaEntrega.ToString("dd/MM/yyyy");

            if (objFormaPagoDTO!=null)
                drOrdenCompraRow.FormaPago = objFormaPagoDTO.NombreFormaPago;

            if (objParametroDTO != null)
            {
                drOrdenCompraRow.FacturarNombre = objParametroDTO.RazonSocial;
                drOrdenCompraRow.FacturarRuc = objParametroDTO.Ruc;
                drOrdenCompraRow.Direccion = objParametroDTO.Direccion;
            }

            drOrdenCompraRow.Proyecto = objOrdenCompraDTO.NombreProyecto;

            string codigos = "";
            if (ListaPedidoPresupuestoDTO.Count > 0)
            {
                foreach (PedidoPresupuestoDTO item in ListaPedidoPresupuestoDTO)
                {
                    codigos = codigos + " " + item.CodigoPresupuesto;
                }
            }

            drOrdenCompraRow.Descripcion = "Solicitado por " + objUsuarioDTO.NombreUsuario + " - Código: " + codigos;

            if (objOrdenCompraDTO.FlagIGV == "1")
            {
                drOrdenCompraRow.IGV = drOrdenCompraRow.Subtotal * (objIGVDTO.Igv / 100);
                drOrdenCompraRow.Total = drOrdenCompraRow.Subtotal + drOrdenCompraRow.IGV;
                drOrdenCompraRow.PorcentajeIGV = objIGVDTO.Igv.ToString() + "%";
            }
            else
            {
                drOrdenCompraRow.IGV = 0;
                drOrdenCompraRow.Total = drOrdenCompraRow.Subtotal + drOrdenCompraRow.IGV;
                drOrdenCompraRow.PorcentajeIGV = "0%";
            }

            /*
            if (objOrdenCompraDTO.IdTipoOrdenCompra == 2)
            {
                drOrdenCompraRow.IGV = 0;
                drOrdenCompraRow.Total = drOrdenCompraRow.Subtotal + drOrdenCompraRow.IGV;
                drOrdenCompraRow.PorcentajeIGV = "0%";
            }
            else
            {
                drOrdenCompraRow.IGV = drOrdenCompraRow.Subtotal * (objIGVDTO.Igv / 100);
                drOrdenCompraRow.Total = drOrdenCompraRow.Subtotal + drOrdenCompraRow.IGV;
                drOrdenCompraRow.PorcentajeIGV = objIGVDTO.Igv.ToString() + "%";
            }
            */
            drOrdenCompraRow.TotalLetras = "SON: " + AppUtilidad.numberToText(drOrdenCompraRow.Total.ToString()) + " " + objMonedaDTO.NombreMoneda;

            dsReporte.OrdenCompra.AddOrdenCompraRow(drOrdenCompraRow);

            foreach (OrdenCompraLineaDTO linea in objOrdenCompraLinea)
            {

                InvUnidadMedidaDTO objInvUnidadMedidaDTO = objInvUnidadMedidaDAO.ListarPorClave(linea.IdUnidadMedida);
                dsReportes.OrdenCompraLineasRow drOrdenCompraLineasRow = dsReporte.OrdenCompraLineas.NewOrdenCompraLineasRow();

                drOrdenCompraLineasRow.IdReporte = 1;
                drOrdenCompraLineasRow.IdOrdenCompra = objOrdenCompraDTO.IdOrdenCompra;
                drOrdenCompraLineasRow.Linea = linea.NumeroLinea;
                drOrdenCompraLineasRow.Cantidad = linea.Cantidad;

                if (objInvUnidadMedidaDTO != null)
                    drOrdenCompraLineasRow.UnidadMedida = objInvUnidadMedidaDTO.NombreCorto;

                drOrdenCompraLineasRow.DescripcionLinea = linea.DescripcionLinea;
                drOrdenCompraLineasRow.PrecioUnitario = linea.Precio;
                drOrdenCompraLineasRow.Importe = linea.Importe;
                dsReporte.OrdenCompraLineas.AddOrdenCompraLineasRow(drOrdenCompraLineasRow);
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
            myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string strRuta = Server.MapPath("rptOrdenCompra.rpt");
            myReportDocument.Load(strRuta);
            myReportDocument.SetDataSource(dsReporte);
            Session.Add("ReporteCrystal", myReportDocument);
            Session.Add("FormatoReporte", "PDF");

            MemoryStream stream = new MemoryStream();
            stream = (MemoryStream)myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.ContentType = "application/pdf";

            myReportDocument.Close();
            myReportDocument.Dispose();

            Response.Clear();
            Response.Buffer = true;

            Response.BinaryWrite(stream.ToArray());
            Response.End();

            stream.Flush();
            stream.Close();
            stream.Dispose();
        }
예제 #11
0
        public ActionResult ExportData_View_IU(ApplicationHeaderInfo pInfo, App_Detail_C01_Info pDetail,
                                               List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo, List <AppDocumentOthersInfo> pAppDocOtherInfo, List <AppDocumentOthersInfo> pLstImagePublic)
        {
            try
            {
                string _datetimenow             = DateTime.Now.ToString("ddMMyyyyHHmm");
                string language                 = AppsCommon.GetCurrentLang();
                List <App_Detail_C01_Info> _lst = new List <App_Detail_C01_Info>();

                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                if (language == Language.LangVI)
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf";
                }
                else
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf";
                }

                AppsCommon.Prepare_Data_Export_C01(ref pDetail, pInfo, pAppDocumentInfo, pLstImagePublic);
                if (pAppDocOtherInfo != null)
                {
                    foreach (var item in pAppDocOtherInfo)
                    {
                        pDetail.Note += item.Documentname + " ; ";
                    }

                    if (pAppDocOtherInfo.Count > 0)
                    {
                        pDetail.Note = pDetail.Note.Substring(0, pDetail.Note.Length - 2);
                    }
                }
                _lst.Add(pDetail);

                DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_C01_Info>(_lst, false);
                //_ds_all.WriteXml(@"C:\inetpub\A01.xml", XmlWriteMode.WriteSchema);
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _tempfile = "C01.rpt";
                if (language == Language.LangEN)
                {
                    _tempfile = "C01_EN.rpt";
                }
                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table";
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                //oRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fileName_pdf);

                System.IO.Stream oStream   = oRpt.ExportToStream(ExportFormatType.PortableDocFormat);
                byte[]           byteArray = new byte[oStream.Length];
                oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
                System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
예제 #12
0
    private void ShowReport()
    {
        #region

        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        try
        {
            string strFileName = "";

            report.Load(Server.MapPath("./REPORT/ALO21/ALO21R01.rpt"));
            strFileName = HttpUtility.UrlEncode("轉門市進貨單明細表.pdf", System.Text.Encoding.UTF8);


            #region 2010/02/11 重新查詢
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(SLP_SLPDate1.Text);//門市進貨日
            ParameterList.Add(SLP_SLPDate2.Text);//轉門市進貨單日
            ParameterList.Add(GetDisTypeSelectedValue());//配本方式
            ParameterList.Add(SLP_SLPNumber1.Text);//理貨批次
            ParameterList.Add(Session["UID"].ToString());//執行者
            ParameterList.Add(DateTime.Now);//執行日期
            ParameterList.Add(string.Format("{0}_{1}", PageTimeStamp.Value, Session["UID"].ToString()));//PageTimeStamp_LoginID :Session_ID
            ParameterList.Add(-1);//最大筆數

            ALOModel.MaintainStAccept BCO = new ALOModel.MaintainStAccept(ConnectionDB);

            string strErrMsg = "";
            DataTable Dt = null;

            if (rbtn_TransStatus1.Checked)//已轉單
            {
                #region
                Dt = BCO.QueryStOutAcceptData(ParameterList, out strErrMsg);
                #endregion
            }
            else//未轉單
            {
                #region
                Dt = BCO.QueryForFind(ParameterList, out strErrMsg);
                #endregion
            }

            #endregion

            report.SetDataSource(Dt);

            string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();

            report.SetParameterValue("par_Program_ID", "ALO21R01");
            report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
            report.SetParameterValue("par_StAcceptDate", SLP_SLPDate1.Text);
            report.SetParameterValue("par_OutStAcceptDate", SLP_SLPDate2.Text);
            report.SetParameterValue("par_DisType", GetDisTypeSelectedText());

            System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            byte[] bytesPDF = new byte[streamPDF.Length];
            streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
            streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

            //export file  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);//pdf檔名  
            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
            Response.Flush();
            Response.Close();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            report.Close();
        }
        #endregion
    }
예제 #13
0
        protected void InicializaPagina()
        {
            int linea = 0;

            string id = Request.QueryString["id"].ToString();
            string id2 = Request.QueryString["id2"].ToString();

            Decimal dStockArticulo = 0;
            List<InvTransaccionDTO> objTransaccionLista = objTransaccionDAO.ListarPorArticuloProyecto(Convert.ToInt32(id), Convert.ToInt32(id2));
            ParametroDTO objParametroDTO = objParametroDAO.ListarPorClave(1);
            ArticuloDTO objArticuloDTO = objArticuloDAO.ListarPorClave(Convert.ToInt32(id));
            InvUnidadMedidaDTO objInvUnidadMedidaDTO = objUnidadMedidaDAO.ListarPorClave(objArticuloDTO.IdUnidadMedida);
            ProyectoDTO objProyectoDTO = objProyectoDAO.ListarPorClave(Convert.ToInt32(id2));

            dsReportes dsReporte = new dsReportes();
            dsReportes.ParametroRow drParametroRow = dsReporte.Parametro.NewParametroRow();
            drParametroRow.id_reporte = 1;
            drParametroRow.empresa = objParametroDTO.RazonSocial;
            drParametroRow.fecha = DateTime.Now.ToString("dd/MM/yyyy");
            dsReporte.Parametro.AddParametroRow(drParametroRow);

            foreach (InvTransaccionDTO fila in objTransaccionLista)
            {
                InvTipoTransaccionDTO objInvTipoTransaccionDTO = objTipoTransaccionDAO.ListarPorClave(fila.IdTipoTransaccion);
                dsReportes.KardexRow drKardexRow = dsReporte.Kardex.NewKardexRow();
                linea = linea + 1;
                drKardexRow.id_reporte = 1;
                drKardexRow.linea = linea;
                drKardexRow.fecha = fila.Fecha.ToString("dd/MM/yyyy");
                drKardexRow.nombre_articulo = objArticuloDTO.Descripcion;
                drKardexRow.codigo_articulo = objArticuloDTO.CodigoArticulo;
                drKardexRow.unidad_medida = objInvUnidadMedidaDTO.NombreUnidadMedida;
                drKardexRow.area = objProyectoDTO.NombreProyecto;
                drKardexRow.observaciones = fila.Descripcion;// objInvTipoTransaccionDTO.NombreTransaccion;

                if (objInvTipoTransaccionDTO.Clase.Equals("I"))
                {
                    dStockArticulo += fila.Cantidad;
                    drKardexRow.entrada = fila.Cantidad;
                    drKardexRow.saldo = dStockArticulo;
                }
                else
                {
                    dStockArticulo -= fila.Cantidad;
                    drKardexRow.salida = fila.Cantidad;
                    drKardexRow.saldo = dStockArticulo;
                }

                dsReporte.Kardex.AddKardexRow(drKardexRow);

            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
            myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string strRuta = Server.MapPath("KardexArticulo.rpt");
            myReportDocument.Load(strRuta);
            myReportDocument.SetDataSource(dsReporte);
            Session.Add("ReporteCrystal", myReportDocument);
            Session.Add("FormatoReporte", "PDF");

            MemoryStream stream = new MemoryStream();
            stream = (MemoryStream)myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.ContentType = "application/pdf";

            myReportDocument.Close();
            myReportDocument.Dispose();

            Response.Clear();
            Response.Buffer = true;

            Response.BinaryWrite(stream.ToArray());
            Response.End();

            stream.Flush();
            stream.Close();
            stream.Dispose();
        }
예제 #14
0
    //列印報表
    private void ShowReport(DataSet ds)
    {
        #region 利用CrystalReport列印報表

        //使用者名稱
        DataTable dt1 = new DataTable();
        dt1 = (DataTable)Session["UserInfo"];
        string Login_Name = dt1.Rows[0]["Name"].ToString();

        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        report.Load(Server.MapPath("./REPORT/ITM061R.rpt"));
        report.SetDataSource(ds);
        report.Subreports["ITM061R2"].SetDataSource(ds);
        report.Subreports["ITM061R3"].SetDataSource(ds);

        report.SetParameterValue("ProgramName", "ITM061R");
        report.SetParameterValue("UserName", Session["UID"].ToString() + Login_Name);

        if (this.txtCREATEDATE.StartDate.ToString() == "" && this.txtCREATEDATE.EndDate.ToString() == "")
            report.SetParameterValue("QueryDateRange", "全部");
        else
            report.SetParameterValue("QueryDateRange", this.txtCREATEDATE.StartDate.ToString() + "~" + this.txtCREATEDATE.EndDate.ToString());

        if (this.SLP_TimeRange1.StartTime.ToString() == "" && this.SLP_TimeRange1.EndTime.ToString() == "")
            report.SetParameterValue("QueryTime", "全部");
        else
            report.SetParameterValue("QueryTime", this.SLP_TimeRange1.StartTime.ToString() + "~" + this.SLP_TimeRange1.EndTime.ToString());

        report.SetParameterValue("Par_Count", Convert.ToString(ds.Tables["DataTable1"].Rows.Count) + "筆");

        //檔案匯出
        System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        byte[] bytesPDF = new byte[streamPDF.Length];
        streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
        streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("商品期別異動表.PDF", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/pdf";
        Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
        Response.Flush();
        Response.Close();
        report.Close();
        #endregion
    }
예제 #15
0
    //匯出Excel
    private void ShowReportB(DataTable dt)
    {
        #region 利用CrystalReport匯出Excel

        //使用者名稱
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        report.Load(Server.MapPath("./REPORT/ITM061/ITM062R01.rpt"));
        report.SetDataSource(dt);        

        //檔案匯出
        System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        byte[] bytesXLS = new byte[streamXLS.Length];
        streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
        streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("商品期別異動表_" + System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + ".XLS", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/xls";
        Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
        Response.Flush();
        Response.Close();
        report.Close();
        #endregion
    }
예제 #16
0
        public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate)
        {
            try
            {
                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                string language     = AppsCommon.GetCurrentLang();

                List <E01_Info_Export> _lst = new List <E01_Info_Export>();

                List <AppDocumentInfo> appDocumentInfos      = new List <AppDocumentInfo>();
                List <AppFeeFixInfo>   _lst_appFeeFixInfos   = new List <AppFeeFixInfo>();
                ApplicationHeaderInfo  applicationHeaderInfo = new ApplicationHeaderInfo();

                E01_Info_Export _E01_Info_Export = new E01_Info_Export();
                var             objBL            = new BussinessFacade.ModuleTrademark.Application_Header_BL();

                ApplicationHeaderInfo _app = objBL.GetAllByID(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref _lst_appFeeFixInfos);
                AppsCommon.Prepare_Data_Export_E01(ref _E01_Info_Export, applicationHeaderInfo, appDocumentInfos, _lst_appFeeFixInfos);

                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01" + _datetimenow + ".pdf");
                string _tempfile    = "E01.rpt";
                if (p_View_Translate == 1)
                {
                    // nếu là tiếng việt thì xem bản tiếng anh và ngược lại
                    if (applicationHeaderInfo.Languague_Code == Language.LangEN)
                    {
                        _tempfile    = "E01.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        _tempfile    = "E01_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf";
                    }
                }
                else
                {
                    if (applicationHeaderInfo.Languague_Code == Language.LangVI)
                    {
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        _tempfile    = "E01_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf";
                    }
                }
                _lst.Add(_E01_Info_Export);
                DataSet _ds_all = ConvertData.ConvertToDataSet <E01_Info_Export>(_lst, false);
                //_ds_all.WriteXml(@"D:\E01.xml", XmlWriteMode.WriteSchema);

                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();


                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table1";
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                //oRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fileName_pdf);

                System.IO.Stream oStream   = oRpt.ExportToStream(ExportFormatType.PortableDocFormat);
                byte[]           byteArray = new byte[oStream.Length];
                oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
                System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
예제 #17
0
        public ActionResult ExportData_View_IU(ApplicationHeaderInfo pInfo, List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo)
        {
            try
            {
                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                string language     = AppsCommon.GetCurrentLang();

                List <E01_Info_Export> _lst = new List <E01_Info_Export>();

                string p_appCode    = "E01_Preview";
                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_VN_" + _datetimenow + ".pdf");
                if (language == Language.LangVI)
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_VN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01_VN_" + _datetimenow + ".pdf";
                }
                else
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf";
                }

                E01_Info_Export _E01_Info_Export = new E01_Info_Export();



                // Phí cố định
                List <AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_E01(pInfo);
                AppsCommon.Prepare_Data_Export_E01(ref _E01_Info_Export, pInfo, pAppDocumentInfo, _lstFeeFix);

                _lst.Add(_E01_Info_Export);
                DataSet _ds_all = ConvertData.ConvertToDataSet <E01_Info_Export>(_lst, false);
                //_ds_all.WriteXml(@"D:\E01.xml", XmlWriteMode.WriteSchema);
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _tempfile = "E01.rpt";
                if (language == Language.LangEN)
                {
                    _tempfile = "E01_EN.rpt";
                }
                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table1";
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                //oRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fileName_pdf);

                System.IO.Stream oStream   = oRpt.ExportToStream(ExportFormatType.PortableDocFormat);
                byte[]           byteArray = new byte[oStream.Length];
                oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
                System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
예제 #18
0
        /// <summary>
        /// 產生輸出檔案
        /// </summary>
        /// <param name="s_FileName">產生檔案檔名</param>
        /// <param name="s_rptFilePath">RPT報表檔路徑及檔名</param>
        /// <param name="dt_Source">DB抓取的資料集(DataTable)</param>
        /// <param name="RP">報表變數,如無變數請輸入null</param>
        /// <param name="ROF">報表格式</param>        
        public void LoadCrystalReport(string s_FileName,
                                      string s_rptFilePath,
                                      ref DataTable dt_Source,
                                      ReportParameter[] RP,
                                      string ReportOutputFormat
                                      )
        {
            int bytesRead = 0;

            FileStream FS = new FileStream(s_FileName, FileMode.Create, FileAccess.Write);
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            try
            {
                report.Load(s_rptFilePath);
                report.SetDataSource(dt_Source);

                //判斷輸出檔案型態
                switch (ReportOutputFormat)
                {
                    case "EXCEL":

                        //如果有報表參數
                        if (RP != null)
                        {
                            for (int i = 0; i < RP.Length; i++)
                            {
                                if ((RP[i].ParameterName != "") && (RP[i].ParameterValue != null))
                                {
                                    report.SetParameterValue(RP[i].ParameterName, RP[i].ParameterValue);
                                }
                            }
                        }

                        Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                        byte[] bytesXLS;

                        try
                        {
                            bytesXLS = new byte[streamXLS.Length];
                            bytesRead = streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                            //export file 
                            while (bytesRead > 0)
                            {
                                FS.Write(bytesXLS, 0, bytesRead);
                                bytesRead = streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            bytesXLS = null;

                            streamXLS.Flush();
                            streamXLS.Close();
                            streamXLS.Dispose();
                        }

                        break;


                    case "PDF":

                        //如果有報表參數
                        if (RP != null)
                        {
                            for (int i = 0; i < RP.Length; i++)
                            {
                                if ((RP[i].ParameterName != "") && (RP[i].ParameterValue != null))
                                {
                                    report.SetParameterValue(RP[i].ParameterName, RP[i].ParameterValue);
                                }
                            }
                        }

                        Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                        byte[] bytesPDF;

                        try
                        {
                            bytesPDF = new byte[streamPDF.Length];
                            bytesRead = streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                            //streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                            //export file
                            while (bytesRead > 0)
                            {
                                FS.Write(bytesPDF, 0, bytesRead);
                                bytesRead = streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            bytesPDF = null;

                            streamPDF.Flush();
                            streamPDF.Close();
                            streamPDF.Dispose();
                        }

                        break;
                    default:

                        break;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                FS.Flush();
                FS.Close();
                FS.Dispose();

                report.Close();
                report.Dispose();
                dt_Source.Dispose();
            }
        }
예제 #19
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);


        string par_ProgramID = string.Empty;
        string par_LoginUser = string.Empty;

        #region 前置檢查與參數過濾

        string par_AcceptDate = this.txtST_ACCEPT_DATE.Text;
        string par_ChanName = this.ddlChanNo.SelectedItem.Text.Replace("(", " ") ;
        par_ChanName = par_ChanName.Replace(")", "");

        string par_StoreName = string.Empty;
        if (this.ddlStore.SelectedIndex > 0 )
            par_StoreName = this.ddlStore.SelectedItem.Text;

        par_StoreName = par_StoreName.Replace("(", " ");
        par_StoreName = par_StoreName.Replace(")", " "); 

        par_ProgramID = this.PageCode;
//        par_LoginUser = "******"; 
        par_LoginUser = Session["UID"].ToString();

        #endregion


        #region 組合查詢條件至ArrayList

        ArrayList returnList = new ArrayList();

        returnList.Clear();
        
        report.SetParameterValue("AcceptDate", par_AcceptDate);
        report.SetParameterValue("ProgramName", par_ProgramID);
        report.SetParameterValue("UserName", par_LoginUser);
        report.SetParameterValue("ChanName", par_ChanName);
        report.SetParameterValue("StoreName", par_StoreName);
        

        #endregion

        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                Response.ContentType = "application/vnd.ms-excel";


                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            case "PDF":


                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";

                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            default:

                break;
        }

    }
예제 #20
0
    //Crystal Report 直接輸出 PDF 檔
    private void ExportReport(DataTable dt)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(Server.MapPath("../REPORT/IVM14/CRIVM14R01.rpt"));
        report.SetDataSource(dt);

        //CrystalReport Parameter 參數設定
        string Program_ID = string.Empty;
        string LoginUser = string.Empty;
        string ChanTransNo = string.Empty;

        Program_ID = this.PageCode.Substring(0, 5) + "R01";
        LoginUser = Session["UID"].ToString();
        ChanTransNo = Session["ForChanTransNo"].ToString();

        report.SetParameterValue("par_Program_ID", this.PageCode);
        report.SetParameterValue("par_LoginUser", LoginUser);
        report.SetParameterValue("par_ChanTransNo", ChanTransNo);

        //檔案匯出
        System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        byte[] bytesPDF = new byte[streamPDF.Length];
        streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
        streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("轉入異常資料.PDF", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/pdf";
        Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
        Response.Flush();
        Response.Close();

    }
예제 #21
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="PickNo">揀貨單號</param>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="reportFormatType">檔案型態</param>
    /// <param name="ReportOrderOption">排序類型 "item":品項 "locate":儲位 </param>
    private void LoadCrystalReport(string PickNo, string s_FileName, string s_rptFilePath, string reportFormatType, string ReportOrderOption)
    {

        try
        {
            IVMModel.MaintainPickData BCO = new IVMModel.MaintainPickData(ConntionDB);
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            report.Load(Server.MapPath(s_rptFilePath));

            ParameterList.Clear();
            ParameterList.Add(PickNo);

            if (s_rptFilePath != "./REPORT/IVM15/CRIVM15R03.rpt")
            {

                DataTable dtResult = new DataTable();

                string ProgName = "";

                if (s_rptFilePath == "./REPORT/IVM15/CRIVM15R01.rpt")
                {
                    dtResult = BCO.GetPrintRpt01(ParameterList);
                    ProgName = "IVM15R01";
                }
                else
                {
                    dtResult = BCO.GetPrintRpt02(ParameterList);
                    ProgName = "IVM15R02";
                }

                DataView dv = new DataView(dtResult);

                switch (ReportOrderOption)
                {
                    case "item":
                        dv.Sort = "item";
                        break;

                    case "locate":
                        dv.Sort = "BLocate_No";
                        break;

                    default:
                        dv.Sort = "item";
                        break;
                }

                report.SetDataSource(dv.ToTable());

                report.SetParameterValue("paraProg", ProgName);
                report.SetParameterValue("paraUserID", Session["UID"].ToString());
                report.SetParameterValue("paraPickNo", PickNo);
                report.SetParameterValue("paraSource", this.MenuIVM15.SelectedItem.Text);
                report.SetParameterValue("paraAccDate", "");
                report.SetParameterValue("paraReturnNo", "");
                report.SetParameterValue("paraRemoveNo", "");
                report.SetParameterValue("paraBLocate", "");
                report.SetParameterValue("paraELocate", "");
                report.SetParameterValue("paraVendor", "");

            }
            else
            {
                DataTable dtResult = new DataTable();

                dtResult = BCO.GetPrintRpt03(ParameterList);

                report.SetDataSource(dtResult);

                report.SetParameterValue("paraProg", "IVM15R03");
                report.SetParameterValue("paraUserID", Session["UID"].ToString());
                //report.SetParameterValue("paraKind", "");
            }

            switch (reportFormatType)
            {
                case "EXCEL":

                    System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                    byte[] bytesXLS = new byte[streamXLS.Length];
                    streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                    streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                    Response.ContentType = "application/vnd.ms-excel";


                    Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                    Response.Flush();
                    Response.Close();

                    break;
                case "PDF":


                    System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    byte[] bytesPDF = new byte[streamPDF.Length];
                    streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                    streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                    Response.ContentType = "application/pdf";
                    Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                    Response.Flush();
                    Response.Close();
                    break;
                default:

                    break;
            }

            report.Close();

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }
예제 #22
0
    /// <summary>
    /// 利用 CrystalReport 列印報表
    /// </summary>
    /// <param name="s_FileName">報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// <param name="reportFormatType">檔案型態</param> 
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source1, DataTable dt_Source2, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source2);
        string par_Vendor = string.Empty;
        string par_VendorName = string.Empty;
        string par_PurDate = string.Empty;
        string par_PurchaseNo = string.Empty;
        string par_PlanAcceptDate = string.Empty;

        par_Vendor = dt_Source1.Rows[0]["VENDOR"].ToString();
        par_VendorName = dt_Source1.Rows[0]["VENDOR_NAME"].ToString();
        par_PurDate = dt_Source1.Rows[0]["PURCHSE_DATE"].ToString();
        par_PurchaseNo = dt_Source1.Rows[0]["PURCHASE_NO"].ToString();

        if (dt_Source2.Rows.Count != 0)
        {
            par_PlanAcceptDate = dt_Source2.Rows[0]["PLAN_ACCEPT_DATE"].ToString();
        }
        #region 組合查詢條件至ArrayList
        report.SetParameterValue("par_Vendor", par_Vendor);
        report.SetParameterValue("par_VendorName", par_VendorName);
        if (par_PurDate.Trim() != "")
        {
            report.SetParameterValue("par_PurDate", GetValueSetParameter(par_PurDate, "date"));
        }
        else
        {
            report.SetParameterValue("par_PurDate", "");
        }
        report.SetParameterValue("par_PurchaseNo", par_PurchaseNo);
        if (par_PlanAcceptDate.Trim() != "")
        {
            report.SetParameterValue("par_PlanAcceptDate", GetValueSetParameter(par_PlanAcceptDate, "date"));
        }
        else
        {
            report.SetParameterValue("par_PlanAcceptDate", "");
        }
        #endregion
        #region 判斷輸出檔案型態
        try
        {
            switch (reportFormatType)
            {
                case "EXCEL":

                    System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                    byte[] bytesXLS = new byte[streamXLS.Length];
                    streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                    streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName); // excel 檔名  

                    Response.ContentType = "application/vnd.ms-excel";

                    Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                    Response.Flush();
                    Response.Close();

                    break;
                case "PDF":
                    System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    byte[] bytesPDF = new byte[streamPDF.Length];
                    streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                    streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);
                    Response.ContentType = "application/pdf";
                    Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                    Response.Flush();
                    Response.Close();
                    break;
                default:
                    break;
            }
        }
        catch (Exception ex)
        { 
            this.ErrorMsgLabel.Text = ex.Message; 
        }
        finally 
        {
            report.Close();
        }
        #endregion
    }
예제 #23
0
        public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate)
        {
            try
            {
                string language = AppsCommon.GetCurrentLang();

                App_Detail_C01_BL            objBL = new App_Detail_C01_BL();
                ApplicationHeaderInfo        applicationHeaderInfo  = new ApplicationHeaderInfo();
                App_Detail_C01_Info          app_Detail             = new App_Detail_C01_Info();
                List <AppFeeFixInfo>         appFeeFixInfos         = new List <AppFeeFixInfo>();
                List <AppDocumentInfo>       appDocumentInfos       = new List <AppDocumentInfo>();
                List <AppDocumentOthersInfo> _LstDocumentOthersInfo = new List <AppDocumentOthersInfo>();
                List <AppDocumentOthersInfo> pLstImagePublic        = new List <AppDocumentOthersInfo>();

                app_Detail = objBL.GetByID(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref appFeeFixInfos, ref _LstDocumentOthersInfo, ref pLstImagePublic);

                AppsCommon.Prepare_Data_Export_C01(ref app_Detail, applicationHeaderInfo, appDocumentInfos, pLstImagePublic);

                if (_LstDocumentOthersInfo != null)
                {
                    foreach (var item in _LstDocumentOthersInfo)
                    {
                        app_Detail.Note += item.Documentname + " ; ";
                    }

                    if (_LstDocumentOthersInfo.Count > 0)
                    {
                        app_Detail.Note = app_Detail.Note.Substring(0, app_Detail.Note.Length - 2);
                    }
                }

                List <App_Detail_C01_Info> _lst = new List <App_Detail_C01_Info>();
                _lst.Add(app_Detail);
                DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_C01_Info>(_lst, false);
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                string _tempfile    = "C01.rpt";
                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                if (p_View_Translate == 1)
                {
                    // nếu là tiếng việt thì xem bản tiếng anh và ngược lại
                    if (applicationHeaderInfo.Languague_Code == Language.LangVI)
                    {
                        _tempfile    = "C01_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf";
                    }
                }
                else
                {
                    if (applicationHeaderInfo.Languague_Code == Language.LangVI)
                    {
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        _tempfile    = "C01_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf";
                    }
                }

                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table";
                    //_ds_all.WriteXml(@"C:\inetpub\C01.xml", XmlWriteMode.WriteSchema);

                    // đè các bản dịch lên
                    if (p_View_Translate == 1)
                    {
                        // nếu là bản xem của thằng dịch
                        App_Translate_BL          _App_Translate_BL = new App_Translate_BL();
                        List <App_Translate_Info> _lst_translate    = _App_Translate_BL.App_Translate_GetBy_AppId(pAppHeaderId);

                        AppsCommon.Overwrite_DataSouce_Export(ref _ds_all, _lst_translate);
                    }

                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();


                System.IO.Stream oStream   = oRpt.ExportToStream(ExportFormatType.PortableDocFormat);
                byte[]           byteArray = new byte[oStream.Length];
                oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
                System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
        public ActionResult ExportDataNew(ApplicationHeaderInfo pInfo, AppTM06DKQTInfoExport pDetail, List <AppDocumentInfo> pAppDocumentInfo,
                                          List <AppClassDetailInfo> pAppClassInfo)
        {
            try
            {
                //  AppTM06DKQTInfoExport pDetail= new AppTM06DKQTInfoExport();
                string _fileTemp = System.Web.HttpContext.Current.Server.MapPath("/Content/AppForms/C06_Request for_international_trademark_registration_vi_exp.doc");

                // Fill export_header
                string fileName = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C06_Request_for_international_trademark_registration_vi_exp_" + pInfo.Appcode + ".pdf");
                // Fill export_detail
                pDetail.Status        = 254;
                pDetail.Status_Form   = 252;
                pDetail.Relationship  = "11";
                pDetail.strNgayNopDon = pDetail.NGAYNOPDON.ToDateStringN0();
                if (pDetail.REF_APPNO_TEXT != null)
                {
                    pDetail.REF_APPNO_TEXT = pDetail.REF_APPNO_TEXT.Trim();
                }
                pDetail = CreateInstanceTM06DKQT.CopyAppHeaderInfo(pDetail, pInfo);

                if (pAppClassInfo != null)
                {
                    Hashtable _hsGroupclass = new Hashtable();
                    foreach (var item in pAppClassInfo)
                    {
                        AppClassDetailInfo _newinfo = new AppClassDetailInfo();
                        _newinfo.CloneObj();
                        if (_hsGroupclass.ContainsKey(item.Code.Substring(0, 2)))
                        {
                            _newinfo = (AppClassDetailInfo)_hsGroupclass[item.Code.Substring(0, 2)];
                        }
                        _newinfo.Code       = item.Code;
                        _newinfo.Textinput += item.Textinput + ", ";
                        _newinfo.IntTongSanPham++;
                        _hsGroupclass[item.Code.Substring(0, 2)] = _newinfo;
                    }
                    List <AppClassDetailInfo> _listApp = new List <AppClassDetailInfo>();
                    foreach (DictionaryEntry item in _hsGroupclass)
                    {
                        _listApp.Add((AppClassDetailInfo)item.Value);
                    }
                    foreach (AppClassDetailInfo item in _listApp.OrderBy(m => m.Code))
                    {
                        pDetail.strListClass += "Nhóm " + item.Code.Substring(0, 2) + ": " + item.Textinput.Trim().Trim(',') + " (" + (item.IntTongSanPham < 10 ? "0" + item.IntTongSanPham.ToString() : item.IntTongSanPham.ToString()) + " sản phẩm)" + "\n";
                    }
                }

                // đẩy file lên server
                if (pDetail.pfileLogo != null)
                {
                    pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo);
                }

                if (!string.IsNullOrEmpty(pDetail.LOGOURL))
                {
                    //Kết xuất ảnh
                }

                #region hiển thị tài liệu đính kèm
                if (pAppDocumentInfo == null)
                {
                    pAppDocumentInfo = new List <AppDocumentInfo>();
                }
                foreach (AppDocumentInfo item in pAppDocumentInfo)
                {
                    if (item.Document_Id == "C06DKQT_D_01")
                    {
                        pDetail.TOKHAI_USED    = item.Isuse.ToString();
                        pDetail.TOKHAI_SOTRANG = item.CHAR01;
                        pDetail.TOKHAI_SOBAN   = item.CHAR02;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_02")
                    {
                        pDetail.MAUDK_VPQT_USED    = item.Isuse.ToString();
                        pDetail.MAUDK_VPQT_SO      = item.CHAR01;
                        pDetail.MAUDK_VPQT_NGONNGU = item.CHAR02;
                        pDetail.MAUDK_VPQT_SOTRANG = item.CHAR03;
                        pDetail.MAUDK_VPQT_SOBAN   = item.CHAR04;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_03")
                    {
                        pDetail.MAUNDH_USED  = item.Isuse.ToString();
                        pDetail.MAUNDH_SOMAU = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_04")
                    {
                        pDetail.BANSAO_TOKHAI_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_05")
                    {
                        pDetail.BANSAO_GIAYDK_NHCS_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_06")
                    {
                        pDetail.BAN_CK_SD_NGANHANG_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_07")
                    {
                        pDetail.GIAY_UQ_USED    = item.Isuse.ToString();
                        pDetail.GIAY_UQ_NGONNGU = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_08")
                    {
                        pDetail.GIAY_UQ_BANDICH_USED    = item.Isuse.ToString();
                        pDetail.GIAY_UQ_BANDICH_SOTRANG = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_09")
                    {
                        pDetail.GIAY_UQ_BANDICH_BANGOC_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_010")
                    {
                        pDetail.GIAY_UQ_BANDICH_BANSAO_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_011")
                    {
                        pDetail.GIAY_UQ_BANGOCNOPSAU_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_012")
                    {
                        pDetail.GIAY_UQ_BANGOCNOP_THEOSO_USED = item.Isuse.ToString();
                        pDetail.GIAY_UQ_BANGOCNOP_THEOSO      = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_013")
                    {
                        pDetail.CHUNGTU_LEPHI_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_014")
                    {
                        pDetail.TAILIEUBOSUNG_USED = item.Isuse.ToString();
                        pDetail.TAILIEUBOSUNG      = item.CHAR01;
                        continue;
                    }
                }

                #endregion
                List <AppFeeFixInfo> pFeeFixInfo = CommonFunction.Call_Fee.CallFee_C06(pDetail);
                pDetail.LEPHI = (pFeeFixInfo[0] as AppFeeFixInfo).Amount;
                if (pInfo.Languague_Code == Language.LangEN)
                {
                    pDetail.LEPHI = (pFeeFixInfo[0] as AppFeeFixInfo).Amount_Usd;
                }
                List <AppTM06DKQTInfoExport> _lst = new List <AppTM06DKQTInfoExport>();
                pDetail.LOGOURL = Server.MapPath(pDetail.LOGOURL);
                _lst.Add(pDetail);
                DataSet _ds_all = ConvertData.ConvertToDataSet <AppTM06DKQTInfoExport>(_lst, false);

                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                string _tempfile = "C06.rpt";
                //if(AppsCommon.GetCurrentLang() == Language.LangEN)
                if (pInfo.Languague_Code != Language.LangVI)
                {
                    _tempfile = "C06.rpt";
                }

                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile), OpenReportMethod.OpenReportByTempCopy);

                //   _ds_all.WriteXmlSchema(@"C:\Users\user\Desktop\LEGALTECH\XMLFILE\TM06DKQT.xml");
                //Logger.LogInfo("b3: ");
                CrystalDecisions.CrystalReports.Engine.PictureObject _pic01;
                _pic01        = (CrystalDecisions.CrystalReports.Engine.PictureObject)oRpt.ReportDefinition.Sections[0].ReportObjects["Picture1"];
                _pic01.Width  = 200;
                _pic01.Height = 200;

                System.IO.FileInfo file = new System.IO.FileInfo(pDetail.LOGOURL);
                Bitmap             img  = new Bitmap(pDetail.LOGOURL);
                try
                {
                    double _Const = 6.666666666666 / 2;
                    int    _left = 0, _top = 0, _marginleft = 225, _margintop = 5580;
                    int    _h  = 600;
                    double _d1 = (_h - img.Width) / 2;
                    _d1   = _Const * _d1;
                    _left = _marginleft + Convert.ToInt32(_d1);
                    if (_left < 0)
                    {
                        _left = _marginleft;
                    }
                    _pic01.Left = _left;
                    // top

                    _d1  = (_h - img.Height) / 2;
                    _d1  = _Const * _d1;
                    _top = _margintop + Convert.ToInt32(_d1);
                    if (_top < 0)
                    {
                        _top = _margintop;
                    }
                    _pic01.Top = _top;
                }
                catch (Exception)
                {
                }
                finally
                {
                    img.Dispose();
                }

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table1";
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                System.IO.Stream oStream   = oRpt.ExportToStream(ExportFormatType.PortableDocFormat);
                byte[]           byteArray = new byte[oStream.Length];
                oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
                System.IO.File.WriteAllBytes(fileName, byteArray.ToArray()); // Requires System.Linq


                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
예제 #25
0
    /// <summary>
    /// 利用 CrystalReport 列印報表
    /// </summary>
    /// <param name="s_FileName">報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// <param name="reportFormatType">檔案型態</param> 
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source1, DataTable dt_Source2, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source2);
        string par_Vendor = string.Empty;
        string par_VendorName = string.Empty;
        string par_PurDate = string.Empty;
        string par_PurchaseNo = string.Empty;
        string par_FAX = string.Empty;
        string par_TEL = string.Empty;
        string par_BusinessContact = string.Empty;
        double par_Tax = 0;

        par_Vendor = dt_Source1.Rows[0]["VENDOR"].ToString();
        par_VendorName = dt_Source1.Rows[0]["VENDOR_NAME"].ToString();
        par_PurDate = dt_Source1.Rows[0]["PURCHSE_DATE"].ToString();
        par_PurchaseNo = dt_Source1.Rows[0]["PURCHASE_NO"].ToString();
        par_FAX = dt_Source1.Rows[0]["INV_FAX_AREA"].ToString() + "-" + dt_Source1.Rows[0]["INV_FAX"].ToString();
        par_TEL = dt_Source1.Rows[0]["INV_TEL_AREA"].ToString() + "-" + dt_Source1.Rows[0]["INV_TEL"].ToString();
        par_BusinessContact = dt_Source1.Rows[0]["BUSINESS_CONTACT"].ToString();
        if (dt_Source2.Rows.Count == 0)
            par_Tax = 0;
        else
            par_Tax = double.Parse(dt_Source2.Rows[0]["TAXRATE"].ToString());

        #region 組合查詢條件至ArrayList
        report.SetParameterValue("par_Vendor", par_Vendor);
        report.SetParameterValue("par_VendorName", par_VendorName);
        if (par_PurDate.Trim() != "")
        {
            report.SetParameterValue("par_PurDate", GetValueSetParameter(par_PurDate, "date"));
        }
        else
        {
            report.SetParameterValue("par_PurDate", "");
        }
        report.SetParameterValue("par_PurchaseNo", par_PurchaseNo);
        report.SetParameterValue("par_FAX", par_FAX);
        report.SetParameterValue("par_TEL", par_TEL);
        report.SetParameterValue("par_BusinessContact", par_BusinessContact);
        report.SetParameterValue("par_Tax", par_Tax);
        #endregion

        #region 判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "PDF":
                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            default:

                break;
        }
        #endregion
    }
예제 #26
0
        public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate)
        {
            try
            {
                string language = AppsCommon.GetCurrentLang();
                ApplicationHeaderInfo      applicationHeaderInfo = new ApplicationHeaderInfo();
                App_Detail_PLD01_HDCN_Info app_Detail            = new App_Detail_PLD01_HDCN_Info();
                List <AppFeeFixInfo>       appFeeFixInfos        = new List <AppFeeFixInfo>();
                List <AppDocumentInfo>     appDocumentInfos      = new List <AppDocumentInfo>();

                App_Detail_PLD01_HDCN_BL objBL = new App_Detail_PLD01_HDCN_BL();
                app_Detail = objBL.GetByID(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref appFeeFixInfos);

                string        _fileTemp = System.Web.HttpContext.Current.Server.MapPath("/Content/AppForms/D01_VI.docx");
                DocumentModel document  = DocumentModel.Load(_fileTemp);

                AppsCommon.Prepare_Data_Export_D01(ref app_Detail, applicationHeaderInfo, appDocumentInfos, appFeeFixInfos);

                List <App_Detail_PLD01_HDCN_Info> _lst = new List <App_Detail_PLD01_HDCN_Info>();
                _lst.Add(app_Detail);

                DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_PLD01_HDCN_Info>(_lst, false);
                _ds_all.Tables[0].TableName = "Table_4c2";
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                string _tempfile    = "TM_PLD01_HDCN.rpt";
                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf");
                if (p_View_Translate == 1)
                {
                    // nếu là tiếng việt thì xem bản tiếng anh và ngược lại
                    if (applicationHeaderInfo.Languague_Code == Language.LangVI)
                    {
                        _tempfile    = "TM_PLD01_HDCN_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf";
                    }
                }
                else
                {
                    if (applicationHeaderInfo.Languague_Code == Language.LangVI)
                    {
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        _tempfile    = "TM_PLD01_HDCN_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf";
                    }
                }
                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));
                if (_ds_all != null)
                {
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                System.IO.Stream oStream   = oRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[]           byteArray = new byte[oStream.Length];
                oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
                System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
예제 #27
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source)
    {
        #region
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);

        System.IO.Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        byte[] bytes = new byte[stream.Length];
        stream.Read(bytes, 0, bytes.Length);
        stream.Seek(0, System.IO.SeekOrigin.Begin);

        //export file  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  

        Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");

        Response.OutputStream.Write(bytes, 0, bytes.Length);
        Response.Flush();
        Response.Close();
        #endregion
    }
예제 #28
0
        public void Convert()
        {
            //System.Web.HttpContext.Current.Response.Write("hello");
            string vstExcep;
            this._stNmRpt = this._stNmRpt.Replace(".rpt", "");
            this._stNmRpt = this._stNmRpt.Replace(".RPT", "");
            try
            {
                    //System.Web.HttpContext.Current.Response.Write(_stNmRpt);
                System.IO.MemoryStream vioMemor = new System.IO.MemoryStream();
                CrystalDecisions.CrystalReports.Engine.ReportDocument vrpRepor = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string vstRepor = System.Web.HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"].ToString() + "report\\"+this._stNmRpt + ".rpt";
                                //System.Web.HttpContext.Current.Response.Write(vstRepor);
                vrpRepor.Load(vstRepor);
                if (_dsDatas == null) { return; }
                vrpRepor.Database.Tables[0].SetDataSource(this._dsDatas.Tables[0]);
                vrpRepor.Refresh();
                //vioMemor = (System.IO.MemoryStream)vrpRepor.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                vioMemor = (System.IO.MemoryStream)vrpRepor.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                vrpRepor.Close();
                try
                {
                    System.Web.HttpContext.Current.Response.Buffer = false;
                    System.Web.HttpContext.Current.Response.ClearContent();
                    System.Web.HttpContext.Current.Response.ClearHeaders();
                    System.Web.HttpContext.Current.Response.ContentType = "application/pdf";
                    System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" + this._stNmRpt.Replace("\\", "") + ".pdf");
                    System.Web.HttpContext.Current.Response.BinaryWrite(vioMemor.ToArray());
                    System.Web.HttpContext.Current.Response.Buffer = true;
                }
                catch (System.Exception vsqExcep) { vstExcep = vsqExcep.Message; }
                finally
                {
                    if (vioMemor != null) { vioMemor.Flush(); vioMemor = null; }
                    else { vioMemor = null; }
                    if (vrpRepor != null) vrpRepor = null;
                }
            }
            catch (System.Exception vsqExcep) { vstExcep = vsqExcep.Message; }
        }