Findfrm.frm
上传用户:zhuahui520
上传日期:2007-05-21
资源大小:347k
文件大小:12k
源码类别:

其他智力游戏

开发平台:

Java

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form Findfrm 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "查找图书"
  6.    ClientHeight    =   6000
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   7740
  10.    Icon            =   "Findfrm.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   6000
  15.    ScaleWidth      =   7740
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   1  '所有者中心
  18.    Begin VB.PictureBox Picture2 
  19.       BorderStyle     =   0  'None
  20.       Height          =   735
  21.       Left            =   2520
  22.       ScaleHeight     =   735
  23.       ScaleWidth      =   3135
  24.       TabIndex        =   10
  25.       Top             =   2280
  26.       Width           =   3135
  27.       Begin VB.Label Label3 
  28.          AutoSize        =   -1  'True
  29.          Caption         =   "以实现多个记录的查找"
  30.          ForeColor       =   &H000000C0&
  31.          Height          =   180
  32.          Left            =   0
  33.          TabIndex        =   12
  34.          Top             =   360
  35.          Width           =   1800
  36.       End
  37.       Begin VB.Label Label2 
  38.          AutoSize        =   -1  'True
  39.          Caption         =   "提示:书名查询可输入*来代替多个字符"
  40.          ForeColor       =   &H000000C0&
  41.          Height          =   180
  42.          Left            =   0
  43.          TabIndex        =   11
  44.          Top             =   120
  45.          Width           =   3060
  46.       End
  47.    End
  48.    Begin MSComctlLib.ListView LV 
  49.       Height          =   2535
  50.       Left            =   120
  51.       TabIndex        =   9
  52.       Top             =   3360
  53.       Width           =   7455
  54.       _ExtentX        =   13150
  55.       _ExtentY        =   4471
  56.       Sorted          =   -1  'True
  57.       LabelWrap       =   -1  'True
  58.       HideSelection   =   -1  'True
  59.       _Version        =   393217
  60.       ForeColor       =   32768
  61.       BackColor       =   16777215
  62.       BorderStyle     =   1
  63.       Appearance      =   1
  64.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  65.          Name            =   "宋体"
  66.          Size            =   10.5
  67.          Charset         =   134
  68.          Weight          =   700
  69.          Underline       =   0   'False
  70.          Italic          =   0   'False
  71.          Strikethrough   =   0   'False
  72.       EndProperty
  73.       NumItems        =   0
  74.    End
  75.    Begin VB.CommandButton Command1 
  76.       Cancel          =   -1  'True
  77.       Caption         =   "关  闭(&C)"
  78.       Height          =   375
  79.       Left            =   6240
  80.       TabIndex        =   8
  81.       ToolTipText     =   "关闭此对话框"
  82.       Top             =   2760
  83.       Width           =   1335
  84.    End
  85.    Begin VB.CommandButton cmdKong 
  86.       Caption         =   "全部清空(&L)"
  87.       Height          =   375
  88.       Left            =   6240
  89.       TabIndex        =   7
  90.       ToolTipText     =   "清空所有文本"
  91.       Top             =   1200
  92.       Width           =   1335
  93.    End
  94.    Begin VB.CommandButton cmdBeginFind 
  95.       Caption         =   "开始查找(&F)"
  96.       Height          =   375
  97.       Left            =   6240
  98.       TabIndex        =   6
  99.       ToolTipText     =   "开始查找符合条件的记录"
  100.       Top             =   600
  101.       Width           =   1335
  102.    End
  103.    Begin VB.TextBox txtBookName 
  104.       BeginProperty Font 
  105.          Name            =   "宋体"
  106.          Size            =   12
  107.          Charset         =   134
  108.          Weight          =   700
  109.          Underline       =   0   'False
  110.          Italic          =   0   'False
  111.          Strikethrough   =   0   'False
  112.       EndProperty
  113.       ForeColor       =   &H00FF0000&
  114.       Height          =   375
  115.       Left            =   2520
  116.       TabIndex        =   5
  117.       Text            =   "Text1"
  118.       Top             =   1800
  119.       Width           =   3135
  120.    End
  121.    Begin VB.TextBox txtBookBian 
  122.       BeginProperty Font 
  123.          Name            =   "宋体"
  124.          Size            =   12
  125.          Charset         =   134
  126.          Weight          =   700
  127.          Underline       =   0   'False
  128.          Italic          =   0   'False
  129.          Strikethrough   =   0   'False
  130.       EndProperty
  131.       ForeColor       =   &H00FF0000&
  132.       Height          =   360
  133.       Left            =   2520
  134.       TabIndex        =   0
  135.       Text            =   "Text1"
  136.       Top             =   1200
  137.       Width           =   3135
  138.    End
  139.    Begin VB.PictureBox Picture1 
  140.       BorderStyle     =   0  'None
  141.       Height          =   2175
  142.       Left            =   600
  143.       ScaleHeight     =   2175
  144.       ScaleWidth      =   1815
  145.       TabIndex        =   2
  146.       Top             =   720
  147.       Width           =   1815
  148.       Begin VB.Label Label1 
  149.          AutoSize        =   -1  'True
  150.          Caption         =   "书   名"
  151.          BeginProperty Font 
  152.             Name            =   "宋体"
  153.             Size            =   12
  154.             Charset         =   134
  155.             Weight          =   700
  156.             Underline       =   0   'False
  157.             Italic          =   0   'False
  158.             Strikethrough   =   0   'False
  159.          EndProperty
  160.          ForeColor       =   &H00FF0000&
  161.          Height          =   240
  162.          Index           =   1
  163.          Left            =   720
  164.          TabIndex        =   4
  165.          Top             =   1200
  166.          Width           =   930
  167.       End
  168.       Begin VB.Image Image1 
  169.          Height          =   480
  170.          Left            =   0
  171.          Picture         =   "Findfrm.frx":0442
  172.          Top             =   360
  173.          Width           =   480
  174.       End
  175.       Begin VB.Label Label1 
  176.          AutoSize        =   -1  'True
  177.          Caption         =   "图书编号"
  178.          BeginProperty Font 
  179.             Name            =   "宋体"
  180.             Size            =   12
  181.             Charset         =   134
  182.             Weight          =   700
  183.             Underline       =   0   'False
  184.             Italic          =   0   'False
  185.             Strikethrough   =   0   'False
  186.          EndProperty
  187.          ForeColor       =   &H00FF0000&
  188.          Height          =   240
  189.          Index           =   0
  190.          Left            =   720
  191.          TabIndex        =   3
  192.          Top             =   480
  193.          Width           =   1035
  194.       End
  195.    End
  196.    Begin MSComctlLib.TabStrip TabStrip1 
  197.       Height          =   2895
  198.       Left            =   120
  199.       TabIndex        =   1
  200.       Top             =   240
  201.       Width           =   5775
  202.       _ExtentX        =   10186
  203.       _ExtentY        =   5106
  204.       _Version        =   393216
  205.       BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
  206.          NumTabs         =   1
  207.          BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
  208.             Caption         =   "查找"
  209.             ImageVarType    =   2
  210.          EndProperty
  211.       EndProperty
  212.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  213.          Name            =   "宋体"
  214.          Size            =   9.75
  215.          Charset         =   134
  216.          Weight          =   400
  217.          Underline       =   0   'False
  218.          Italic          =   0   'False
  219.          Strikethrough   =   0   'False
  220.       EndProperty
  221.    End
  222.    Begin VB.Image Image2 
  223.       Height          =   480
  224.       Left            =   6600
  225.       Picture         =   "Findfrm.frx":088C
  226.       Top             =   1920
  227.       Width           =   480
  228.    End
  229. End
  230. Attribute VB_Name = "Findfrm"
  231. Attribute VB_GlobalNameSpace = False
  232. Attribute VB_Creatable = False
  233. Attribute VB_PredeclaredId = True
  234. Attribute VB_Exposed = False
  235. Dim rst1 As Recordset '打开表Book
  236. Dim rst2 As Recordset '打开表BookFf
  237. Dim rst As Recordset
  238. Dim db1 As Database
  239. Dim db2 As Database
  240. Dim qry1 As QueryDef
  241. Dim qry2 As QueryDef
  242. Dim RecNum As Integer '查找符合条件总记录数
  243. Dim i As Integer
  244. Dim FindStr As String  '查找SQL语句
  245. Private Sub cmdBeginFind_Click()
  246. If txtBookBian = "" And txtBookName = "" Then
  247.     MsgBox "请填写相关查找信息!", 0 + 48, "提示"
  248.     txtBookBian.SetFocus
  249.     Exit Sub
  250. End If
  251. LV.ListItems.Clear
  252. Findfrm.MousePointer = 11
  253. If txtBookBian <> "" And txtBookName = "" Then
  254.     rst1.Seek "=", txtBookBian
  255.     If rst1.NoMatch Then
  256.         MsgBox "没有找到匹配记录!", 0 + 48, "查找失败"
  257.         Findfrm.MousePointer = 0
  258.         Exit Sub
  259.     End If
  260.     If rst1.Fields("是否借出") = True Then
  261.         rst2.Seek "=", txtBookBian
  262.         LV.ListItems.Add , , rst1.Fields("图书编号") & vbNullString
  263.         With LV.ListItems(1)
  264.             .SubItems(1) = rst1.Fields("书名") & vbNullString
  265.             .SubItems(2) = rst1.Fields("类别") & vbNullString
  266.             .SubItems(3) = rst1.Fields("价格") & Empty
  267.             .SubItems(4) = rst1.Fields("出版社") & vbNullString
  268.             .SubItems(5) = rst1.Fields("是否借出")
  269.             .SubItems(6) = rst2.Fields("借书证号") & vbNullString
  270.             .SubItems(7) = rst2.Fields("姓名") & vbNullString
  271.             .SubItems(8) = rst2.Fields("借出日期")
  272.         End With
  273.     Else
  274.         LV.ListItems.Add , , rst1.Fields("图书编号") & vbNullString
  275.         With LV.ListItems(1)
  276.             .SubItems(1) = rst1.Fields("书名") & vbNullString
  277.             .SubItems(2) = rst1.Fields("类别") & vbNullString
  278.             .SubItems(3) = rst1.Fields("价格") & Empty
  279.             .SubItems(4) = rst1.Fields("出版社") & vbNullString
  280.             .SubItems(5) = rst1.Fields("是否借出")
  281.         End With
  282.     End If
  283. ElseIf txtBookBian = "" And txtBookName <> "" Then
  284.     FindStr = "select * from Book where 书名 like"
  285.     FindStr = FindStr & "'" & txtBookName & "'"
  286.     
  287.     qry1.SQL = FindStr
  288.     Set rst = qry1.OpenRecordset
  289.     If rst.RecordCount = 0 Then
  290.         MsgBox "没有找到匹配记录!", 0 + 48, "查找失败"
  291.         Findfrm.MousePointer = 0
  292.         Exit Sub
  293.     End If
  294.     rst.MoveLast
  295.     RecNum = rst.RecordCount
  296.     rst.MoveFirst
  297.     For i = 1 To RecNum
  298.         If rst.Fields("是否借出") = True Then
  299.         rst2.Seek "=", rst.Fields("图书编号")
  300.         LV.ListItems.Add i, , rst.Fields("图书编号") & vbNullString
  301.         With LV.ListItems(i)
  302.             .SubItems(1) = rst.Fields("书名") & vbNullString
  303.             .SubItems(2) = rst.Fields("类别") & vbNullString
  304.             .SubItems(3) = rst.Fields("价格") & Empty
  305.             .SubItems(4) = rst.Fields("出版社") & vbNullString
  306.             .SubItems(5) = rst.Fields("是否借出")
  307.             .SubItems(6) = rst2.Fields("借书证号") & vbNullString
  308.             .SubItems(7) = rst2.Fields("姓名") & vbNullString
  309.             .SubItems(8) = rst2.Fields("借出日期")
  310.         End With
  311.         Else
  312.            LV.ListItems.Add i, , rst.Fields("图书编号") & vbNullString
  313.         With LV.ListItems(i)
  314.             .SubItems(1) = rst.Fields("书名") & vbNullString
  315.             .SubItems(2) = rst.Fields("类别") & vbNullString
  316.             .SubItems(3) = rst.Fields("价格") & Empty
  317.             .SubItems(4) = rst.Fields("出版社") & vbNullString
  318.             .SubItems(5) = rst.Fields("是否借出")
  319.         End With
  320.         End If
  321.         rst.MoveNext
  322.         If rst.EOF Then Exit For
  323.     Next
  324. Else
  325.     MsgBox "请选择一项进行查找", 0 + 48, "提示"
  326.     txtBookBian = ""
  327.     txtBookName = ""
  328.     txtBookBian.SetFocus
  329.     Findfrm.MousePointer = 0
  330.     Exit Sub
  331. End If
  332. Findfrm.MousePointer = 0
  333. End Sub
  334. Private Sub cmdKong_Click()
  335. txtBookBian = ""
  336. txtBookName = ""
  337. LV.ListItems.Clear
  338. txtBookBian.SetFocus
  339. End Sub
  340. Private Sub Command1_Click()
  341. Unload Me
  342. End Sub
  343. Private Sub Form_Load()
  344. Set db1 = Workspaces(0).OpenDatabase("DataBaseData.mdb", False)
  345. Set rst1 = db1.OpenRecordset("Book", dbOpenTable)
  346. Set qry1 = db1.CreateQueryDef("")
  347. rst1.Index = "图书编号"
  348. Set db2 = Workspaces(0).OpenDatabase("DataBaseData.mdb", False)
  349. Set rst2 = db2.OpenRecordset("BookFf", dbOpenTable)
  350. Set qry2 = db2.CreateQueryDef("")
  351. rst2.Index = "图书编号"
  352. txtBookBian = ""
  353. txtBookName = ""
  354. LV.View = lvwReport
  355. LV.GridLines = False
  356. LV.ColumnHeaders.Add , , "图书编号"
  357. LV.ColumnHeaders.Add , , "书名"
  358. LV.ColumnHeaders.Add , , "类别"
  359. LV.ColumnHeaders.Add , , "价格"
  360. LV.ColumnHeaders.Add , , "出版社"
  361. LV.ColumnHeaders.Add , , "是否借出"
  362. LV.ColumnHeaders.Add , , "借书证号"
  363. LV.ColumnHeaders.Add , , "借书人姓名"
  364. LV.ColumnHeaders.Add , , "借书日期"
  365. End Sub
  366. Private Sub txtBookBian_KeyPress(KeyAscii As Integer)
  367. If KeyAscii = 13 Then
  368.     txtBookName.Text = ""
  369.     cmdBeginFind_Click
  370. End If
  371. End Sub
  372. Private Sub txtBookName_KeyPress(KeyAscii As Integer)
  373. If KeyAscii = 13 Then
  374.     txtBookBian.Text = ""
  375.     cmdBeginFind_Click
  376. End If
  377. End Sub