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

📄 libary.frm

📁 图书管理系统.一个具有多功能的图书馆里系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
         Caption         =   "图书类别"
      End
      Begin VB.Menu ReaderMnu 
         Caption         =   "读者管理"
      End
      Begin VB.Menu NullMnu2 
         Caption         =   "-"
      End
      Begin VB.Menu ExitMNu 
         Caption         =   "退出系统(&E)"
      End
   End
   Begin VB.Menu system_m 
      Caption         =   "系统管理(&S)"
      Begin VB.Menu SysConfMnu 
         Caption         =   "系统配置"
      End
      Begin VB.Menu RuleMnu 
         Caption         =   "借阅规则"
      End
   End
   Begin VB.Menu HSysMnu 
      Caption         =   "帮助系统(&H)"
      Begin VB.Menu HelpMnu 
         Caption         =   "使用说明"
      End
      Begin VB.Menu TeckMnu 
         Caption         =   "技术支持"
      End
      Begin VB.Menu NullMnu3 
         Caption         =   "-"
      End
      Begin VB.Menu AboutMNu 
         Caption         =   "关于天海图书管理系统(&A)"
      End
   End
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub AboutMNu_Click()
frmAbout.Show
FrmMain.Enabled = False
End Sub

Private Sub AddNewMnu_Click()
AddBook.Show
End Sub

Private Sub BookId2_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 0 And KeyAscii = 13 Then
 BookReturn_Conn
End If
End Sub

Private Sub BookMnu_Click()
BookMange.Show
End Sub

Private Sub BookTxt_DblClick(Index As Integer)
 If Index = 5 Then
   CaleFrm.Show
   CaleFrm.Text1 = 3
   FrmMain.Enabled = False
 End If
End Sub
Private Sub BookTxt_KeyPress(Index As Integer, KeyAscii As Integer)
 If Index = 0 And KeyAscii = 13 Then BookMsg_Conn
End Sub
Private Sub BookReturn_Conn() '还书图片框中
   Dim i As Integer
   Dim sSql As String
   Dim adoPrimaryRS As New Recordset
   On Error GoTo ErrExit
  sSql = "select 图书编号,图书名称,图书类别,借出时间,是否借出,读者工号,读者姓名 from books where 图书编号=" & BookId2(0)
  adoPrimaryRS.Open sSql, tsdata.db, adOpenStatic, adLockOptimistic
    If adoPrimaryRS.Fields(4) = False Then
       MsgBox "对不起,这本书不是你借的!请输入正确的书籍编号!", vbOKOnly, "敬告"
       BookId2(0) = ""
       Exit Sub
     End If
   For i = 1 To 3
     BookId2(i) = adoPrimaryRS.Fields(i)
   Next
   BookId2(4) = Date
   BookId2(6) = Date - adoPrimaryRS.Fields(3)
   ReaderId2.Text = adoPrimaryRS.Fields(5)
   ReaderName2.Text = adoPrimaryRS.Fields(6)
   
   Set adoPrimaryRS = Nothing
   sSql = "select 类别名称,借阅天数 from sort where 类别名称='" & BookId2(2) & "'"
  adoPrimaryRS.Open sSql, tsdata.db, adOpenStatic, adLockOptimistic
  BookId2(5) = adoPrimaryRS.Fields(1)
  BookId2(7) = BookId2(6) - BookId2(5)
  If BookId2(7) < 0 Then BookId2(7) = 0
  BookId2(8) = BookId2(7) * 0.05
   Set adoPrimaryRS = Nothing
   Exit Sub
ErrExit:
    MsgBox "请确认你输入的书号是否正确,或者没有本书!", vbOKOnly, "提示"
     BookId2(0) = ""
End Sub
Private Sub BookMsg_Conn() '图书编号
   Dim i As Integer
   Dim sSql As String
   Dim adoPrimaryRS As New Recordset
  On Error GoTo ErrExit
   sSql = "select 图书编号,图书名称,图书类别,图书作者,出版社,是否借出 from books " & "where 图书编号=" & BookTxt(0)
    adoPrimaryRS.Open sSql, tsdata.db, adOpenStatic, adLockOptimistic
    If adoPrimaryRS.Fields(5) = True Then
       MsgBox "对不起,本书已经借出!请选择其他书籍!", vbOKOnly, "敬告"
       BookTxt(0) = ""
       Exit Sub
     End If
   For i = 1 To 4
     BookTxt(i) = adoPrimaryRS.Fields(i)
   Next
   Set adoPrimaryRS = Nothing
   Exit Sub
ErrExit:
    MsgBox "对不起,书库中没有这本书!", vbOKOnly, "敬告"
    BookTxt(0) = ""
End Sub
Private Sub Borrow_Conn(Index As Integer) '借书还书
   Dim i As Integer
   Dim sSql As String
   Dim adoPrimaryRS As New Recordset
  On Error GoTo ErrExit
  
   If Index = 1 Then '借书
      sSql = "select 借出时间,是否借出,读者工号,读者姓名 from books " & "where 图书编号=" & BookTxt(0)
      adoPrimaryRS.Open sSql, tsdata.db, adOpenKeyset, adLockOptimistic, adCmdText
      adoPrimaryRS!借出时间 = Date
      adoPrimaryRS!是否借出 = True
      adoPrimaryRS!读者工号 = ReadId.Text
      adoPrimaryRS!读者姓名 = ReaderName.Text
       For i = 0 To 4
       BookTxt(i) = ""
      Next
    ElseIf Index = 2 Then '还书
       sSql = "select 借出时间,是否借出,读者工号,读者姓名 from books " & "where 图书编号=" & BookId2(0)
       adoPrimaryRS.Open sSql, tsdata.db, adOpenKeyset, adLockOptimistic, adCmdText
       adoPrimaryRS.Fields(0) = Null
      adoPrimaryRS.Fields(1) = False
      adoPrimaryRS.Fields(2) = Null
      adoPrimaryRS.Fields(3) = Null
     Else  '续借
       sSql = "select 借出时间,是否借出,读者工号,读者姓名 from books " & "where 图书编号=" & BookId2(0)
       adoPrimaryRS.Open sSql, tsdata.db, adOpenKeyset, adLockOptimistic, adCmdText
      adoPrimaryRS.Fields(0) = Date
    End If
     For i = 0 To 8
      BookId2(i) = ""
     Next
    ReaderId2 = "": ReaderName2 = ""
    adoPrimaryRS.Update
    'adoPrimaryRS.MoveFirst
    Set adoPrimaryRS = Nothing
    Exit Sub
ErrExit:
    MsgBox "请确认你输入的书号是否正确,或者没有本书!", vbOKOnly, "提示"
End Sub

Private Sub BorrowMnu_Click()
BorrowFrm.Show
End Sub

Private Sub CmdBorrow_Click()
 Borrow_Conn 1
 Data_Reader ReadId.Text
End Sub

Private Sub CmdClear_Click()
Dim i As Integer
 For i = 0 To 4
  BookTxt(i) = ""
 Next
End Sub

Private Sub Command1_Click()
If ReaderName = "" And ReadId = "" Then
   MsgBox "请先登录读者!", vbOKOnly
   ReadId = "": ReaderName = ""
   Exit Sub
 End If
 BookTxt(5) = Date
Data_Reader ReadId.Text
End Sub

Private Sub Command2_Click()
aa.Show
End Sub

Private Sub ExitMNu_Click()
  End
End Sub

Private Sub Form_Load()
  StatusBar1.Panels(6).Text = Date
  Picture1.Visible = True
  Picture2.Visible = False
End Sub

Private Sub P2Cmdgh_Click()
Borrow_Conn 2
End Sub

Private Sub P2Cmdxj_Click()
Borrow_Conn 3
End Sub

Private Sub ReaderMnu_Click()
Reader.Show
End Sub
Private Sub ReaderName_KeyPress(KeyAscii As Integer)
  Dim a As String
 a = ReaderName.Text
 If KeyAscii = 13 Then Reader_Conn 2, a
End Sub
Private Sub ReadId_KeyPress(KeyAscii As Integer)
Dim a As String
a = ReadId.Text
  If KeyAscii = 13 Then Reader_Conn 1, a
End Sub
Private Sub Reader_Conn(i As Integer, mStr As String)
   Dim j As Integer
   Dim sSql As String
  Dim adoPrimaryRS As New Recordset
  sSql = "select 读者工号,读者姓名 from user "
 adoPrimaryRS.Open sSql, tsdata.db, adOpenStatic, adLockOptimistic
  If i = 1 Then
    For j = 0 To adoPrimaryRS.RecordCount - 1
      If adoPrimaryRS.Fields(0) = Val(mStr) Then
        ReaderName.Text = adoPrimaryRS.Fields(1)
        Exit Sub
      End If
      adoPrimaryRS.MoveNext
    Next j
   Else
     For j = 0 To adoPrimaryRS.RecordCount - 1
       If adoPrimaryRS.Fields(1) = mStr Then
          ReadId.Text = adoPrimaryRS.Fields(0)
          Exit Sub
        End If
        adoPrimaryRS.MoveNext
     Next j
  End If
 Set adoPrimaryRS = Nothing
End Sub

Private Sub SortMnu_Click()
 BookSort.Show
End Sub

Private Sub SysConfMnu_Click()
frmOptions.Show
End Sub

Private Sub TabStrip1_Click()
 Select Case TabStrip1.SelectedItem.Key
   Case "key1"
      Picture1.Visible = True
      Picture2.Visible = False
      ReadId.SetFocus
   Case "key2"
      Picture1.Visible = False
      Picture2.Visible = True
      BookId2(0).SetFocus
End Select
End Sub

Private Sub TeckMnu_Click()
 FrmTeck.Show
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
 Case "key1"
  BookMange.Show
 Case "key2"
  AddBook.Show
 Case "key3"
  BorrowFrm.Show
 Case "key4"
  BookSort.Show
 Case "key5"
  Reader.Show
 Case "key6"
   
 Case "key7"
  End
End Select

End Sub
Private Sub Data_Reader(Borrows As String)
 '连接借数据库,显示阅者全部借书情况
    Dim sSql As String
    Dim datPrimaryRS As New Recordset
    On Error GoTo ErrExit
    ' 设置字符串
    sSql = "select 图书编号,图书名称,图书类别,图书作者,出版社,借出时间,备注 from books " & "where 读者工号=" & Borrows & " Order by 图书编号"
    ' 打开连接
    
    ' 使用提供的集合创建 recordset
    'Set datPrimaryRs = New Recordset
   
    datPrimaryRS.CursorLocation = adUseClient
    datPrimaryRS.Open sSql, tsdata.db, adOpenForwardOnly, adLockReadOnly
       Set BorrowMgrid.DataSource = datPrimaryRS
    With BorrowMgrid

        .Redraw = False
        ' 设置网格列宽度
        .ColWidth(0) = -1
        .ColWidth(1) = -1
        .ColWidth(2) = -1
        .ColWidth(3) = -1
        .ColWidth(4) = -1
        .ColWidth(5) = -1
        .ColWidth(6) = -1

        ' 设置网格样式
        .AllowBigSelection = True
        .FillStyle = flexFillRepeat

        ' 将标头作成粗体
        .Row = 0
        .Col = 0
        .RowSel = .FixedRows - 1
        .ColSel = .Cols - 1
        .CellFontBold = True

        .AllowBigSelection = False
        .FillStyle = flexFillSingle
        .Redraw = True

       ' .FormatString = "图书编号|图书名称|类别编号|图书类别|图书作者|图书价格|出版社|出版时间|入库时间|是否借出|借出时间|读者姓名|备注"
    
    End With
  Set datPrimaryRS = Nothing
ErrExit:
 
End Sub

⌨️ 快捷键说明

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