-
Notifications
You must be signed in to change notification settings - Fork 11
/
EditPropertyType.ascx.vb
executable file
·333 lines (228 loc) · 13.7 KB
/
EditPropertyType.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
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Namespace Ventrian.PropertyAgent
Partial Public Class EditPropertyType
Inherits PropertyAgentBase
#Region " Private Members "
Private _propertyTypeID As Integer = Null.NullInteger
Private _parentID As Integer = Null.NullInteger
#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("ParentID") Is Nothing) Then
_parentID = Convert.ToInt32(Request("ParentID"))
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)
Dim objPropertyTypeEdit As New CrumbInfo
If (_propertyTypeID <> Null.NullInteger) Then
objPropertyTypeEdit.Caption = Localization.GetString("EditPropertyType", LocalResourceFile)
Else
objPropertyTypeEdit.Caption = Localization.GetString("AddPropertyType", LocalResourceFile)
End If
objPropertyTypeEdit.Url = Request.RawUrl
crumbs.Add(objPropertyTypeEdit)
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 BindParentTypes()
Dim objPropertyTypeController As New PropertyTypeController
drpParentType.DataSource = objPropertyTypeController.ListAll(Me.ModuleId, True, Me.PropertySettings.TypesSortBy, Null.NullString())
drpParentType.DataBind()
drpParentType.Items.Insert(0, New ListItem(GetResourceString("NoneSpecified"), "-1"))
If Not (drpParentType.Items.FindByValue(_parentID.ToString()) Is Nothing) Then
drpParentType.SelectedValue = _parentID.ToString()
End If
End Sub
Private Sub BindPropertyType()
If (_propertyTypeID = Null.NullInteger) Then
cmdDelete.Visible = False
Else
Dim objPropertyTypeController As New PropertyTypeController
Dim objPropertyTypeInfo As PropertyTypeInfo = objPropertyTypeController.Get(Me.ModuleId, _propertyTypeID)
If Not (objPropertyTypeInfo Is Nothing) Then
If Not (drpParentType.Items.FindByValue(objPropertyTypeInfo.ParentID.ToString()) Is Nothing) Then
drpParentType.SelectedValue = objPropertyTypeInfo.ParentID.ToString()
End If
txtName.Text = objPropertyTypeInfo.Name
txtDescription.Text = objPropertyTypeInfo.Description
ctlImage.Url = objPropertyTypeInfo.ImageFile
chkIsPublished.Checked = objPropertyTypeInfo.IsPublished
chkAllowProperties.Checked = objPropertyTypeInfo.AllowProperties
End If
End If
End Sub
#End Region
#Region " Event Handlers "
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
Try
ReadQueryString()
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
ctlImage.FileFilter = glbImageFileTypes
If (Page.IsPostBack = False) Then
Page.SetFocus(txtName)
cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" & Localization.GetString("Confirmation", LocalResourceFile) & "');")
BindParentTypes()
BindPropertyType()
End If
cmdUpdate.CssClass = PropertySettings.ButtonClass
cmdCancel.CssClass = PropertySettings.ButtonClass
cmdDelete.CssClass = PropertySettings.ButtonClass
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
Try
If (Page.IsValid) Then
Dim objPropertyTypeController As New PropertyTypeController
Dim objPropertyTypeInfo As New PropertyTypeInfo
objPropertyTypeInfo.ParentID = Convert.ToInt32(drpParentType.SelectedValue)
objPropertyTypeInfo.Name = txtName.Text
objPropertyTypeInfo.Description = txtDescription.Text
objPropertyTypeInfo.ImageFile = ctlImage.Url
objPropertyTypeInfo.IsPublished = chkIsPublished.Checked
objPropertyTypeInfo.AllowProperties = chkAllowProperties.Checked
objPropertyTypeInfo.ModuleID = Me.ModuleId
If (_propertyTypeID = Null.NullInteger) Then
Dim objPropertyTypes As List(Of PropertyTypeInfo) = objPropertyTypeController.List(Me.ModuleId, False)
If (objPropertyTypes.Count = 0) Then
objPropertyTypeInfo.SortOrder = 0
Else
objPropertyTypeInfo.SortOrder = CType(objPropertyTypes(objPropertyTypes.Count - 1), PropertyTypeInfo).SortOrder + 1
End If
objPropertyTypeController.Add(objPropertyTypeInfo)
Else
Dim objPropertyTypeInfoOld As PropertyTypeInfo = objPropertyTypeController.Get(Me.ModuleId, _propertyTypeID)
objPropertyTypeInfo.SortOrder = objPropertyTypeInfoOld.SortOrder
objPropertyTypeInfo.PropertyTypeID = _propertyTypeID
objPropertyTypeController.Update(objPropertyTypeInfo)
End If
If (drpParentType.SelectedValue <> "-1") Then
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes", PropertySettings.SEOPropertyTypeID & "=" & drpParentType.SelectedValue), True)
Else
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes"), True)
End If
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
Try
If (_propertyTypeID <> Null.NullInteger) Then
Dim objPropertyTypeController As New PropertyTypeController
Dim objPropertyType As PropertyTypeInfo = objPropertyTypeController.Get(Me.ModuleId, _propertyTypeID)
If Not (objPropertyType Is Nothing) Then
If (objPropertyType.ParentID <> Null.NullInteger) Then
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes", PropertySettings.SEOPropertyTypeID & "=" & objPropertyType.ParentID.ToString()), True)
End If
End If
End If
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes"), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
Try
Dim objPropertyController As New PropertyController
Dim objProperties As List(Of PropertyInfo) = objPropertyController.List(Me.ModuleId, _propertyTypeID, SearchStatusType.Any, Null.NullInteger, Null.NullInteger, False, Null.NullBoolean, SortByType.Published, Null.NullInteger, SortDirectionType.Descending, Null.NullString, Null.NullString, 0, 100000, False)
For Each objProperty As PropertyInfo In objProperties
Dim objPhotoController As New PhotoController
Dim objPhotos As ArrayList = objPhotoController.List(objProperty.PropertyID)
For Each objPhoto As PhotoInfo In objPhotos
System.IO.File.Delete(Me.PortalSettings.HomeDirectoryMapPath & "PropertyAgent/" & Me.ModuleId & "/" & objPhoto.Filename)
Next
objPhotoController.DeleteByPropertyID(objProperty.PropertyID)
objPropertyController.Delete(objProperty.PropertyID)
Next
Dim objPropertyTypeController As New PropertyTypeController
Dim objSubPropertyTypes As List(Of PropertyTypeInfo) = objPropertyTypeController.List(Me.ModuleId, True, PropertyTypeSortByType.Standard, Null.NullString(), _propertyTypeID)
For Each objPropertyType As PropertyTypeInfo In objSubPropertyTypes
objPropertyType.ParentID = Null.NullInteger
objPropertyTypeController.Update(objPropertyType)
Next
If (_propertyTypeID <> Null.NullInteger) Then
Dim objPropertyType As PropertyTypeInfo = objPropertyTypeController.Get(Me.ModuleId, _propertyTypeID)
If Not (objPropertyType Is Nothing) Then
objPropertyTypeController.Delete(Me.ModuleId, _propertyTypeID)
If (objPropertyType.ParentID <> Null.NullInteger) Then
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes", PropertySettings.SEOPropertyTypeID & "=" & objPropertyType.ParentID.ToString()), True)
End If
End If
End If
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditPropertyTypes"), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub valParentType_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles valParentType.ServerValidate
Try
If (_propertyTypeID = Null.NullInteger) Then
args.IsValid = True
Return
End If
' Loop through parent IDs to make should an infinite loop is not created.
If (drpParentType.SelectedValue <> "-1") Then
Dim objPropertyTypeController As New PropertyTypeController
Dim objPropertyType As PropertyTypeInfo = objPropertyTypeController.Get(Me.ModuleId, Convert.ToInt32(drpParentType.SelectedValue))
If (objPropertyType.PropertyTypeID = _propertyTypeID) Then
args.IsValid = False
Return
End If
While Not (objPropertyType Is Nothing)
If (objPropertyType.PropertyTypeID = _propertyTypeID) Then
args.IsValid = False
Return
End If
objPropertyType = objPropertyTypeController.Get(Me.ModuleId, objPropertyType.ParentID)
End While
Else
args.IsValid = True
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace