-
Notifications
You must be signed in to change notification settings - Fork 0
/
Default.aspx.vb
98 lines (83 loc) · 4.4 KB
/
Default.aspx.vb
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
Imports DevExpress.DataAccess.ConnectionParameters
Imports System
Imports System.Collections.Generic
Namespace WebApplication1
Partial Public Class [Default]
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim sqlDataSource As DevExpress.DataAccess.Sql.SqlDataSource = GenerateSqlDataSource()
Dim objDataSource As DevExpress.DataAccess.ObjectBinding.ObjectDataSource = GenerateObjectDataSource()
Dim efDataSource As DevExpress.DataAccess.EntityFramework.EFDataSource = GenerateEFDataSource()
Dim excelDataSource As DevExpress.DataAccess.Excel.ExcelDataSource = GenerateExcelDataSource()
Dim jsonDataSource As DevExpress.DataAccess.Json.JsonDataSource = GenerateJsonDataSource()
ASPxReportDesigner1.DataSources.Add(sqlDataSource.Name, sqlDataSource)
ASPxReportDesigner1.DataSources.Add(objDataSource.Name, objDataSource)
ASPxReportDesigner1.DataSources.Add(efDataSource.Name, efDataSource)
ASPxReportDesigner1.DataSources.Add(excelDataSource.Name, excelDataSource)
ASPxReportDesigner1.DataSources.Add(jsonDataSource.Name, jsonDataSource)
ASPxReportDesigner1.OpenReport("XtraReportTest")
End Sub
Private Function GenerateJsonDataSource() As DevExpress.DataAccess.Json.JsonDataSource
Dim jsonDataSource As New DevExpress.DataAccess.Json.JsonDataSource()
jsonDataSource.Name = "CustomJsonDataSource"
Dim sourceUri As New Uri("~/App_Data/nwind.json", System.UriKind.Relative)
jsonDataSource.JsonSource = New DevExpress.DataAccess.Json.UriJsonSource(sourceUri)
jsonDataSource.Fill()
Return jsonDataSource
End Function
Private Function GenerateExcelDataSource() As DevExpress.DataAccess.Excel.ExcelDataSource
Dim excelDS As New DevExpress.DataAccess.Excel.ExcelDataSource()
excelDS.FileName = Server.MapPath("App_Data/Categories.xlsx")
excelDS.Name = "CustomExcelDataSource"
Dim excelWorksheetSettings1 As New DevExpress.DataAccess.Excel.ExcelWorksheetSettings() With {.CellRange = Nothing, .WorksheetName = "Sheet"}
Dim excelSourceOptions1 As New DevExpress.DataAccess.Excel.ExcelSourceOptions(excelWorksheetSettings1) With {.SkipEmptyRows = True, .SkipHiddenColumns = True, .SkipHiddenRows = True, .UseFirstRowAsHeader = True}
excelDS.SourceOptions = excelSourceOptions1
Dim fieldInfo1 As New DevExpress.DataAccess.Excel.FieldInfo() With {.Name = "CategoryID", .Type = GetType(Double)}
Dim fieldInfo2 As New DevExpress.DataAccess.Excel.FieldInfo() With {.Name = "CategoryName", .Type = GetType(String)}
Dim fieldInfo3 As New DevExpress.DataAccess.Excel.FieldInfo() With {.Name = "Description", .Type = GetType(String)}
excelDS.Schema.AddRange(New DevExpress.DataAccess.Excel.FieldInfo() { fieldInfo1, fieldInfo2, fieldInfo3 })
excelDS.RebuildResultSchema()
Return excelDS
End Function
Private Function GenerateEFDataSource() As DevExpress.DataAccess.EntityFramework.EFDataSource
Dim efds As New DevExpress.DataAccess.EntityFramework.EFDataSource()
efds.Name = "CustomEntityFrameworkDataSource"
efds.ConnectionParameters = New DevExpress.DataAccess.EntityFramework.EFConnectionParameters()
efds.ConnectionParameters.ConnectionStringName = "NorthwindEntitiesConnString"
efds.ConnectionParameters.Source = GetType(Models.NorthwindEntities)
Return efds
End Function
Private Function GenerateSqlDataSource() As DevExpress.DataAccess.Sql.SqlDataSource
Dim ds As New DevExpress.DataAccess.Sql.SqlDataSource("localhost_Northwind_Connection")
ds.Name = "CustomSqlDataSource"
Dim query As New DevExpress.DataAccess.Sql.CustomSqlQuery()
query.Name = "customQuery1"
query.Sql = "SELECT * FROM Products"
ds.Queries.Add(query)
ds.RebuildResultSchema()
Return ds
End Function
Private Function GenerateObjectDataSource() As DevExpress.DataAccess.ObjectBinding.ObjectDataSource
Dim objds As New DevExpress.DataAccess.ObjectBinding.ObjectDataSource()
objds.BeginInit()
objds.Name = "CustomObjectDataSource"
objds.DataSource = GetType(ItemList)
objds.Constructor = New DevExpress.DataAccess.ObjectBinding.ObjectConstructorInfo()
objds.EndInit()
Return objds
End Function
End Class
#Region "Object Data Source"
Public Class ItemList
Inherits List(Of Item)
Public Sub New()
For i As Integer = 0 To 9
Add(New Item() With {.Name = i.ToString()})
Next i
End Sub
End Class
Public Class Item
Public Property Name() As String
End Class
#End Region
End Namespace