-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReportHelper.vb
More file actions
68 lines (64 loc) · 3.4 KB
/
ReportHelper.vb
File metadata and controls
68 lines (64 loc) · 3.4 KB
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
Imports DevExpress.ReportServer.ServiceModel.DataContracts
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports DevExpress.XtraReports.Parameters
Imports DevExpress.XtraReports.UI
Imports System.Drawing
Imports DevExpress.DataAccess.ObjectBinding
Namespace WindowsFormsApp1
Public Module ReportHelper
Public Function CreateReport() As XtraReport
Dim departments = New StaticListLookUpSettings()
departments.LookUpValues.AddRange({
New LookUpValue("Management", "Management"),
New LookUpValue("Financial", "Financial"),
New LookUpValue("Sales", "Sales")
})
Dim report = New XtraReport()
Dim band = New DetailBand() With {.HeightF = 25}
Dim label1 = New XRLabel() With {
.Name = "EmployeeName",
.BoundsF = New RectangleF(0, 0, 200, 25)}
Dim label2 = New XRLabel() With {
.Name = "EmployeePosition",
.BoundsF = New RectangleF(200, 0, 150, 25)}
label1.ExpressionBindings.Add(New ExpressionBinding("Text", "[EmployeeName]"))
label2.ExpressionBindings.Add(New ExpressionBinding("Text", "[EmployeePosition]"))
band.Controls.AddRange(New XRControl() {label1, label2})
report.Bands.Add(band)
Dim param1 = New DevExpress.XtraReports.Parameters.Parameter() With {
.Name = "pDepartment",
.Type = GetType(System.String),
.ValueSourceSettings = departments,
.Description = "Department",
.Value = "Management"}
Dim param2 = New DevExpress.XtraReports.Parameters.Parameter() With {
.Name = "NumberOfRecords",
.Type = GetType(System.Int32),
.Value = 2}
report.Parameters.AddRange(New DevExpress.XtraReports.Parameters.Parameter() {param1, param2})
Dim objectDataSource1 As New ObjectDataSource()
objectDataSource1.Name = "Employees"
objectDataSource1.DataSource = GetType(EmployeeDataSource)
objectDataSource1.BeginUpdate()
objectDataSource1.DataMember = "GetEmployeeList"
Dim parameterNumberOfRecords = New DevExpress.DataAccess.ObjectBinding.Parameter() With {
.Name = "recordCount",
.Type = GetType(DevExpress.DataAccess.Expression),
.Value = New DevExpress.DataAccess.Expression("?NumberOfRecords", GetType(Integer))}
objectDataSource1.Parameters.Add(parameterNumberOfRecords)
Dim parameterDepartment = New DevExpress.DataAccess.ObjectBinding.Parameter() With {
.Name = "department",
.Type = GetType(DevExpress.DataAccess.Expression),
.Value = New DevExpress.DataAccess.Expression("?pDepartment", GetType(String))}
objectDataSource1.Constructor = New ObjectConstructorInfo(parameterDepartment)
objectDataSource1.EndUpdate()
objectDataSource1.Fill()
report.DataSource = objectDataSource1
Return report
End Function
End Module
End Namespace