-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWebTiles.aspx.vb
187 lines (173 loc) · 7.92 KB
/
WebTiles.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
Imports System.Data
Imports System.Data.SqlClient
Imports Ext.Net
Imports Immap.Service
Imports Immap.Model
Partial Class WebTiles
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim database As String = Convert.ToString(Session("database"))
If String.IsNullOrEmpty(database) = True Then
Session("RedirectURL") = Request.Url.AbsoluteUri
Dim cookieDetails = Request.Cookies("ADMINTOOL")
If cookieDetails IsNot Nothing Then
Response.Cookies.Add(cookieDetails)
End If
Response.Redirect("~/Login")
End If
InitImageFomat()
If Not (Page.IsPostBack) AndAlso Not (RequestManager.IsAjaxRequest) Then
Session("TITLE") = "Web Titles"
UserGroupService.GetInstance().LoadUserGroupStore(database, UserGroupStore)
If Not (Session("cboUserGroupValue") Is Nothing) Then
cboUserGroups.SetValue(Session("cboUserGroupsSelectedItem"))
cboUserGroups.SelectedItem.Text = Session("cboUserGroupText")
cboUserGroups.DataBind()
ReloadWebTiles()
End If
End If
End Sub
Protected Sub cboUserGroups_Select(sender As Object, e As Ext.Net.DirectEventArgs)
Session("cboUserGroupValue") = cboUserGroups.SelectedItem.Value
Session("cboUserGroupText") = cboUserGroups.SelectedItem.Text
ReloadWebTiles()
Me.frmWebTiles.Reset()
End Sub
Protected Sub RowDelete(sender As Object, e As DirectEventArgs)
Dim database As String = Convert.ToString(Session("database"))
Dim msg As New MessageBox()
Dim userGroup As String = cboUserGroups.SelectedItem.Text
Dim Caption As String = e.ExtraParams("Caption")
If ID Is Nothing Then
e.Success = False
e.ErrorMessage = "The list of Web tilels is empty"
Exit Sub
End If
Try
WebTilesService.GetInstance().DeleteByCaption(database, userGroup, Caption)
e.Success = True
Catch ex As Exception
e.Success = False
End Try
frmWebTiles.Reset()
ReloadWebTiles()
End Sub
Protected Sub UserGroupStore_Refresh(sender As Object, e As StoreRefreshDataEventArgs)
If Session("database") Is Nothing Then
Exit Sub
End If
End Sub
Protected Sub WebTilesStore_Refresh(sender As Object, e As Ext.Net.StoreRefreshDataEventArgs)
ReloadWebTiles()
End Sub
Protected Sub btnInsert_Click(sender As Object, e As DirectEventArgs)
InsertOrUpdate("INSERT")
End Sub
Protected Sub btnUpdate_Click(sender As Object, e As DirectEventArgs)
InsertOrUpdate("UPDATE")
End Sub
Protected Sub InsertOrUpdate(ByVal command As String)
Dim database As String = Convert.ToString(Session("database"))
Dim msg As New MessageBox()
Dim userGroup As String = cboUserGroups.SelectedItem.Text
If String.IsNullOrEmpty(userGroup) Then
msg.Show(New MessageBoxConfig() With {
.Title = "Warning",
.Message = "Please select user group",
.Buttons = MessageBox.Button.OK,
.Icon = MessageBox.Icon.WARNING,
.AnimEl = Me.frmWebTiles.ClientID
})
End If
If String.IsNullOrWhiteSpace(txtCaption.Text) Then
msg.Show(New MessageBoxConfig() With {
.Title = "Warning",
.Message = "Please enter caption",
.Buttons = MessageBox.Button.OK,
.Icon = MessageBox.Icon.WARNING,
.AnimEl = Me.frmWebTiles.ClientID
})
Exit Sub
End If
Dim espgNumber As String = Nothing
If String.IsNullOrWhiteSpace(nbfESPGNumber.Text) = False Then espgNumber = CInt(nbfESPGNumber.Text).ToString()
If command.Equals("INSERT") Then
Dim isDuplicate As Boolean = WebTilesService.GetInstance().CheckDuplicateCaption(database, userGroup, txtCaption.Text.Trim(), txtHiddenCaption.Text)
If isDuplicate Then
msg.Show(New MessageBoxConfig() With {
.Title = "Warning",
.Message = "This caption is duplicated",
.Buttons = MessageBox.Button.OK,
.Icon = MessageBox.Icon.WARNING,
.AnimEl = Me.frmWebTiles.ClientID
})
Exit Sub
End If
WebTilesService.GetInstance().Insert(database,
userGroup,
txtCaption.Text,
txtURL1.Text,
txtURL2.Text,
txtURL3.Text,
espgNumber,
cboImageFormat.Text.ToLower(),
If(chkForceWGS.Checked = True, "1", "0"))
frmWebTiles.Reset()
ReloadWebTiles()
Dim sm As RowSelectionModel = TryCast(Me.gpWebTiles.SelectionModel.Primary, RowSelectionModel)
sm.ClearSelections()
gpWebTiles.Call("clearMemory")
ElseIf command.Equals("UPDATE") Then
If String.IsNullOrEmpty(txtHiddenCaption.Text) = True Then
msg.Show(New MessageBoxConfig() With {
.Title = "Warning",
.Message = "Please insert data before update it.",
.Buttons = MessageBox.Button.OK,
.Icon = MessageBox.Icon.WARNING,
.AnimEl = Me.frmWebTiles.ClientID
})
Exit Sub
End If
Dim isDuplicate As Boolean = WebTilesService.GetInstance().CheckDuplicateCaption(database, userGroup, txtCaption.Text.Trim(), txtHiddenCaption.Text)
If isDuplicate Then
msg.Show(New MessageBoxConfig() With {
.Title = "Warning",
.Message = "This caption is duplicated",
.Buttons = MessageBox.Button.OK,
.Icon = MessageBox.Icon.WARNING,
.AnimEl = Me.frmWebTiles.ClientID
})
Exit Sub
End If
WebTilesService.GetInstance().Update(database,
userGroup,
txtCaption.Text,
txtHiddenCaption.Text,
txtURL1.Text,
txtURL2.Text,
txtURL3.Text,
espgNumber,
cboImageFormat.Text.ToLower(),
If(chkForceWGS.Checked = True, "1", "0"))
frmWebTiles.Reset()
ReloadWebTiles()
Dim sm As RowSelectionModel = TryCast(Me.gpWebTiles.SelectionModel.Primary, RowSelectionModel)
sm.ClearSelections()
gpWebTiles.Call("clearMemory")
End If
End Sub
Protected Sub InitImageFomat()
Dim store = Me.cboImageFormat.GetStore()
store.DataSource = New Object() {
New Object() {"png", "PNG"},
New Object() {"jpg", "JPG"}
}
store.DataBind()
End Sub
Protected Sub ReloadWebTiles()
Dim database As String = Convert.ToString(Session("database"))
Dim userGroup As String = cboUserGroups.SelectedItem.Text
WebTilesService.GetInstance().RunPrepareUserGroupDatabaseScript(database, userGroup)
WebTilesService.GetInstance().FindAll(database, cboUserGroups.SelectedItem.Text, WebTilesStore)
End Sub
End Class