⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmnewbook.frm

📁 这里是源码。 宛枫书社图书管理系统 V1.0 Beta 测试版 面向中小型书店、个体书店进行全面的人员、物流管理
💻 FRM
📖 第 1 页 / 共 2 页
字号:
    Screen.MousePointer = vbDefault
    MsgBox Err.Description, vbOKOnly + vbExclamation, "创建类别"
    Err.Clear
    '关闭数据库
    userRD.Close
    Set userRD = Nothing
    userDB.Close
    Set userDB = Nothing
End Function

Public Function checkGYSID(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 [Book] 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
    
    checkGYSID = True
    Screen.MousePointer = vbDefault
Else
    '关闭数据库
    userRD.Close
    Set userRD = Nothing
    userDB.Close
    Set userDB = Nothing
    
    Screen.MousePointer = vbDefault
    checkGYSID = 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
Load FrmBook
FrmBook.Show vbModal
End Sub

Private Sub CmdLei_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 TxtBianHao.Text = "" Then
    MsgBox "请填写图书编号!", vbOKOnly + vbExclamation, "图书登记"
    TxtBianHao.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 = "无"

If checkGYSID(TxtBianHao.Text) Then
    MsgBox "图书编号不唯一,请另选一个!", vbOKOnly + vbExclamation, "图书登记"
    TxtBianHao.SelStart = 0
    TxtBianHao.SelLength = Len(TxtBianHao.Text)
    TxtBianHao.SetFocus
    Exit Sub
End If

Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "Book"
Adodc1.Refresh
'添加记录
Adodc1.Recordset.AddNew
Adodc1.Recordset!图书编号 = TxtBianHao.Text
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!库存量 = 0
Adodc1.Recordset!入库时间 = Now()
Adodc1.Recordset.Update

MsgBox "图书资料登记成功!", vbOKOnly + vbInformation, "登记成功"
Call CmdClose_Click
Exit Sub

errEnd:
    MsgBox "更新数据库失败!无法添加记录!", vbOKOnly + vbExclamation, "数据库出错"

End Sub

Private Sub CmdNewGYS_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 TxtBianHao.Text = "" Then
    MsgBox "请填写图书编号!", vbOKOnly + vbExclamation, "图书登记"
    TxtBianHao.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 = "无"

If checkGYSID(TxtBianHao.Text) Then
    MsgBox "图书编号不唯一,请另选一个!", vbOKOnly + vbExclamation, "图书登记"
    TxtBianHao.SelStart = 0
    TxtBianHao.SelLength = Len(TxtBianHao.Text)
    TxtBianHao.SetFocus
    Exit Sub
End If

Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "Book"
Adodc1.Refresh
'添加记录
Adodc1.Recordset.AddNew
Adodc1.Recordset!图书编号 = TxtBianHao.Text
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!库存量 = 0
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 CmdUpdate_Click()
Load FrmBookMemo
FrmBookMemo.Show vbModal
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 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 + -