Private Sub cmdOkCancel_Click(Index As Integer)
Select Case Index
Case 0
mAddEditId = "": mAddEditIdName = ""
mAddEditIdClass = "": mAddEditIdDepart = ""
mAddEditIdZhi = ""
If txtBookId.Text = "" Or txtBookIdName = "" Or txtBookIdClass = "" Or txtBookIdDepart = "" Or txtBookIdZhi = "" Then
' Or txtBookIdDepart = "" Or txtBookIdZhi = "" Then
MsgBox "请把借书证内容填写完整!", 0 + 48, "提示"
Exit Sub
End If
mAddEditId = txtBookId
mAddEditIdName = txtBookIdName
mAddEditIdClass = txtBookIdClass
mAddEditIdDepart = txtBookIdDepart
mAddEditIdZhi = txtBookIdZhi
Unload Me
mSave = True
Case 1
mSave = False
Unload Me
End Select
End Sub
Private Sub txtBookId_GotFocus()
txtBookId.BackColor = vbBlue
txtBookId.ForeColor = vbYellow
End Sub
Private Sub txtBookId_LostFocus()
txtBookId.BackColor = vbWhite
txtBookId.ForeColor = vbBlack
End Sub
Dim db As Database
Dim rst As Recordset
Dim db1 As Database
Dim rst1 As Recordset
Private Sub cmdOkCancel_Click(Index As Integer)
Select Case Index
Case 0
If txtBookNum = "" Or txtBookName = "" Or Combo1.Text = "" _
Or txtCost = "" Or Combo2.Text = "" Or txtBookw = "" Or txtBookcbrq = "" Then
MsgBox "请将所有信息填写完整!", 0 + 48, "提示"
Exit Sub
End If
rst.Seek "=", Trim(txtBookNum.Text)
If rst.NoMatch = False Then
MsgBox "此编号已经存在,请填写其它编号!", 0 + 48, "提示"
'txtBookNum.SelText = txtBookNum.Text
txtBookNum.SetFocus
Exit Sub
End If
If Not IsDate(txtBookcbrq.Text) Then
MsgBox "请按照yyyy-mm-dd格式输入出版日期", vbOKOnly + vbExclamation, ""
txtBookcbrq.SetFocus
Exit Sub
End If
rst.AddNew
rst.Fields("图书编号") = Trim(txtBookNum.Text)
rst.Fields("书名") = txtBookName.Text
rst.Fields("类别") = Combo1.Text
rst.Fields("价格") = txtCost.Text
rst.Fields("出版社") = Combo2.Text
rst.Fields("出版日期") = txtBookcbrq.Text
rst.Fields("作者") = txtBookw.Text
rst.Fields("借出次数") = 0
rst.Update
MsgBox "添加成功!按回车继续", 0 + 48, "成功"
txtBookNum.Text = ""
txtBookName = ""
txtCost = ""
Combo1.Text = ""
txtBookChu = ""
txtBookw = ""
txtBookcbrq = ""
txtBookNum.SetFocus
Case 1
Unload Me
End Select
End Sub
Private Sub Form_Load()
Set db = Workspaces(0).OpenDatabase("DataBase\Data.mdb", False)
Set rst = db.OpenRecordset("Book", dbOpenTable)
rst.Index = "图书编号"
Set db1 = Workspaces(0).OpenDatabase("DataBase\Data.mdb", False)
Set rst1 = db1.OpenRecordset("type", dbOpenTable)
Set db2 = Workspaces(0).OpenDatabase("DataBase\Data.mdb", False)
Set rst2 = db2.OpenRecordset("chubanshe", dbOpenTable)
rst2.MoveLast
rst2.MoveFirst
For i = 1 To rst2.RecordCount
Combo2.AddItem rst2.Fields("出版社名")
rst2.MoveNext
If rst2.EOF Then Exit For
Next
TypeAdd
txtBookNum.Text = ""
txtBookName = ""
txtCost = ""
Combo1.Text = ""
Combo2.Text = ""
txtBookw = ""
txtBookcbrq = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
rst.Close
rst1.Close
db1.Close
db.Close
End Sub
Private Sub TypeAdd()
rst1.MoveLast
rst1.MoveFirst
For i = 1 To rst1.RecordCount
Combo1.AddItem rst1.Fields("类别")
rst1.MoveNext
If rst1.EOF Then Exit For
Next
End Sub
Private Sub cmdOkCancel_Click(Index As Integer)
Select Case Index
Case 0
mAddEditId = txtBookId & vbNullString
mAddEditIdName = txtBookIdName & vbNullString
mAddEditIdClass = txtBookIdClass & vbNullString & " "
mAddEditIdDepart = txtBookIdDepart & vbNullString & " "
mAddEditIdZhi = txtBookIdZhi & vbNullString & " "
mSave = True
Unload Me
Case 1
mSave = False
Unload Me
End Select
End Sub
Private Sub Form_Load()
txtBookId.Text = mAddEditId
txtBookIdName = mAddEditIdName
txtBookIdClass = mAddEditIdClass
txtBookIdDepart = mAddEditIdDepart
txtBookIdZhi = mAddEditIdZhi
End Sub