-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.vb
485 lines (481 loc) · 23.2 KB
/
Form1.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
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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
Imports System.IO
Imports System.Data.SqlClient
Imports Microsoft.Office.Interop
Public Class Form1
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
Dim BoxToFind As String = txtBoxid.Text.Trim
If String.IsNullOrEmpty(BoxToFind) Then
MsgBox("Please enter a box id in the text box.", MsgBoxStyle.Information, "Empty Box Id")
Exit Sub
End If
btnClose.Enabled = False
btnOK.Enabled = False
'Dim BoxContents As New List(Of BoxItem)
Dim aBox As Box = FindBox(BoxToFind)
If Not aBox.exist Then
MsgBox("Box " & BoxToFind & " was not found.", MsgBoxStyle.Information, "Box not found")
btnClose.Enabled = True
btnOK.Enabled = True
Exit Sub
End If
Dim reportpath As String = CreateExcelReport(aBox)
If Not String.IsNullOrEmpty(reportpath) Then Process.Start(reportpath)
btnClose.Enabled = True
btnOK.Enabled = True
End Sub
Private Function FindBox(Boxid As String) As Box
Dim aBox As New Box
If aBox.exist Then Debug.Print("On new: box " & Boxid & " exists ") Else Debug.Print("On new: box " & Boxid & " DOES NOT exists")
Using conn As New SqlConnection("Data Source=wrselite;Initial Catalog=son_db;Integrated Security=SSPI")
Dim queryString As String = "select ermsbox.bindex,ermsbox.bdesc1,ermsbox.bnumber from ermsbox where bnumber = '" & Boxid & "'"
Dim cmd As New SqlCommand(queryString, conn)
conn.Open()
Dim r As SqlDataReader = cmd.ExecuteReader()
If r.HasRows Then
Try
r.Read()
Return New Box(r)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error finding box")
Return aBox
End Try
Else
Return aBox
End If
End Using
End Function
Private Function CreateExcelReport(aBox As Box) As String
Dim aExcelApp As New Excel.Application
Dim aExcelWrkbook As Excel.Workbook = aExcelApp.Workbooks.Add
Dim xlsWSheet As Excel.Worksheet = aExcelWrkbook.Worksheets(1)
Dim c As Integer = 1
With xlsWSheet
.Name = "BoxExport"
.Range("A1").Value = "findex"
.Range("B1").Value = "fname"
.Range("C1").Value = "fdesc1"
.Range("C1").ColumnWidth = 40
.Range("D1").Value = "mclient"
.Range("E1").Value = "bindex"
.Range("F1").Value = "bdesc1"
.Range("F1").ColumnWidth = 35
.Range("G1").Value = "bdnarr"
.Range("G1").ColumnWidth = 55
.Range("H1").Value = "mmatter"
.Range("H1").ColumnWidth = 10
.Range("I1").Value = "fbarcode"
.Range("I1").ColumnWidth = 10
.Range("J1").Value = "fdesc2"
.Range("K1").Value = "ftmkpr"
.Range("L1").Value = "fopen"
.Range("L1").ColumnWidth = 15
.Range("M1").Value = "fstatus"
.Range("N1").Value = "fcrop"
.Range("O1").Value = "freview"
.Range("O1").ColumnWidth = 15
.Range("P1").Value = "fstore"
.Range("P1").ColumnWidth = 15
.Range("Q1").Value = "fdestroy"
.Range("Q1").ColumnWidth = 15
.Range("R1").Value = "flocation"
.Range("S1").Value = "fbox"
.Range("T1").Value = "fallow"
.Range("U1").Value = "finout"
.Range("V1").Value = "ftype"
.Range("W1").Value = "fclose"
.Range("X1").Value = "fcrtime"
.Range("Y1").Value = "fvolume"
.Range("Z1").Value = "faddlloc"
.Range("AA1").Value = "ffromdate"
.Range("AA1").ColumnWidth = 15
.Range("AB1").Value = "fthrudate"
.Range("AC1").Value = "fmatthk"
.Range("AD1").Value = "fdesc3"
.Range("AE1").Value = "mediatype"
.Range("AF1").Value = "ftkauth"
.Range("AG1").Value = "fvital"
.Range("AH1").Value = "factdestroy"
.Range("AI1").Value = "fdestreason"
.Range("AH1").Value = "fdocumentcount"
.Range("AI1").Value = "finsertcount"
.Range("AJ1").Value = "fcurrloc"
.Range("AK1").Value = "fpleadings"
.Range("AL1").Value = "fmatter"
.Range("AM1").Value = "fsubnumber"
.Range("AN1").Value = "clname1"
.Range("AN1").ColumnWidth = 15
If aBox.folders.Count > 0 Then
For Each i As BoxItem In aBox.folders
c += 1
.Range("A" & c).Value = i.findex
.Range("B" & c).Value = i.fname
.Range("C" & c).Value = i.fdesc1
.Range("D" & c).Value = i.mclient
.Range("E" & c).Value = aBox.bindex
.Range("F" & c).Value = aBox.bdesc1
If Not String.IsNullOrEmpty(aBox.bdnarr.Trim) Then
.Range("G" & c).Value = aBox.bdnarr.Remove(aBox.bdnarr.Length - 1)
End If
.Range("H" & c).Value = i.mmatter
.Range("I" & c).Value = i.fbarcode
.Range("J" & c).Value = i.fdesc2
.Range("K" & c).Value = i.ftmkpr
.Range("L" & c).Value = i.fopen
.Range("M" & c).Value = i.fstatus
.Range("N" & c).Value = i.fcrop
.Range("O" & c).Value = i.freview
.Range("P" & c).Value = i.fstore
.Range("Q" & c).Value = i.fdestroy
.Range("R" & c).Value = i.flocation
.Range("S" & c).Value = i.fbox
.Range("T" & c).Value = i.fallow
.Range("U" & c).Value = i.finout
.Range("V" & c).Value = i.ftype
.Range("W" & c).Value = i.fclose
.Range("X" & c).Value = i.fcrtime
.Range("Y" & c).Value = i.fvolume
.Range("Z" & c).Value = i.faddlloc
.Range("AA" & c).Value = i.ffromdate
.Range("AB" & c).Value = i.fthrudate
.Range("AC" & c).Value = i.fmatthk
.Range("AD" & c).Value = i.fdesc3
.Range("AE" & c).Value = i.mediatype
.Range("AF" & c).Value = i.ftkauth
.Range("AG" & c).Value = i.fvital
.Range("AH" & c).Value = i.factdestroy
.Range("AI" & c).Value = i.fdestreason
.Range("AH" & c).Value = i.fdocumentcount
.Range("AI" & c).Value = i.finsertcount
.Range("AJ" & c).Value = i.fcurrloc
.Range("AK" & c).Value = i.fpleadings
.Range("AL" & c).Value = i.fmatter
.Range("AM" & c).Value = i.fsubnumber
.Range("AN" & c).Value = i.clname1
Next
Else
c += 1
.Range("E" & c).Value = aBox.bindex
.Range("F" & c).Value = aBox.bdesc1
If Not String.IsNullOrEmpty(aBox.bdnarr.Trim) Then
.Range("G" & c).Value = aBox.bdnarr.Remove(aBox.bdnarr.Length - 1)
End If
.Range("S" & c).Value = aBox.bnumber
End If
.Rows(c & ":" & c).RowHeight = 45
End With
aExcelWrkbook.Sheets.Item("Sheet2").delete()
aExcelWrkbook.Sheets.Item("Sheet3").delete()
Dim filepath As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\EliteBoxExport." & Now.ToString("yyyyMMddHHmmss") & ".xlsx"
If File.Exists(filepath) Then
Try
File.Move(filepath, filepath.Replace(".xlsx", "." & Now.Ticks & ".xlsx"))
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Report save error")
Return ""
End Try
End If
aExcelWrkbook.SaveAs(filepath)
aExcelWrkbook.Close()
aExcelApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(aExcelWrkbook)
System.Runtime.InteropServices.Marshal.ReleaseComObject(aExcelApp)
aExcelWrkbook = Nothing
aExcelApp = Nothing
GC.Collect()
Return filepath
End Function
Private Function CreateExcelReport(BoxContents As List(Of BoxItem)) As String
Dim aExcelApp As New Excel.Application
Dim aExcelWrkbook As Excel.Workbook = aExcelApp.Workbooks.Add
Dim xlsWSheet As Excel.Worksheet = aExcelWrkbook.Worksheets(1)
Dim c As Integer = 1
With xlsWSheet
.Name = "BoxExport"
.Range("A1").Value = "findex"
.Range("B1").Value = "fname"
.Range("C1").Value = "fdesc1"
.Range("C1").ColumnWidth = 40
.Range("D1").Value = "mclient"
.Range("E1").Value = "bindex"
.Range("F1").Value = "bdesc1"
.Range("F1").ColumnWidth = 35
.Range("G1").Value = "bdnarr"
.Range("G1").ColumnWidth = 55
.Range("H1").Value = "mmatter"
.Range("H1").ColumnWidth = 10
.Range("I1").Value = "fbarcode"
.Range("I1").ColumnWidth = 10
.Range("J1").Value = "fdesc2"
.Range("K1").Value = "ftmkpr"
.Range("L1").Value = "fopen"
.Range("L1").ColumnWidth = 15
.Range("M1").Value = "fstatus"
.Range("N1").Value = "fcrop"
.Range("O1").Value = "freview"
.Range("O1").ColumnWidth = 15
.Range("P1").Value = "fstore"
.Range("P1").ColumnWidth = 15
.Range("Q1").Value = "fdestroy"
.Range("Q1").ColumnWidth = 15
.Range("R1").Value = "flocation"
.Range("S1").Value = "fbox"
.Range("T1").Value = "fallow"
.Range("U1").Value = "finout"
.Range("V1").Value = "ftype"
.Range("W1").Value = "fclose"
.Range("X1").Value = "fcrtime"
.Range("Y1").Value = "fvolume"
.Range("Z1").Value = "faddlloc"
.Range("AA1").Value = "ffromdate"
.Range("AA1").ColumnWidth = 15
.Range("AB1").Value = "fthrudate"
.Range("AC1").Value = "fmatthk"
.Range("AD1").Value = "fdesc3"
.Range("AE1").Value = "mediatype"
.Range("AF1").Value = "ftkauth"
.Range("AG1").Value = "fvital"
.Range("AH1").Value = "factdestroy"
.Range("AI1").Value = "fdestreason"
.Range("AH1").Value = "fdocumentcount"
.Range("AI1").Value = "finsertcount"
.Range("AJ1").Value = "fcurrloc"
.Range("AK1").Value = "fpleadings"
.Range("AL1").Value = "fmatter"
.Range("AM1").Value = "fsubnumber"
.Range("AN1").Value = "clname1"
.Range("AN1").ColumnWidth = 15
For Each i As BoxItem In BoxContents
c += 1
.Range("A" & c).Value = i.findex
.Range("B" & c).Value = i.fname
.Range("C" & c).Value = i.fdesc1
.Range("D" & c).Value = i.mclient
'.Range("E" & c).Value = i.bindex
'.Range("F" & c).Value = i.bdesc1
'If Not String.IsNullOrEmpty(i.bdnarr.Trim) Then
' .Range("G" & c).Value = i.bdnarr.Remove(i.bdnarr.Length - 1)
'End If
.Range("H" & c).Value = i.mmatter
.Range("I" & c).Value = i.fbarcode
.Range("J" & c).Value = i.fdesc2
.Range("K" & c).Value = i.ftmkpr
.Range("L" & c).Value = i.fopen
.Range("M" & c).Value = i.fstatus
.Range("N" & c).Value = i.fcrop
.Range("O" & c).Value = i.freview
.Range("P" & c).Value = i.fstore
.Range("Q" & c).Value = i.fdestroy
.Range("R" & c).Value = i.flocation
.Range("S" & c).Value = i.fbox
.Range("T" & c).Value = i.fallow
.Range("U" & c).Value = i.finout
.Range("V" & c).Value = i.ftype
.Range("W" & c).Value = i.fclose
.Range("X" & c).Value = i.fcrtime
.Range("Y" & c).Value = i.fvolume
.Range("Z" & c).Value = i.faddlloc
.Range("AA" & c).Value = i.ffromdate
.Range("AB" & c).Value = i.fthrudate
.Range("AC" & c).Value = i.fmatthk
.Range("AD" & c).Value = i.fdesc3
.Range("AE" & c).Value = i.mediatype
.Range("AF" & c).Value = i.ftkauth
.Range("AG" & c).Value = i.fvital
.Range("AH" & c).Value = i.factdestroy
.Range("AI" & c).Value = i.fdestreason
.Range("AH" & c).Value = i.fdocumentcount
.Range("AI" & c).Value = i.finsertcount
.Range("AJ" & c).Value = i.fcurrloc
.Range("AK" & c).Value = i.fpleadings
.Range("AL" & c).Value = i.fmatter
.Range("AM" & c).Value = i.fsubnumber
.Range("AN" & c).Value = i.clname1
.Rows(c & ":" & c).RowHeight = 45
Next
End With
aExcelWrkbook.Sheets.Item("Sheet2").delete()
aExcelWrkbook.Sheets.Item("Sheet3").delete()
Dim filepath As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\EliteBoxExport." & Now.ToString("yyyyMMddHHmmss") & ".xlsx"
If File.Exists(filepath) Then
Try
File.Move(filepath, filepath.Replace(".xlsx", "." & Now.Ticks & ".xlsx"))
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Report save error")
Return ""
End Try
End If
aExcelWrkbook.SaveAs(filepath)
aExcelWrkbook.Close()
aExcelApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(aExcelWrkbook)
System.Runtime.InteropServices.Marshal.ReleaseComObject(aExcelApp)
aExcelWrkbook = Nothing
aExcelApp = Nothing
GC.Collect()
Return filepath
End Function
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
Me.Close()
End Sub
End Class
Public Class BoxItem
#Region "Class Variables"
'Public bindex As String = ""
'Public bdesc1 As String = ""
Public findex As String = ""
Public fname As String = ""
Public fdesc1 As String = ""
Public mclient As String = ""
Public mmatter As String = ""
Public fbarcode As String = ""
Public fdesc2 As String = ""
Public ftmkpr As String = ""
Public fopen As String = ""
Public fstatus As String = ""
Public fcrop As String = ""
Public freview As String = ""
Public fstore As String = ""
Public fdestroy As String = ""
Public flocation As String = ""
Public fbox As String = ""
Public fallow As String = ""
Public finout As String = ""
Public ftype As String = ""
Public fclose As String = ""
Public fcrtime As String = ""
Public fvolume As String = ""
Public faddlloc As String = ""
Public ffromdate As String = ""
Public fthrudate As String = ""
Public fmatthk As String = ""
Public fdesc3 As String = ""
Public mediatype As String = ""
Public ftkauth As String = ""
Public fvital As String = ""
Public factdestroy As String = ""
Public fdestreason As String = ""
Public fdocumentcount As String = ""
Public finsertcount As String = ""
Public fcurrloc As String = ""
Public fpleadings As String = ""
Public fmatter As String = ""
Public fsubnumber As String = ""
Public clname1 As String = ""
#End Region
Sub New(r As SqlDataReader)
Try
'If Not IsDBNull(r.Item("bindex")) Then bindex = r.Item("bindex")
'If Not IsDBNull(r.Item("bdesc1")) Then bdesc1 = Trim(r.Item("bdesc1"))
If Not IsDBNull(r.Item("findex")) Then findex = Trim(r.Item("findex"))
If Not IsDBNull(r.Item("fname")) Then fname = Trim(r.Item("fname"))
If Not IsDBNull(r.Item("fdesc1")) Then fdesc1 = Trim(r.Item("fdesc1"))
If Not IsDBNull(r.Item("mclient")) Then mclient = Trim(r.Item("mclient"))
If Not IsDBNull(r.Item("mmatter")) Then mmatter = Trim(r.Item("mmatter"))
If Not IsDBNull(r.Item("fbarcode")) Then fbarcode = Trim(r.Item("fbarcode"))
If Not IsDBNull(r.Item("fdesc2")) Then fdesc2 = Trim(r.Item("fdesc2"))
If Not IsDBNull(r.Item("ftmkpr")) Then ftmkpr = Trim(r.Item("ftmkpr"))
If Not IsDBNull(r.Item("fopen")) Then fopen = Trim(r.Item("fopen"))
If Not IsDBNull(r.Item("fstatus")) Then fstatus = Trim(r.Item("fstatus"))
If Not IsDBNull(r.Item("fcrop")) Then fcrop = Trim(r.Item("fcrop"))
If Not IsDBNull(r.Item("freview")) Then freview = Trim(r.Item("freview"))
If Not IsDBNull(r.Item("fstore")) Then fstore = Trim(r.Item("fstore"))
If Not IsDBNull(r.Item("fdestroy")) Then fdestroy = Trim(r.Item("fdestroy"))
If Not IsDBNull(r.Item("flocation")) Then flocation = Trim(r.Item("flocation"))
If Not IsDBNull(r.Item("fbox")) Then fbox = Trim(r.Item("fbox"))
If Not IsDBNull(r.Item("fallow")) Then fallow = Trim(r.Item("fallow"))
If Not IsDBNull(r.Item("finout")) Then finout = Trim(r.Item("finout"))
If Not IsDBNull(r.Item("ftype")) Then ftype = Trim(r.Item("ftype"))
If Not IsDBNull(r.Item("fclose")) Then fclose = Trim(r.Item("fclose"))
If Not IsDBNull(r.Item("fcrtime")) Then fcrtime = Trim(r.Item("fcrtime"))
If Not IsDBNull(r.Item("fvolume")) Then fvolume = Trim(r.Item("fvolume"))
If Not IsDBNull(r.Item("faddlloc")) Then faddlloc = Trim(r.Item("faddlloc"))
If Not IsDBNull(r.Item("ffromdate")) Then ffromdate = Trim(r.Item("ffromdate"))
If Not IsDBNull(r.Item("fthrudate")) Then fthrudate = Trim(r.Item("fthrudate"))
If Not IsDBNull(r.Item("fmatthk")) Then fmatthk = Trim(r.Item("fmatthk"))
If Not IsDBNull(r.Item("fdesc3")) Then fdesc3 = Trim(r.Item("fdesc3"))
If Not IsDBNull(r.Item("mediatype")) Then mediatype = Trim(r.Item("mediatype"))
If Not IsDBNull(r.Item("ftkauth")) Then ftkauth = Trim(r.Item("ftkauth"))
If Not IsDBNull(r.Item("fvital")) Then fvital = Trim(r.Item("fvital"))
If Not IsDBNull(r.Item("factdestroy")) Then factdestroy = Trim(r.Item("factdestroy"))
If Not IsDBNull(r.Item("fdestreason")) Then fdestreason = Trim(r.Item("fdestreason"))
If Not IsDBNull(r.Item("fdocumentcount")) Then fdocumentcount = Trim(r.Item("fdocumentcount"))
If Not IsDBNull(r.Item("finsertcount")) Then finsertcount = Trim(r.Item("finsertcount"))
If Not IsDBNull(r.Item("fcurrloc")) Then fcurrloc = Trim(r.Item("fcurrloc"))
If Not IsDBNull(r.Item("fpleadings")) Then fpleadings = Trim(r.Item("fpleadings"))
If Not IsDBNull(r.Item("fmatter")) Then fmatter = Trim(r.Item("fmatter"))
If Not IsDBNull(r.Item("fsubnumber")) Then fsubnumber = Trim(r.Item("fsubnumber"))
Using conn As New SqlConnection("Data Source=wrselite;Initial Catalog=son_db;Integrated Security=SSPI")
Dim queryString As String = "select clname1 from client where client.clnum = '" & mclient & "'"
Dim cmd As New SqlCommand(queryString, conn)
conn.Open()
Dim rr As SqlDataReader = cmd.ExecuteReader()
If rr.HasRows Then
Try
While rr.Read
If Not IsDBNull(rr.Item("clname1")) Then clname1 = Trim(rr.Item("clname1"))
End While
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "SQL Error On clname1")
End Try
End If
End Using
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "SQL Error no 2")
End Try
End Sub
End Class
Public Class Box
Public exist As Boolean = False
Public bindex As String = ""
Public bdesc1 As String = ""
Public bnumber As String = ""
Public bdnarr As String = ""
Public folders As New List(Of BoxItem)
Sub New()
End Sub
Sub New(r As SqlDataReader)
exist = True
Try
If Not IsDBNull(r.Item("bindex")) Then bindex = r.Item("bindex")
If Not IsDBNull(r.Item("bdesc1")) Then bdesc1 = Trim(r.Item("bdesc1"))
If Not IsDBNull(r.Item("bnumber")) Then bnumber = Trim(r.Item("bnumber"))
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "SQL Error no 3")
End Try
Using conn As New SqlConnection("Data Source=wrselite;Initial Catalog=son_db;Integrated Security=SSPI")
Dim queryString As String = "SELECT bdnarr FROM boxnarr WHERE bindex = " & bindex & " ORDER BY bdline"
Dim cmd As New SqlCommand(queryString, conn)
conn.Open()
Dim rr As SqlDataReader = cmd.ExecuteReader()
If rr.HasRows Then
Try
While rr.Read
If Not IsDBNull(rr.Item("bdnarr")) Then bdnarr &= Trim(rr.Item("bdnarr")) & vbCrLf
End While
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "SQL Error On bdnarr")
End Try
End If
End Using
folders = QueryResult()
End Sub
Private Function QueryResult() As List(Of BoxItem)
Dim BoxItems As New List(Of BoxItem)
Using conn As New SqlConnection("Data Source=wrselite;Initial Catalog=son_db;Integrated Security=SSPI")
Dim queryString As String = "SELECT DISTINCT folder.findex,folder.fname,folder.fdesc1,matter.mclient,matter.mmatter,folder.fbarcode,folder.fdesc2,folder.ftmkpr,folder.fopen,folder.fstatus,folder.fcrop,folder.freview,folder.fstore,folder.fdestroy,folder.flocation,folder.fbox,folder.fallow,folder.finout,folder.ftype,folder.fclose,folder.fcrtime,folder.fvolume,folder.faddlloc,folder.ffromdate,folder.fthrudate,folder.fmatthk,folder.fdesc3,folder.mediatype,folder.ftkauth,folder.fvital,folder.factdestroy,folder.fdestreason,folder.fdocumentcount,folder.finsertcount,folder.fcurrloc,folder.fpleadings,folder.fmatter,folder.fsubnumber FROM folder,matter WHERE folder.fmatter = matter.mmatter AND folder.fbox = '" & bnumber & "' ORDER BY folder.fname,folder.findex"
Dim cmd As New SqlCommand(queryString, conn)
conn.Open()
Dim r As SqlDataReader = cmd.ExecuteReader()
If r.HasRows Then
Try
While r.Read
BoxItems.Add(New BoxItem(r))
End While
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "SQL Error on all")
End Try
End If
End Using
Return BoxItems
End Function
End Class