-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.frm
419 lines (400 loc) · 13.7 KB
/
state.frm
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
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form state
BorderStyle = 1 'Fixed Single
Caption = "图书查询"
ClientHeight = 9600
ClientLeft = 2490
ClientTop = 1380
ClientWidth = 14070
Icon = "state.frx":0000
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 9600
ScaleWidth = 14070
Begin VB.CommandButton Command5
Caption = "退出"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 10080
TabIndex = 11
Top = 1560
Width = 2775
End
Begin VB.CommandButton Command3
Caption = "查询"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1920
TabIndex = 7
Top = 1680
Width = 2175
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
ItemData = "state.frx":000C
Left = 2400
List = "state.frx":0022
TabIndex = 6
Text = "书名"
Top = 720
Width = 3135
End
Begin VB.Frame Frame3
Caption = "检索"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2175
Left = 360
TabIndex = 5
Top = 240
Width = 6015
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 9
Top = 960
Width = 5535
End
Begin VB.Label Label1
Caption = "检索类型"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 720
TabIndex = 8
Top = 480
Width = 1215
End
End
Begin VB.CommandButton Command1
Caption = "借出"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 7200
TabIndex = 1
Top = 600
Width = 2775
End
Begin MSComctlLib.ListView ListView1
Height = 5415
Left = 600
TabIndex = 0
Top = 3120
Width = 12615
_ExtentX = 22251
_ExtentY = 9551
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
NumItems = 0
End
Begin VB.Frame Frame1
Caption = "检索内容"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 6735
Left = 360
TabIndex = 2
Top = 2640
Width = 13215
Begin VB.Label Label2
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 12
Top = 6120
Width = 10335
End
End
Begin VB.Frame Frame2
Caption = "操作"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2175
Left = 6960
TabIndex = 3
Top = 240
Width = 6615
Begin VB.CommandButton Command4
Caption = "增加图书"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 3120
TabIndex = 10
Top = 360
Width = 2775
End
Begin VB.CommandButton Command2
Caption = "归还"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 240
TabIndex = 4
Top = 1320
Width = 2775
End
End
End
Attribute VB_Name = "state"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Public xlApp As Excel.Application
Public rowc As Integer '得到列数
Public XlBook As Excel.Workbook
Public xlSheet As Excel.Worksheet
Public key As String
Private Sub Command1_Click()
If Me.ListView1.SelectedItem Is Nothing Then
MsgBox "未能选择对象", vbExclamation, "未能选择对象"
Else
If xlSheet.Cells(state.ListView1.SelectedItem, 4) <> 0 Then
MsgBox "该书已被借阅,不能借出", vbExclamation, "已被借阅"
Else
borrow.Show
Me.Visible = False
End If
End If
End Sub
Private Sub Command2_Click()
If Me.ListView1.SelectedItem Is Nothing Then
MsgBox "未能选择对象", vbExclamation, "未能选择对象"
Else
If xlSheet.Cells(state.ListView1.SelectedItem, 4) = 0 Then
MsgBox "该书未被借阅,不能归还", vbExclamation, "未被借阅"
Else
re.Show
Me.Visible = False
End If
End If
End Sub
Private Sub Command3_Click()
rowc = xlSheet.[A65536].End(xlUp).Row
i = 0
Me.AutoRedraw = False
ListView1.Visible = False
ListView1.ListItems.Clear
ListView1.Visible = True
Me.AutoRedraw = True
key = Me.Text1
Select Case Combo1.Text
Case "编号":
For k = 2 To rowc
'xlSheet.Cells(k, 8) = InStr(xlSheet.Cells(k, 2), Me.Frame1.Caption)
If InStr(UCase(xlSheet.Cells(k, 1)), UCase(key)) > 0 Then
add xlSheet.Cells(k, 1), xlSheet.Cells(k, 2), xlSheet.Cells(k, 3), xlSheet.Cells(k, 4), xlSheet.Cells(k, 5), xlSheet.Cells(k, 6), xlSheet.Cells(k, 7), Val(k)
End If
Next k
Case "书名":
For k = 2 To rowc
'xlSheet.Cells(k, 8) = InStr(xlSheet.Cells(k, 2), Me.Frame1.Caption)
If InStr(UCase(xlSheet.Cells(k, 2)), UCase(key)) > 0 Then
add xlSheet.Cells(k, 1), xlSheet.Cells(k, 2), xlSheet.Cells(k, 3), xlSheet.Cells(k, 4), xlSheet.Cells(k, 5), xlSheet.Cells(k, 6), xlSheet.Cells(k, 7), Val(k)
End If
Next k
Case "借阅日期":
For k = 2 To rowc
'xlSheet.Cells(k, 8) = InStr(xlSheet.Cells(k, 2), Me.Frame1.Caption)
If InStr(UCase(xlSheet.Cells(k, 5)), UCase(key)) > 0 Then
add xlSheet.Cells(k, 1), xlSheet.Cells(k, 2), xlSheet.Cells(k, 3), xlSheet.Cells(k, 4), xlSheet.Cells(k, 5), xlSheet.Cells(k, 6), xlSheet.Cells(k, 7), Val(k)
End If
Next k
Case "借阅人姓名":
For k = 2 To rowc
'xlSheet.Cells(k, 8) = InStr(xlSheet.Cells(k, 2), Me.Frame1.Caption)
If InStr(UCase(xlSheet.Cells(k, 6)), UCase(key)) > 0 Then
add xlSheet.Cells(k, 1), xlSheet.Cells(k, 2), xlSheet.Cells(k, 3), xlSheet.Cells(k, 4), xlSheet.Cells(k, 5), xlSheet.Cells(k, 6), xlSheet.Cells(k, 7), Val(k)
End If
Next k
Case "联系方式":
For k = 2 To rowc
'xlSheet.Cells(k, 8) = InStr(xlSheet.Cells(k, 2), Me.Frame1.Caption)
If InStr(UCase(xlSheet.Cells(k, 7)), UCase(key)) > 0 Then
add xlSheet.Cells(k, 1), xlSheet.Cells(k, 2), xlSheet.Cells(k, 3), xlSheet.Cells(k, 4), xlSheet.Cells(k, 5), xlSheet.Cells(k, 6), xlSheet.Cells(k, 7), Val(k)
End If
Next k
Case "系列名称":
For k = 2 To rowc
'xlSheet.Cells(k, 8) = InStr(xlSheet.Cells(k, 2), Me.Frame1.Caption)
If InStr(UCase(xlSheet.Cells(k, 3)), UCase(key)) > 0 Then
add xlSheet.Cells(k, 1), xlSheet.Cells(k, 2), xlSheet.Cells(k, 3), xlSheet.Cells(k, 4), xlSheet.Cells(k, 5), xlSheet.Cells(k, 6), xlSheet.Cells(k, 7), Val(k)
End If
Next k
Case Else:
For k = 2 To rowc
'xlSheet.Cells(k, 8) = InStr(xlSheet.Cells(k, 2), Me.Frame1.Caption)
If InStr(UCase(xlSheet.Cells(k, 2)), UCase(key)) > 0 Then
add xlSheet.Cells(k, 1), xlSheet.Cells(k, 2), xlSheet.Cells(k, 3), xlSheet.Cells(k, 4), xlSheet.Cells(k, 5), xlSheet.Cells(k, 6), xlSheet.Cells(k, 7), Val(k)
End If
Next k
End Select
Me.Label2 = "有关" & key & "的搜索结果共有" & Me.ListView1.ListItems.Count & "项"
End Sub
Private Sub Command4_Click()
addb.Show
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Form_Load()
i = 0
ListView1.View = lvwReport
ListView1.HideSelection = False
ListView1.FullRowSelect = True
ListView1.ColumnHeaders.add , "line", "编录行号"
ListView1.ColumnHeaders.add , "Number", "编号"
ListView1.ColumnHeaders.add , "Name", "书名"
ListView1.ColumnHeaders.add , "xl", "系列名称"
ListView1.ColumnHeaders.add , "state", "借阅状态"
ListView1.ColumnHeaders.add , "date", "借阅日期"
ListView1.ColumnHeaders.add , "bname", "借阅人姓名"
ListView1.ColumnHeaders.add , "contact", "联系方式"
Set xlApp = CreateObject("Excel.Application") '创建Excel对象
Set XlBook = xlApp.Workbooks.Open(data.file) '打开已经存在的Excel工作
Set xlSheet = XlBook.Worksheets(1)
End Sub
Private Function add(number As String, name As String, xl As String, state As Integer, bdate As String, bname As String, contact As String, line As String)
i = i + 1
Dim itmx As ListItem
'添加column1的名称。
Set itmx = ListView1.ListItems.add(i, , line)
'使用SubItemIndex将SubItem与正确的ColumnHeader关联。使用关键字("Sex")指定正确的ColumnHeader。
itmx.SubItems(ListView1.ColumnHeaders("Name").SubItemIndex) = name
'使用ColumnHeader关键字将SubItems字符串与
'正确的ColumnHeader关联。
If state = 1 Then
itmx.SubItems(ListView1.ColumnHeaders("state").SubItemIndex) = "已借阅"
Else
itmx.SubItems(ListView1.ColumnHeaders("state").SubItemIndex) = "未借阅"
End If
itmx.SubItems(ListView1.ColumnHeaders("Number").SubItemIndex) = number
itmx.SubItems(ListView1.ColumnHeaders("xl").SubItemIndex) = xl
itmx.SubItems(ListView1.ColumnHeaders("date").SubItemIndex) = bdate
itmx.SubItems(ListView1.ColumnHeaders("contact").SubItemIndex) = contact
itmx.SubItems(ListView1.ColumnHeaders("bname").SubItemIndex) = bname
End Function
Private Sub Form_Unload(Cancel As Integer)
XlBook.Close '关闭工作簿
Set XlBook = Nothing '从内存中清除
xlApp.Quit '关闭excel
Set xlApp = Nothing '从内存中清除
End Sub
Private Sub ListView1_DblClick()
If xlSheet.Cells(state.ListView1.SelectedItem, 4) = 0 Then
borrow.Show
Me.Visible = False
Else
re.Show
Me.Visible = False
End If
End Sub