1
1
using System ;
2
2
using System . Windows . Forms ;
3
+ #region usings_sql
3
4
using DevExpress . DataAccess . ConnectionParameters ;
4
5
using DevExpress . DataAccess . Sql ;
6
+ #endregion
7
+ #region using_datafederation
5
8
using DevExpress . DataAccess . DataFederation ;
9
+ #endregion
10
+ #region using_excel
6
11
using DevExpress . DataAccess . Excel ;
7
12
using System . IO ;
13
+ #endregion
14
+ #region usings_report
8
15
using System . ComponentModel ;
9
16
using System . Drawing ;
10
17
using DevExpress . XtraReports . UI ;
18
+ #endregion
11
19
12
20
namespace BindReportToFederatedUnionQuery {
13
21
public partial class Form1 : Form {
14
22
public Form1 ( ) {
15
23
InitializeComponent ( ) ;
16
24
}
17
25
void Button1_Click ( object sender , EventArgs e ) {
26
+ #region ShowDesigner
18
27
ReportDesignTool designTool = new ReportDesignTool ( CreateReport ( ) ) ;
19
28
designTool . ShowRibbonDesignerDialog ( ) ;
29
+ #endregion
20
30
}
31
+ #region CreateFederationDataSource
21
32
static FederationDataSource CreateFederationDataSource ( SqlDataSource sql , ExcelDataSource excel ) {
22
33
// Create a federated query's SQL and Excel sources.
23
34
Source sqlSource = new Source ( sql . Name , sql , "Customers" ) ;
@@ -45,6 +56,8 @@ static FederationDataSource CreateFederationDataSource(SqlDataSource sql, ExcelD
45
56
46
57
return federationDataSource ;
47
58
}
59
+ #endregion
60
+ #region CreateReport
48
61
public static XtraReport CreateReport ( ) {
49
62
// Create a new report.
50
63
var report = new XtraReport ( ) ;
@@ -72,14 +85,17 @@ public static XtraReport CreateReport() {
72
85
73
86
return report ;
74
87
}
88
+ #endregion
89
+ #region CreateSqlDataSource
75
90
static SqlDataSource CreateSqlDataSource ( ) {
76
- var connectionParameters = new Access97ConnectionParameters ( Path . Combine ( Path . GetDirectoryName ( typeof ( Form1 ) . Assembly . Location ) , "Data/nwind.mdb" ) , "" , "" ) ;
77
- var sqlDataSource = new SqlDataSource ( connectionParameters ) { Name = "Sql_Customers" } ;
91
+ var connectionParameters = new SQLiteConnectionParameters ( "Data/nwind.db" , null ) ; var sqlDataSource = new SqlDataSource ( connectionParameters ) { Name = "Sql_Customers" } ;
78
92
var categoriesQuery = SelectQueryFluentBuilder . AddTable ( "Customers" ) . SelectAllColumnsFromTable ( ) . Build ( "Customers" ) ;
79
93
sqlDataSource . Queries . Add ( categoriesQuery ) ;
80
94
sqlDataSource . RebuildResultSchema ( ) ;
81
95
return sqlDataSource ;
82
96
}
97
+ #endregion
98
+ #region CreateExcelDataSource
83
99
static ExcelDataSource CreateExcelDataSource ( ) {
84
100
var excelDataSource = new ExcelDataSource ( ) { Name = "Excel_Suppliers" } ;
85
101
excelDataSource . FileName = Path . Combine ( Path . GetDirectoryName ( typeof ( Form1 ) . Assembly . Location ) , "Data/Suppliers.xlsx" ) ;
@@ -89,5 +105,6 @@ static ExcelDataSource CreateExcelDataSource() {
89
105
excelDataSource . RebuildResultSchema ( ) ;
90
106
return excelDataSource ;
91
107
}
108
+ #endregion
92
109
}
93
110
}
0 commit comments