frmBorrow1.frm
资源名称:图书馆管理系统11.rar [点击查看]
上传用户:wang_li173
上传日期:2007-06-22
资源大小:43k
文件大小:19k
源码类别:
系统设计方案
开发平台:
Visual Basic
- VERSION 5.00
- Begin VB.Form frmBorrow1
- BorderStyle = 3 'Fixed Dialog
- Caption = "借书信息"
- ClientHeight = 4368
- ClientLeft = 48
- ClientTop = 336
- ClientWidth = 8112
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 4368
- ScaleWidth = 8112
- ShowInTaskbar = 0 'False
- StartUpPosition = 1 'CenterOwner
- Begin VB.TextBox Text1
- Height = 270
- Left = 1200
- TabIndex = 25
- TabStop = 0 'False
- Top = 3960
- Visible = 0 'False
- Width = 735
- End
- Begin VB.TextBox txtNo
- Height = 270
- Left = 2520
- TabIndex = 20
- TabStop = 0 'False
- Top = 3960
- Visible = 0 'False
- Width = 735
- End
- Begin VB.Frame Frame2
- Caption = "读者信息"
- Height = 3492
- Left = 4080
- TabIndex = 15
- Top = 240
- Width = 3735
- Begin VB.ComboBox cboItem
- Height = 288
- Index = 6
- Left = 1320
- Style = 2 'Dropdown List
- TabIndex = 24
- Top = 1080
- Width = 2175
- End
- Begin VB.ComboBox cboItem
- Height = 288
- Index = 5
- Left = 1320
- Style = 2 'Dropdown List
- TabIndex = 23
- Top = 720
- Width = 2175
- End
- Begin VB.ComboBox cboItem
- Height = 288
- Index = 4
- Left = 1320
- Style = 2 'Dropdown List
- TabIndex = 22
- Top = 360
- Width = 2175
- End
- Begin VB.TextBox txtItem
- Height = 270
- Index = 0
- Left = 1320
- MaxLength = 20
- TabIndex = 5
- Top = 1440
- Width = 2175
- End
- Begin VB.TextBox txtItem
- Height = 1200
- Index = 1
- Left = 240
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 6
- Top = 2160
- Width = 3252
- End
- Begin VB.Label Label2
- Caption = "备 注 信 息:"
- Height = 252
- Index = 7
- Left = 240
- TabIndex = 21
- Top = 1800
- Width = 972
- End
- Begin VB.Label Label2
- Caption = "读者种类:"
- Height = 252
- Index = 11
- Left = 240
- TabIndex = 19
- Top = 1080
- Width = 972
- End
- Begin VB.Label Label2
- Caption = "借书日期:"
- Height = 252
- Index = 6
- Left = 240
- TabIndex = 18
- Top = 1440
- Width = 972
- End
- Begin VB.Label Label2
- Caption = "读者姓名:"
- Height = 255
- Index = 5
- Left = 240
- TabIndex = 17
- Top = 720
- Width = 975
- End
- Begin VB.Label Label2
- Caption = "读者编号:"
- Height = 255
- Index = 4
- Left = 240
- TabIndex = 16
- Top = 360
- Width = 975
- End
- End
- Begin VB.Frame Frame1
- Caption = "书籍信息"
- Height = 3492
- Left = 240
- TabIndex = 9
- Top = 240
- Width = 3735
- Begin VB.TextBox txtItem
- Height = 960
- Index = 5
- Left = 1320
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 4
- Top = 2400
- Width = 2175
- End
- Begin VB.ComboBox cboItem
- Height = 288
- Index = 3
- Left = 1320
- Style = 2 'Dropdown List
- TabIndex = 3
- Top = 1920
- Width = 2175
- End
- Begin VB.ComboBox cboItem
- Height = 288
- Index = 2
- Left = 1320
- Style = 2 'Dropdown List
- TabIndex = 2
- Top = 1440
- Width = 2175
- End
- Begin VB.ComboBox cboItem
- Height = 288
- Index = 1
- Left = 1320
- Style = 2 'Dropdown List
- TabIndex = 1
- Top = 960
- Width = 2175
- End
- Begin VB.ComboBox cboItem
- Height = 288
- Index = 0
- Left = 1320
- Style = 2 'Dropdown List
- TabIndex = 0
- Top = 480
- Width = 2175
- End
- Begin VB.Label Label2
- Caption = "出版社:"
- Height = 255
- Index = 3
- Left = 240
- TabIndex = 14
- Top = 1920
- Width = 975
- End
- Begin VB.Label Label2
- Caption = "书籍名称:"
- Height = 255
- Index = 0
- Left = 240
- TabIndex = 13
- Top = 480
- Width = 975
- End
- Begin VB.Label Label2
- Caption = "书籍类别:"
- Height = 255
- Index = 1
- Left = 240
- TabIndex = 12
- Top = 960
- Width = 975
- End
- Begin VB.Label Label2
- Caption = "书籍备注信息:"
- Height = 252
- Index = 2
- Left = 240
- TabIndex = 11
- Top = 2400
- Width = 1092
- End
- Begin VB.Label Label2
- Caption = "作者姓名:"
- Height = 255
- Index = 16
- Left = 240
- TabIndex = 10
- Top = 1440
- Width = 975
- End
- End
- Begin VB.CommandButton cmdExit
- Caption = "返回 (&X)"
- Height = 375
- Left = 6120
- TabIndex = 8
- Top = 3840
- Width = 1215
- End
- Begin VB.CommandButton cmdSave
- Caption = "保存 (&S)"
- Height = 375
- Left = 4680
- TabIndex = 7
- Top = 3840
- Width = 1215
- End
- End
- Attribute VB_Name = "frmBorrow1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- '是否改动过记录,ture为改过
- Dim mblChange As Boolean
- Dim mrc As ADODB.Recordset
- Public txtSQL As String
- Dim bookNUM As Integer
- Private Sub cboItem_Change(Index As Integer)
- '有变化设置gblchange
- mblChange = True
- End Sub
- Private Sub cboItem_Click(Index As Integer)
- Dim mrcc As ADODB.Recordset
- Dim mrcd As ADODB.Recordset
- Dim intCount As Integer
- Dim MsgText As String
- If gintBOmode = 1 Then
- If Index = 1 Then
- cboItem(0).Clear
- txtSQL = "select distinct bookname from books where booktype = '" & Trim(cboItem(1)) & "'"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
- If Not mrcc.EOF Then
- Do While Not mrcc.EOF
- cboItem(0).AddItem mrcc.Fields(0)
- mrcc.MoveNext
- Loop
- End If
- cboItem(0).ListIndex = 0
- mrcc.Close
- ElseIf Index = 0 Then
- If Trim(cboItem(0)) = "" Then
- MsgBox "请首先选择书籍种类!", vbOKOnly + vbExclamation, "警告"
- cboItem(1).SetFocus
- Exit Sub
- Else
- txtSQL = "select * from books where bookname = '" & Trim(cboItem(0)) & "'"
- Set mrcd = ExecuteSQL(txtSQL, MsgText)
- If Not mrcd.EOF Then
- cboItem(2).Clear
- cboItem(3).Clear
- cboItem(2).AddItem mrcd!bookauthor
- cboItem(3).AddItem mrcd!bookpub
- cboItem(2).ListIndex = 0
- cboItem(3).ListIndex = 0
- txtItem(5) = mrcd!bookmemo
- Text1 = mrcd!BookID
- End If
- mrcd.Close
- End If
- ElseIf Index = 6 Then
- cboItem(5).Clear
- txtSQL = "select distinct readername from readers where readertype = '" & Trim(cboItem(6)) & "'"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
- If Not mrcc.EOF Then
- Do While Not mrcc.EOF
- cboItem(5).AddItem mrcc.Fields(0)
- mrcc.MoveNext
- Loop
- End If
- cboItem(5).ListIndex = 0
- mrcc.Close
- ElseIf Index = 5 Then
- txtSQL = "select * from readers where readername = '" & Trim(cboItem(5)) & "'"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
- If Not mrcc.EOF Then
- cboItem(4).Clear
- cboItem(4).AddItem mrcc!readerno
- cboItem(4).ListIndex = 0
- End If
- mrcc.Close
- End If
- End If
- End Sub
- Private Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
- EnterToTab KeyCode
- End Sub
- Private Sub cmdExit_Click()
- If mblChange And cmdSave.Enabled Then
- If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
- '保存
- Call cmdSave_Click
- End If
- End If
- Unload Me
- End Sub
- Private Sub cmdSave_Click()
- Dim intCount As Integer
- Dim sMeg As String
- Dim mrcc As ADODB.Recordset
- Dim MsgText As String
- For intCount = 0 To 5 Step 5
- If Trim(cboItem(intCount) & " ") = "" Then
- Select Case intCount
- Case 0
- sMeg = "书籍名称"
- Case 5
- sMeg = "读者姓名"
- End Select
- sMeg = sMeg & "不能为空!"
- MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
- txtItem(intCount).SetFocus
- Exit Sub
- End If
- Next intCount
- If Trim(txtItem(0)) = "" Then
- MsgBox "借书日期不能为空!", vbOKOnly + vbExclamation, "警告"
- txtItem(0).SetFocus
- Exit Sub
- End If
- If IsDate(txtItem(0)) Then
- txtItem(0) = Format(txtItem(0), "yyyy-mm-dd")
- Else
- MsgBox "入库时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
- txtItem(0).SetFocus
- Exit Sub
- End If
- If gintBOmode = 2 Then
- txtSQL = "delete from borrowinfo where borrowno = '" & Trim(txtNo) & "'"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
- End If
- txtSQL = "select * from readertype where typename = '" & Trim(cboItem(6)) & "'"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
- If Not mrcc.EOF Then
- bookNUM = mrcc.Fields(2)
- End If
- mrcc.Close
- txtSQL = "select * from borrowinfo where readername = '" & Trim(cboItem(5)) & "' and returndate is null "
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
- If Not mrcc.EOF Then
- Do While Not mrcc.EOF
- bookNUM = bookNUM - 1
- mrcc.MoveNext
- Loop
- End If
- mrcc.Close
- If bookNUM <= 0 Then
- MsgBox "借书数量已经到达极限,不能再借!", vbOKOnly + vbExclamation, "警告"
- Exit Sub
- End If
- txtSQL = "select * from books where bookid = '" & Trim(Text1) & "' and putup <> 'y'"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
- If mrcc.EOF Then
- MsgBox "这本书已经借出!", vbOKOnly + vbExclamation, "警告"
- Exit Sub
- End If
- txtSQL = "select * from borrowinfo"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
- mrcc.AddNew
- mrcc.Fields(0) = Trim(txtNo)
- For intCount = 0 To 1
- mrcc.Fields(intCount + 1) = Trim(cboItem(intCount + 4))
- Next intCount
- mrcc!BookID = Trim(Text1)
- mrcc!bookname = Trim(cboItem(0))
- mrcc!borrowdate = Trim(txtItem(0))
- mrcc.Fields(7) = Trim(txtItem(1))
- mrcc.Update
- mrcc.Close
- txtSQL = "select * from books where bookid = '" & Trim(Text1) & "'"
- Set mrcc = ExecuteSQL(txtSQL, MsgText)
- If Not mrcc.EOF Then
- mrcc!putup = "y"
- End If
- mrcc.Update
- mrcc.Close
- If gintBOmode = 1 Then
- MsgBox "添加借书信息成功!", vbOKOnly + vbExclamation, "添加借书消息"
- Unload Me
- If flagBOedit Then
- Unload frmBorrow
- End If
- frmBorrow.txtSQL = "select borrowno,readerid,readername,bookid,bookname,borrowdate,memo from borrowinfo where returndate is null"
- frmBorrow.Show
- Else
- MsgBox "修改借书信息成功!", vbOKOnly + vbExclamation, "修改借书消息"
- Unload Me
- If flagBOedit Then
- Unload frmBorrow
- End If
- frmBorrow.txtSQL = "select borrowno,readerid,readername,bookid,bookname,borrowdate,memo from borrowinfo where returndate is null"
- frmBorrow.Show
- End If
- End Sub
- Private Sub Form_Load()
- Dim sSql As String
- Dim intCount As Integer
- Dim MsgText As String
- If gintBOmode = 1 Then
- Me.Caption = Me.Caption & "添加"
- '初始化客房信息
- txtSQL = "select DISTINCT booktype from books "
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- If Not mrc.EOF Then
- Do While Not mrc.EOF
- cboItem(1).AddItem Trim(mrc.Fields(0))
- mrc.MoveNext
- Loop
- Else
- MsgBox "请先进行书籍登记!", vbOKOnly + vbExclamation, "警告"
- cmdSave.Enabled = False
- Exit Sub
- End If
- mrc.Close
- txtSQL = "select DISTINCT readertype from readers "
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- If Not mrc.EOF Then
- Do While Not mrc.EOF
- cboItem(6).AddItem Trim(mrc.Fields(0))
- mrc.MoveNext
- Loop
- Else
- MsgBox "请先进行读者登记!", vbOKOnly + vbExclamation, "警告"
- cmdSave.Enabled = False
- Exit Sub
- End If
- mrc.Close
- txtNo = GetRkno
- ElseIf gintBOmode = 2 Then
- Me.Caption = Me.Caption & "修改"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- If Not mrc.EOF Then
- txtNo = mrc!borrowno
- cboItem(4).Clear
- cboItem(4).AddItem mrc!readerid
- cboItem(4).ListIndex = 0
- cboItem(5).Clear
- cboItem(5).AddItem mrc!readername
- cboItem(5).ListIndex = 0
- Text1 = Trim(mrc!BookID)
- cboItem(0).Clear
- cboItem(0).AddItem mrc!bookname
- cboItem(0).ListIndex = 0
- txtItem(0) = mrc!borrowdate
- txtItem(1) = mrc.Fields(6)
- End If
- mrc.Close
- txtSQL = "select distinct readertype from readers where readerno = '" & Trim(cboItem(4)) & "'"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- If Not mrc.EOF Then
- cboItem(6).Clear
- cboItem(6).AddItem mrc.Fields(0)
- cboItem(6).ListIndex = 0
- End If
- mrc.Close
- txtSQL = "select * from books where bookid = '" & Trim(Text1) & "'"
- Set mrc = ExecuteSQL(txtSQL, MsgText)
- If Not mrc.EOF Then
- cboItem(1).Clear
- cboItem(1).AddItem mrc!booktype
- cboItem(1).ListIndex = 0
- cboItem(2).Clear
- cboItem(2).AddItem mrc!bookauthor
- cboItem(2).ListIndex = 0
- cboItem(3).Clear
- cboItem(3).AddItem mrc!bookpub
- cboItem(3).ListIndex = 0
- txtItem(5) = mrc!bookmemo
- mrc!putup = " "
- mrc.Update
- End If
- mrc.Close
- End If
- mblChange = False
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- gintBOmode = 0
- End Sub
- Private Sub txtItem_Change(Index As Integer)
- '有变化设置gblchange
- mblChange = True
- End Sub
- Private Sub txtItem_GotFocus(Index As Integer)
- txtItem(Index).SelStart = 0
- txtItem(Index).SelLength = Len(txtItem(Index))
- End Sub
- Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
- EnterToTab KeyCode
- End Sub
- Private Function GetRkno() As String
- GetRkno = Format(Now, "yymmddhhmmss")
- Randomize
- GetRkno = GetRkno & Int((99 - 10 + 1) * Rnd + 10)
- End Function