-
Notifications
You must be signed in to change notification settings - Fork 4
/
EditPlan.ascx.vb
executable file
·323 lines (224 loc) · 12.3 KB
/
EditPlan.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
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.Entities.Tabs
Imports DotNetNuke.Security
Imports DotNetNuke.Security.Roles
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.UI.Utilities
Imports Ventrian.SubscriptionTools.Entities
Namespace Ventrian.SubscriptionTools
Partial Public Class EditPlan
Inherits ModuleBase
#Region " Private Members "
Private _planID As Integer = Null.NullInteger
#End Region
#Region " Private Methods "
Private Sub ReadQueryString()
If Not (Request("PlanID") Is Nothing) Then
_planID = Convert.ToInt32(Request("PlanID"))
End If
End Sub
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)
Dim objCrumbEditPlan As New CrumbInfo
objCrumbEditPlan.Caption = Localization.GetString("EditPlan", LocalResourceFile)
objCrumbEditPlan.Url = EditUrl("PlanID", _planID.ToString(), "EditPlan")
crumbs.Add(objCrumbEditPlan)
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End Sub
Private Sub BindCurrency()
Dim ctlList As New Lists.ListController
Dim colCurrency As Lists.ListEntryInfoCollection = ctlList.GetListEntryInfoCollection("Currency", "")
drpCurrency.DataSource = colCurrency
drpCurrency.DataBind()
drpCurrency.Items.Insert(0, New ListItem(Localization.GetString("DefaultCurrency", Me.LocalResourceFile), ""))
End Sub
Private Sub BindRoles()
Dim objRoleController As New RoleController
drpRole.DataSource = objRoleController.GetPortalRoles(Me.PortalId)
drpRole.DataBind()
drpRole.Items.Insert(0, New ListItem(Localization.GetString("SelectRole.Text", Me.LocalResourceFile), "-1"))
rptRoles.DataSource = objRoleController.GetPortalRoles(Me.PortalId)
rptRoles.DataBind()
End Sub
Private Sub BindFrequency()
For Each value As Integer In System.Enum.GetValues(GetType(FrequencyType))
Dim li As New ListItem
li.Value = value.ToString()
li.Text = System.Enum.GetName(GetType(FrequencyType), value)
drpPlanDuration.Items.Add(li)
Next
drpPlanDuration.Items.Insert(0, New ListItem(Localization.GetString("SelectPlanDuration.Text", Me.LocalResourceFile), "-1"))
txtPlanDuration.Visible = False
End Sub
Private Sub BindPlan()
If (_planID = Null.NullInteger) Then
cmdDelete.Visible = False
Else
cmdDelete.Visible = True
' ClientAPI.AddButtonConfirm(cmdDelete, "Are You Sure You Want To Delete This Plan?")
Dim objPlanController As New PlanController
Dim objPlan As PlanInfo = objPlanController.Get(_planID)
If Not (objPlan Is Nothing) Then
txtName.Text = objPlan.Name
txtDescription.Text = objPlan.Description
txtViewOrder.Text = objPlan.ViewOrder.ToString()
chkIsActive.Checked = objPlan.IsActive
If Not (drpRole.Items.FindByValue(objPlan.RoleID.ToString()) Is Nothing) Then
drpRole.SelectedValue = objPlan.RoleID.ToString()
End If
If Not (drpCurrency.Items.FindByValue(objPlan.Currency) Is Nothing) Then
drpCurrency.SelectedValue = objPlan.Currency
End If
txtServiceFee.Text = objPlan.ServiceFee.ToString("N2")
If Not (drpPlanDuration.Items.FindByValue(objPlan.BillingFrequency.ToString()) Is Nothing) Then
drpPlanDuration.SelectedValue = objPlan.BillingFrequency.ToString()
ShowPlanDuration()
If (txtPlanDuration.Visible) Then
txtPlanDuration.Text = objPlan.BillingPeriod.ToString()
End If
End If
If (objPlan.EndDate <> Null.NullDate) Then
txtEndDate.Text = objPlan.EndDate.ToShortDateString()
End If
chkAutoRenew.Checked = objPlan.AutoRenew
Else
Response.Redirect(NavigateURL("EditPlan"), True)
End If
End If
End Sub
Private Sub ShowPlanDuration()
txtPlanDuration.Visible = Not (drpPlanDuration.SelectedValue = "1" Or drpPlanDuration.SelectedValue = "6" Or drpPlanDuration.SelectedIndex = 0)
valPlanDuration.Enabled = Not (drpPlanDuration.SelectedValue = "1" Or drpPlanDuration.SelectedValue = "6" Or drpPlanDuration.SelectedIndex = 0)
valPlanDuration1.Enabled = Not (drpPlanDuration.SelectedValue = "1" Or drpPlanDuration.SelectedValue = "6" Or drpPlanDuration.SelectedIndex = 0)
trEndDate.Visible = (drpPlanDuration.SelectedValue = "6")
trAutoRenew.Visible = (drpPlanDuration.SelectedValue = "2" Or drpPlanDuration.SelectedValue = "3" Or drpPlanDuration.SelectedValue = "4" Or drpPlanDuration.SelectedValue = "5")
End Sub
#End Region
#Region " Event Handlers "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cmdEndDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtEndDate)
ReadQueryString()
BindCrumbs()
If (IsPostBack = False) Then
BindRoles()
BindFrequency()
BindCurrency()
BindPlan()
End If
End Sub
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
If (Page.IsValid) Then
Dim objPlanController As New PlanController
Dim objPlan As New PlanInfo
objPlan.ModuleID = Me.ModuleId
objPlan.PortalID = Me.PortalId
objPlan.Name = txtName.Text
objPlan.Description = txtDescription.Text
If (txtViewOrder.Text <> "") Then
objPlan.ViewOrder = Convert.ToInt32(txtViewOrder.Text)
Else
objPlan.ViewOrder = 0
End If
objPlan.IsActive = chkIsActive.Checked
objPlan.RoleID = Convert.ToInt32(drpRole.SelectedValue)
objPlan.ServiceFee = Convert.ToDecimal(txtServiceFee.Text)
objPlan.BillingFrequency = Convert.ToInt32(drpPlanDuration.SelectedValue)
If (txtPlanDuration.Text.Length > 0) Then
objPlan.BillingPeriod = Convert.ToInt32(txtPlanDuration.Text)
End If
objPlan.Currency = drpCurrency.SelectedValue
If (trEndDate.Visible) Then
If (txtEndDate.Text <> "") Then
Try
objPlan.EndDate = Convert.ToDateTime(txtEndDate.Text)
Catch
objPlan.EndDate = Null.NullDate
End Try
Else
objPlan.EndDate = Null.NullDate
End If
Else
objPlan.EndDate = Null.NullDate
End If
objPlan.AutoRenew = chkAutoRenew.Checked
If (_planID = Null.NullInteger) Then
objPlan.PlanID = objPlanController.Add(objPlan)
Else
objPlan.PlanID = _planID
objPlanController.Update(objPlan)
End If
Dim advancedPricing As String = ""
For Each item As RepeaterItem In rptRoles.Items
If (item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem) Then
Dim txtServiceFee As TextBox = CType(item.FindControl("txtServiceFee"), TextBox)
Dim lblRoleName As Label = CType(item.FindControl("lblRoleName"), Label)
If (txtServiceFee IsNot Nothing And lblRoleName IsNot Nothing) Then
Dim roleName As String = lblRoleName.Text
If (txtServiceFee.Text <> "" AndAlso IsNumeric(txtServiceFee.Text)) Then
If (advancedPricing = "") Then
advancedPricing = lblRoleName.Text & "-" & txtServiceFee.Text
Else
advancedPricing = advancedPricing & ";" & lblRoleName.Text & "-" & txtServiceFee.Text
End If
End If
End If
End If
Next
If (advancedPricing <> "") Then
Dim objModuleController As New ModuleController()
objModuleController.UpdateModuleSetting(Me.ModuleId, "ST-" & objPlan.PlanID.ToString(), advancedPricing)
End If
Response.Redirect(EditUrl("EditPlans"), True)
End If
End Sub
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
Response.Redirect(EditUrl("EditPlans"), True)
End Sub
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
Dim objPlanController As New PlanController
objPlanController.Delete(_planID)
Response.Redirect(EditUrl("EditPlans"), True)
End Sub
Private Sub drpPlanDuration_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drpPlanDuration.SelectedIndexChanged
ShowPlanDuration()
End Sub
Private Sub rptRoles_ItemDataBound(ByVal sender As System.Object, ByVal e As RepeaterItemEventArgs) Handles rptRoles.ItemDataBound
If (_planID <> Null.NullInteger) Then
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim objRole As RoleInfo = CType(e.Item.DataItem, RoleInfo)
Dim txtServiceFee As TextBox = CType(e.Item.FindControl("txtServiceFee"), TextBox)
If (txtServiceFee IsNot Nothing) Then
If (Settings.Contains("ST-" & _planID.ToString())) Then
Dim pricing As String = Settings("ST-" & _planID.ToString()).ToString()
If (pricing <> "") Then
For Each p As String In pricing.Split(";"c)
If (p.Split("-"c).Length = 2) Then
If (objRole.RoleName.ToLower() = p.Split("-"c)(0).ToLower()) Then
txtServiceFee.Text = p.Split("-"c)(1)
End If
End If
Next
End If
End If
End If
End If
End If
End Sub
#End Region
End Class
End Namespace