-
Notifications
You must be signed in to change notification settings - Fork 4
/
EditReceipt.ascx.vb
executable file
·312 lines (230 loc) · 12.3 KB
/
EditReceipt.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
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.Entities.Users
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 EditReceipt
Inherits ModuleBase
#Region " Private Members "
Private _receiptID As Integer = Null.NullInteger
#End Region
#Region " Private Methods "
Private Sub ReadQueryString()
If Not (Request("ReceiptID") Is Nothing) Then
_receiptID = Convert.ToInt32(Request("ReceiptID"))
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 objCrumbEditReceipts As New CrumbInfo
objCrumbEditReceipts.Caption = Localization.GetString("EditReceipts", LocalResourceFile)
objCrumbEditReceipts.Url = EditUrl("EditReceipts")
crumbs.Add(objCrumbEditReceipts)
Dim objCrumbEditReceipt As New CrumbInfo
If (_receiptID = Null.NullInteger) Then
objCrumbEditReceipt.Caption = Localization.GetString("AddReceipt", LocalResourceFile)
Else
objCrumbEditReceipt.Caption = Localization.GetString("EditReceipt", LocalResourceFile)
End If
objCrumbEditReceipt.Url = EditUrl("ReceiptID", _receiptID.ToString(), "EditReceipt")
crumbs.Add(objCrumbEditReceipt)
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End Sub
Private Sub BindPlans()
Dim objPlanController As New PlanController
Dim objPlans As ArrayList = objPlanController.List(Me.PortalId, Me.ModuleId)
For Each objPlan As PlanInfo In objPlans
If (objPlan.IsActive) Then
Dim symbol As String = "$"
Select Case Me.Currency
Case "USD"
symbol = "$"
Case "GBP"
symbol = "£"
Case "EUR"
symbol = "€"
Case "CAD"
symbol = "$"
Case "JPY"
symbol = "¥"
End Select
Dim _details As String = ""
If (objPlan.BillingFrequencyType = FrequencyType.OneTimeFee) Then
_details = Localization.GetString("PermanentAccess", LocalResourceFile)
If (_details.Length > 0) Then
_details = _details.Replace("[FEE]", symbol & objPlan.ServiceFee.ToString("##0.00"))
End If
Else
If (objPlan.BillingFrequencyType = FrequencyType.FixedEndDate) Then
_details = Localization.GetString("FixedEndDate", LocalResourceFile)
If (_details.Length > 0) Then
_details = _details.Replace("[FEE]", symbol & objPlan.ServiceFee.ToString("##0.00"))
_details = _details.Replace("[PERIOD]", objPlan.EndDate.ToString("MMM, dd yyyy"))
End If
Else
If (objPlan.BillingPeriod = 1) Then
_details = Localization.GetString("FrequencyAccessSingular", LocalResourceFile)
Else
_details = Localization.GetString("FrequencyAccessPlural", LocalResourceFile)
End If
If (_details.Length > 0) Then
_details = _details.Replace("[FEE]", symbol & objPlan.ServiceFee.ToString("##0.00"))
_details = _details.Replace("[PERIOD]", objPlan.BillingPeriod.ToString())
_details = _details.Replace("[FREQUENCY]", Localization.GetString(objPlan.BillingFrequencyType.ToString(), Me.LocalResourceFile))
End If
End If
End If
drpSelectPlan.Items.Add(New ListItem(objPlan.Name & " - " & _details, objPlan.PlanID.ToString()))
End If
Next
End Sub
Private Sub BindReceipt()
If (_receiptID = Null.NullInteger) Then
txtProcessor.Text = Localization.GetString("Manual", Me.LocalResourceFile)
pnlAddReceipt.Visible = True
pnlDetail.Visible = False
cmdDelete.Visible = False
Else
pnlAddReceipt.Visible = False
pnlDetail.Visible = True
cmdUpdate.Visible = False
cmdDelete.Visible = True
cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" & Localization.GetString("Confirmation", LocalResourceFile) & "');")
Dim objReceiptController As New ReceiptController
Dim objReceipt As ReceiptInfo = objReceiptController.Get(_receiptID)
If Not (objReceipt Is Nothing) Then
lblUserName.Text = objReceipt.UserName
lblPlan.Text = objReceipt.Name
lblCreateDate.Text = objReceipt.DateCreated.ToShortDateString()
lblStartDate.Text = objReceipt.DateStart.ToShortDateString()
If (objReceipt.DateEnd <> Null.NullDate) Then
lblEndDate.Text = objReceipt.DateEnd.ToShortDateString()
End If
lblProcessor.Text = objReceipt.Processor
If (objReceipt.Processor = "PayPal") Then
lnkTransactionID.Text = objReceipt.ProcessorTxID
lnkTransactionID.Target = "_blank"
If (Me.UseLiveProcessor) Then
lnkTransactionID.NavigateUrl = "https://www.paypal.com/vst/id=" & objReceipt.ProcessorTxID
Else
lnkTransactionID.NavigateUrl = "https://www.sandbox.paypal.com/vst/id=" & objReceipt.ProcessorTxID
End If
lnkTransactionID.Visible = True
Else
lblTransactionID.Text = objReceipt.ProcessorTxID
lblTransactionID.Visible = True
End If
lblServiceFee.Text = objReceipt.ServiceFee.ToString("##0.00")
Else
Response.Redirect(NavigateURL("EditReceipt"), True)
End If
End If
End Sub
#End Region
#Region " Event Handlers "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
ReadQueryString()
BindCrumbs()
cmdStartDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtStartDate)
If (IsPostBack = False) Then
BindPlans()
BindReceipt()
End If
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
If (Page.IsValid) Then
Dim objReceipt As New ReceiptInfo
objReceipt.ModuleID = Me.ModuleId
objReceipt.PortalID = Me.PortalId
objReceipt.Status = "Complete"
objReceipt.Processor = txtProcessor.Text
objReceipt.ProcessorTxID = txtTransactionID.Text
Dim objPlanController As New PlanController
Dim objPlan As PlanInfo = objPlanController.Get(Convert.ToInt32(drpSelectPlan.SelectedValue))
objReceipt.BillingFrequency = objPlan.BillingFrequency
objReceipt.BillingPeriod = objPlan.BillingPeriod
objReceipt.ServiceFee = objPlan.ServiceFee
objReceipt.Name = objPlan.Name
objReceipt.DateCreated = DateTime.Now
If (txtStartDate.Text <> "") Then
objReceipt.DateStart = Convert.ToDateTime(txtStartDate.Text)
Else
objReceipt.DateStart = DateTime.Now
End If
Dim objUser As UserInfo = UserController.GetUserByName(Me.PortalId, txtUserName.Text)
objReceipt.UserID = objUser.UserID
Dim objRoleController As New RoleController
Dim objUserRole As UserRoleInfo = objRoleController.GetUserRole(objReceipt.PortalID, objReceipt.UserID, objPlan.RoleID)
If Not (objUserRole Is Nothing) Then
If (objUserRole.ExpiryDate <> Null.NullDate) Then
If (objUserRole.ExpiryDate > DateTime.Now) Then
objReceipt.DateStart = objUserRole.ExpiryDate
End If
End If
End If
Select Case objPlan.BillingFrequencyType
Case FrequencyType.OneTimeFee
objReceipt.DateEnd = Null.NullDate
Exit Select
Case FrequencyType.Day
objReceipt.DateEnd = objReceipt.DateStart.AddDays(objPlan.BillingPeriod)
Exit Select
Case FrequencyType.Week
objReceipt.DateEnd = objReceipt.DateStart.AddDays(objPlan.BillingPeriod * 7)
Exit Select
Case FrequencyType.Month
objReceipt.DateEnd = objReceipt.DateStart.AddMonths(objPlan.BillingPeriod)
Exit Select
Case FrequencyType.Year
objReceipt.DateEnd = objReceipt.DateStart.AddYears(objPlan.BillingPeriod)
Exit Select
Case FrequencyType.FixedEndDate
objReceipt.DateEnd = objPlan.EndDate
Exit Select
End Select
Dim objReceiptController As New ReceiptController
objReceiptController.Add(objReceipt)
If (chkAddToRole.Checked) Then
objRoleController.AddUserRole(objReceipt.PortalID, objReceipt.UserID, objPlan.RoleID, objReceipt.DateEnd)
End If
Response.Redirect(EditUrl("EditReceipts"), 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("EditReceipts"), True)
End Sub
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
Dim objReceiptController As New ReceiptController
objReceiptController.Delete(_receiptID)
Response.Redirect(EditUrl("EditReceipts"), True)
End Sub
Private Sub valUserNameExists_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles valUserNameExists.ServerValidate
Dim objUser As UserInfo = UserController.GetUserByName(PortalId, txtUserName.Text)
If (objUser Is Nothing) Then
args.IsValid = False
Else
args.IsValid = True
End If
End Sub
#End Region
End Class
End Namespace