/// <summary>
        /// 转成PDF
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToPDFbtn_Click(object sender, EventArgs e)
        {
            try
            {
                //reportDataBind();
                string ExportPath;
                string Fname;
                ExportPath = User.rootpath + "\\" + drawingno + "附页";
                if (!Directory.Exists(ExportPath))
                {
                    System.IO.Directory.CreateDirectory(ExportPath);
                }

                Fname = "Accessories";
                CrystalDecisions.Shared.DiskFileDestinationOptions opts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                //导出为磁盘文件
                CrystalDecisions.Shared.ExportOptions myExportOptiions = tpm.ExportOptions;
                myExportOptiions.ExportDestinationOptions = opts;
                myExportOptiions.ExportDestinationType    = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                tpm.ExportOptions.ExportFormatType        = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                Fname             = Fname + ".PDF";
                opts.DiskFileName = ExportPath + "\\" + Fname;
                tpm.Export();
                MessageBox.Show("--------转换成功---------");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                return;
            }
        }
        private void Btn_Excel_Click(object sender, EventArgs e)
        {
            SaveFileDialog Archivo = new SaveFileDialog();

            if (Archivo.ShowDialog() == DialogResult.OK)
            {
                CrystalDecisions.Shared.ExportOptions              Opt     = new CrystalDecisions.Shared.ExportOptions();
                CrystalDecisions.Shared.ExcelFormatOptions         Opt_Exc = new CrystalDecisions.Shared.ExcelFormatOptions();
                CrystalDecisions.Shared.DiskFileDestinationOptions Opt_Dsk = new CrystalDecisions.Shared.DiskFileDestinationOptions();

                Opt.ExportFormatType      = CrystalDecisions.Shared.ExportFormatType.Excel;
                Opt.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;

                Opt_Exc.ExcelUseConstantColumnWidth = false;
                Opt.ExportFormatOptions             = Opt_Exc;

                Opt_Dsk.DiskFileName         = Archivo.FileName;
                Opt.ExportDestinationOptions = Opt_Dsk;
                Reporte.Export(Opt);
            }
        }
        private void ExportPDF()
        {
            try
            {

                string exportPath;
                string fileName;
                exportPath = User.rootpath + "\\" + DrawingNo + "附页";
                if (!Directory.Exists(exportPath))
                {
                    System.IO.Directory.CreateDirectory(exportPath);
                }

                fileName = "TotalPipeMaterialCR.pdf";

                CrystalDecisions.Shared.DiskFileDestinationOptions opts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                //导出为磁盘文件
                CrystalDecisions.Shared.ExportOptions myExportOptions = cr.ExportOptions;
                myExportOptions.DestinationOptions = opts;
                myExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                //导出为pdf格式
                cr.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                //目的路径
                fileName = exportPath + "\\" + fileName;
                opts.DiskFileName = fileName;
                if (File.Exists(fileName))
                    File.Delete(fileName);
                //导出操作
                cr.Export();
                MessageBox.Show("--------转换成功---------");
                button1.Enabled = false;

            }
            catch (Exception ex)
            {
                MessageBox.Show("导出PDF时:" + ex.Message.ToString());

                this.Close();
            }
        }
Exemplo n.º 4
0
        private void ExportPDF()
        {
            try
            {
                string exportPath;
                string fileName;
                exportPath = User.rootpath + "\\" + DrawingNo + "附页";
                if (!Directory.Exists(exportPath))
                {
                    System.IO.Directory.CreateDirectory(exportPath);
                }

                fileName = "TotalPipeMaterialCR.pdf";

                CrystalDecisions.Shared.DiskFileDestinationOptions opts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                //导出为磁盘文件
                CrystalDecisions.Shared.ExportOptions myExportOptions = cr.ExportOptions;
                myExportOptions.DestinationOptions    = opts;
                myExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                //导出为pdf格式
                cr.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                //目的路径
                fileName          = exportPath + "\\" + fileName;
                opts.DiskFileName = fileName;
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
                //导出操作
                cr.Export();
                MessageBox.Show("--------转换成功---------");
                button1.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("导出PDF时:" + ex.Message.ToString());

                this.Close();
            }
        }
        //private void EXPORTTOPDF(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        string exportPath;
        //        string fileName;
        //        exportPath = Application.StartupPath + "\\" + DrawingNo + "附页";
        //        if (!Directory.Exists(exportPath))
        //        {
        //            System.IO.Directory.CreateDirectory(exportPath);
        //        }

        //        fileName = "WeightBarycenterCR.pdf";

        //        CrystalDecisions.Shared.DiskFileDestinationOptions opts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
        //        //导出为磁盘文件
        //        CrystalDecisions.Shared.ExportOptions myExportOptions = cr.ExportOptions;
        //        myExportOptions.DestinationOptions = opts;
        //        myExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
        //        //导出为pdf格式
        //        cr.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
        //        //目的路径
        //        fileName = exportPath + "\\" + fileName;
        //        opts.DiskFileName = fileName;
        //        if (File.Exists(fileName))
        //            File.Delete(fileName);
        //        //导出操作
        //        cr.Export();
        //        MessageBox.Show("--------转换成功---------");
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show("导出PDF时:" + ex.Message.ToString());

        //        this.Close();
        //    }
        //}
        //private void ReplaceExportButton()
        //{
        //    //遍历crystalReportViewer1控件里的控件
        //    foreach (object ctl in crystalReportViewer1.Controls)
        //    {
        //        string sControl = ctl.GetType().Name.ToString().ToLower();
        //        if (sControl == "toolstrip")
        //        {
        //            ToolStrip tab1 = (ToolStrip)ctl;
        //            for (int i = 0; i <= tab1.Items.Count - 1; i++)
        //            {
        //                if (tab1.Items[i].ToolTipText == "导出报表")
        //                {
        //                    ToolStripButton tbutton = new ToolStripButton();
        //                    Image img1 = tab1.Items[i].Image;
        //                    tab1.Items.Remove(tab1.Items[i]);
        //                    tbutton.Image = img1;
        //                    tbutton.ToolTipText = "导出报表";
        //                    tab1.Items.Insert(0, tbutton);
        //                    tbutton.Click += new System.EventHandler(this.EXPORTTOPDF);
        //                    break;
        //                }
        //            }
        //        }
        //    }
        //}

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string exportPath;
                string fileName;
                exportPath = Application.StartupPath + "\\" + DrawingNo + "附页";
                if (!Directory.Exists(exportPath))
                {
                    System.IO.Directory.CreateDirectory(exportPath);
                }

                fileName = "WeightBarycenterCR.pdf";

                CrystalDecisions.Shared.DiskFileDestinationOptions opts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                //导出为磁盘文件
                CrystalDecisions.Shared.ExportOptions myExportOptions = cr.ExportOptions;
                myExportOptions.DestinationOptions    = opts;
                myExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                //导出为pdf格式
                cr.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                //目的路径
                fileName          = exportPath + "\\" + fileName;
                opts.DiskFileName = fileName;
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
                //导出操作
                cr.Export();
                MessageBox.Show("--------转换成功---------");
            }
            catch (Exception ex)
            {
                MessageBox.Show("导出PDF时:" + ex.Message.ToString());

                this.Close();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 转成PDF
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToPDFbtn_Click(object sender, EventArgs e)
        {
            try
            {
                //reportDataBind();
                string ExportPath;
                string Fname;
                ExportPath = User.rootpath + "\\" + drawingno +"附页";
                if (!Directory.Exists(ExportPath))
                {
                    System.IO.Directory.CreateDirectory(ExportPath);
                }

                Fname = "Accessories";
                CrystalDecisions.Shared.DiskFileDestinationOptions opts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                //导出为磁盘文件
                CrystalDecisions.Shared.ExportOptions myExportOptiions = tpm.ExportOptions;
                myExportOptiions.ExportDestinationOptions = opts;
                myExportOptiions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                tpm.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                Fname = Fname + ".PDF";
                opts.DiskFileName = ExportPath + "\\"+ Fname;
                tpm.Export();
                MessageBox.Show("--------转换成功---------");
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                return;
            }
        }
Exemplo n.º 7
0
        private void exportReport(CrystalDecisions.CrystalReports.Engine.ReportClass selectedReport, CrystalDecisions.Shared.ExportFormatType eft)
        {
            selectedReport.ExportOptions.ExportFormatType = eft;

            string contentType = "";
            // Make sure asp.net has create and delete permissions in the directory
            string tempDir      = System.Configuration.ConfigurationSettings.AppSettings["TempDir"];
            string tempFileName = Session.SessionID.ToString() + ".";

            switch (eft)
            {
            case CrystalDecisions.Shared.ExportFormatType.PortableDocFormat:
                tempFileName += "pdf";
                contentType   = "application/pdf";
                break;

            case CrystalDecisions.Shared.ExportFormatType.WordForWindows:
                tempFileName += "doc";
                contentType   = "application/msword";
                break;

            case CrystalDecisions.Shared.ExportFormatType.Excel:
                tempFileName += "xls";
                contentType   = "application/vnd.ms-excel";
                break;

            case CrystalDecisions.Shared.ExportFormatType.HTML32:
            case CrystalDecisions.Shared.ExportFormatType.HTML40:
                tempFileName += "htm";
                contentType   = "text/html";
                CrystalDecisions.Shared.HTMLFormatOptions hop = new CrystalDecisions.Shared.HTMLFormatOptions();
                hop.HTMLBaseFolderName = tempDir;
                hop.HTMLFileName       = tempFileName;
                selectedReport.ExportOptions.FormatOptions = hop;
                break;
            }

            CrystalDecisions.Shared.DiskFileDestinationOptions dfo = new CrystalDecisions.Shared.DiskFileDestinationOptions();
            dfo.DiskFileName = tempDir + tempFileName;
            selectedReport.ExportOptions.DestinationOptions    = dfo;
            selectedReport.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;

            selectedReport.Export();
            selectedReport.Close();

            string tempFileNameUsed;

            //if (eft == CrystalDecisions.Shared.ExportFormatType.HTML32 || eft == CrystalDecisions.Shared.ExportFormatType.HTML40)
            //{
            //    string[] fp = selectedReport.FilePath.Split("\\".ToCharArray());
            //    string leafDir = fp[fp.Length - 1];
            //    // strip .rpt extension
            //    leafDir = leafDir.Substring(0, leafDir.Length–4);
            //    tempFileNameUsed = string.Format("{0}{1}\\{2}", tempDir, leafDir, tempFileName);
            //}
            //else
            tempFileNameUsed = tempDir + tempFileName;

            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = contentType;

            Response.WriteFile(tempFileNameUsed);
            Response.Flush();
            Response.Close();

            System.IO.File.Delete(tempFileNameUsed);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public static string GenerateExport(CrystalDecisions.CrystalReports.Engine.ReportDocument selectedReport, CrystalDecisions.Shared.ExportFormatType eft, string ExportFileName)
        {
            selectedReport.ExportOptions.ExportFormatType = eft;

                string contentType = "";

                // Make sure asp.net has create and delete permissions in the directory
                string tempDir = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["tempDir"]);
                string tempFileName = string.Concat(Path.GetFileNameWithoutExtension(selectedReport.FileName), ".");
                if (! string.IsNullOrEmpty(ExportFileName))
                {
                    tempFileName = string.Concat(ExportFileName, ".");
                }

                switch (eft)
                {
                    case CrystalDecisions.Shared.ExportFormatType.PortableDocFormat:
                        tempFileName += "pdf";
                        break;
                    case CrystalDecisions.Shared.ExportFormatType.WordForWindows:
                        tempFileName += "doc";
                        break;
                    case CrystalDecisions.Shared.ExportFormatType.Excel:
                        tempFileName += "xls";
                        break;
                    case CrystalDecisions.Shared.ExportFormatType.HTML32:
                    case CrystalDecisions.Shared.ExportFormatType.HTML40:
                        tempFileName += "htm";
                        CrystalDecisions.Shared.HTMLFormatOptions hop = new CrystalDecisions.Shared.HTMLFormatOptions();
                        hop.HTMLBaseFolderName = tempDir;
                        hop.HTMLFileName = tempFileName;
                        selectedReport.ExportOptions.FormatOptions = hop;
                        break;
                }

                CrystalDecisions.Shared.DiskFileDestinationOptions dfo = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                dfo.DiskFileName = Path.Combine(tempDir, tempFileName);
                selectedReport.ExportOptions.DestinationOptions = dfo;
                selectedReport.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;

                selectedReport.Export();
                selectedReport.Close();

                string tempFileNameUsed;
                if (eft == CrystalDecisions.Shared.ExportFormatType.HTML32 || eft == CrystalDecisions.Shared.ExportFormatType.HTML40)
                {
                    string[] fp = selectedReport.FilePath.Split("\\" .ToCharArray());
                    string leafDir = fp[fp.Length - 1];
                    // strip .rpt extension
                    leafDir = leafDir.Substring(0, leafDir.Length - 4);
                    tempFileNameUsed = string.Format("{0}{1}\\{2}", tempDir, leafDir, tempFileName);
                }
                else
                {
                    tempFileNameUsed = Path.Combine(tempDir, tempFileName);
                }

                return tempFileNameUsed;
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //先处理下附件文件夹中的备案表,防止过大
                DeleteSignedFile(Server.MapPath(Request.ApplicationPath + "/AttachStorage/"));
                HeTongBeiAn_ND myReport          = new HeTongBeiAn_ND();
                string         strSql            = "";
                string         WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/合同备案公章.gif");

                //先初始化项目信息

                //看看该公司所在的地区

                CRS_BeiAn.Report.FileName = System.Configuration.ConfigurationManager.AppSettings["BeiAnPrint_ND"];

                #region 人员
                HeTongInfo ds = new HeTongInfo();
                strSql = "select * from RG_XMAndRY RY where XMGuid='" + Request["RowGuid"] + "' order by substring(RY.ZhuanYeCode,1,4) asc,ddrole desc";
                DataView dvRY = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);

                for (int i = 0; i < dvRY.Count; i++)
                {
                    DataRow dr4;
                    dr4 = ds.Tables["RYOfXM"].NewRow();
                    dr4["ZiZhiText"]   = dvRY[i]["ZiZhiText"].ToString();
                    dr4["ZhuanYeText"] = dvRY[i]["ZhuanYeText"].ToString();
                    dr4["RYName"]      = dvRY[i]["RYName"].ToString();
                    dr4["IDNum"]       = dvRY[i]["IDNum"];//Convert.ToDecimal(
                    dr4["ZhiCheng"]    = DB_CM.GetCodeText_FromHash("职称", Convert.ToString(dvRY[i]["ZhiCheng"]));;
                    dr4["YinZhangNo"]  = dvRY[i]["YinZhangNo"].ToString();
                    dr4["ZhuanYeSX"]   = dvRY[i]["ZhuanYeSX"].ToString();

                    //处理下从事的专业,尽量缩小
                    string ZhuanYeCS = dvRY[i]["ZhuanYeCS"].ToString();

                    dr4["ZhuanYeCS"] = ZhuanYeCS;
                    dr4["GongLing"]  = dvRY[i]["GongLing"];
                    dr4["DDRole"]    = DB_CM.GetCodeText_FromHash("项目角色", Convert.ToString(dvRY[i]["DDRole"]));
                    dr4["OrNo"]      = i + 1;
                    ds.Tables["RYOfXM"].Rows.Add(dr4);
                }

                myReport.SetDataSource(ds.Tables["RYOfXM"]);
                #endregion

                #region 参数
                strSql = "select * from RG_XMBeiAn where RowGuid='" + Request["RowGuid"] + "'";
                DataView dv          = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);
                string   DWName      = "";
                string   TJDate      = "";
                string   XMName      = "";
                string   XMAdd       = "";
                string   ToTalMoney  = "";
                string   GuiMoDJ     = "";
                string   JSDWName    = "";
                string   XMLXR_JS    = "";
                string   LXDH_JS     = "";
                string   XMLXR_KS    = "";
                string   LXDH_KS     = "";
                string   XMFZR       = "";
                string   ZiZhiDJ     = "";
                string   ZiZhiDJ_ZH  = "";
                string   HeTongMoney = "";
                string   XMBH        = "";
                string   STATUS      = "";
                //有效期
                string YXQ = "";
                if (dv.Count > 0)
                {
                    STATUS = dv[0]["STATUS"].ToString();
                    strSql = "select EnterpriseName from RG_OUInfo where RowGuid='" + dv[0]["DWGuid"] + "'";
                    DWName = Epoint.MisBizLogic2.DB.ExecuteToString(strSql);

                    myReport.SetParameterValue("DWName", DWName);
                    if (dv[0]["TJDate"].ToString() != "")
                    {
                        TJDate = DateTime.Parse(dv[0]["TJDate"].ToString()).ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        TJDate = "";
                    }
                    myReport.SetParameterValue("TJDate", TJDate);
                    XMName = dv[0]["XMName"].ToString();
                    myReport.SetParameterValue("XMName", XMName);
                    XMAdd = DB_CM.GetCodeText_FromHash("项目地点", Convert.ToString(dv[0]["XMAddress"]));
                    myReport.SetParameterValue("XMAddress", XMAdd);
                    ToTalMoney = dv[0]["ToTalMoney"] + "万元";
                    myReport.SetParameterValue("ToTalMoney", ToTalMoney);
                    ZiZhiDJ    = dv[0]["ZiZhiDJ"].ToString();
                    ZiZhiDJ_ZH = dv[0]["ZiZhiBH"].ToString();
                    myReport.SetParameterValue("ZiZhiDJ", ZiZhiDJ);
                    //myReport.SetParameterValue("ZiZhiDJ_ZH", ZiZhiDJ_ZH);
                    HeTongMoney = dv[0]["HeTongMoney"] + "万元";
                    myReport.SetParameterValue("HeTongMoney", HeTongMoney);
                    GuiMoDJ = DB_CM.GetCodeText_FromHash("项目规模等级", Convert.ToString(dv[0]["GuiMoDJ"]));
                    myReport.SetParameterValue("GuiMoDJ", GuiMoDJ);
                    //JSDWName = dv[0]["JSDWName"].ToString();
                    //myReport.SetParameterValue("JSDWName", JSDWName);
                    //XMLXR_JS = dv[0]["XMLXR_JS"].ToString();
                    //myReport.SetParameterValue("XMLXR_JS", XMLXR_JS);
                    //LXDH_JS = dv[0]["LXDH_JS"].ToString();
                    //myReport.SetParameterValue("LXDH_JS", LXDH_JS);
                    XMLXR_KS = dv[0]["XMLXR_KS"].ToString();
                    myReport.SetParameterValue("XMLXR_KS", XMLXR_KS);
                    LXDH_KS = dv[0]["LXDH_KS"].ToString();//+ "/" + dv[0]["SJ_KS"].ToString()
                    myReport.SetParameterValue("LXDH_KS", LXDH_KS);
                    XMFZR = dv[0]["XMFZR"].ToString();
                    myReport.SetParameterValue("XMFZR", XMFZR);
                    XMBH = dv[0]["XMBH"].ToString();
                    //注意处理,如果没有的话,就把编号的前面取出来
                    XMBH = RG_DW.GetXMBH(dv[0]["RowGuid"], dv[0]["DWGuid"], dv[0]["XMAdd"], dv[0]["XMBH"], dv[0]["XMLB"]);
                    myReport.SetParameterValue("XMBH", XMBH);
                    //获取最后一次审核通过意见
                    if (dv[0]["Status"].ToString() == "90")
                    {
                        //myReport.SetParameterValue("SHOpinion", RG_DW.GetLastSHOpinion(Request["RowGuid"], ""));
                        if (dv[0]["TGDate"].ToString() != "")
                        {
                            //myReport.SetParameterValue("TGDate", DateTime.Parse(dv[0]["TGDate"].ToString()).ToString("yyyy年MM月dd日"));
                            DateTime dtPass = DateTime.Parse(dv[0]["TGDate"].ToString());
                            YXQ = "有效期至:" + dtPass.AddYears(2).ToString("yyyy年MM月dd日");
                            myReport.SetParameterValue("TGDate", dtPass.ToString("yyyy年MM月dd日") + "\n" + YXQ);
                        }
                        else
                        {
                            myReport.SetParameterValue("TGDate", "    年  月  日");
                        }
                    }
                    else
                    {
                        //myReport.SetParameterValue("SHOpinion", "");
                        myReport.SetParameterValue("TGDate", "    年  月  日");
                    }
                    //重点注意,要分地区加盖相应的公章,宜兴的就加盖宜兴,江阴的就加盖江阴公章
                    //判断是否是宜兴的或江阴的
                    if (dv[0]["XMAdd"].ToString() == "320281")//江阴
                    {
                        WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/江阴合同备案公章.gif");
                    }
                    else if (dv[0]["XMAdd"].ToString() == "320282")//宜兴
                    {
                        WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/宜兴合同备案公章.gif");
                    }
                }

                #endregion

                CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                myReport.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                myReport.ExportOptions.ExportFormatType      = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                string thisTime = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                string fileName = thisTime + "XMBA.pdf";
                DiskOpts.DiskFileName = Server.MapPath(Request.ApplicationPath + "/AttachStorage/" + fileName);
                myReport.ExportOptions.DestinationOptions = DiskOpts;
                myReport.Export();
                //判断下状态,如果是已经审核通过了,那么就处理公章,否则直接加载
                if (STATUS != "90")
                {
                    if (this.LoginID == "admin")
                    {
                        string message     = "";
                        string fileNewName = thisTime + "_2XMBA.pdf";
                        string fileNew     = Request.ApplicationPath + "/AttachStorage/" + fileNewName;
                        WatermarkPDF(DiskOpts.DiskFileName, Server.MapPath(fileNew), WatermarkImageUrl, 400, 500, 115, 115, out message, dvRY.Count);
                        Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileNewName + "'; </script> ");
                    }
                    else
                    {
                        Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileName + "'; </script> ");
                    }
                }
                else
                {
                    //string WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/合同备案公章.gif");
                    string message     = "";
                    string fileNewName = thisTime + "_2XMBA.pdf";
                    string fileNew     = Request.ApplicationPath + "/AttachStorage/" + fileNewName;
                    WatermarkPDF(DiskOpts.DiskFileName, Server.MapPath(fileNew), WatermarkImageUrl, 400, 500, 115, 115, out message, dvRY.Count);
                    Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileNewName + "'; </script> ");
                }
            }
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //先处理下附件文件夹中的备案表,防止过大
                DeleteSignedFile(Server.MapPath(Request.ApplicationPath + "/AttachStorage/"));
                HeTongBeiAn myReport = new HeTongBeiAn();
                string strSql = "";
                //先初始化项目信息

                //看看该公司所在的地区

                CRS_BeiAn.Report.FileName = System.Configuration.ConfigurationManager.AppSettings["BeiAnPrint_SN"]; //Epoint.Frame.Common.ApplicationOperate.GetConfigValueByName("BeiAnPrint_SN", ""); ;
                //CRS_BeiAn.Report.
                #region 人员
                HeTongInfo ds = new HeTongInfo();
                strSql = "select * from RG_XMAndRY RY where XMGuid='" + Request["RowGuid"] + "' order by substring(RY.ZhuanYeCode,1,4) asc,RY.DDRole desc ";
                DataView dvRY = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);

                int count = dvRY.Count;
                for (int i = 0; i < dvRY.Count; i++)
                {
                    DataRow dr4;
                    dr4 = ds.Tables["RYOfXM"].NewRow();
                    dr4["ZiZhiText"] = dvRY[i]["ZiZhiText"].ToString();
                    dr4["ZhuanYeText"] = dvRY[i]["ZhuanYeText"].ToString();
                    dr4["RYName"] = dvRY[i]["RYName"].ToString();
                    dr4["IDNum"] = dvRY[i]["IDNum"];//Convert.ToDecimal(
                    dr4["ZhiCheng"] = DB_CM.GetCodeText_FromHash("职称", Convert.ToString(dvRY[i]["ZhiCheng"])); ;
                    dr4["YinZhangNo"] = dvRY[i]["YinZhangNo"].ToString();
                    dr4["ZhuanYeSX"] = dvRY[i]["ZhuanYeSX"].ToString();

                    //处理下从事的专业,尽量缩小
                    string ZhuanYeCS = dvRY[i]["ZhuanYeCS"].ToString();
                    //string ZYCS = "";// RG_DW.GetItemTextByLen2("29b7967e-8098-42d5-8b40-ec757b0865a5", ZhuanYeCS, 4);
                    //string[] CS = ZhuanYeCS.Split(';');
                    //for (int m = 0; m < CS.Length; m++)
                    //{
                    //    ZYCS += RG_DW.GetItemTextByLen2("29b7967e-8098-42d5-8b40-ec757b0865a5", CS[m], 4);
                    //    ZYCS += ";";
                    //}
                    //if (ZYCS.Length > 0)
                    //{
                    //    ZYCS = ZYCS.Substring(0, ZYCS.Length - 1);
                    //}
                    dr4["ZhuanYeCS"] = ZhuanYeCS;
                    dr4["GongLing"] = dvRY[i]["GongLing"];
                    dr4["DDRole"] = DB_CM.GetCodeText_FromHash("项目角色", Convert.ToString(dvRY[i]["DDRole"]));
                    dr4["OrNo"] = i + 1;
                    ds.Tables["RYOfXM"].Rows.Add(dr4);
                }

                //for (int m = 19; m > dvRY.Count; m--)
                //{
                //    DataRow dr4;
                //    dr4 = ds.Tables["RYOfXM"].NewRow();
                //    dr4["ZiZhiText"] = "";
                //    dr4["ZhuanYeText"] = "";
                //    dr4["RYName"] = "";
                //    dr4["IDNum"] = "";//Convert.ToDecimal(
                //    dr4["ZhiCheng"] = ""; ;
                //    dr4["YinZhangNo"] = "";
                //    dr4["ZhuanYeSX"] = "";

                //    dr4["ZhuanYeCS"] = "";
                //    dr4["GongLing"] = "";
                //    dr4["DDRole"] = "";
                //    dr4["OrNo"] = dvRY.Count + 19 - m;
                //    ds.Tables["RYOfXM"].Rows.Add(dr4);
                //}

                //HeTongBeiAn oCR = new HeTongBeiAn();
                myReport.SetDataSource(ds.Tables["RYOfXM"]);
                #endregion

                #region 参数
                strSql = "select * from RG_XMBeiAn where RowGuid='" + Request["RowGuid"] + "' ";
                DataView dv = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);
                string DWName = "";
                string TJDate = "";
                string XMName = "";
                string XMAdd = "";
                string ToTalMoney = "";
                string GuiMoDJ = "";
                string JSDWName = "";
                string XMLXR_JS = "";
                string LXDH_JS = "";
                string XMLXR_KS = "";
                string LXDH_KS = "";
                string XMFZR = "";
                string ZiZhiDJ = "";
                string ZiZhiDJ_ZH = "";
                string HeTongMoney = "";
                string XMBH = "";
                string STATUS = "";

                if (dv.Count > 0)
                {
                    STATUS = dv[0]["STATUS"].ToString();
                    strSql = "select EnterpriseName from RG_OUInfo where RowGuid='" + dv[0]["DWGuid"] + "'";
                    DWName = Epoint.MisBizLogic2.DB.ExecuteToString(strSql);

                    myReport.SetParameterValue("DWName", DWName);
                    if (dv[0]["TJDate"].ToString() != "")
                    {
                        TJDate = DateTime.Parse(dv[0]["TJDate"].ToString()).ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        TJDate = "";
                    }
                    myReport.SetParameterValue("TJDate", TJDate);
                    XMName = dv[0]["XMName"].ToString();
                    myReport.SetParameterValue("XMName", XMName);
                    XMAdd = DB_CM.GetCodeText_FromHash("项目地点", Convert.ToString(dv[0]["XMAddress"]));
                    myReport.SetParameterValue("XMAddress", XMAdd);
                    ToTalMoney = dv[0]["ToTalMoney"] + "万元";
                    myReport.SetParameterValue("ToTalMoney", ToTalMoney);
                    ZiZhiDJ = dv[0]["ZiZhiDJ"].ToString();
                    ZiZhiDJ_ZH = dv[0]["ZiZhiBH"].ToString();
                    myReport.SetParameterValue("ZiZhiDJ", ZiZhiDJ);
                    myReport.SetParameterValue("ZiZhiDJ_ZH", ZiZhiDJ_ZH);
                    HeTongMoney = dv[0]["HeTongMoney"] + "万元";
                    myReport.SetParameterValue("HeTongMoney", HeTongMoney);
                    GuiMoDJ = DB_CM.GetCodeText_FromHash("项目规模等级", Convert.ToString(dv[0]["GuiMoDJ"]));
                    myReport.SetParameterValue("GuiMoDJ", GuiMoDJ);
                    JSDWName = dv[0]["JSDWName"].ToString();
                    myReport.SetParameterValue("JSDWName", JSDWName);
                    XMLXR_JS = dv[0]["XMLXR_JS"].ToString();
                    myReport.SetParameterValue("XMLXR_JS", XMLXR_JS);
                    LXDH_JS = dv[0]["LXDH_JS"].ToString();
                    myReport.SetParameterValue("LXDH_JS", LXDH_JS);
                    XMLXR_KS = dv[0]["XMLXR_KS"].ToString();
                    myReport.SetParameterValue("XMLXR_KS", XMLXR_KS);
                    LXDH_KS = dv[0]["LXDH_KS"].ToString();//+ "/" + dv[0]["SJ_KS"].ToString()
                    myReport.SetParameterValue("LXDH_KS", LXDH_KS);
                    XMFZR = dv[0]["XMFZR"].ToString();
                    myReport.SetParameterValue("XMFZR", XMFZR);
                    XMBH = dv[0]["XMBH"].ToString();
                    //注意处理,如果没有的话,就把编号的前面取出来
                    XMBH = RG_DW.GetXMBH(dv[0]["RowGuid"], dv[0]["DWGuid"], dv[0]["XMAdd"], dv[0]["XMBH"], dv[0]["XMLB"]);
                    myReport.SetParameterValue("XMBH", XMBH);
                    //有效期
                    string YXQ = "";
                    //获取最后一次审核通过意见
                    if (dv[0]["Status"].ToString() == "90")
                    {
                        myReport.SetParameterValue("SHOpinion", RG_DW.GetLastSHOpinion(Request["RowGuid"], ""));
                        if (dv[0]["TGDate"].ToString() != "")
                        {
                            DateTime dtPass = DateTime.Parse(dv[0]["TGDate"].ToString());
                            YXQ = "有效期至:" + dtPass.AddYears(2).ToString("yyyy年MM月dd日");
                            myReport.SetParameterValue("TGDate", dtPass.ToString("yyyy年MM月dd日") + "\n" + YXQ);

                        }
                        else
                        {
                            myReport.SetParameterValue("TGDate", "    年  月  日");
                        }
                    }
                    else
                    {
                        myReport.SetParameterValue("SHOpinion", "");
                        myReport.SetParameterValue("TGDate", "    年  月  日");
                    }
                    //myReport.SetParameterValue("YXQ", YXQ);
                }

                #endregion

                CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                myReport.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                myReport.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                string thisTime = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                string fileName = thisTime + "XMBA.pdf";
                DiskOpts.DiskFileName = Server.MapPath(Request.ApplicationPath + "/AttachStorage/" + fileName);
                myReport.ExportOptions.DestinationOptions = DiskOpts;
                myReport.Export();
                //判断下状态,如果是已经审核通过了,那么就处理公章,否则直接加载
                if (STATUS != "90")
                {
                    if (this.LoginID == "admin")
                    {
                        string WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/合同备案公章.gif");
                        string message = "";
                        string fileNewName = thisTime + "_2XMBA.pdf";
                        string fileNew = Request.ApplicationPath + "/AttachStorage/" + fileNewName;
                        WatermarkPDF(DiskOpts.DiskFileName, Server.MapPath(fileNew), WatermarkImageUrl, 400, 500, 115, 115, out message, dvRY.Count);
                        //Response.Write("<script language=javascript> window.location.href = '../../../AttachStorage/" + fileNewName + "'; </script> ");
                        Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileNewName + "'; </script> ");
                        //Response.Redirect(fileNew);
                    }
                    else
                    {
                        Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileName + "'; </script> ");
                    }
                }
                else
                {
                    string WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/合同备案公章.gif");
                    string message = "";
                    string fileNewName = thisTime + "_2XMBA.pdf";
                    string fileNew = Request.ApplicationPath + "/AttachStorage/" + fileNewName;
                    WatermarkPDF(DiskOpts.DiskFileName, Server.MapPath(fileNew), WatermarkImageUrl, 400, 500, 115, 115, out message, dvRY.Count);
                    //Response.Write("<script language=javascript> window.location.href = '../../../AttachStorage/" + fileNewName + "'; </script> ");
                    Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileNewName + "'; </script> ");
                    //Response.Redirect(fileNew);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Genera el reporte
        /// </summary>
        /// <param name="reportPath">Ruta del reporte</param>
        /// <param name="outputPath">Regresa el reporte</param>
        /// <param name="fechaInicial">Valor fecha inicial</param>
        /// <param name="fechaFinal">Valor fecha final</param>
        /// <param name="oficinaVentas">Código de la oficina</param>
        /// <param name="Usuario">Código del usuario</param>
        /// <param name="_Company">Objeto de SAP</param>
        /// <param name="msgError">Mensaje de error</param>
        /// <returns>true/false</returns>
        public bool RunReport(string reportPath, string outputPath, DateTime fechaInicial, DateTime fechaFinal, string oficinaVentas, SAPbobsCOM.Company _Company, ref string msgError)
        {
            msgError = string.Empty;
            if (System.IO.File.Exists(outputPath))
            {
                try
                {
                    System.IO.File.Delete(outputPath);
                }
                catch (Exception ex)
                {
                    throw new Exception("No se pudo reemplazar el archivo " + System.IO.Path.GetFileName(outputPath) + ", revise que no se esté ejecutando.");
                }
            }
            try
            {
                rpt = new ReportDocument();

                loginfo              = new CrystalDecisions.Shared.ConnectionInfo();
                loginfo.ServerName   = _Company.Server;
                loginfo.DatabaseName = _Company.CompanyDB;
                loginfo.UserID       = _Company.DbUserName;
                loginfo.Password     = Extensor.Configuracion.PBD.PBD; //ConfigurationManager.AppSettings["PBD"].ToString();

                rpt.Load(reportPath);
                Actualiza(ref rpt, loginfo);

                rpt.SetParameterValue("@FechaInicial", fechaInicial);
                rpt.SetParameterValue("@FechaFinal", fechaFinal);
                rpt.SetParameterValue("@AlmacenOficina", oficinaVentas);
                //rpt.SetParameterValue("@Usuario", Usuario);


                CrystalDecisions.Shared.DiskFileDestinationOptions filedest = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                CrystalDecisions.Shared.ExportOptions o = default(CrystalDecisions.Shared.ExportOptions);
                o = new CrystalDecisions.Shared.ExportOptions();

                ExportOptions opt = new ExportOptions();

                opt = rpt.ExportOptions;

                o.ExportFormatType      = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                o.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                filedest.DiskFileName   = outputPath;


                o.ExportDestinationOptions = (ExportDestinationOptions)filedest.Clone();

                rpt.Export(o);
                o = null;

                filedest = null;
                rpt.Dispose();
                rpt.Close();


                opt = null;
                rpt = null;

                return(true);
            }
            catch (Exception ex)
            {
                msgError = "No se creó el archivo: " + ex.Message + Environment.NewLine +
                           "Detalles: " + ex.InnerException.Message;
                return(false);
            }
        }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //先处理下附件文件夹中的备案表,防止过大
                DeleteSignedFile(Server.MapPath(Request.ApplicationPath + "/AttachStorage/"));
                HeTongBeiAn_WS myReport = new HeTongBeiAn_WS();
                string         strSql   = "";
                //先初始化项目信息

                //看看该公司所在的地区

                CRS_BeiAn.Report.FileName = System.Configuration.ConfigurationManager.AppSettings["BeiAnPrint_SW"];// Epoint.Frame.Common.ApplicationOperate.GetConfigValueByName("BeiAnPrint_SW", ""); ;
                //CRS_BeiAn.Report.
                #region
                HeTongInfo ds = new HeTongInfo();
                strSql = "select * from RG_XMAndRY RY where XMGuid='" + Request["RowGuid"] + "' order by substring(RY.ZhuanYeCode,1,4) asc,ddrole desc";
                DataView dvRY = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);

                for (int i = 0; i < dvRY.Count; i++)
                {
                    DataRow dr4;
                    dr4 = ds.Tables["RYOfXM"].NewRow();
                    dr4["ZiZhiText"]   = dvRY[i]["ZiZhiText"].ToString();
                    dr4["ZhuanYeText"] = dvRY[i]["ZhuanYeText"].ToString();
                    dr4["RYName"]      = dvRY[i]["RYName"].ToString();
                    dr4["IDNum"]       = dvRY[i]["IDNum"];//Convert.ToDecimal(
                    dr4["ZhiCheng"]    = DB_CM.GetCodeText_FromHash("职称", Convert.ToString(dvRY[i]["ZhiCheng"]));;
                    dr4["YinZhangNo"]  = dvRY[i]["YinZhangNo"].ToString();
                    dr4["ZhuanYeSX"]   = dvRY[i]["ZhuanYeSX"].ToString();

                    //处理下从事的专业,尽量缩小
                    string ZhuanYeCS = dvRY[i]["ZhuanYeCS"].ToString();

                    dr4["ZhuanYeCS"] = ZhuanYeCS;
                    dr4["GongLing"]  = dvRY[i]["GongLing"];
                    dr4["DDRole"]    = DB_CM.GetCodeText_FromHash("项目角色", Convert.ToString(dvRY[i]["DDRole"]));
                    dr4["OrNo"]      = i + 1;
                    ds.Tables["RYOfXM"].Rows.Add(dr4);
                }

                //HeTongBeiAn oCR = new HeTongBeiAn();
                myReport.SetDataSource(ds.Tables["RYOfXM"]);
                #endregion

                #region 参数
                strSql = "select * from RG_XMBeiAn where RowGuid='" + Request["RowGuid"] + "'";
                DataView dv = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);

                string XMAdd = "";

                string XMBH   = "";
                string STATUS = "";
                if (dv.Count > 0)
                {
                    strSql = "select * from RG_OUInfo where RowGuid='" + dv[0]["DWGuid"] + "'";
                    DataView dvDW = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);
                    if (dvDW.Count > 0)
                    {
                        STATUS = dv[0]["STATUS"].ToString();
                        myReport.SetParameterValue("DWName", dvDW[0]["EnterpriseName"]);
                        myReport.SetParameterValue("DWAddress", dvDW[0]["ZhuCeDi_XX"].ToString());
                        myReport.SetParameterValue("DWYB", dvDW[0]["YouZhengCode"].ToString());
                        myReport.SetParameterValue("DWXZ", dvDW[0]["DanWeiXZ"].ToString());
                        myReport.SetParameterValue("DWFR", dvDW[0]["FaRen"].ToString());
                        myReport.SetParameterValue("DWDH", dvDW[0]["DanWeiTel"].ToString());
                        myReport.SetParameterValue("DWLXR", dvDW[0]["LianXiRen"].ToString());
                        myReport.SetParameterValue("DWLXRDH", dvDW[0]["LianXiRenTel"].ToString());
                        string tb = dv[0]["TJDate"].ToString() == "" ? dv[0]["OperateDate"].ToString() : dv[0]["TJDate"].ToString();
                        myReport.SetParameterValue("TBDate", DateTime.Parse(tb).ToString("yyyy-MM-dd"));
                        myReport.SetParameterValue("FuZaCD", dv[0]["FuZaCD"].ToString());
                        myReport.SetParameterValue("YeWuFW", dv[0]["YeWuFW"].ToString());
                    }
                    else
                    {
                        myReport.SetParameterValue("DWName", "");
                        myReport.SetParameterValue("DWAddress", "");
                        myReport.SetParameterValue("DWYB", "");
                        myReport.SetParameterValue("DWXZ", "");
                        myReport.SetParameterValue("DWFR", "");
                        myReport.SetParameterValue("DWDH", "");
                        myReport.SetParameterValue("DWLXR", "");
                        myReport.SetParameterValue("DWLXRDH", "");
                    }
                    //注意处理,如果没有的话,就把编号的前面取出来
                    XMBH = RG_DW.GetXMBH(dv[0]["RowGuid"], dv[0]["DWGuid"], dv[0]["XMAdd"], dv[0]["XMBH"], dv[0]["XMLB"]);
                    myReport.SetParameterValue("XMBH", XMBH);
                    XMAdd = dv[0]["XMAdd"].ToString();
                    //加区县通过时间和市建设局通过时间
                    //看看有没有市的通过时间,如果有就加在后面,否则加在区县的后面

                    string YXQ = "";
                    if (dv[0]["TGDate"].ToString() == "")
                    {
                        if (dv[0]["QXTG_Date"].ToString() != "")
                        {
                            DateTime dtPass   = DateTime.Parse(dv[0]["QXTG_Date"].ToString());
                            string   qxTGDate = dtPass.ToString("yyyy 年 MM 月 dd 日 ");
                            YXQ = "有效期至:" + dtPass.AddYears(2).ToString("yyyy年MM月dd日");
                            myReport.SetParameterValue("QXTGDate", qxTGDate + "\n" + YXQ);
                        }
                        else
                        {
                            string qxTGDate = "      年    月    日 ";
                            myReport.SetParameterValue("QXTGDate", qxTGDate);
                        }
                        myReport.SetParameterValue("TGDate", "      年    月    日 ");
                    }
                    else
                    {
                        if (dv[0]["QXTG_Date"].ToString() != "")
                        {
                            myReport.SetParameterValue("QXTGDate", DateTime.Parse(dv[0]["QXTG_Date"].ToString()).ToString("yyyy年MM月dd日"));
                        }
                        else
                        {
                            myReport.SetParameterValue("QXTGDate", "      年    月    日 ");
                        }
                        DateTime dtPass = DateTime.Parse(dv[0]["TGDate"].ToString());
                        string   TGDate = dtPass.ToString("yyyy年MM月dd日");
                        YXQ = "有效期至:" + dtPass.AddYears(2).ToString("yyyy年MM月dd日");
                        myReport.SetParameterValue("TGDate", TGDate + "\n" + YXQ);
                    }
                }

                #endregion

                CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                myReport.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                myReport.ExportOptions.ExportFormatType      = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                string timeNow  = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                string fileName = timeNow + "XMBA.pdf";
                DiskOpts.DiskFileName = Server.MapPath(Request.ApplicationPath + "/AttachStorage/" + fileName);
                myReport.ExportOptions.DestinationOptions = DiskOpts;
                myReport.Export();

                //判断下状态,如果是已经审核通过了,那么就处理公章,否则直接加载
                if (STATUS != "90")
                {
                    if (this.LoginID == "admin")
                    {
                        string WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/合同备案公章.gif");
                        string message           = "";
                        string fileNewName       = timeNow + "_2XMBA.pdf";
                        string fileNew           = Request.ApplicationPath + "/AttachStorage/" + fileNewName;
                        WatermarkPDF(DiskOpts.DiskFileName, Server.MapPath(fileNew), WatermarkImageUrl, 568, 500, 115, 115, out message, XMAdd);
                        Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileNewName + "'; </script> ");
                    }
                    else
                    {
                        Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileName + "'; </script> ");
                    }
                }
                else
                {
                    string WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/合同备案公章.gif");
                    string message           = "";
                    string fileNewName       = timeNow + "_2XMBA.pdf";
                    string fileNew           = Request.ApplicationPath + "/AttachStorage/" + fileNewName;
                    WatermarkPDF(DiskOpts.DiskFileName, Server.MapPath(fileNew), WatermarkImageUrl, 568, 500, 115, 115, out message, XMAdd);
                    Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileNewName + "'; </script> ");
                }
            }
        }
Exemplo n.º 14
0
        //private void EXPORTTOPDF(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        string exportPath;
        //        string fileName;
        //        exportPath = Application.StartupPath + "\\" + DrawingNo + "附页";
        //        if (!Directory.Exists(exportPath))
        //        {
        //            System.IO.Directory.CreateDirectory(exportPath);
        //        }
        //        fileName = "WeightBarycenterCR.pdf";
        //        CrystalDecisions.Shared.DiskFileDestinationOptions opts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
        //        //导出为磁盘文件
        //        CrystalDecisions.Shared.ExportOptions myExportOptions = cr.ExportOptions;
        //        myExportOptions.DestinationOptions = opts;
        //        myExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
        //        //导出为pdf格式
        //        cr.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
        //        //目的路径
        //        fileName = exportPath + "\\" + fileName;
        //        opts.DiskFileName = fileName;
        //        if (File.Exists(fileName))
        //            File.Delete(fileName);
        //        //导出操作
        //        cr.Export();
        //        MessageBox.Show("--------转换成功---------");
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show("导出PDF时:" + ex.Message.ToString());
        //        this.Close();
        //    }
        //}
        //private void ReplaceExportButton()
        //{
        //    //遍历crystalReportViewer1控件里的控件
        //    foreach (object ctl in crystalReportViewer1.Controls)
        //    {
        //        string sControl = ctl.GetType().Name.ToString().ToLower();
        //        if (sControl == "toolstrip")
        //        {
        //            ToolStrip tab1 = (ToolStrip)ctl;
        //            for (int i = 0; i <= tab1.Items.Count - 1; i++)
        //            {
        //                if (tab1.Items[i].ToolTipText == "导出报表")
        //                {
        //                    ToolStripButton tbutton = new ToolStripButton();
        //                    Image img1 = tab1.Items[i].Image;
        //                    tab1.Items.Remove(tab1.Items[i]);
        //                    tbutton.Image = img1;
        //                    tbutton.ToolTipText = "导出报表";
        //                    tab1.Items.Insert(0, tbutton);
        //                    tbutton.Click += new System.EventHandler(this.EXPORTTOPDF);
        //                    break;
        //                }
        //            }
        //        }
        //    }
        //}
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string exportPath;
                string fileName;
                exportPath = Application.StartupPath + "\\" + DrawingNo + "附页";
                if (!Directory.Exists(exportPath))
                {
                    System.IO.Directory.CreateDirectory(exportPath);
                }

                fileName = "WeightBarycenterCR.pdf";

                CrystalDecisions.Shared.DiskFileDestinationOptions opts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                //导出为磁盘文件
                CrystalDecisions.Shared.ExportOptions myExportOptions = cr.ExportOptions;
                myExportOptions.DestinationOptions = opts;
                myExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                //导出为pdf格式
                cr.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                //目的路径
                fileName = exportPath + "\\" + fileName;
                opts.DiskFileName = fileName;
                if (File.Exists(fileName))
                    File.Delete(fileName);
                //导出操作
                cr.Export();
                MessageBox.Show("--------转换成功---------");
            }
            catch (Exception ex)
            {
                MessageBox.Show("导出PDF时:" + ex.Message.ToString());

                this.Close();
            }
        }
Exemplo n.º 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //先处理下附件文件夹中的备案表,防止过大
                DeleteSignedFile(Server.MapPath(Request.ApplicationPath + "/AttachStorage/"));
                HeTongBeiAn_WS myReport = new HeTongBeiAn_WS();
                string strSql = "";
                //先初始化项目信息

                //看看该公司所在的地区

                CRS_BeiAn.Report.FileName = System.Configuration.ConfigurationManager.AppSettings["BeiAnPrint_SW"];// Epoint.Frame.Common.ApplicationOperate.GetConfigValueByName("BeiAnPrint_SW", ""); ;
                //CRS_BeiAn.Report.
                #region
                HeTongInfo ds = new HeTongInfo();
                strSql = "select * from RG_XMAndRY RY where XMGuid='" + Request["RowGuid"] + "' order by substring(RY.ZhuanYeCode,1,4) asc,ddrole desc";
                DataView dvRY = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);

                for (int i = 0; i < dvRY.Count; i++)
                {
                    DataRow dr4;
                    dr4 = ds.Tables["RYOfXM"].NewRow();
                    dr4["ZiZhiText"] = dvRY[i]["ZiZhiText"].ToString();
                    dr4["ZhuanYeText"] = dvRY[i]["ZhuanYeText"].ToString();
                    dr4["RYName"] = dvRY[i]["RYName"].ToString();
                    dr4["IDNum"] = dvRY[i]["IDNum"];//Convert.ToDecimal(
                    dr4["ZhiCheng"] = DB_CM.GetCodeText_FromHash("职称", Convert.ToString(dvRY[i]["ZhiCheng"])); ;
                    dr4["YinZhangNo"] = dvRY[i]["YinZhangNo"].ToString();
                    dr4["ZhuanYeSX"] = dvRY[i]["ZhuanYeSX"].ToString();

                    //处理下从事的专业,尽量缩小
                    string ZhuanYeCS = dvRY[i]["ZhuanYeCS"].ToString();

                    dr4["ZhuanYeCS"] = ZhuanYeCS;
                    dr4["GongLing"] = dvRY[i]["GongLing"];
                    dr4["DDRole"] = DB_CM.GetCodeText_FromHash("项目角色", Convert.ToString(dvRY[i]["DDRole"]));
                    dr4["OrNo"] = i + 1;
                    ds.Tables["RYOfXM"].Rows.Add(dr4);
                }

                //HeTongBeiAn oCR = new HeTongBeiAn();
                myReport.SetDataSource(ds.Tables["RYOfXM"]);
                #endregion

                #region 参数
                strSql = "select * from RG_XMBeiAn where RowGuid='" + Request["RowGuid"] + "'";
                DataView dv = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);

                string XMAdd = "";

                string XMBH = "";
                string STATUS = "";
                if (dv.Count > 0)
                {
                    strSql = "select * from RG_OUInfo where RowGuid='" + dv[0]["DWGuid"] + "'";
                    DataView dvDW = Epoint.MisBizLogic2.DB.ExecuteDataView(strSql);
                    if (dvDW.Count > 0)
                    {
                        STATUS = dv[0]["STATUS"].ToString();
                        myReport.SetParameterValue("DWName", dvDW[0]["EnterpriseName"]);
                        myReport.SetParameterValue("DWAddress", dvDW[0]["ZhuCeDi_XX"].ToString());
                        myReport.SetParameterValue("DWYB", dvDW[0]["YouZhengCode"].ToString());
                        myReport.SetParameterValue("DWXZ", dvDW[0]["DanWeiXZ"].ToString());
                        myReport.SetParameterValue("DWFR", dvDW[0]["FaRen"].ToString());
                        myReport.SetParameterValue("DWDH", dvDW[0]["DanWeiTel"].ToString());
                        myReport.SetParameterValue("DWLXR", dvDW[0]["LianXiRen"].ToString());
                        myReport.SetParameterValue("DWLXRDH", dvDW[0]["LianXiRenTel"].ToString());
                        string tb = dv[0]["TJDate"].ToString() == "" ? dv[0]["OperateDate"].ToString() : dv[0]["TJDate"].ToString();
                        myReport.SetParameterValue("TBDate", DateTime.Parse(tb).ToString("yyyy-MM-dd"));
                        myReport.SetParameterValue("FuZaCD", dv[0]["FuZaCD"].ToString());
                        myReport.SetParameterValue("YeWuFW", dv[0]["YeWuFW"].ToString());
                    }
                    else
                    {
                        myReport.SetParameterValue("DWName", "");
                        myReport.SetParameterValue("DWAddress", "");
                        myReport.SetParameterValue("DWYB", "");
                        myReport.SetParameterValue("DWXZ", "");
                        myReport.SetParameterValue("DWFR", "");
                        myReport.SetParameterValue("DWDH", "");
                        myReport.SetParameterValue("DWLXR", "");
                        myReport.SetParameterValue("DWLXRDH", "");
                    }
                    //注意处理,如果没有的话,就把编号的前面取出来
                    XMBH = RG_DW.GetXMBH(dv[0]["RowGuid"], dv[0]["DWGuid"], dv[0]["XMAdd"], dv[0]["XMBH"], dv[0]["XMLB"]);
                    myReport.SetParameterValue("XMBH", XMBH);
                    XMAdd = dv[0]["XMAdd"].ToString();
                    //加区县通过时间和市建设局通过时间
                    //看看有没有市的通过时间,如果有就加在后面,否则加在区县的后面

                    string YXQ = "";
                    if (dv[0]["TGDate"].ToString() == "")
                    {
                        if (dv[0]["QXTG_Date"].ToString() != "")
                        {
                            DateTime dtPass = DateTime.Parse(dv[0]["QXTG_Date"].ToString());
                            string qxTGDate = dtPass.ToString("yyyy 年 MM 月 dd 日 ");
                            YXQ = "有效期至:" + dtPass.AddYears(2).ToString("yyyy年MM月dd日");
                            myReport.SetParameterValue("QXTGDate", qxTGDate + "\n" + YXQ);
                        }
                        else
                        {
                            string qxTGDate = "      年    月    日 ";
                            myReport.SetParameterValue("QXTGDate", qxTGDate);
                        }
                        myReport.SetParameterValue("TGDate", "      年    月    日 ");
                    }
                    else
                    {
                        if (dv[0]["QXTG_Date"].ToString() != "")
                        {
                            myReport.SetParameterValue("QXTGDate", DateTime.Parse(dv[0]["QXTG_Date"].ToString()).ToString("yyyy年MM月dd日"));
                        }
                        else
                        {
                            myReport.SetParameterValue("QXTGDate", "      年    月    日 ");
                        }
                        DateTime dtPass = DateTime.Parse(dv[0]["TGDate"].ToString());
                        string TGDate = dtPass.ToString("yyyy年MM月dd日");
                        YXQ = "有效期至:" + dtPass.AddYears(2).ToString("yyyy年MM月dd日");
                        myReport.SetParameterValue("TGDate", TGDate + "\n" + YXQ);
                    }
                }

                #endregion

                CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                myReport.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
                myReport.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                string timeNow = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                string fileName = timeNow + "XMBA.pdf";
                DiskOpts.DiskFileName = Server.MapPath(Request.ApplicationPath + "/AttachStorage/" + fileName);
                myReport.ExportOptions.DestinationOptions = DiskOpts;
                myReport.Export();

                //判断下状态,如果是已经审核通过了,那么就处理公章,否则直接加载
                if (STATUS != "90")
                {
                    if (this.LoginID == "admin")
                    {
                        string WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/合同备案公章.gif");
                        string message = "";
                        string fileNewName = timeNow + "_2XMBA.pdf";
                        string fileNew = Request.ApplicationPath + "/AttachStorage/" + fileNewName;
                        WatermarkPDF(DiskOpts.DiskFileName, Server.MapPath(fileNew), WatermarkImageUrl, 568, 500, 115, 115, out message, XMAdd);
                        Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileNewName + "'; </script> ");
                    }
                    else
                    {
                        Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileName + "'; </script> ");
                    }
                }
                else
                {
                    string WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/合同备案公章.gif");
                    string message = "";
                    string fileNewName = timeNow + "_2XMBA.pdf";
                    string fileNew = Request.ApplicationPath + "/AttachStorage/" + fileNewName;
                    WatermarkPDF(DiskOpts.DiskFileName, Server.MapPath(fileNew), WatermarkImageUrl, 568, 500, 115, 115, out message, XMAdd);
                    Response.Write("<script language=javascript> window.location.href = 'pdfReader.aspx?fileName=" + fileNewName + "'; </script> ");
                }

            }
        }