-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTestPanel.frm
More file actions
325 lines (313 loc) · 10.6 KB
/
TestPanel.frm
File metadata and controls
325 lines (313 loc) · 10.6 KB
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
VERSION 5.00
Begin VB.Form TestPanel
Caption = "QuickBaseClient Test Panel"
ClientHeight = 5385
ClientLeft = 45
ClientTop = 270
ClientWidth = 8820
LinkTopic = "Form1"
ScaleHeight = 5385
ScaleWidth = 8820
StartUpPosition = 3 'Windows Default
Begin VB.FileListBox File1
Height = 3015
Left = 2880
TabIndex = 22
Top = 2160
Width = 2175
End
Begin VB.DirListBox Dir1
Height = 1890
Left = 840
TabIndex = 21
Top = 3240
Width = 1935
End
Begin VB.DriveListBox Drive1
Height = 315
Left = 840
TabIndex = 20
Top = 2640
Width = 1935
End
Begin VB.TextBox txtServer
Height = 288
Left = 2280
TabIndex = 18
Text = "www.quickbase.com"
Top = 1680
Width = 1695
End
Begin VB.TextBox txtErrorText
Height = 288
Left = 5280
TabIndex = 15
Top = 2520
Width = 3255
End
Begin VB.TextBox txtErrorCode
Height = 288
Left = 7680
TabIndex = 14
Top = 2160
Width = 735
End
Begin VB.TextBox txtRid
Height = 288
Left = 2280
TabIndex = 9
Top = 1200
Width = 1695
End
Begin VB.TextBox txtDBName
Height = 288
Left = 5520
TabIndex = 8
Text = "QuickBase VB API Demo"
Top = 240
Width = 3015
End
Begin VB.TextBox txtdbid
Height = 288
Left = 5520
TabIndex = 5
Top = 720
Width = 3015
End
Begin VB.TextBox txtPassword
Height = 288
IMEMode = 3 'DISABLE
Left = 2280
PasswordChar = "*"
TabIndex = 4
Text = "Password"
Top = 600
Width = 1695
End
Begin VB.TextBox txtUsername
Height = 288
Left = 2280
TabIndex = 3
Text = "Depositor"
Top = 210
Width = 1695
End
Begin VB.TextBox txtResult
Height = 1815
Left = 5280
MultiLine = -1 'True
TabIndex = 2
Top = 3360
Width = 3375
End
Begin VB.CommandButton cmdSubmit
Caption = "Submit"
Height = 372
Left = 6360
TabIndex = 1
Top = 1680
Width = 1092
End
Begin VB.ComboBox cmbAction
Height = 315
ItemData = "TestPanel.frx":0000
Left = 5520
List = "TestPanel.frx":0013
TabIndex = 0
Text = "Choose an API Call!"
Top = 1200
Width = 3015
End
Begin VB.Label UserTokenTip
Caption = "Omit for User Token"
Height = 255
Left = 720
TabIndex = 25
Top = 840
Width = 1455
End
Begin VB.Label lblResult
Caption = "Result of API Call"
Height = 255
Left = 5400
TabIndex = 24
Top = 3000
Width = 2055
End
Begin VB.Label lblFile
Caption = "Pick a file to Upload"
Height = 255
Left = 840
TabIndex = 23
Top = 2280
Width = 1695
End
Begin VB.Label lblServer
Caption = "Host or IP Address"
Height = 255
Left = 840
TabIndex = 19
Top = 1680
Width = 1935
End
Begin VB.Label lblErrorText
Caption = "Error Text"
Height = 255
Left = 5400
TabIndex = 17
Top = 2160
Width = 855
End
Begin VB.Label lblErrcode
Caption = "Error Code"
Height = 255
Left = 6720
TabIndex = 16
Top = 2160
Width = 855
End
Begin VB.Label lblDBID
Caption = "Database DBID"
Height = 255
Left = 4200
TabIndex = 13
Top = 720
Width = 1215
End
Begin VB.Label lblDBName
Caption = "Database Name"
Height = 255
Left = 4200
TabIndex = 12
Top = 240
Width = 1215
End
Begin VB.Label lblAction
Caption = "Action"
Height = 255
Left = 4440
TabIndex = 11
Top = 1200
Width = 615
End
Begin VB.Label lblRid
Caption = "Record ID#"
Height = 255
Left = 1320
TabIndex = 10
Top = 1200
Width = 1215
End
Begin VB.Label lblPassword
Caption = "Password"
Height = 255
Left = 1440
TabIndex = 7
Top = 600
Width = 1455
End
Begin VB.Label lblUsername
AutoSize = -1 'True
Caption = "Username/UserToken"
Height = 195
Left = 600
TabIndex = 6
Top = 240
Width = 1815
End
End
Attribute VB_Name = "TestPanel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'© 2001 Intuit Inc. All rights reserved.
'Use is subject to the IP Rights Notice and Restrictions available at
'http://developer.intuit.com/legal/IPRNotice_021201.html
Dim QDB As QuickBase.QuickBaseClient
Private Sub cmdSubmit_Click()
Dim objFs As Object
Dim objFile As Object
Dim RecordArray(2, 4)
Dim xmlQDBResponse As New MSXML.DOMDocument
Dim strUpdateID As String
Set QDB = New QuickBase.QuickBaseClient
QDB.setServer txtServer.Text, True
If txtPassword.Text = "" Then
txtResult.Text = QDB.Authenticate(, , txtUsername.Text)
Else
txtResult.Text = QDB.Authenticate(txtUsername.Text, txtPassword.Text)
End If
DoEvents
Select Case cmbAction.Text
Case "API_FindDBByName"
'I don't recommend using this call.
'It's much better practice to either hard code the database identifier by finding it manually.
'Please read https://www.quickbase.com/db/6mztyxu8?a=dr&r=w to learn how to manually find the
'database identifier of a QuickBase table.
txtdbid.Text = QDB.FindDBByName(txtDBName.Text)
Case "API_CloneDatabase"
txtResult.Text = QDB.CloneDatabase(txtdbid.Text, "Delete Please VB API testing", "Please Delete")
txtdbid.Text = txtResult.Text
Case "API_AddRecord"
'First we'll add a record with the function call that takes a variable number of arguments
txtResult.Text = QDB.AddRecord(txtdbid.Text, "", "Assigned to", "Barney", 1006, "set by a fid!")
'Now we'll use the call that takes a two dimensional array
RecordArray(0, 0) = "Assigned to"
RecordArray(1, 0) = "Barney"
RecordArray(0, 1) = 1006
RecordArray(1, 1) = "set by a fid!"
RecordArray(0, 2) = "Status"
RecordArray(1, 2) = "Completed"
RecordArray(0, 3) = "Analysis"
RecordArray(1, 3) = "set by a field name!"
RecordArray(0, 4) = 1017
Set objFs = CreateObject("Scripting.FileSystemObject")
If File1.FileName <> "" Then
If Mid(File1.Path, Len(File1.Path)) = "\" Then
Set objFile = objFs.GetFile(File1.Path & File1.FileName)
Else
Set objFile = objFs.GetFile(File1.Path & "\" & File1.FileName)
End If
Set RecordArray(1, 4) = objFile
End If
txtResult.Text = QDB.AddRecordByArray(txtdbid.Text, strUpdateID, RecordArray())
txtRid.Text = txtResult.Text
Case "API_EditRecord"
txtResult.Text = QDB.EditRecord(txtdbid.Text, txtRid.Text, "", "Assigned to", "Fred", 1006, "Edited by Edit Record")
Case "API_DoQuery"
Set xmlQDBResponse = QDB.DoQuery(txtdbid.Text, "1", "", "", "")
Dim i As Integer
Dim j As Integer
Dim FieldNodeList
Dim RecordNodeList
Dim RecordNode
Set FieldNodeList = xmlQDBResponse.documentElement.selectNodes("/*/table/fields/field")
Set RecordNodeList = xmlQDBResponse.documentElement.selectNodes("/*/table/records/record")
For i = 0 To RecordNodeList.length - 1
Set RecordNode = RecordNodeList.nextNode()
Dim FieldValues
Set FieldValues = RecordNode.selectNodes("f")
Dim FieldNode
For j = 0 To FieldValues.length - 1
Set FieldNode = FieldValues.nextNode()
txtResult.Text = txtResult.Text + "Field Name: " + FieldNodeList(j).selectSingleNode("label").nodeTypedValue
txtResult.Text = txtResult.Text + " Field Value: " + FieldNode.selectSingleNode(".").nodeTypedValue + vbCrLf
Next j
Next i
Dim ResultArray() As Variant
ResultArray = QDB.DoQueryAsArray(txtdbid.Text, "{'0'.CT.''}", "", "", "")
For i = 0 To UBound(ResultArray, 1)
For j = 0 To UBound(ResultArray, 2)
txtResult.Text = txtResult.Text + " " + CStr(ResultArray(i, j))
Next j
txtResult.Text = txtResult.Text + vbCrLf
Next i
Case Else
MsgBox "Please Choose an API Call!"
End Select
txtErrorCode.Text = Format(QDB.errorcode)
txtErrorText.Text = Format(QDB.errortext)
Set QDB = Nothing
End Sub