-
Notifications
You must be signed in to change notification settings - Fork 12
/
EditPropertyTypes.ascx.vb
executable file
·405 lines (273 loc) · 16 KB
/
EditPropertyTypes.ascx.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Namespace Ventrian.PropertyAgent
Partial Public Class EditPropertyTypes
Inherits PropertyAgentBase
#Region " Private Members "
Dim _propertyTypeID As Integer = Null.NullInteger
Dim _currentPage As Integer = 1
Dim _pageRecords As Integer = Null.NullInteger
Dim _propertyTypes As List(Of PropertyTypeInfo)
#End Region
#Region " Private Methods "
Private Sub ReadQueryString()
Dim propertyTypeIDParam As String = PropertySettings.SEOPropertyTypeID
If (Request(propertyTypeIDParam) = "") Then
propertyTypeIDParam = "PropertyTypeID"
End If
If Not (Request(propertyTypeIDParam) Is Nothing) Then
_propertyTypeID = Convert.ToInt32(Request(propertyTypeIDParam))
End If
If Not (Request("CurrentPage") Is Nothing) Then
_currentPage = Convert.ToInt32(Request("CurrentPage"))
End If
If Not (Request("PageRecords") Is Nothing) Then
_pageRecords = Convert.ToInt32(Request("PageRecords"))
End If
End Sub
Private Sub BindPageCount()
If (_pageRecords <> Null.NullInteger) Then
If Not (drpRecordsPerPage.Items.FindByValue(_pageRecords.ToString()) Is Nothing) Then
drpRecordsPerPage.SelectedValue = _pageRecords.ToString()
End If
End If
End Sub
Private Sub BindCrumbs()
Dim crumbs As New ArrayList
Dim objCrumbMain As New CrumbInfo
objCrumbMain.Caption = PropertySettings.MainLabel
objCrumbMain.Url = NavigateURL()
crumbs.Add(objCrumbMain)
Dim objPropertyTypeManager As New CrumbInfo
objPropertyTypeManager.Caption = Localization.GetString("PropertyTypeManager", LocalResourceFile)
objPropertyTypeManager.Url = NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes")
crumbs.Add(objPropertyTypeManager)
If (PropertySettings.BreadcrumbPlacement = BreadcrumbType.Portal) Then
For i As Integer = 0 To crumbs.Count - 1
Dim objCrumb As CrumbInfo = crumbs(i)
If (i > 0) Then
Dim objTab As New DotNetNuke.Entities.Tabs.TabInfo
objTab.TabID = -8888 + i
objTab.TabName = objCrumb.Caption
objTab.Url = objCrumb.Url
PortalSettings.ActiveTab.BreadCrumbs.Add(objTab)
End If
Next
End If
If (PropertySettings.BreadcrumbPlacement = BreadcrumbType.Module) Then
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End If
End Sub
Private Sub BindPropertyTypes()
Dim PageSize As Integer = Convert.ToInt32(drpRecordsPerPage.SelectedItem.Value)
Localization.LocalizeDataGrid(grdPropertyTypes, Me.LocalResourceFile)
Dim objPropertyTypeController As New PropertyTypeController
_propertyTypes = objPropertyTypeController.List(Me.ModuleId, False, Me.PropertySettings.TypesSortBy, Null.NullString(), _propertyTypeID)
If (Me.PropertySettings.TypesSortBy = PropertyTypeSortByType.Standard) Then
If (_propertyTypes.Count > 1) Then
For i As Integer = 0 To _propertyTypes.Count - 1
Dim objPropertyType As PropertyTypeInfo = CType(_propertyTypes(i), PropertyTypeInfo)
objPropertyType.SortOrder = i
objPropertyTypeController.Update(objPropertyType)
Next
End If
End If
Dim objPagedDataSource As New PagedDataSource
objPagedDataSource.AllowPaging = True
objPagedDataSource.DataSource = _propertyTypes
objPagedDataSource.PageSize = PageSize
objPagedDataSource.CurrentPageIndex = _currentPage - 1
If (_propertyTypes.Count > 0) Then
grdPropertyTypes.DataSource = objPagedDataSource
grdPropertyTypes.DataBind()
If (Me.PropertySettings.TypesSortBy = PropertyTypeSortByType.Name) Then
grdPropertyTypes.Columns(4).Visible = False
End If
grdPropertyTypes.Visible = True
lblNoPropertyTypes.Visible = False
ctlPagingControl.Visible = True
ctlPagingControl.Visible = True
ctlPagingControl.TotalRecords = _propertyTypes.Count
ctlPagingControl.PageSize = PageSize
ctlPagingControl.CurrentPage = _currentPage
If (_propertyTypeID = Null.NullInteger) Then
ctlPagingControl.QuerystringParams = PropertySettings.SEOAgentType & "=EditPropertyTypes"
Else
ctlPagingControl.QuerystringParams = PropertySettings.SEOAgentType & "=EditPropertyTypes&" & PropertySettings.SEOPropertyTypeID & "=" & _propertyTypeID.ToString()
End If
If (drpRecordsPerPage.SelectedIndex <> 0) Then
ctlPagingControl.QuerystringParams = ctlPagingControl.QuerystringParams & "&PageRecords=" + drpRecordsPerPage.SelectedValue
End If
ctlPagingControl.TabID = TabId
Else
grdPropertyTypes.Visible = False
lblNoPropertyTypes.Visible = True
ctlPagingControl.Visible = False
End If
Dim crumbs As New ArrayList
Dim objCrumb As New CrumbInfo
objCrumb.Caption = GetResourceString("Top Level")
objCrumb.Url = NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes")
crumbs.Add(objCrumb)
If (_propertyTypeID <> Null.NullInteger) Then
Dim objPropertyType As PropertyTypeInfo = objPropertyTypeController.Get(Me.ModuleId, _propertyTypeID)
If Not (objPropertyType Is Nothing) Then
Dim parentID As Integer = objPropertyType.ParentID
Do
Dim objCrumbType As New CrumbInfo
objCrumbType.Caption = objPropertyType.Name
objCrumbType.Url = NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes", PropertySettings.SEOPropertyTypeID & "=" & objPropertyType.PropertyTypeID)
If (_propertyTypeID = objPropertyType.PropertyTypeID) Then
crumbs.Add(objCrumbType)
Else
crumbs.Insert(1, objCrumbType)
End If
objPropertyType = objPropertyTypeController.Get(Me.ModuleId, objPropertyType.ParentID)
If (objPropertyType Is Nothing) Then
parentID = Null.NullInteger
Else
parentID = objPropertyType.PropertyTypeID
End If
Loop While (parentID <> Null.NullInteger)
End If
End If
If (crumbs.Count > 1) Then
rptTypeCrumbs.DataSource = crumbs
rptTypeCrumbs.DataBind()
End If
If (ctlPagingControl.TotalRecords <= PageSize) Then
ctlPagingControl.Visible = False
End If
End Sub
#End Region
#Region " Protected Methods "
Protected Function GetPropertyTypeEditUrl(ByVal propertyTypeID As String) As String
Return NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyType", "propertyTypeID=" & propertyTypeID)
End Function
Protected Function GetSubPropertyTypeEditUrl(ByVal propertyTypeID As String) As String
Return NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes", "propertyTypeID=" & propertyTypeID)
End Function
#End Region
#Region " Event Handlers "
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
Try
BindCrumbs()
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
ReadQueryString()
If (Page.IsPostBack = False) Then
BindPageCount()
BindPropertyTypes()
End If
cmdAddPropertyType.CssClass = PropertySettings.ButtonClass
cmdReturnToModule.CssClass = PropertySettings.ButtonClass
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdAddPropertyType_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddPropertyType.Click
Try
If (_propertyTypeID = Null.NullInteger) Then
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyType"), True)
Else
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyType", "parentID=" & _propertyTypeID.ToString()), True)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdReturnToModule_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReturnToModule.Click
Try
Response.Redirect(NavigateURL(Me.TabId), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub drpRecordsPerPage_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drpRecordsPerPage.SelectedIndexChanged
Try
If (_propertyTypeID <> Null.NullInteger) Then
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes", "PageRecords=" & drpRecordsPerPage.SelectedValue, PropertySettings.SEOPropertyTypeID & "=" & _propertyTypeID.ToString()), True)
Else
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes", "PageRecords=" & drpRecordsPerPage.SelectedValue), True)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub grdPropertyTypes_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdPropertyTypes.ItemDataBound
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim btnUp As ImageButton = CType(e.Item.FindControl("btnUp"), ImageButton)
Dim btnDown As ImageButton = CType(e.Item.FindControl("btnDown"), ImageButton)
Dim objPropertyType As PropertyTypeInfo = CType(e.Item.DataItem, PropertyTypeInfo)
If Not (btnUp Is Nothing And btnDown Is Nothing) Then
If (objPropertyType.PropertyTypeID = CType(_propertyTypes(0), PropertyTypeInfo).PropertyTypeID) Then
btnUp.Visible = False
End If
If (objPropertyType.PropertyTypeID = CType(_propertyTypes(_propertyTypes.Count - 1), PropertyTypeInfo).PropertyTypeID) Then
btnDown.Visible = False
End If
btnUp.CommandArgument = objPropertyType.PropertyTypeID.ToString()
btnUp.CommandName = "Up"
btnDown.CommandArgument = objPropertyType.PropertyTypeID.ToString()
btnDown.CommandName = "Down"
End If
Dim btnPublished As ImageButton = CType(e.Item.FindControl("btnPublished"), ImageButton)
If Not (btnPublished Is Nothing) Then
If (objPropertyType.IsPublished) Then
btnPublished.ImageUrl = "~/images/checked.gif"
btnPublished.CommandName = "PublishedChecked"
Else
btnPublished.ImageUrl = "~/images/cancel.gif"
btnPublished.CommandName = "PublishedCancel"
End If
btnPublished.CommandArgument = objPropertyType.PropertyTypeID.ToString()
End If
End If
End Sub
Private Sub grdPropertyTypes_ItemCommand(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdPropertyTypes.ItemCommand
Dim objPropertyTypeController As New PropertyTypeController
_propertyTypes = objPropertyTypeController.List(Me.ModuleId, False, PropertyTypeSortByType.Standard, Null.NullString(), _propertyTypeID)
Dim propertyTypeID As Integer = Convert.ToInt32(e.CommandArgument)
For i As Integer = 0 To _propertyTypes.Count - 1
Dim objPropertyType As PropertyTypeInfo = CType(_propertyTypes(i), PropertyTypeInfo)
If (propertyTypeID = objPropertyType.PropertyTypeID) Then
If (e.CommandName = "Up") Then
Dim objPropertyTypeToSwap As PropertyTypeInfo = CType(_propertyTypes(i - 1), PropertyTypeInfo)
Dim sortOrder As Integer = objPropertyType.SortOrder
Dim sortOrderPrevious As Integer = objPropertyTypeToSwap.SortOrder
objPropertyType.SortOrder = sortOrderPrevious
objPropertyTypeToSwap.SortOrder = sortOrder
objPropertyTypeController.Update(objPropertyType)
objPropertyTypeController.Update(objPropertyTypeToSwap)
End If
If (e.CommandName = "Down") Then
Dim objPropertyTypeToSwap As PropertyTypeInfo = CType(_propertyTypes(i + 1), PropertyTypeInfo)
Dim sortOrder As Integer = objPropertyType.SortOrder
Dim sortOrderNext As Integer = objPropertyTypeToSwap.SortOrder
objPropertyType.SortOrder = sortOrderNext
objPropertyTypeToSwap.SortOrder = sortOrder
objPropertyTypeController.Update(objPropertyType)
objPropertyTypeController.Update(objPropertyTypeToSwap)
End If
If (e.CommandName = "PublishedChecked") Then
objPropertyType.IsPublished = False
objPropertyTypeController.Update(objPropertyType)
End If
If (e.CommandName = "PublishedCancel") Then
objPropertyType.IsPublished = True
objPropertyTypeController.Update(objPropertyType)
End If
End If
Next
Response.Redirect(Request.RawUrl, True)
End Sub
#End Region
End Class
End Namespace