1
yhj
2024-07-24 5e5d945e91568b973faa27d8ab0bcef99fc4a6c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#region
 
using System;
using System.IO;
using CSFrameworkV5.Core;
using FastReport;
using FastReport.Export;
using FastReport.Export.Html;
using FastReport.Export.Image;
using FastReport.Export.Pdf;
using FastReport.Export.Xml;
 
#endregion
 
namespace CSFrameworkV5.Library
{
    public enum ReportType
    {
        PrintDocument = 0,
        PrintCheckList = 1
    } //
 
    public class ExportReportItem
    {
        public enum ExportType
        {
            IMG,
            PDF,
            XLS,
            HTML
        }
 
        private ExportType _exportType;
 
        private string _ItemCaption;
 
        public ExportReportItem(string itemCaption, ExportType exportType)
        {
            _ItemCaption = itemCaption;
            _exportType = exportType;
        }
 
        public string ExportToFile(Report report)
        {
            ExportBase export = null;
            var fileName = Path.GetTempPath() + @"\_rpt" +
                           DateTime.Now.ToString("yyyyMMddhhmmss") + "_" +
                           Loginer.CurrentUser.Account;
 
            if (ExportType.IMG == _exportType)
            {
                fileName = fileName + ".png";
                export = new ImageExport();
                (export as ImageExport).ImageFormat = ImageExportFormat.Png;
            }
            else if (ExportType.PDF == _exportType)
            {
                fileName = fileName + ".pdf";
                export = new PDFExport();
            }
            else if (ExportType.XLS == _exportType)
            {
                fileName = fileName + ".xls";
                export = new XMLExport();
            }
            else if (ExportType.HTML == _exportType)
            {
                fileName = fileName + ".html";
                export = new HTMLExport();
            }
 
            if (export != null)
            {
                export.AllowOpenAfter = false;
                report.Export(export, fileName);
            }
 
            return fileName;
        }
 
        public override string ToString()
        {
            return _ItemCaption;
        }
    }
 
    public class ReportLib
    {
        public static void DesignReport(string file, bool isCreateNew)
        {
            var rpt = new Report();
            if (isCreateNew)
            {
                rpt.Design(true);
            }
            else
            {
                rpt.Load(file);
                rpt.Design(true);
            }
        }
    }
}