📄 frmbookmemo.frm
字号:
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "FrmBookMemo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim FuLeiBianHao As String
Dim bianHao As String
Public Function checkFenLei(UID As String) As Boolean
Dim userDB As Database
Dim userRD As Recordset
Dim dbName As String
Dim STRSQL As String
Screen.MousePointer = 11
On Error GoTo errEnd
dbName = App.Path
If Right(dbName, 1) <> "\" Then dbName = dbName + "\"
dbName = dbName + "DataBase\WFSSDataBase.mdb"
STRSQL = "select [图书分类] from [图书分类] where [图书分类]=""" & UID & """"
'打开数据库
Set userDB = DBEngine.Workspaces(0).OpenDatabase(dbName, False, True)
'检索用户,验证密码
Set userRD = userDB.OpenRecordset(STRSQL, dbOpenSnapshot)
If userRD.RecordCount > 0 Then
'关闭数据库
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
checkFenLei = True
Screen.MousePointer = vbDefault
Else
'关闭数据库
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
Screen.MousePointer = vbDefault
checkFenLei = False
End If
Exit Function
errEnd:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbOKOnly + vbExclamation, "创建类别"
Err.Clear
'关闭数据库
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
End Function
Private Sub CmdClose_Click()
Unload Me
End Sub
Private Sub CmdUpdate_Click()
On Error GoTo errEnd
If ComboFuLei.Text = "" Or ComboFuLei.Text = "请选择图书类别" Then
MsgBox "请选择图书分类!", vbOKOnly + vbExclamation, "资料更正"
ComboFuLei.SetFocus
Exit Sub
End If
If Not checkFenLei(ComboFuLei.Text) Then
MsgBox "所选分类不存在!", vbOKOnly + vbExclamation, "资料更正"
ComboFuLei.SetFocus
Exit Sub
End If
If ComboZiLei.Text = "" Or ComboFuLei.Text = "请选择子类" Then
MsgBox "请选择图书详细分类!", vbOKOnly + vbExclamation, "资料更正"
ComboZiLei.SetFocus
Exit Sub
End If
If Not checkFenLei(ComboZiLei.Text) Then
MsgBox "所选详细分类不存在!", vbOKOnly + vbExclamation, "资料更正"
ComboZiLei.SetFocus
Exit Sub
End If
If TxtBook.Text = "" Then
MsgBox "请填写图书名称!", vbOKOnly + vbExclamation, "资料更正"
TxtBook.SetFocus
Exit Sub
End If
If TxtChuBanShe.Text = "" Then
MsgBox "请填写出版社名称!", vbOKOnly + vbExclamation, "资料更正"
TxtChuBanShe.SetFocus
Exit Sub
End If
If TxtZuoZhe.Text = "" Then
MsgBox "请填写图书作者姓名!", vbOKOnly + vbExclamation, "资料更正"
TxtZuoZhe.SetFocus
Exit Sub
End If
If TxtChuBanRQ.Text = "" Then TxtChuBanRQ.Text = Now()
If TxtDingJia.Text = "" Then
MsgBox "请填写图书定价!", vbOKOnly + vbExclamation, "资料更正"
TxtDingJia.SetFocus
Exit Sub
End If
If TxtBanCi.Text = "" Then TxtBanCi.Text = "未知"
If TxtISBN.Text = "" Then TxtISBN.Text = "未知"
If TxtCongShu.Text = "" Then TxtCongShu.Text = "无"
If TxtGuanJianCi.Text = "" Then
MsgBox "请填写图书关键词!", vbOKOnly + vbExclamation, "资料更正"
TxtGuanJianCi.SetFocus
Exit Sub
End If
If TxtJianJie.Text = "" Then TxtJianJie.Text = "无"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from [Book] where [图书编号]=""" & bianHao & """"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox "数据丢失,清重试!", vbOKOnly + vbExclamation, "资料更正"
Exit Sub
End If
Adodc1.Recordset.MoveFirst
Adodc1.Recordset!图书分类号 = FuLeiBianHao
Adodc1.Recordset!书名 = TxtBook.Text
Adodc1.Recordset!出版社 = TxtChuBanShe.Text
Adodc1.Recordset!作者 = TxtZuoZhe.Text
Adodc1.Recordset!出版日期 = TxtChuBanRQ.Text
Adodc1.Recordset!定价 = TxtDingJia.Text
Adodc1.Recordset!版次 = TxtBanCi.Text
Adodc1.Recordset!ISBN = TxtISBN.Text
Adodc1.Recordset!丛书 = TxtCongShu.Text
Adodc1.Recordset!关键词 = TxtGuanJianCi.Text
Adodc1.Recordset!内容简介 = TxtJianJie.Text
Adodc1.Recordset!入库时间 = Now()
Adodc1.Recordset.Update
MsgBox "图书资料修改成功!", vbOKOnly + vbInformation, "修改成功"
TxtBianHao.Text = ""
TxtBook.Text = ""
TxtChuBanShe.Text = ""
TxtZuoZhe.Text = ""
TxtChuBanRQ.Text = ""
TxtDingJia.Text = ""
TxtBanCi.Text = ""
TxtISBN.Text = ""
TxtCongShu.Text = ""
TxtGuanJianCi.Text = ""
TxtJianJie.Text = ""
TxtBianHao.SetFocus
Exit Sub
errEnd:
MsgBox "更新数据库失败!无法修改记录!", vbOKOnly + vbExclamation, "数据库出错"
End Sub
Private Sub ComboFuLei_Click()
On Error GoTo errEnd
If ComboFuLei.Text = "" Or ComboFuLei.Text = "请选择图书类别" Then
MsgBox "请选择图书分类!", vbOKOnly + vbExclamation, "资料更正"
ComboFuLei.SetFocus
Exit Sub
End If
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select [图书分类号] from [图书分类] where [图书分类]=""" & ComboFuLei.Text & """"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
FuLeiBianHao = Adodc1.Recordset!图书分类号
Else
MsgBox "该类别不存在!", vbOKOnly + vbExclamation, "选择父类"
Exit Sub
End If
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select [图书分类] from [图书分类] where [所属父类编号]=""" & FuLeiBianHao & """"
Adodc1.Refresh
ComboZiLei.Clear
ComboZiLei.Text = "请选择子类"
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
While Not Adodc1.Recordset.EOF
ComboZiLei.AddItem Adodc1.Recordset!图书分类
Adodc1.Recordset.MoveNext
Wend
End If
Exit Sub
errEnd:
MsgBox "检索数据库失败!", vbOKOnly + vbExclamation, "数据库出错"
End Sub
Private Sub ComboZiLei_Click()
On Error GoTo errEnd
If ComboZiLei.Text = "" Or ComboZiLei.Text = "请选择子类" Then
MsgBox "请选择图书详细分类!", vbOKOnly + vbExclamation, "资料更正"
ComboZiLei.SetFocus
Exit Sub
End If
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select [图书分类号] from [图书分类] where [图书分类]=""" & ComboZiLei.Text & """"
Adodc1.Refresh
Adodc1.Recordset.MoveFirst
FuLeiBianHao = Adodc1.Recordset!图书分类号
Exit Sub
errEnd:
MsgBox "检索数据库失败!", vbOKOnly + vbExclamation, "数据库出错"
End Sub
Private Sub Form_Activate()
On Error GoTo errEnd
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select [图书分类] from [图书分类] where [图书分类号]=[所属父类编号]"
Adodc1.Refresh
ComboFuLei.Clear
ComboFuLei.Text = "请选择图书类别"
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
While Not Adodc1.Recordset.EOF
ComboFuLei.AddItem Adodc1.Recordset!图书分类
Adodc1.Recordset.MoveNext
Wend
End If
Exit Sub
errEnd:
MsgBox "检索数据库失败!", vbOKOnly + vbExclamation, "数据库出错"
End Sub
Private Sub Form_Load()
Dim dbName As String
Dim connSTR As String
On Error GoTo errEnd
ChDir App.Path
dbName = App.Path
If Right(dbName, 1) <> "\" Then dbName = dbName + "\"
dbName = dbName + "DataBase\WFSSDataBase.mdb"
connSTR = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbName & ";Persist Security Info=False"
Adodc1.ConnectionString = connSTR
Exit Sub
errEnd:
MsgBox "连接数据库失败!", vbOKOnly + vbExclamation, "打开数据库出错"
End
End Sub
Private Sub TxtBianHao_LostFocus()
On Error GoTo errEnd
If TxtBianHao.Text <> "" Then
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from [Book] where [图书编号]=""" & TxtBianHao.Text & """"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
bianHao = Adodc1.Recordset!图书编号 & ""
TxtBook.Text = Adodc1.Recordset!书名 & ""
TxtChuBanShe.Text = Adodc1.Recordset!出版社 & ""
TxtZuoZhe.Text = Adodc1.Recordset!作者 & ""
TxtChuBanRQ.Text = Adodc1.Recordset!出版日期 & ""
TxtDingJia.Text = Adodc1.Recordset!定价 & ""
TxtBanCi.Text = Adodc1.Recordset!版次 & ""
TxtISBN.Text = Adodc1.Recordset!ISBN & ""
TxtCongShu.Text = Adodc1.Recordset!丛书 & ""
TxtGuanJianCi.Text = Adodc1.Recordset!关键词 & ""
TxtJianJie.Text = Adodc1.Recordset!内容简介 & ""
Else
MsgBox "该图书编号不存在!", vbOKOnly + vbExclamation, "资料更正"
TxtBianHao.SelStart = 0
TxtBianHao.SelLength = Len(TxtBianHao.Text)
TxtBianHao.SetFocus
Exit Sub
End If
End If
Exit Sub
errEnd:
MsgBox "检索数据库失败!", vbOKOnly + vbExclamation, "数据库出错"
End Sub
Private Sub TxtDingJia_KeyUp(KeyCode As Integer, Shift As Integer)
If Not (KeyCode >= 48 And KeyCode <= 57) Then
If Not (KeyCode >= 96 And KeyCode <= 105) Then
If KeyCode <> 13 And KeyCode <> 190 And KeyCode <> 110 And KeyCode <> 8 And KeyCode <> 46 Then
MsgBox "图书定价错误!", vbOKOnly + vbExclamation, "定价错误"
TxtDingJia.Text = ""
End If
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -