?? frmnewbook.frm
字號:
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 "更新數據庫失?。o法添加記錄!", 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 + -