图书管理系统ER图-流程图-功能结构图-源代码 第13页

VB+Access图书管理系统

DataGrid1.AllowDelete = False                                 '不可删除

DataGrid1.AllowUpdate = False

If userpow = "guest" Then                                     '权限相关

   Frame2.Enabled = False

End If

Set DataGrid1.DataSource = rs_reader

Exit Sub

loaderror:

   MsgBox Err.Description

End Sub

5、文件名 frmaddbookinfofrmaddbookinfo.frm

功能说明:添加图书信息,包括图书编号、书名、出版日期、入库日期、作者等信息。

源代码:

Option Explicit

Private Sub Command1_Click()

Dim rs_addbook As New ADODB.Recordset

Dim sql As String

If Trim(Combo1.Text) = "" Then

   MsgBox "请选择图书种类", vbOKOnly + vbExclamation, ""

   Combo1.SetFocus

   Exit Sub

End If

If Trim(Text1.Text) = "" Then

   MsgBox "图书编号不能为空", vbOKOnly + vbExclamation, ""

   Text1.SetFocus

   Exit Sub

End If

If Trim(Text2.Text) = "" Then

   MsgBox "书名不能为空", vbOKOnly + vbExclamation, ""

   Text2.SetFocus

   Exit Sub

End If

   If Not IsDate(Text5.Text) Then

      MsgBox "请按照yyyy-mm-dd格式输入日期", vbOKOnly + vbExclamation, ""

      Text5.SetFocus

      Exit Sub

   End If

   If Not IsDate(Text6.Text) Then

      MsgBox "请按照yyyy-mm-dd格式输入日期", vbOKOnly + vbExclamation, ""

      Text6.SetFocus

      Exit Sub

   End If

sql = "select * from 书籍信息 where 书籍编号='" & Text1.Text & "'"

rs_addbook.Open sql, conn, adOpenKeyset, adLockPessimistic

If rs_addbook.EOF Then

   rs_addbook.AddNew

   rs_addbook.Fields(0) = Trim(Text1.Text)

   rs_addbook.Fields(1) = Trim(Text2.Text)

   rs_addbook.Fields(2) = Trim(Combo1.Text)

   rs_addbook.Fields(3) = Trim(Text3.Text)

   rs_addbook.Fields(4) = Trim(Text4.Text)

   rs_addbook.Fields(5) = Trim(Text5.Text)

   rs_addbook.Fields(6) = Trim(Text6.Text)

   rs_addbook.Fields(7) = ""

   rs_addbook.Update

   MsgBox "添加书籍信息成功!", vbOKOnly, ""

   rs_addbook.Close

Else

   MsgBox "图书编号重复!", vbOKOnly + vbExclamation, ""

   Text1.SetFocus

   Text1.Text = ""

   rs_addbook.Close

   Exit Sub

Private Sub Form_Load()

Dim rs_leibie As New ADODB.Recordset

Dim sql As String

sql = "select * from 图书类别"

rs_leibie.Open sql, conn, adOpenKeyset, adLockPessimistic

rs_leibie.MoveFirst

Do While Not rs_leibie.EOF

  Combo1.AddItem rs_leibie.Fields(0)

  rs_leibie.MoveNext

Loop

rs_leibie.Close

End Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

6、文件名 frmfindbookform

功能说明:查询图书信息,可以选择性的输入图书的编号、名称或者类别查询图书的详细信息。

源代码:

Option Explicit

Dim panduan As String

Private Sub Command1_Click()

Dim rs_findbook As New ADODB.Recordset

Dim sql As String

If Check1.Value = vbChecked Then

   sql = "书名='" & Trim(Text1.Text & " ") & "'"

End If

If Check2.Value = vbChecked Then

   If Trim(sql) = "" Then

      sql = "类别='" & Trim(Combo1.Text & " ") & "'"

   Else

      sql = sql & "and 书名='" & Trim(Combo1.Text & " ") & "'"

   End If

End If

If Check3.Value = vbChecked Then

   If Trim(sql) = "" Then

      sql = "作者='" & Trim(Text2.Text & " ") & "'"

   Else

      sql = sql & "and  作者='" & Trim(Text2.Text & " ") & "'"

   End If

End If

If Check4.Value = vbChecked Then

   If Trim(sql) = "" Then

      sql = "出版社='" & Trim(Text3.Text & " ") & "'"

   Else

      sql = sql & "and  出版社='" & Trim(Text3.Text & " ") & "'"

   End If

End If

 << 上一页  [11] [12] [13] [14] [15] [16] [17] [18] 下一页

  • 上一篇文章:
  • 下一篇文章:
  • Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有