⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmbook_choose.frm

📁 图书简明管理系统源代码(VB),可作为软件工程课程设计用,也可以作为学习用。
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmbook_choose 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "图书列表选择"
   ClientHeight    =   6045
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   8565
   Icon            =   "frmbook_choose.frx":0000
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6045
   ScaleWidth      =   8565
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmdchoose 
      Caption         =   "选   择"
      Default         =   -1  'True
      Height          =   495
      Left            =   7200
      TabIndex        =   3
      Top             =   4680
      Width           =   1215
   End
   Begin VB.CommandButton cmdexit 
      Cancel          =   -1  'True
      Caption         =   "返  回"
      Height          =   495
      Left            =   7200
      TabIndex        =   4
      Top             =   5400
      Width           =   1215
   End
   Begin VB.TextBox txt图书名称 
      Height          =   375
      Left            =   3960
      TabIndex        =   1
      Top             =   464
      Width           =   2535
   End
   Begin VB.TextBox txt图书编号 
      Height          =   390
      Left            =   1200
      TabIndex        =   0
      Top             =   456
      Width           =   1695
   End
   Begin VB.PictureBox Picbg1 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   1440
      Left            =   7080
      Picture         =   "frmbook_choose.frx":19862
      ScaleHeight     =   1440
      ScaleWidth      =   1440
      TabIndex        =   7
      Top             =   720
      Width           =   1440
   End
   Begin MSFlexGridLib.MSFlexGrid bookGrid 
      Height          =   4815
      Left            =   120
      TabIndex        =   2
      Top             =   1080
      Width           =   6855
      _ExtentX        =   12091
      _ExtentY        =   8493
      _Version        =   393216
      Rows            =   1
      Cols            =   7
      FixedCols       =   0
      BackColor       =   -2147483639
      BackColorBkg    =   14737632
      GridColor       =   14737632
      GridColorFixed  =   14737632
      SelectionMode   =   1
      AllowUserResizing=   1
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "图书名称:"
      Height          =   180
      Left            =   3090
      TabIndex        =   6
      Top             =   561
      Width           =   900
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "图书编号:"
      Height          =   180
      Left            =   240
      TabIndex        =   5
      Top             =   561
      Width           =   900
   End
End
Attribute VB_Name = "frmbook_choose"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'-------------------------------------------------------
'       作者:邹雪桃
'       功能: 借书时列出所有读者,还书和续借时列出有借书的读者
'              可以模糊查询,把相应信息返回主框
'-------------------------------------------------------



Public Function borrowBookChoose(sql As String) '借书--图书列表框初始化
   Dim rs, rs2 As New ADODB.Recordset
   Dim i As Integer
   Dim sql2 As String
   Set rs = TransactSQL(sql)
   
   bookGrid.Rows = 1
   If Not rs.EOF Then
      With bookGrid
         .Rows = 1
         While Not rs.EOF
            .Rows = .Rows + 1
            If frmborrow_read.opt借书.Value Then
                .TextMatrix(.Rows - 1, 0) = rs(0)
                .TextMatrix(.Rows - 1, 1) = rs(1)
                .TextMatrix(.Rows - 1, 2) = rs(17)
                .TextMatrix(.Rows - 1, 3) = rs(11)
                .TextMatrix(.Rows - 1, 4) = rs(12)
                .TextMatrix(.Rows - 1, 5) = rs(5)
            Else
                sql2 = "select * from tsxxb where 图书编号 = '" & Trim(rs(0)) & "'"
                Set rs2 = TransactSQL(sql2)
                .TextMatrix(.Rows - 1, 0) = rs2(0)
                .TextMatrix(.Rows - 1, 1) = rs2(1)
                .TextMatrix(.Rows - 1, 2) = rs2(17)
                .TextMatrix(.Rows - 1, 3) = rs2(11)
                .TextMatrix(.Rows - 1, 4) = rs(4)
                .TextMatrix(.Rows - 1, 5) = rs2(5)
                .TextMatrix(.Rows - 1, 6) = rs(5)
                .TextMatrix(.Rows - 1, 7) = rs(6)
                .TextMatrix(.Rows - 1, 8) = rs(7)
                .TextMatrix(.Rows - 1, 9) = rs(8)
                rs2.Close
            End If
            rs.MoveNext
         Wend
      End With
      
      rs.Close
   End If
   
End Function



'Public Function backReturnBookChoose()  '归还/续借--图书列表框初始化
'   Dim rs As New ADODB.Recordset, rs2 As New ADODB.Recordset
'   Dim sql As String, sql2 As String
'   Dim i As Integer
'
'   sql = "select * from jsxxb where 读者编号= '" & frmborrow_read.txt读者编号.Text & "'"
'   Set rs = TransactSQL(sql)
'
'   bookGrid.Rows = 1
'   If rs.EOF Then
'   Else
'       bookGrid.Rows = 1
'       While Not rs.EOF
'           sql2 = "select * from tsxxb where 图书编号='" & rs(0) & "'"
'           Set rs2 = TransactSQL(sql2)
'           bookGrid.AddItem rs2(0) & vbTab & rs2(1) & vbTab & rs2(15) & vbTab & _
'                            rs2(11) & vbTab & rs(4) & vbTab & rs2(5) & vbTab & rs(5)
'           rs.MoveNext
'       Wend
'       rs2.Close
'   End If
'   rs.Close
'
'End Function




Private Sub cmdchoose_Click()

    frmborrow_read.txt图书编号.Text = bookGrid.TextMatrix(bookGrid.Row, 0)

    With bookGrid
          frmborrow_read.lst图书.AddItem "图书名称:" & vbTab & .TextMatrix(.Row, 1), 0
          frmborrow_read.lst图书.AddItem "出版日期:" & vbTab & .TextMatrix(.Row, 2), 1
          frmborrow_read.lst图书.AddItem "图书价格:" & vbTab & .TextMatrix(.Row, 3), 2
          frmborrow_read.lst图书.AddItem "现 存 量:" & vbTab & .TextMatrix(.Row, 4), 3
          frmborrow_read.lst图书.AddItem "书架位置:" & vbTab & .TextMatrix(.Row, 5), 4
    End With
    '归还/续借中增加的项
    If frmborrow_read.opt归还.Value Or frmborrow_read.opt续借.Value Then
        With bookGrid
          frmborrow_read.lst图书.AddItem "借阅数量:" & vbTab & .TextMatrix(.Row, 4), 3
          frmborrow_read.lst图书.AddItem "借阅日期:" & vbTab & .TextMatrix(.Row, 6), 5
       End With
    Else
    
    End If
    
    'txt借阅天数赋值
    Dim sql As String, sql1 As String
    Dim rs As New ADODB.Recordset, rs1 As New ADODB.Recordset
    
    sql = "select 读者类别 from dzxxb where 读者编号= '" & frmborrow_read.txt读者编号.Text & "'"
    Set rs = TransactSQL(sql)

    sql1 = "select 可借书天数 from dzlbb where 读者类别= '" & rs(0) & "'"
    Set rs1 = TransactSQL(sql1)
    frmborrow_read.txt借阅天数.Text = rs1(0)
        
    frmborrow_read.cmdadd.Enabled = True
    Unload Me
End Sub

Private Sub cmdexit_Click()
Unload Me
Call frmborrow_read.clean      '清空表框
End Sub

Private Sub Form_Load()
Call fullpic(Me, Picbg1) '背景图
Me.Left = (frmmain.ScaleWidth - Me.Width) / 2
Me.Top = (frmmain.ScaleHeight - Me.Height) / 2

With bookGrid
    .TextMatrix(0, 0) = "图书编号"
    .TextMatrix(0, 1) = "图书名称"
    .TextMatrix(0, 2) = "出版日期"
    .TextMatrix(0, 3) = "图书价格"
    .TextMatrix(0, 4) = "现存量"
    .TextMatrix(0, 5) = "书架位置"
    .ColAlignment(0) = 1
    .ColWidth(0) = 1000
    .ColWidth(1) = 1800
    .ColWidth(2) = 1000
    .ColWidth(3) = 800
    .ColWidth(4) = 800
End With

Dim sql As String
    
    '借书----按图书编号显示图书信息
    If frmborrow_read.opt借书.Value Then
      With bookGrid
        .Cols = 6
        .TextMatrix(0, 4) = "现存量"
        .ColWidth(5) = 1000
      End With
        sql = "select * from tsxxb where 现存量 > 0"

    End If



   '归还/续借----按图书编号显示图书信息
   If frmborrow_read.opt归还.Value Or frmborrow_read.opt续借.Value Then
     With bookGrid
          .Cols = 10
          .TextMatrix(0, 4) = "借阅数量"
          .TextMatrix(0, 6) = "借阅日期"
          .TextMatrix(0, 7) = "归还日期"
          .TextMatrix(0, 8) = "续借次数"
          .TextMatrix(0, 9) = "操作员"
          .ColWidth(5) = 800
          .ColWidth(6) = 800
      End With
    
'      Call backReturnBookChoose
       sql = "select * from jsxxb where 读者编号 = '" & Trim(frmborrow_read.txt读者编号.Text) & "'"
       
   End If
   
   Call borrowBookChoose(sql)

End Sub




Private Sub txt图书编号_Change()
    Dim sql As String
    
    '借书----按图书编号显示图书信息
    If frmborrow_read.opt借书.Value Then
    
        sql = "select * from tsxxb where 图书编号 like '" & Trim(txt图书编号.Text) & "%' and 现存量 > 0"
 
        If txt图书编号.Text = "" And txt图书名称.Text = "" Then
             sql = "select * from tsxxb where 现存量 > 0"
        End If

    End If

     
  
   '归还/续借----按图书编号显示图书信息
'   If frmborrow_read.opt归还.Value Or frmborrow_read.opt续借.Value Then
'       Dim rs As New ADODB.Recordset, rs2 As New ADODB.Recordset
'       Dim sql2 As String
'
'       sql = "select * from jsxxb where  读者编号 = '" & Trim(frmborrow_read.txt读者编号.Text) & "' and 现存量 > 0"
'      If txt图书编号.Text = "" And txt图书名称.Text = "" Then
'          Call backReturnBookChoose
'      Else
'          Set rs = TransactSQL(sql)
'          bookGrid.Rows = 1
'          While Not rs.EOF
'               If Left(rs(0), Len(Trim(txt图书编号.Text))) = Trim(txt图书编号.Text) Then
'                   sql2 = "select * from tsxxb where 图书编号='" & rs(0) & "'"
'                   Set rs2 = TransactSQL(sql2)
'                   bookGrid.AddItem rs2(0) & vbTab & rs2(1) & vbTab & rs2(15) & vbTab & rs2(11) & vbTab & rs2(12) & vbTab & rs2(5) & vbTab & rs(5)
'                    rs2.Close
'               End If
'               rs.MoveNext
'          Wend
'          rs.Close
'      End If
'   End If

     If frmborrow_read.opt归还.Value Or frmborrow_read.opt续借.Value Then
           Dim rs As New ADODB.Recordset, rs2 As New ADODB.Recordset
           Dim sql2 As String
    
           sql = "select * from jsxxb where  图书编号 like '" & Trim(txt图书编号.Text) & "%' and 读者编号 = '" & _
                 Trim(frmborrow_read.txt读者编号.Text) & "'"
                 
           If txt图书编号.Text = "" And txt图书名称.Text = "" Then
              sql = "select * from jsxxb where 读者编号 = '" & Trim(frmborrow_read.txt读者编号.Text) & "'"
           End If
    End If

   Call borrowBookChoose(sql)
 
End Sub

Private Sub txt图书名称_Change()
    Dim sql As String
    
    '借书----按图书名称显示图书信息
'    If frmborrow_read.opt借书.Value Then
'        sql = "select * from tsxxb where 图书名称 like '" & Trim(txt图书名称.Text) & "%' and 现存量 > 0"
'        If txt图书编号.Text = "" And txt图书名称.Text = "" Then
'             sql = "select * from tsxxb where 现存量 > 0 "
'        End If
'        Call borrowBookChoose(sql)
'    End If
     
    If frmborrow_read.opt借书.Value Then
    
        sql = "select * from tsxxb where 图书名称 like '" & Trim(txt图书名称.Text) & "%' and 现存量 > 0"
 
        If txt图书名称.Text = "" And txt图书名称.Text = "" Then
             sql = "select * from tsxxb where 现存量 > 0"
        End If

    End If

   '归还/续借----按图书名称显示图书信息
'   If frmborrow_read.opt归还.Value Or frmborrow_read.opt续借.Value Then
'       Dim rs As New ADODB.Recordset, rs2 As New ADODB.Recordset
'       Dim sql2 As String
'      sql = "select * from jsxxb where  读者= '" & frmborrow_read.txt读者编号.Text & "' and 现存量 > 0"
'      If txt图书编号.Text = "" And txt图书名称.Text = "" Then
'          Call backReturnBookChoose
'      Else
'          Set rs = TransactSQL(sql)
'           bookGrid.Rows = 1
'          While Not rs.EOF
'               If Left(rs(1), Len(Trim(txt图书名称.Text))) = Trim(txt图书名称.Text) Then
'                   sql2 = "select * from tsxxb where 图书名称='" & rs(1) & "'"
'                   Set rs2 = TransactSQL(sql2)
'                   bookGrid.AddItem rs2(0) & vbTab & rs2(1) & vbTab & rs2(15) & vbTab & rs2(11) & vbTab & rs2(12) & vbTab & rs2(5) & vbTab & rs(5)
'                    rs2.Close
'               End If
'               rs.MoveNext
'          Wend
'          rs.Close
'      End If
'   End If

    If frmborrow_read.opt归还.Value Or frmborrow_read.opt续借.Value Then
           Dim rs As New ADODB.Recordset, rs2 As New ADODB.Recordset
           Dim sql2 As String
    
           sql = "select * from jsxxb where  图书名称 like '" & Trim(txt图书名称.Text) & "%' and 读者编号 = '" & _
                 Trim(frmborrow_read.txt读者编号.Text) & "'"
                 
           If txt图书编号.Text = "" And txt图书名称.Text = "" Then
              sql = "select * from jsxxb where 读者编号 = '" & Trim(frmborrow_read.txt读者编号.Text) & "'"
           End If
    End If

   Call borrowBookChoose(sql)
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -