-
Notifications
You must be signed in to change notification settings - Fork 1
/
Default.aspx.vb
68 lines (56 loc) · 2.39 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
Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
' ...
Namespace SimpleWebReportCatalog
Partial Public Class [Default]
Inherits System.Web.UI.Page
Private reportsTable As New DataTable()
Private reportsTableAdapter As SqlDataAdapter
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim connectionString = ConfigurationManager.ConnectionStrings("catalogConnectionString").ConnectionString
reportsTableAdapter = New SqlDataAdapter("Select * from ReportLayout", New SqlConnection(connectionString))
Dim builder As New SqlCommandBuilder(reportsTableAdapter)
reportsTableAdapter.InsertCommand = builder.GetInsertCommand()
reportsTableAdapter.UpdateCommand = builder.GetUpdateCommand()
reportsTableAdapter.DeleteCommand = builder.GetDeleteCommand()
reportsTableAdapter.Fill(reportsTable)
Dim keyColumns(0) As DataColumn
keyColumns(0) = reportsTable.Columns(0)
reportsTable.PrimaryKey = keyColumns
If Not IsPostBack Then
reportsList.DataSource = reportsTable
reportsList.DataMember = "Reports"
reportsList.DataTextField = "DisplayName"
reportsList.DataValueField = "ReportId"
Me.DataBind()
End If
End Sub
Protected Sub NewReportButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Session("DesignerTask") = New DesignerTask With {.mode = ReportEdditingMode.NewReport}
Response.Redirect("Designer.aspx")
End Sub
Protected Sub EditButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim selected As ListItem = reportsList.SelectedItem
If selected IsNot Nothing Then
Session("DesignerTask") = New DesignerTask With {.mode = ReportEdditingMode.ModifyReport, .reportID = selected.Value}
Session("ReportID") = selected.Value
Response.Redirect("Designer.aspx")
End If
End Sub
Protected Sub DeleteButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim selected As ListItem = reportsList.SelectedItem
If selected IsNot Nothing Then
Dim row As DataRow = reportsTable.Rows.Find(Integer.Parse(selected.Value))
If row IsNot Nothing Then
row.Delete()
reportsTableAdapter.Update(reportsTable)
reportsTable.AcceptChanges()
End If
reportsList.Items.Remove(reportsList.SelectedItem)
End If
End Sub
End Class
End Namespace