-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathform_Shipments
149 lines (99 loc) · 4.38 KB
/
form_Shipments
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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' form_Shipments (userform)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'RGB for an unselected textbox
Const lockedRed As Integer = 211
Const lockedGreen As Integer = 211
Const lockedBlue As Integer = 211
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Initialization event
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub UserForm_Initialize()
'To generate a list of active sessions
Dim objAS400ConnList As Object
Dim i As Integer
Dim container As String
SID_Textbox = vbNullString
Status_Textbox = vbNullString
Status_Textbox.Locked = True
Status_Textbox.BackColor = RGB(lockedRed, lockedGreen, lockedBlue)
Status_Textbox = "Select a shipment option." & Space(5) & _
"(Please ensure the session and Student ID values are correct before continuing)"
'For defaulting the session and Student ID values
If DebugFlag Then On Error GoTo 0 Else On Error Resume Next
Set rnglastSession = Range("lastSession")
Set rngStudentID = Range("lastStudentID")
SID_Textbox = Trim(rngStudentID.Value)
If DebugFlag Then On Error GoTo 0 Else On Error GoTo 0
'Connects to the AS/400 to generate a list of active session names
If DebugFlag Then On Error GoTo 0 Else On Error GoTo AS400NotActive
Set objAS400ConnList = CreateObject("PCOMM.autECLConnList")
objAS400ConnList.Refresh
If DebugFlag Then On Error GoTo 0 Else On Error GoTo 0
container = Trim(Range("DefaultSession"))
'Populates the selection boxes
With Session_ComboBox
.Clear
If Len(Trim(rnglastSession)) = 1 Then
.AddItem rnglastSession
End If
If Len(container) = 1 And InStr(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", container) >= 1 Then
.AddItem container
End If
For i = 1 To objAS400ConnList.Count
If objAS400ConnList(i).Ready Then
.AddItem objAS400ConnList(i).name
End If
Next i
.Text = Session_ComboBox.List(0)
End With
Set objAS400ConnList = Nothing
'Sets the initial focus
SID_Textbox.SetFocus
Exit Sub
ObjectNotFound:
SID_Textbox = vbNullString
Resume Next
AS400NotActive:
MsgBox "Note: The AS/400 has not been detected", vbInformation, "Attempting to connect to the AS/400"
Resume Next
End Sub
Private Sub button_FullRelease_Click()
Status_Textbox.BackColor = &HFFFF00
Status_Textbox = "Releasing all shipments ..."
If MsgBox("This will RELEASE every shipment on the account." & vbNewLine & vbNewLine & _
"Do you wish to proceed?", vbYesNo, "Shipment Selection: Release All Shipments") = vbYes Then
Status_Textbox.BackColor = RGB(lockedRed, lockedGreen, lockedBlue)
RunShipmentSelection form_Shipments, True
Else
Status_Textbox = "Select a shipment option."
Status_Textbox = "All shipments have been released!"
End If
End Sub
Private Sub button_FullStop_Click()
Status_Textbox.BackColor = &H8080FF
Status_Textbox = "Stopping all shipments ..."
If MsgBox("This will STOP every shipment on the account." & vbNewLine & vbNewLine & _
"Do you wish to proceed?", vbYesNo, "Shipment Selection: Stop All Shipments") = vbYes Then
Status_Textbox.BackColor = RGB(lockedRed, lockedGreen, lockedBlue)
RunShipmentSelection form_Shipments, False
Else
Status_Textbox = "Select a shipment option."
Status_Textbox = "All shipments have been stopped!"
End If
End Sub
Private Sub button_NoAction_Click()
Status_Textbox.BackColor = &HC0FFFF
Status_Textbox = "Closing the form ..."
If MsgBox("This selection will close the Shipments form." & vbNewLine & vbNewLine & _
"Do you wish to close the form?", vbYesNo, "Shipment Selection: Perform No Action") = vbYes Then
Unload Me
Else
Status_Textbox = "Select a shipment option."
Status_Textbox.BackColor = RGB(lockedRed, lockedGreen, lockedBlue)
End If
End Sub
Private Sub SID_Textbox_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
RestrictToPostiveWholeNumbers KeyAscii
End Sub