?? borrowbook.vb
字號:
Me.btnLend.Size = New System.Drawing.Size(48, 32)
Me.btnLend.TabIndex = 0
Me.btnLend.Text = "借出"
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(104, 16)
Me.btnClear.Name = "btnClear"
Me.btnClear.Size = New System.Drawing.Size(48, 32)
Me.btnClear.TabIndex = 0
Me.btnClear.Text = "清空"
'
'btnClose
'
Me.btnClose.Location = New System.Drawing.Point(192, 16)
Me.btnClose.Name = "btnClose"
Me.btnClose.Size = New System.Drawing.Size(48, 32)
Me.btnClose.TabIndex = 0
Me.btnClose.Text = "關閉"
'
'GroupBox5
'
Me.GroupBox5.Controls.Add(Me.rdoBookId)
Me.GroupBox5.Controls.Add(Me.rdoBarCode)
Me.GroupBox5.Location = New System.Drawing.Point(592, 0)
Me.GroupBox5.Name = "GroupBox5"
Me.GroupBox5.Size = New System.Drawing.Size(168, 160)
Me.GroupBox5.TabIndex = 3
Me.GroupBox5.TabStop = False
Me.GroupBox5.Text = "選擇圖書關鍵字"
'
'rdoBookId
'
Me.rdoBookId.Checked = True
Me.rdoBookId.Location = New System.Drawing.Point(16, 32)
Me.rdoBookId.Name = "rdoBookId"
Me.rdoBookId.TabIndex = 0
Me.rdoBookId.TabStop = True
Me.rdoBookId.Text = "圖書編號"
'
'rdoBarCode
'
Me.rdoBarCode.Location = New System.Drawing.Point(16, 72)
Me.rdoBarCode.Name = "rdoBarCode"
Me.rdoBarCode.TabIndex = 0
Me.rdoBarCode.Text = "條形碼"
'
'Label4
'
Me.Label4.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))
Me.Label4.Location = New System.Drawing.Point(592, 168)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(168, 104)
Me.Label4.TabIndex = 4
Me.Label4.Text = "先在讀者學號處輸入讀者學號然后按回車鍵,調出讀者信息 再在圖書編號/條碼處輸入圖書的編號/條碼調出圖書信息"
'
'grdLendBook
'
Me.grdLendBook.DataMember = ""
Me.grdLendBook.Dock = System.Windows.Forms.DockStyle.Bottom
Me.grdLendBook.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.grdLendBook.Location = New System.Drawing.Point(0, 327)
Me.grdLendBook.Name = "grdLendBook"
Me.grdLendBook.ReadOnly = True
Me.grdLendBook.Size = New System.Drawing.Size(760, 184)
Me.grdLendBook.TabIndex = 5
'
'frmBorrowBook
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(760, 511)
Me.Controls.Add(Me.grdLendBook)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.GroupBox5)
Me.Controls.Add(Me.GroupBox4)
Me.Controls.Add(Me.GroupBox3)
Me.Controls.Add(Me.GroupBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.Name = "frmBorrowBook"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "借書"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox3.ResumeLayout(False)
Me.GroupBox4.ResumeLayout(False)
Me.GroupBox5.ResumeLayout(False)
CType(Me.grdLendBook, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private bookds As New DataSet
Private readerds As New DataSet
Private borrowds As New DataSet
Private bookstr As String
Private readerstr As String
Private Sub rdoBookId_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoBookId.CheckedChanged
labInfo.Text = "圖書編號"
End Sub
Private Sub rdoBarCode_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoBarCode.CheckedChanged
labInfo.Text = "條形碼"
End Sub
Private Sub frmBorrowBook_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtBorrowTime.Text = Date.Now.ToShortDateString
End Sub
Private Sub txtReaderId_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtReaderId.KeyDown
If e.KeyCode = Keys.Return Then
If txtReaderId.Text <> "" Then
readerstr = "select * from 讀者 where 學號='" & txtReaderId.Text & "'"
Try
readerds.Clear()
OleConn.SelectQuery(readerstr, readerds)
If readerds.Tables.Count < 1 Or readerds.Tables(0).Rows.Count < 1 Then
MsgBox("找不到此讀者")
Else
Dim dr As DataRow = readerds.Tables(0).Rows(0)
If Not dr.IsNull("姓名") Then
txtReaderName.Text = dr("姓名")
End If
If Not dr.IsNull("性別") Then
txtReaderSex.Text = dr("性別")
End If
If Not dr.IsNull("類別") Then
txtReaderType.Text = dr("類別")
End If
If Not dr.IsNull("系別") Then
txtReaderDepartment.Text = dr("系別")
End If
If Not dr.IsNull("聯系電話") Then
txtReaderTelephone.Text = dr("聯系電話")
End If
If Not dr.IsNull("宿舍") Then
txtReaderAddress.Text = dr("宿舍")
End If
If Not dr.IsNull("登記日期") Then
txtReaderAddTime.Text = dr("登記日期")
End If
If Not dr.IsNull("借書次數") Then
txtLendCount.Text = dr("借書次數")
End If
If Not dr.IsNull("可借書數") Then
txtCanBorrowCount.Text = dr("可借書數")
End If
If Not dr.IsNull("未還書數") Then
txtUnReturnedCount.Text = dr("未還書數")
End If
If Not dr.IsNull("備注") Then
txtDemo.Text = dr("備注")
End If
txtReturnTime.Text = CDate(txtBorrowTime.Text).AddDays(CInt(dr.Item("借書期限")))
borrowstr = "select * from 借出圖書 where 借書者學號='" & txtReaderId.Text & "' and 在館='否'"
borrowds.Clear()
OleConn.SelectQuery(borrowstr, borrowds)
grdLendBook.SetDataBinding(borrowds, "Table")
txtBookId.Enabled = True
btnLend.Enabled = False
txtBookId.Focus()
End If
Catch ex As Exception
OleConn.DisplayError(ex)
End Try
End If
End If
End Sub
Private Sub txtBookId_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtBookId.KeyDown
If e.KeyCode = Keys.Return Then
If txtBookId.Text <> "" Then
Try
If rdoBookId.Checked Then
bookstr = "select * from 圖書 where 圖書編號='" & txtBookId.Text & "'"
Else
bookstr = "select * from 圖書 where 條形碼='" & txtBookId.Text & "'"
End If
bookds.Clear()
OleConn.SelectQuery(bookstr, bookds)
If bookds.Tables.Count < 1 Or bookds.Tables(0).Rows.Count < 1 Then
MsgBox("找不到此書")
Else
Dim dr As DataRow = bookds.Tables(0).Rows(0)
If Not dr.IsNull("書名") Then
txtBookName.Text = dr.Item("書名")
End If
If Not dr.IsNull("類別") Then
txtBookType.Text = dr("類別")
End If
If Not dr.IsNull("作者") Then
txtBookAuthor.Text = dr("作者")
End If
If Not dr.IsNull("出版社") Then
txtPublisher.Text = dr("出版社")
End If
If Not dr.IsNull("出版時間") Then
txtPublishTime.Text = dr("出版時間")
End If
If Not dr.IsNull("圖書價格") Then
txtBookPrice.Text = dr("圖書價格")
End If
If Not dr.IsNull("圖書總數") Then
txtBookCount.Text = dr("圖書總數")
End If
If Not dr.IsNull("現存數量") Then
txtExistCount.Text = dr("現存數量")
End If
btnLend.Enabled = True
End If
Catch ex As Exception
OleConn.DisplayError(ex)
End Try
End If
End If
End Sub
Private Sub btnLend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLend.Click
Try
Dim readerdr As DataRow = readerds.Tables(0).Rows(0)
If readerdr.Item("未還書數") >= readerdr.Item("可借書數") Then
MsgBox("讀者的可借書數已經達到上限")
Else
Dim bookdr As DataRow = bookds.Tables(0).Rows(0)
If bookdr.Item("現存數量") < 1 Then
MsgBox("此書已全部借出")
Else
Dim str As String = "圖書編號='" & txtBookId.Text & "'"
Dim dr As DataRow() = borrowds.Tables(0).Select(str)
If dr.GetLength(0) > 1 Then
MsgBox("讀者已經借了此書,并且還未還")
Else
Dim borrowdr As DataRow = borrowds.Tables(0).NewRow
borrowdr.Item("圖書編號") = txtBookId.Text
borrowdr.Item("書名") = bookdr.Item("書名")
borrowdr.Item("借書者學號") = readerdr.Item("學號")
borrowdr.Item("借書者姓名") = readerdr.Item("姓名")
borrowdr.Item("借書日期") = txtBorrowTime.Text
borrowdr.Item("應還日期") = txtReturnTime.Text
borrowdr.Item("在館") = "否"
borrowdr.Item("條形碼") = bookdr.Item("條形碼")
borrowdr.Item("出版社") = bookdr.Item("出版社")
borrowdr.Item("出版時間") = bookdr.Item("出版時間")
borrowdr.Item("類別") = bookdr.Item("類別")
borrowdr.Item("圖書價格") = bookdr.Item("圖書價格")
borrowds.Tables(0).Rows.Add(borrowdr)
OleConn.Adapter.SelectCommand.CommandText = borrowstr
OleConn.UpDate(borrowds.Tables(0))
borrowds.AcceptChanges()
readerdr.BeginEdit()
readerdr.Item("未還書數") = readerdr.Item("未還書數") + 1
readerdr.Item("借書次數") = readerdr.Item("借書次數") + 1
readerdr.Item("借書日期") = txtBorrowTime.Text
readerdr.EndEdit()
OleConn.Adapter.SelectCommand.CommandText = readerstr
OleConn.UpDate(readerds.Tables(0))
readerds.AcceptChanges()
txtUnReturnedCount.Text = readerdr.Item("未還書數")
txtLendCount.Text = readerdr.Item("借書次數")
bookdr.BeginEdit()
bookdr.Item("現存數量") = bookdr.Item("現存數量") - 1
bookdr.Item("借出次數") = bookdr.Item("借出次數") + 1
bookdr.EndEdit()
OleConn.Adapter.SelectCommand.CommandText = bookstr
OleConn.UpDate(bookds.Tables(0))
bookds.AcceptChanges()
txtExistCount.Text = bookdr.Item("現存數量")
btnLend.Enabled = False
MsgBox("借書成功")
End If
End If
End If
Catch ex As Exception
OleConn.DisplayError(ex)
End Try
End Sub
Private Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click
borrowds.Clear()
txtReaderId.Text = ""
txtReaderName.Text = ""
txtReaderSex.Text = ""
txtReaderType.Text = ""
txtReaderDepartment.Text = ""
txtReaderTelephone.Text = ""
txtReaderAddress.Text = ""
txtReaderAddTime.Text = ""
txtLendCount.Text = ""
txtCanBorrowCount.Text = ""
txtUnReturnedCount.Text = ""
txtDemo.Text = ""
txtBookId.Text = ""
txtBookName.Text = ""
txtBookType.Text = ""
txtBookAuthor.Text = ""
txtPublisher.Text = ""
txtPublishTime.Text = ""
txtBookPrice.Text = ""
txtBookCount.Text = ""
txtExistCount.Text = ""
txtReturnTime.Text = ""
btnLend.Enabled = False
txtReaderId.Focus()
End Sub
Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -