-
Notifications
You must be signed in to change notification settings - Fork 12
/
EditContactField.ascx.vb
executable file
·340 lines (237 loc) · 12.9 KB
/
EditContactField.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
'
' Property Agent for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2005-2007
' by Ventrian Systems ( [email protected] ) ( http://www.ventrian.com )
'
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Security.Roles
Namespace Ventrian.PropertyAgent
Partial Public Class EditContactField
Inherits PropertyAgentBase
#Region " Private Members "
Private _contactFieldID As Integer = Null.NullInteger
#End Region
#Region " Private Methods "
Private Sub AdjustFieldElements()
Dim objFieldType As ContactFieldType = CType(System.Enum.Parse(GetType(ContactFieldType), drpFieldType.SelectedValue.ToString()), ContactFieldType)
Select Case objFieldType
Case ContactFieldType.DropDownList
phRequired.Visible = True
trFieldElements.Visible = True
trMaximumLength.Visible = False
trCustomField.Visible = False
Case ContactFieldType.MultiCheckBox
phRequired.Visible = True
trFieldElements.Visible = True
trMaximumLength.Visible = False
trCustomField.Visible = False
Case ContactFieldType.MultiLineTextBox
phRequired.Visible = True
trFieldElements.Visible = False
trMaximumLength.Visible = True
trCustomField.Visible = False
Case ContactFieldType.OneLineTextBox
phRequired.Visible = True
trFieldElements.Visible = False
trMaximumLength.Visible = True
trCustomField.Visible = False
Case ContactFieldType.CustomField
phRequired.Visible = True
trFieldElements.Visible = False
trMaximumLength.Visible = False
trCustomField.Visible = True
End Select
End Sub
Private Sub ReadQueryString()
If Not (Request("ContactFieldID") Is Nothing) Then
_ContactFieldID = Convert.ToInt32(Request("ContactFieldID"))
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 objCustomFieldManager As New CrumbInfo
objCustomFieldManager.Caption = Localization.GetString("ContactFieldManager", LocalResourceFile)
objCustomFieldManager.Url = NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditContactFields")
crumbs.Add(objCustomFieldManager)
Dim objContactFieldEdit As New CrumbInfo
If (_ContactFieldID <> Null.NullInteger) Then
objContactFieldEdit.Caption = Localization.GetString("EditContactField", LocalResourceFile)
Else
objContactFieldEdit.Caption = Localization.GetString("AddContactField", LocalResourceFile)
End If
objContactFieldEdit.Url = Request.RawUrl
crumbs.Add(objContactFieldEdit)
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 BindFieldTypes()
For Each value As Integer In System.Enum.GetValues(GetType(ContactFieldType))
Dim li As New ListItem
li.Value = value.ToString()
li.Text = Localization.GetString(System.Enum.GetName(GetType(ContactFieldType), value), Me.LocalResourceFile)
If (value = ContactFieldType.CustomField) Then
If (drpCustomField.Items.Count > 0) Then
drpFieldType.Items.Add(li)
End If
Else
drpFieldType.Items.Add(li)
End If
Next
End Sub
Private Sub BindCustomFields()
For Each objCustomField As CustomFieldInfo In CustomFields
If (objCustomField.FieldType = CustomFieldType.DropDownList Or objCustomField.FieldType = CustomFieldType.ListBox) Then
Dim li As New ListItem
li.Value = objCustomField.CustomFieldID.ToString()
li.Text = objCustomField.Name
drpCustomField.Items.Add(li)
End If
Next
End Sub
Private Sub BindContactField()
If (_ContactFieldID = Null.NullInteger) Then
cmdDelete.Visible = False
Else
Dim objContactFieldController As New ContactFieldController
Dim objContactFieldInfo As ContactFieldInfo = objContactFieldController.Get(_ContactFieldID)
If Not (objContactFieldInfo Is Nothing) Then
txtName.Text = objContactFieldInfo.Name
txtCaption.Text = objContactFieldInfo.Caption
txtCaptionHelp.Text = objContactFieldInfo.CaptionHelp
If Not (drpFieldType.Items.FindByValue(Convert.ToInt32(objContactFieldInfo.FieldType).ToString()) Is Nothing) Then
drpFieldType.SelectedValue = Convert.ToInt32(objContactFieldInfo.FieldType).ToString()
End If
If (drpCustomField.Items.FindByValue(objContactFieldInfo.CustomFieldID.ToString()) IsNot Nothing) Then
drpCustomField.SelectedValue = objContactFieldInfo.CustomFieldID.ToString()
End If
AdjustFieldElements()
txtFieldElements.Text = objContactFieldInfo.FieldElements
txtDefaultValue.Text = objContactFieldInfo.DefaultValue
If (objContactFieldInfo.Length <> Null.NullInteger) Then
txtMaximumLength.Text = objContactFieldInfo.Length
End If
chkRequired.Checked = objContactFieldInfo.IsRequired
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
If (Page.IsPostBack = False) Then
BindCustomFields()
BindFieldTypes()
BindContactField()
Page.SetFocus(txtName)
cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" & Localization.GetString("Confirmation", LocalResourceFile) & "');")
AdjustFieldElements()
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 objContactFieldController As New ContactFieldController
Dim objContactFieldInfo As New ContactFieldInfo
objContactFieldInfo.ModuleID = Me.ModuleId
objContactFieldInfo.Name = txtName.Text
objContactFieldInfo.Caption = txtCaption.Text
objContactFieldInfo.CaptionHelp = txtCaptionHelp.Text
objContactFieldInfo.FieldType = CType(System.Enum.Parse(GetType(ContactFieldType), drpFieldType.SelectedValue.ToString()), ContactFieldType)
objContactFieldInfo.FieldElements = txtFieldElements.Text
objContactFieldInfo.CustomFieldID = Null.NullInteger
If (drpCustomField.Visible) Then
If (drpCustomField.Items.Count > 0) Then
objContactFieldInfo.CustomFieldID = Convert.ToInt32(drpCustomField.SelectedValue)
End If
End If
objContactFieldInfo.DefaultValue = txtDefaultValue.Text
If (txtMaximumLength.Text.Trim() = "") Then
objContactFieldInfo.Length = Null.NullInteger
Else
objContactFieldInfo.Length = Convert.ToInt32(txtMaximumLength.Text)
If (objContactFieldInfo.Length <= 0) Then
objContactFieldInfo.Length = Null.NullInteger
End If
End If
objContactFieldInfo.IsRequired = chkRequired.Checked
If (_contactFieldID = Null.NullInteger) Then
Dim objContactFields As List(Of ContactFieldInfo) = objContactFieldController.List(Me.ModuleId)
If (objContactFields.Count = 0) Then
objContactFieldInfo.SortOrder = 0
Else
objContactFieldInfo.SortOrder = CType(objContactFields(objContactFields.Count - 1), ContactFieldInfo).SortOrder + 1
End If
objContactFieldInfo.ContactFieldID = objContactFieldController.Add(objContactFieldInfo)
Else
Dim objContactFieldInfoOld As ContactFieldInfo = objContactFieldController.Get(_contactFieldID)
objContactFieldInfo.SortOrder = objContactFieldInfoOld.SortOrder
objContactFieldInfo.ContactFieldID = _contactFieldID
objContactFieldController.Update(objContactFieldInfo)
End If
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditContactFields"), True)
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
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditContactFields"), 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 objContactFieldController As New ContactFieldController
objContactFieldController.Delete(_contactFieldID)
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditContactFields"), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub drpFieldType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drpFieldType.SelectedIndexChanged
Try
AdjustFieldElements()
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace