?? frmbookmemo.frm
字號:
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 + -