-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.vb
67 lines (57 loc) · 2.3 KB
/
Form1.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
Imports System
Imports System.IO
Imports System.Data
Imports System.Windows.Forms
Imports DevExpress.XtraReports.UI
Imports StoreRepInDB.ReportsDBDataSetTableAdapters
' ...
Namespace StoreRepInDB
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private dataAdapter1 As ReportsTableAdapter = New ReportsTableAdapter()
Private dataSet1 As ReportsDBDataSet = New ReportsDBDataSet()
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs)
' Create a new report.
Dim report As XtraReport1 = New XtraReport1()
' Save the report to a stream.
Dim stream As MemoryStream = New MemoryStream()
report.SaveLayout(stream)
' Prepare the stream for reading.
stream.Position = 0
' Insert the report to a database.
Using sr As StreamReader = New StreamReader(stream)
' Read the report from the stream to a string variable.
Dim s As String = sr.ReadToEnd()
' Add a row to a table.
Dim dt As DataTable = dataSet1.Tables("Reports")
Dim row As DataRow = dt.NewRow()
row("Report") = s
dt.Rows.Add(row)
End Using
' Commit changes.
dataAdapter1.Update(dataSet1)
dataSet1.AcceptChanges()
End Sub
Private Sub btnLoad_Click(ByVal sender As Object, ByVal e As EventArgs)
' Declare a base report variable.
Dim newReport As XtraReport
' Retrieve a string which contains the report.
Dim s As String = dataSet1.Tables(CStr("Reports")).Rows(0)("Report").ToString()
' Obtain the report from the string.
Using sw As StreamWriter = New StreamWriter(New MemoryStream())
sw.Write(s)
sw.Flush()
newReport = XtraReport.FromStream(sw.BaseStream, True)
End Using
' Preview the report.
newReport.ShowPreview()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
' Fill the datasource.
dataAdapter1.Fill(dataSet1.Reports)
End Sub
End Class
End Namespace