-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditCustomFields.ascx.vb
executable file
·155 lines (90 loc) · 5.22 KB
/
EditCustomFields.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
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Localization
Imports Ventrian.FeedbackCenter.Entities.CustomFields
Namespace Ventrian.FeedbackCenter
Partial Public Class EditCustomFields
Inherits FeedbackCenterBase
#Region " Private Members "
Dim _customFields As ArrayList
#End Region
#Region " Private Methods "
Private Sub BindCustomFields()
Localization.LocalizeDataGrid(grdCustomFields, Me.LocalResourceFile)
Dim objCustomFieldController As New CustomFieldController()
_customFields = objCustomFieldController.List(Me.ModuleId)
grdCustomFields.DataSource = _customFields
grdCustomFields.DataBind()
If (grdCustomFields.Items.Count = 0) Then
grdCustomFields.Visible = False
lblNoCustomFields.Visible = True
Else
grdCustomFields.Visible = True
lblNoCustomFields.Visible = False
End If
End Sub
#End Region
#Region " Protected Methods "
Protected Function GetCustomFieldEditUrl(ByVal customFieldID As String) As String
Return EditUrl("CustomFieldID", customFieldID.ToString(), "EditCustomField")
End Function
#End Region
#Region " Event Handlers "
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Page.IsPostBack = False) Then
BindCustomFields()
End If
End Sub
Protected Sub cmdAddCustomField_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdAddCustomField.Click
Response.Redirect(EditUrl("EditCustomField"), True)
End Sub
Private Sub grdCustomFields_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdCustomFields.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 objCustomField As CustomFieldInfo = CType(e.Item.DataItem, CustomFieldInfo)
If Not (btnUp Is Nothing And btnDown Is Nothing) Then
If (objCustomField.CustomFieldID = CType(_customFields(0), CustomFieldInfo).CustomFieldID) Then
btnUp.Visible = False
End If
If (objCustomField.CustomFieldID = CType(_customFields(_customFields.Count - 1), CustomFieldInfo).CustomFieldID) Then
btnDown.Visible = False
End If
btnUp.CommandArgument = objCustomField.CustomFieldID.ToString()
btnUp.CommandName = "Up"
btnDown.CommandArgument = objCustomField.CustomFieldID.ToString()
btnDown.CommandName = "Down"
End If
End If
End Sub
Private Sub grdCustomFields_ItemCommand(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdCustomFields.ItemCommand
Dim objCustomFieldController As New CustomFieldController
_customFields = objCustomFieldController.List(Me.ModuleId)
Dim customFieldID As Integer = Convert.ToInt32(e.CommandArgument)
For i As Integer = 0 To _customFields.Count - 1
Dim objCustomField As CustomFieldInfo = CType(_customFields(i), CustomFieldInfo)
If (customFieldID = objCustomField.CustomFieldID) Then
If (e.CommandName = "Up") Then
Dim objCustomFieldToSwap As CustomFieldInfo = CType(_customFields(i - 1), CustomFieldInfo)
Dim sortOrder As Integer = objCustomField.SortOrder
Dim sortOrderPrevious As Integer = objCustomFieldToSwap.SortOrder
objCustomField.SortOrder = sortOrderPrevious
objCustomFieldToSwap.SortOrder = sortOrder
objCustomFieldController.Update(objCustomField)
objCustomFieldController.Update(objCustomFieldToSwap)
End If
If (e.CommandName = "Down") Then
Dim objCustomFieldToSwap As CustomFieldInfo = CType(_customFields(i + 1), CustomFieldInfo)
Dim sortOrder As Integer = objCustomField.SortOrder
Dim sortOrderNext As Integer = objCustomFieldToSwap.SortOrder
objCustomField.SortOrder = sortOrderNext
objCustomFieldToSwap.SortOrder = sortOrder
objCustomFieldController.Update(objCustomField)
objCustomFieldController.Update(objCustomFieldToSwap)
End If
End If
Next
Response.Redirect(Request.RawUrl, True)
End Sub
#End Region
End Class
End Namespace