-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTransferCredits
447 lines (336 loc) · 14.4 KB
/
TransferCredits
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' TransferCredits (Module)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'User action
Public Const applyTR As String = "Apply Transder Credits"
Public Const populateTR As String = "Populate the student's courses"
'RGB for completed actions
Const completedRed As Integer = 135
Const completedGreen As Integer = 206
Const completedBlue As Integer = 280
'AS400 specific values
Const rowHome As Long = 19
Const colHome As Long = 7
Const startRow As Long = 17
Const endRow As Long = 22
Const selectCourse As Long = 1
Const optionCustomerService As String = "1"
Const optionEducationInquiry As String = "15"
Const locationTR As String = "60211"
Const actionCodeC As String = "I"
Const applyCodeY As String = "Y"
Const schoolCode As String = "H"
Public Sub PopulateCoursesFromAccount(ByRef CreditsForm As MSForms.UserForm, _
ByVal AS400 As cAS400, ByRef Exception As cException)
'Pass error handling up the call stack
On Error GoTo 0
Exception.Push "TransferCredits.PopulateCoursesFromAccount"
Dim i As Integer
Dim j As Long
Dim SID As String
Const maxSize As Integer = 30
Dim textboxArray() As Object
ReDim textboxArray(1 To maxSize, 1 To 2)
SID = Trim(CreditsForm.SID_Textbox)
Exception.ErrMessage = "Student ID: " & SID
Exception.ErrMessage = "Navigating ..."
Select Case AS400.GetText(1, 2, 8)
Case "60210 ": AS400.SendKeys F3Key
Case "603132_B": AS400.Pause
Case Else
NavigateHome AS400, Exception
If ConfirmHomeScreen(AS400, Exception) = False Then GoTo NavigationFailure
AS400.SetText optionCustomerService, rowHome, colHome
AS400.SendKeys EnterKey
AS400.SetText optionEducationInquiry, rowHome, colHome
AS400.SendKeys EnterKey
End Select
AS400.SetText SID, 3, 13
AS400.SendKeys EnterKey
AS400.SendKeys F11Key
Exception.ErrMessage = "Confirming location"
If AS400.SearchText("60210", 1, 1, forward) = False Then GoTo NavigationFailure
If Len(Trim(AS400.GetText(5, 23, modLength))) < 2 Then GoTo DoesNotExist
LoadTextboxesFromCredits textboxArray(), CreditsForm, Exception
With AS400
Exception.ErrMessage = "Passing information from the AS/400 to the userform"
i = 1
Do While i <= maxSize
For j = startRow To endRow
Exception.ErrMessage = "... ... Course #" & CStr(i) & " Line #" & CStr(j)
textboxArray(i, 1) = Trim(.GetText(j, 4, modLength))
textboxArray(i, 2) = Trim(.GetText(j, 13, 30))
i = i + 1
Next j
If Len(Trim(AS400.GetText(endRow, 4, 2))) = 0 Then
Exception.ErrMessage = "... ... At the final page, exiting loop"
Exit Do
Else
Exception.ErrMessage = "... ... Moving to the next page"
.SendKeys "[pagedn]"
End If
Loop
End With
CreditsForm.AlphaName_Textbox = CheckString(AS400.GetText(4, 32, 38), 1)
'''''''''''''''''''''''''''
' Cleanup
'''''''''''''''''''''''''''
Cleanup:
TurnOnExcelDefaults Exception
Exception.Pop
Exit Sub
'''''''''''''''''''''''''''
' Error Handling
'''''''''''''''''''''''''''
NavigationFailure:
With Exception
.IsError = False
.Flag = True
.Throw "An issue has occurred: The AS/400 has not found the correct screen location. " & _
"The procedure has been cancelled." & vbNewLine & vbNewLine & _
"Please ensure the AS/400 is on the correct session, " & _
"and on a friendly screen location, before proceeding."
End With
GoTo Cleanup
'''''''''''''''''''''''''''
DoesNotExist:
With Exception
.IsError = False
.Flag = True
.Throw "The course list on the given student account is empty."
End With
GoTo Cleanup
'''''''''''''''''''''''''''
End Sub
'''''''''''''''''''''''''''
Public Sub ApplyTransferCredits(ByRef CreditsForm As MSForms.UserForm, _
ByVal AS400 As cAS400, ByRef Exception As cException)
'Pass error handling up the call stack
On Error GoTo 0
Exception.Push "TransferCredits.ApplyTransferCredits"
Dim i As Integer
Dim j As Long
Dim TRcounter As Integer
Dim SID As String
Dim finalMessage As String
Const maxSize As Integer = 30
Dim bools() As Boolean
ReDim bools(1 To maxSize)
Dim textboxArray() As Object
ReDim textboxArray(1 To maxSize, 1 To 2)
SID = Trim(CreditsForm.SID_Textbox)
finalMessage = "Transfer credits for SID: " & SID & " have been successfully applied."
Exception.ErrMessage = "Student ID: " & SID
Exception.ErrMessage = "Navigating"
Select Case AS400.GetText(1, 2, 8)
Case "60210 "
With AS400
.SendKeys F3Key
.SendKeys F11Key
End With
Case "603132_B"
AS400.SendKeys F11Key
Case Else
NavigateHome AS400, Exception
If ConfirmHomeScreen(AS400, Exception) = False Then GoTo NavigationFailure
With AS400
.SetText optionCustomerService, rowHome, colHome
.SendKeys EnterKey
.SetText optionEducationInquiry, rowHome, colHome
.SendKeys EnterKey
.SetText SID, 3, 13
.SendKeys EnterKey
.SendKeys F11Key
End With
If AS400.SearchText("60210", 1, 1, forward) = False Then GoTo NavigationFailure
End Select
If AS400.SearchText(SID, 1, 1, forward) = False Then GoTo SIDNotAMatch
LoadTextboxesFromCredits textboxArray(), CreditsForm, Exception
LoadBools bools(), CreditsForm, Exception
With AS400
Exception.ErrMessage = "Selecting courses for transfer"
i = 1
Do While i <= maxSize
For j = startRow To endRow
Exception.ErrMessage = "... ... Course #" & CStr(i) & " Line #" & CStr(j)
If bools(i) = True And Len(Trim(textboxArray(i, 1).Value)) > 1 Then
.SetText selectCourse, j, 2
textboxArray(i, 1).BackColor = RGB(completedRed, completedGreen, completedBlue)
textboxArray(i, 2).BackColor = RGB(completedRed, completedGreen, completedBlue)
TRcounter = TRcounter + 1
Exception.ErrMessage = "... ... A course has been added to the list (" & CStr(TRcounter) & ")"
End If
i = i + 1
Next j
If Len(Trim(AS400.GetText(endRow, 4, 2))) = 0 Then
Exit Do
Else
.SendKeys "[pagedn]"
End If
Loop
End With
If TRcounter <> 0 Then
If AS400.SearchText(locationTR, 1, 1, forward) Then GoTo NavigationFailure
With AS400
Exception.ErrMessage = "Applying transfer credits to the selected courses"
Do Until TRcounter <= 0
Exception.ErrMessage = "... ... Courses remaining: " & CStr(TRcounter)
.SetText actionCodeC, 3, 19
.SetText applyCodeY, 8, 19
.SetText schoolCode, 10, 19
.SendKeys EnterKey
.SendKeys F3Key
TRcounter = TRcounter - 1
Loop
Exception.ErrMessage = "Setting the student account to acknowledge the applied TR"
.SetText actionCodeC, 3, 23
.SetText applyCodeY, 14, 60
.SendKeys EnterKey
.SendKeys F3Key
MsgBox finalMessage, vbInformation, "Transfer Credits"
End With
Else
Exception.ErrMessage = "No courses have been selected for transfer"
AS400.SendKeys F3Key
MsgBox "No class has been selected for transfer", vbInformation, "Transfer Credits"
End If
'''''''''''''''''''''''''''
' Cleanup
'''''''''''''''''''''''''''
Cleanup:
TurnOnExcelDefaults Exception
Exception.Pop
Exit Sub
'''''''''''''''''''''''''''
' Error Handling
'''''''''''''''''''''''''''
NavigationFailure:
With Exception
.IsError = False
.Flag = True
.Throw "An issue has occurred: The AS/400 has not found the correct screen location. " & _
"The procedure has been cancelled." & vbNewLine & vbNewLine & _
"Please ensure the AS/400 is on the correct session, " & _
"and on a friendly screen location, before proceeding."
End With
GoTo Cleanup
'''''''''''''''''''''''''''
SIDNotAMatch:
With Exception
.IsError = False
.Flag = True
.Throw "The selected Student ID# has changed since starting the procedure. " & _
"The procedure has been cancelled." & vbNewLine & vbNewLine & _
"Please ensure the Student ID# is correct before proceeding."
End With
GoTo Cleanup
'''''''''''''''''''''''''''
End Sub
'''''''''''''''''''''''''''
Private Sub LoadTextboxesFromCredits(ByRef textboxArray() As Object, _
ByVal CreditsForm As MSForms.UserForm, ByRef Exception As cException)
On Error Resume Next
Exception.Push "TransferCredits.LoadTextboxesFromCredits"
With CreditsForm
Set textboxArray(1, 1) = .Mod1_Textbox
Set textboxArray(2, 1) = .Mod2_Textbox
Set textboxArray(3, 1) = .Mod3_Textbox
Set textboxArray(4, 1) = .Mod4_Textbox
Set textboxArray(5, 1) = .Mod5_Textbox
Set textboxArray(6, 1) = .Mod6_Textbox
Set textboxArray(7, 1) = .Mod7_Textbox
Set textboxArray(8, 1) = .Mod8_Textbox
Set textboxArray(9, 1) = .Mod9_Textbox
Set textboxArray(10, 1) = .Mod10_Textbox
Set textboxArray(11, 1) = .Mod11_Textbox
Set textboxArray(12, 1) = .Mod12_Textbox
Set textboxArray(13, 1) = .Mod13_Textbox
Set textboxArray(14, 1) = .Mod14_Textbox
Set textboxArray(15, 1) = .Mod15_Textbox
Set textboxArray(16, 1) = .Mod16_Textbox
Set textboxArray(17, 1) = .Mod17_Textbox
Set textboxArray(18, 1) = .Mod18_Textbox
Set textboxArray(19, 1) = .Mod19_Textbox
Set textboxArray(20, 1) = .Mod20_Textbox
Set textboxArray(21, 1) = .Mod21_Textbox
Set textboxArray(22, 1) = .Mod22_Textbox
Set textboxArray(23, 1) = .Mod23_Textbox
Set textboxArray(24, 1) = .Mod24_Textbox
Set textboxArray(25, 1) = .Mod25_Textbox
Set textboxArray(26, 1) = .Mod26_Textbox
Set textboxArray(27, 1) = .Mod27_Textbox
Set textboxArray(28, 1) = .Mod28_Textbox
Set textboxArray(29, 1) = .Mod29_Textbox
Set textboxArray(30, 1) = .Mod30_Textbox
Set textboxArray(1, 2) = .Title1_Textbox
Set textboxArray(2, 2) = .Title2_Textbox
Set textboxArray(3, 2) = .Title3_Textbox
Set textboxArray(4, 2) = .Title4_Textbox
Set textboxArray(5, 2) = .Title5_Textbox
Set textboxArray(6, 2) = .Title6_Textbox
Set textboxArray(7, 2) = .Title7_Textbox
Set textboxArray(8, 2) = .Title8_Textbox
Set textboxArray(9, 2) = .Title9_Textbox
Set textboxArray(10, 2) = .Title10_Textbox
Set textboxArray(11, 2) = .Title11_Textbox
Set textboxArray(12, 2) = .Title12_Textbox
Set textboxArray(13, 2) = .Title13_Textbox
Set textboxArray(14, 2) = .Title14_Textbox
Set textboxArray(15, 2) = .Title15_Textbox
Set textboxArray(16, 2) = .Title16_Textbox
Set textboxArray(17, 2) = .Title17_Textbox
Set textboxArray(18, 2) = .Title18_Textbox
Set textboxArray(19, 2) = .Title19_Textbox
Set textboxArray(20, 2) = .Title20_Textbox
Set textboxArray(21, 2) = .Title21_Textbox
Set textboxArray(22, 2) = .Title22_Textbox
Set textboxArray(23, 2) = .Title23_Textbox
Set textboxArray(24, 2) = .Title24_Textbox
Set textboxArray(25, 2) = .Title25_Textbox
Set textboxArray(26, 2) = .Title26_Textbox
Set textboxArray(27, 2) = .Title27_Textbox
Set textboxArray(28, 2) = .Title28_Textbox
Set textboxArray(29, 2) = .Title29_Textbox
Set textboxArray(30, 2) = .Title30_Textbox
End With
Exception.Pop
End Sub
Private Sub LoadBools(ByRef bools() As Boolean, _
ByVal CreditsForm As MSForms.UserForm, ByRef Exception As cException)
On Error Resume Next
Exception.Push "TransferCredits.LoadBools"
With CreditsForm
bools(1) = .Class1_Checkbox.Value
bools(2) = .Class2_Checkbox.Value
bools(3) = .Class3_Checkbox.Value
bools(4) = .Class4_Checkbox.Value
bools(5) = .Class5_Checkbox.Value
bools(6) = .Class6_Checkbox.Value
bools(7) = .Class7_Checkbox.Value
bools(8) = .Class8_Checkbox.Value
bools(9) = .Class9_Checkbox.Value
bools(10) = .Class10_Checkbox.Value
bools(11) = .Class11_Checkbox.Value
bools(12) = .Class12_Checkbox.Value
bools(13) = .Class13_Checkbox.Value
bools(14) = .Class14_Checkbox.Value
bools(15) = .Class15_Checkbox.Value
bools(16) = .Class16_Checkbox.Value
bools(17) = .Class17_Checkbox.Value
bools(18) = .Class18_Checkbox.Value
bools(19) = .Class19_Checkbox.Value
bools(20) = .Class20_Checkbox.Value
bools(21) = .Class21_Checkbox.Value
bools(22) = .Class22_Checkbox.Value
bools(23) = .Class23_Checkbox.Value
bools(24) = .Class24_Checkbox.Value
bools(25) = .Class25_Checkbox.Value
bools(26) = .Class26_Checkbox.Value
bools(27) = .Class27_Checkbox.Value
bools(28) = .Class28_Checkbox.Value
bools(29) = .Class29_Checkbox.Value
bools(30) = .Class30_Checkbox.Value
End With
Exception.Pop
End Sub