-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEditPlans.ascx.vb
executable file
·242 lines (157 loc) · 8.01 KB
/
EditPlans.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
Imports System.Web.UI.WebControls
Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Modules.Actions
Imports DotNetNuke.Security
Imports DotNetNuke.Security.Roles
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports Ventrian.SubscriptionTools.Entities
Namespace Ventrian.SubscriptionTools
Partial Public Class EditPlans
Inherits ModuleBase
#Region " Private Members "
Private _plans As New ArrayList
#End Region
#Region " Private Methods "
Private Sub BindCrumbs()
Dim crumbs As New ArrayList
Dim objCrumbMain As New CrumbInfo
objCrumbMain.Caption = Localization.GetString("Main", LocalResourceFile)
objCrumbMain.Url = NavigateURL()
crumbs.Add(objCrumbMain)
Dim objCrumbEditPlans As New CrumbInfo
objCrumbEditPlans.Caption = Localization.GetString("EditPlans", LocalResourceFile)
objCrumbEditPlans.Url = EditUrl("EditPlans")
crumbs.Add(objCrumbEditPlans)
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End Sub
Private Sub BindPlans()
Dim objPlanController As New PlanController
DotNetNuke.Services.Localization.Localization.LocalizeDataGrid(grdPlans, Me.LocalResourceFile)
_plans = objPlanController.List(Me.PortalId, Me.ModuleId)
If (_plans.Count > 1) Then
If (CType(_plans(0), PlanInfo).ViewOrder = 0 And CType(_plans(1), PlanInfo).ViewOrder = 0) Then
' Sort Order must be messed up, fix now..
For i As Integer = 0 To _plans.Count - 1
Dim objPlan As PlanInfo = CType(_plans(i), PlanInfo)
objPlan.ViewOrder = i
objPlanController.Update(objPlan)
Next
End If
End If
grdPlans.DataSource = _plans
grdPlans.DataBind()
If (grdPlans.Items.Count > 0) Then
grdPlans.Visible = True
lblNoPlans.Visible = False
Else
grdPlans.Visible = False
lblNoPlans.Visible = True
lblNoPlans.Text = DotNetNuke.Services.Localization.Localization.GetString("NoPlansMessage.Text", LocalResourceFile)
End If
End Sub
#End Region
#Region " Protected Methods "
Protected Function GetEditUrl(ByVal planID As String) As String
Return EditUrl("PlanID", planID, "EditPlan")
End Function
#End Region
#Region " Event Handlers "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
BindCrumbs()
If (Page.IsPostBack = False) Then
BindPlans()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdAddPlan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddPlan.Click
Try
Response.Redirect(EditUrl("EditPlan"), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdReturnToSignup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReturnToSignup.Click
Try
Response.Redirect(NavigateURL(), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub grdPlans_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdPlans.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 objPlan As PlanInfo = CType(e.Item.DataItem, PlanInfo)
If Not (btnUp Is Nothing And btnDown Is Nothing) Then
If (objPlan.PlanID = CType(_plans(0), PlanInfo).PlanID) Then
btnUp.Visible = False
End If
If (objPlan.PlanID = CType(_plans(_plans.Count - 1), PlanInfo).PlanID) Then
btnDown.Visible = False
End If
btnUp.CommandArgument = objPlan.PlanID.ToString()
btnUp.CommandName = "Up"
btnDown.CommandArgument = objPlan.PlanID.ToString()
btnDown.CommandName = "Down"
End If
Dim btnPublished As ImageButton = CType(e.Item.FindControl("btnPublished"), ImageButton)
If Not (btnPublished Is Nothing) Then
If (objPlan.IsActive) Then
btnPublished.ImageUrl = "~/images/checked.gif"
btnPublished.CommandName = "PublishedChecked"
Else
btnPublished.ImageUrl = "~/images/cancel.gif"
btnPublished.CommandName = "PublishedCancel"
End If
btnPublished.CommandArgument = objPlan.PlanID.ToString()
End If
End If
End Sub
Private Sub grdPlans_ItemCommand(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdPlans.ItemCommand
Dim objPlanController As New PlanController
_plans = objPlanController.List(Me.PortalId, Me.ModuleId)
Dim planID As Integer = Convert.ToInt32(e.CommandArgument)
For i As Integer = 0 To _plans.Count - 1
Dim objPlan As PlanInfo = CType(_plans(i), PlanInfo)
If (planID = objPlan.PlanID) Then
If (e.CommandName = "Up") Then
Dim objPlanToSwap As PlanInfo = CType(_plans(i - 1), PlanInfo)
Dim sortOrder As Integer = objPlan.ViewOrder
Dim sortOrderPrevious As Integer = objPlanToSwap.ViewOrder
objPlan.ViewOrder = sortOrderPrevious
objPlanToSwap.ViewOrder = sortOrder
objPlanController.Update(objPlan)
objPlanController.Update(objPlanToSwap)
End If
If (e.CommandName = "Down") Then
Dim objPlanToSwap As PlanInfo = CType(_plans(i + 1), PlanInfo)
Dim sortOrder As Integer = objPlan.ViewOrder
Dim sortOrderNext As Integer = objPlanToSwap.ViewOrder
objPlan.ViewOrder = sortOrderNext
objPlanToSwap.ViewOrder = sortOrder
objPlanController.Update(objPlan)
objPlanController.Update(objPlanToSwap)
End If
If (e.CommandName = "PublishedChecked") Then
objPlan.IsActive = False
objPlanController.Update(objPlan)
End If
If (e.CommandName = "PublishedCancel") Then
objPlan.IsActive = True
objPlanController.Update(objPlan)
End If
End If
Next
Response.Redirect(Request.RawUrl, True)
End Sub
#End Region
End Class
End Namespace