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

📄 frmmain.frm

📁 自考软件工程_宋瑞峰 自考软件工程_宋瑞峰
💻 FRM
📖 第 1 页 / 共 4 页
字号:
    TxtBookPrice2.Text = rs.Fields("价钱")
    TxtBookPress2.Text = rs.Fields("出版社")
    TxtBookKind2.Text = rs.Fields("类别")
    TxtBookAuthor2.Text = rs.Fields("作者")
    TxtBorrowDate.Text = rs.Fields("借阅日期")
    dateTemp = rs.Fields("借阅日期")
    iDays = Date - dateTemp
    TxtDays.Text = iDays
    CmdBack.Visible = True
    rs.Close
    Set rs = Nothing
End If
End Sub

Private Sub CmdExit_Click()
'读者退出登陆状态
CmbBookNo.Clear
TxtReaderName.Text = ""
TxtReaderNo.Text = ""
TxtBorrowedCount.Text = ""
TxtReaderName2.Text = ""
TxtReaderNo2.Text = ""
TxtBorrowedCount2.Text = ""
TxtBookNo.Locked = True
TxtBookName.Text = ""
TxtBookPrice.Text = ""
TxtBookPress.Text = ""
TxtBookKind.Text = ""
TxtBookAuthor.Text = ""
TxtRemainCount.Text = ""
TxtBookNo.Text = ""
CmdBorrow.Visible = False
With MSFlexGrid1
    .Rows = 1
    .Cols = 8
    .TextMatrix(0, 1) = "姓名"
    .TextMatrix(0, 2) = "读者类别"
    .TextMatrix(0, 3) = "图书编号"
    .TextMatrix(0, 4) = "书名"
    .TextMatrix(0, 5) = "价格"
    .TextMatrix(0, 6) = "出版社"
    .TextMatrix(0, 7) = "借阅日期"
    .ColWidth(0) = 500
    .ColWidth(1) = 1000
    .ColWidth(2) = 900
    .ColWidth(3) = 1200
    .ColWidth(4) = 2200
    .ColWidth(5) = 1000
    .ColWidth(6) = 2000
    .ColWidth(7) = 1500
End With
End Sub

Private Sub CmdLogin_Click()
Dim rs As ADODB.Recordset
Dim SQL As String

'显示读者登陆对话框
FrmReaderLogin.Show vbModal
If FrmReaderLogin.strUserName <> "" Then
    SQL = "SELECT 借书证号,姓名,已借图书 FROM reader WHERE 借书证号='" & FrmReaderLogin.strUserName & "'"
    Set rs = ExecuteSQL(SQL)
    If Not (rs.EOF And rs.BOF) Then
        TxtReaderName.Text = rs.Fields("姓名")
        TxtReaderNo.Text = rs.Fields("借书证号")
        TxtBorrowedCount.Text = rs.Fields("已借图书")
        TxtReaderName2.Text = rs.Fields("姓名")
        TxtReaderNo2.Text = rs.Fields("借书证号")
        TxtBorrowedCount2.Text = rs.Fields("已借图书")
        TxtBookNo.Locked = False
        Call DisplayFlexGrid
    End If
    rs.Close
    Set rs = Nothing
End If
End Sub

Private Sub Form_Load()


With MSFlexGrid1
    .Rows = 1
    .Cols = 8
    .TextMatrix(0, 1) = "姓名"
    .TextMatrix(0, 2) = "读者类别"
    .TextMatrix(0, 3) = "图书编号"
    .TextMatrix(0, 4) = "书名"
    .TextMatrix(0, 5) = "价格"
    .TextMatrix(0, 6) = "出版社"
    .TextMatrix(0, 7) = "借阅日期"
    .ColWidth(0) = 500
    .ColWidth(1) = 1000
    .ColWidth(2) = 900
    .ColWidth(3) = 1200
    .ColWidth(4) = 2200
    .ColWidth(5) = 1000
    .ColWidth(6) = 2000
    .ColWidth(7) = 1500
End With

CommonDialog1.InitDir = App.Path & "\backup"

FrmLogin.Show vbModal

If FrmLogin.bOK = False Then
   Unload Me
End If

End Sub



Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("是否要退出吗?", vbQuestion + vbYesNo, "加平图书管理系统") = vbNo Then
    Cancel = 1
End If

End Sub

Private Sub Timer1_Timer()
Me.StatusBar1.Panels(4) = Date + Time
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1
    SSTab1.Tab = 0
    
Case 2
    SSTab1.Tab = 1
    
Case 4
    FrmAddReader.Show
    
Case 5
    FrmAddBook.Show
    
Case 7
    FrmBookBrowse.Show
    
Case 8
    FrmReaderBrowse.Show
    
Case 9
    FrmBorrowBrowse.Show
    
Case 11
    FrmLogin.Show vbModal
    If FrmLogin.bOK = False Then
        End
    End If
    
Case 13
    frmAbout.Show
    
Case 15
    Unload Me
End Select
End Sub


Private Sub TxtBookNo_Change()
TxtBookName.Text = ""
TxtBookPrice.Text = ""
TxtBookPress.Text = ""
TxtBookKind.Text = ""
TxtBookAuthor.Text = ""
TxtRemainCount.Text = ""
CmdBorrow.Visible = False
End Sub

Private Sub TxtBookNo_KeyDown(KeyCode As Integer, Shift As Integer)
Dim rs As ADODB.Recordset
Dim SQL As String

If KeyCode = 13 Then
   '进行输入合法性检查
   If TxtBookNo.Text = "" Then
       MsgBox "对不起,请输入图书编号.", vbExclamation + vbOKOnly, "警告"
       Exit Sub
   End If
   
   '查询该图书显示相关信息
   SQL = "SELECT * FROM book WHERE 图书编号='" & TxtBookNo.Text & "'"
   Set rs = ExecuteSQL(SQL)
   If rs.EOF And rs.BOF Then
       MsgBox "对不起,图书编号错误,无此图书.", vbExclamation + vbOKOnly, "警告"
       rs.Close
       Set rs = Nothing
       Exit Sub
   Else
       TxtBookName.Text = rs.Fields("书名")
       TxtBookPrice.Text = rs.Fields("价钱")
       TxtBookPress.Text = rs.Fields("出版社")
       TxtBookKind.Text = rs.Fields("类别")
       TxtBookAuthor.Text = rs.Fields("作者")
       TxtRemainCount.Text = rs.Fields("剩余量")
       rs.Clone
       Set rs = Nothing
       If Val(Trim(TxtRemainCount.Text)) > 0 Then
           CmdBorrow.Visible = True
       Else
           MsgBox "对不起,该图书暂时没有库存!", vbInformation + vbOKOnly, "加平图书管理系统"
           CmdBorrow.Visible = False
       End If
   End If
End If
End Sub

'将数据在FlexGrid中显示
Public Sub DisplayFlexGrid()
Dim rs As ADODB.Recordset
Dim SQL As String

CmbBookNo.Clear

With MSFlexGrid1
    .Rows = 1
    .Cols = 8
    .TextMatrix(0, 1) = "姓名"
    .TextMatrix(0, 2) = "读者类别"
    .TextMatrix(0, 3) = "图书编号"
    .TextMatrix(0, 4) = "书名"
    .TextMatrix(0, 5) = "价钱"
    .TextMatrix(0, 6) = "出版社"
    .TextMatrix(0, 7) = "借阅日期"
    .ColWidth(0) = 500
    .ColWidth(1) = 1000
    .ColWidth(2) = 900
    .ColWidth(3) = 1200
    .ColWidth(4) = 2200
    .ColWidth(5) = 1000
    .ColWidth(6) = 2000
    .ColWidth(7) = 1500
    
    '三表联接查询
    SQL = "SELECT 姓名,读者类别,book.图书编号,书名,价钱,出版社,借阅日期 FROM book,reader,borrow"
    SQL = SQL & " WHERE book.图书编号 = borrow.图书编号 AND reader.借书证号 = borrow.借书证号 AND reader.借书证号='" & TxtReaderNo.Text & "' AND borrow.是否已还 = FALSE"
    Set rs = ExecuteSQL(SQL)
    Do While Not rs.EOF
        CmbBookNo.AddItem rs.Fields("图书编号"), .Rows - 1
        .Rows = .Rows + 1
        .TextMatrix(.Rows - 1, 1) = rs.Fields("姓名")
        .TextMatrix(.Rows - 1, 2) = rs.Fields("读者类别")
        .TextMatrix(.Rows - 1, 3) = rs.Fields("图书编号")
        .TextMatrix(.Rows - 1, 4) = rs.Fields("书名")
        .TextMatrix(.Rows - 1, 5) = rs.Fields("价钱")
        .TextMatrix(.Rows - 1, 6) = rs.Fields("出版社")
        .TextMatrix(.Rows - 1, 7) = rs.Fields("借阅日期")
        rs.MoveNext
    Loop
    rs.Clone
    Set rs = Nothing
End With
End Sub

Private Sub 表清理_Click()
Dim SQL As String

If MsgBox("是否清除所有还书记录", vbOKCancel + vbCritical, "删除") = vbOK Then
    SQL = "DELETE FROM borrow WHERE 是否已还 = TRUE"
    ExecuteSQL (SQL)
End If
End Sub

Private Sub 读者浏览_Click()
FrmReaderBrowse.Show
End Sub

Private Sub 罚款记录_Click()
FrmPunish.Show
End Sub

Private Sub 关于_Click()
frmAbout.Show
End Sub

Private Sub 还书_Click()
SSTab1.Tab = 1
End Sub

Private Sub 借书_Click()
SSTab1.Tab = 0
End Sub

Private Sub 借阅浏览_Click()
FrmBorrowBrowse.Show
End Sub

Private Sub 今日借书记录_Click()
MsgBox "对不起,由于缺少打印控件,该功能暂时无法实现!", vbExclamation + vbOKOnly, "对不起"

End Sub

Private Sub 删除备份_Click()
Dim strFileTo As String

On Error GoTo err
CommonDialog1.FileName = ""
CommonDialog1.ShowSave
strFileTo = CommonDialog1.FileName
If strFileTo = "" Then Exit Sub

Kill strFileTo
Exit Sub

err:
   MsgBox "删除出错"
   
End Sub

Private Sub 数据备份_Click()
Dim strFileTo As String
Dim strFileFrom As String

On Error GoTo err
CommonDialog1.FileName = ""
CommonDialog1.ShowSave
strFileTo = CommonDialog1.FileName

If strFileTo = "" Then Exit Sub

strFileFrom = App.Path & "\book.mdb"

FileCopy strFileFrom, strFileTo
Exit Sub

err:
   MsgBox "数据备份出错"
End Sub

Private Sub 图书浏览_Click()
FrmBookBrowse.Show
End Sub

Private Sub 外借图书_Click()
DataReportBookOut.Show

End Sub

Private Sub 我的网站_Click()
ShellExecute Me.hwnd, "open", "http://jiaping.9xc.com", "", "", SW_SHOWNORMAL
End Sub

Private Sub 系统设置_Click()
FrmSetSystem.Show
End Sub

Private Sub 用户管理_Click()
FrmUserManage.Show
End Sub

Private Sub 源代码_Click()
Dim strFile As String

strFile = Trim(App.Path)
If Right(strFile, 1) <> "\" Then strFile = strFile & "\"
strFile = strFile & "code.txt"
ShellExecute Me.hwnd, "open", "notepad", strFile, "", 1
End Sub

Private Sub 在馆图书_Click()
DataReportBookIn.Show
End Sub

Private Sub 注销用户_Click()
FrmLogin.Show
End Sub

⌨️ 快捷键说明

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