?? frmbase.frm
字號:
Exit Sub
DelErr:
MsgBox "刪除錯誤:" & Err.Description, vbCritical
Exit Sub
End Sub
Private Sub cmdDelSite_Click()
On Error GoTo DelErr
If cmdDelSite.Caption = "取消" Then
cmdDelSite.Caption = "刪除"
cmdModifySite.Caption = "修改"
cmdAddSite.Enabled = True
'1首先給出其名稱
ftSite.Text = ""
lstSite.Enabled = True
ftPrice.Text = "0"
ftSite.SetFocus
Exit Sub
End If
If lstSite.ListCount = 0 Then Exit Sub
If lstSite.Text = "" Then
MsgBox "請選擇需要座位(餐桌),再刪除。 ", vbInformation
lstSite.ListIndex = 0
lstSite.SetFocus
Exit Sub
End If
If MsgBox("真的要刪除〖" & Trim(Mid(lstSite.Text, 1, InStr(1, lstSite, " ", vbTextCompare) - 1)) & "〗座位(餐桌)嗎?(Y/N) ", vbYesNo + vbInformation) = vbNo Then Exit Sub
If DeleteSiteType(Trim(Mid(lstSite.Text, 1, InStr(1, lstSite, " ", vbTextCompare) - 1)), "SiteType") = True Then
lstSite.RemoveItem lstSite.ListIndex
End If
If lstSite.ListCount = 0 Then
cmdDelSite.Enabled = False
Else
cmdDelSite.Enabled = True
End If
ftSite.SetFocus
Exit Sub
DelErr:
MsgBox "刪除錯誤:" & Err.Description, vbCritical
Exit Sub
End Sub
Private Sub cmdDelUnit_Click()
On Error Resume Next
If lstUnitType.ListCount = 0 Then Exit Sub
If lstUnitType.Text = "" Then
MsgBox "請選擇需要類型,再刪除。 ", vbInformation
lstUnitType.ListIndex = 0
lstUnitType.SetFocus
Exit Sub
End If
If MsgBox("真的要刪除〖" & lstUnitType.Text & "〗類型嗎?(Y/N) ", vbYesNo + vbInformation) = vbNo Then Exit Sub
If DeleteType(lstUnitType.Text, "Unittype") = True Then
lstUnitType.RemoveItem lstUnitType.ListIndex
End If
If lstUnitType.ListCount = 0 Then
cmdDelUnit.Enabled = False
Else
cmdDelUnit.Enabled = True
End If
ftUnitType.SetFocus
End Sub
Private Function AddMenuType(sName As String, sSQL As String, iDiscount As Integer) As Boolean
On Error GoTo GetERR
Dim utDB As Connection
Dim utRS As Recordset
Set utDB = CreateObject("ADODB.Connection")
Set utRS = CreateObject("ADODB.Recordset")
utDB.Open Constr
'首先查詢是否有重復
utRS.Open sSQL, utDB, adOpenStatic, adLockOptimistic, adCmdText
If Not (utRS.EOF And utRS.BOF) Then
AddMenuType = False
MsgBox "對不起,類型【" & sName & "】已經存在,修改后繼續? ", vbExclamation
Else
utRS.AddNew
utRS("CLass") = sName
utRS("Discount") = iDiscount '菜單打折狀態
utRS.Update
AddMenuType = True
End If
utRS.Close
utDB.Close
Set utRS = Nothing
Set utDB = Nothing
Exit Function
GetERR:
AddMenuType = False
MsgBox "添加錯誤:" & Err.Description, vbCritical
End Function
Private Function AddType(sName As String, sSQL As String) As Boolean
On Error GoTo GetERR
Dim utDB As Connection
Dim utRS As Recordset
Set utDB = CreateObject("ADODB.Connection")
Set utRS = CreateObject("ADODB.Recordset")
utDB.Open Constr
'首先查詢是否有重復
utRS.Open sSQL, utDB, adOpenStatic, adLockOptimistic, adCmdText
If Not (utRS.EOF And utRS.BOF) Then
AddType = False
MsgBox "對不起,類型【" & sName & "】已經存在,修改后繼續? ", vbExclamation
Else
utRS.AddNew
utRS("CLass") = sName
utRS.Update
AddType = True
End If
utRS.Close
utDB.Close
Set utRS = Nothing
Set utDB = Nothing
Exit Function
GetERR:
AddType = False
MsgBox "添加錯誤:" & Err.Description, vbCritical
End Function
Private Function EditMenuType(sName As String, sOldName As String, sSQL As String, lDiscount As Integer) As Boolean
On Error GoTo GetERR
'SQL中包含原來的類型
Dim utDB As Connection
Dim utRS As Recordset
Set utDB = CreateObject("ADODB.Connection")
Set utRS = CreateObject("ADODB.Recordset")
utDB.Open Constr
utDB.BeginTrans
'首先查詢是否有重復
If UCase(sName) <> UCase(sOldName) Then
Dim dtRs As Recordset
Set dtRs = CreateObject("ADODB.Recordset")
dtRs.Open "Select * from MenuType Where Class='" & sName & "'", utDB, adOpenStatic, adLockReadOnly, adCmdText
'該編號已經存在時
If Not (dtRs.EOF And dtRs.BOF) Then
utDB.RollbackTrans
dtRs.Close
Set dtRs = Nothing
utDB.Close
Set utDB = Nothing
EditMenuType = False
MsgBox "對不起,【" & sName & "】已經存在,修改后繼續? ", vbExclamation
Exit Function
End If
'一切正常
dtRs.Close
Set dtRs = Nothing
End If
utRS.Open sSQL, utDB, adOpenStatic, adLockOptimistic, adCmdText
If utRS.EOF And utRS.BOF Then
EditMenuType = False
utDB.RollbackTrans
MsgBox "對不起,【" & sOldName & "】不存在,修改錯誤? ", vbExclamation
Else
utRS("Class") = sName
utRS("Discount") = lDiscount
utRS.Update
'修改其它單據的ID
Dim sMy As String
sMy = "Update EatList Set MType='" & sName & "' Where MType='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update Cust Set DType='" & sName & "' Where DType='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update prtCust Set DType='" & sName & "' Where DType='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update ptCust Set DType='" & sName & "' Where DType='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update tmpBox Set DType='" & sName & "' Where DType='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update TodayCust Set DType='" & sName & "' Where DType='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update tmpCust Set DType='" & sName & "' Where DType='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update tmpCust1 Set DType='" & sName & "' Where DType='" & sOldName & "'"
utDB.Execute sMy
utDB.CommitTrans
EditMenuType = True
End If
utRS.Close
utDB.Close
Set utRS = Nothing
Set utDB = Nothing
Exit Function
GetERR:
EditMenuType = False
MsgBox "保存菜單類型錯誤:" & Err.Description, vbCritical
End Function
Private Function EditType(sName As String, sOldName As String, sSQL As String, lDiscount As Integer) As Boolean
On Error GoTo GetERR
'SQL中包含原來的類型
Dim utDB As Connection
Dim utRS As Recordset
Set utDB = CreateObject("ADODB.Connection")
Set utRS = CreateObject("ADODB.Recordset")
utDB.Open Constr
utDB.BeginTrans
'首先查詢是否有重復
If UCase(sName) <> UCase(sOldName) Then
Dim dtRs As Recordset
Set dtRs = CreateObject("ADODB.Recordset")
dtRs.Open "Select * from MenuType Where Class='" & sName & "'", utDB, adOpenStatic, adLockReadOnly, adCmdText
'該編號已經存在時
If Not (dtRs.EOF And dtRs.BOF) Then
utDB.RollbackTrans
dtRs.Close
Set dtRs = Nothing
utDB.Close
Set utDB = Nothing
EditType = False
MsgBox "對不起,【" & sName & "】已經存在,修改后繼續? ", vbExclamation
Exit Function
End If
'一切正常
dtRs.Close
Set dtRs = Nothing
End If
utRS.Open sSQL, utDB, adOpenStatic, adLockOptimistic, adCmdText
If utRS.EOF And utRS.BOF Then
EditType = False
utDB.RollbackTrans
MsgBox "對不起,【" & sOldName & "】不存在,修改錯誤? ", vbExclamation
Else
utRS("CLass") = sName
utRS("Discount") = lDiscount
utRS.Update
'修改其它單據的ID
Dim sMy As String
sMy = "Update EatList Set MType='" & sName & "' Where MType='" & sOldName & "'"
utDB.Execute sMy
utDB.CommitTrans
EditType = True
End If
utRS.Close
utDB.Close
Set utRS = Nothing
Set utDB = Nothing
Exit Function
GetERR:
EditType = False
MsgBox "保存錯誤:" & Err.Description, vbCritical
End Function
Private Function EditSiteType(sName As String, sOldName As String, sSQL As String, lDiscount As Currency, lSupper As Currency, lNight As Currency) As Boolean
On Error GoTo GetERR
'SQL中包含原來的類型
Dim utDB As Connection
Dim utRS As Recordset
Set utDB = CreateObject("ADODB.Connection")
Set utRS = CreateObject("ADODB.Recordset")
utDB.Open Constr
utDB.BeginTrans
'首先查詢是否有重復
If UCase(sName) <> UCase(sOldName) Then
Dim dtRs As Recordset
Set dtRs = CreateObject("ADODB.Recordset")
dtRs.Open "Select * from SiteType Where Class='" & sName & "'", utDB, adOpenStatic, adLockReadOnly, adCmdText
'該編號已經存在時
If Not (dtRs.EOF And dtRs.BOF) Then
utDB.RollbackTrans
dtRs.Close
Set dtRs = Nothing
utDB.Close
Set utDB = Nothing
EditSiteType = False
MsgBox "對不起,【" & sName & "】已經存在,修改后繼續? ", vbExclamation
Exit Function
End If
'一切正常
dtRs.Close
Set dtRs = Nothing
End If
utRS.Open sSQL, utDB, adOpenStatic, adLockOptimistic, adCmdText
If utRS.EOF And utRS.BOF Then
EditSiteType = False
utDB.RollbackTrans
MsgBox "對不起,【" & sOldName & "】不存在,修改錯誤? ", vbExclamation
Else
If utRS("SiteStatus") = 2 Then
utDB.RollbackTrans
utRS.Close
Set utRS = Nothing
utDB.Close
Set utDB = Nothing
EditSiteType = False
MsgBox "【" & sName & "】正在上臺,不能修改。請在結帳后再修改? ", vbExclamation
Exit Function
End If
utRS("CLass") = sName
utRS("Price") = lDiscount '中午包廂費
utRS("SupperPrice") = lSupper '下午包廂費
utRS("NightPrice") = lNight '晚上包廂費
utRS.Update
'修改其它單據的ID
Dim sMy As String
sMy = "Update Cust Set Site='" & sName & "' Where Site='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update GatherTodayCust Set Site='" & sName & "' Where Site='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update prtCust Set Site='" & sName & "' Where Site='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update Site Set Site='" & sName & "' Where Site='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update tbdBook Set Class='" & sName & "' Where Class='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update tmpCust Set Site='" & sName & "' Where Site='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update tmpSite Set Site='" & sName & "' Where Site='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update tmpTodayCust Set Site='" & sName & "' Where Site='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update TodayCust Set Site='" & sName & "' Where Site='" & sOldName & "'"
utDB.Execute sMy
sMy = "Update TodayCustx Set Site='" & sName & "' Where Site='" & sOldName & "'"
utDB.Execute sMy
utDB.CommitTrans
EditSiteType = True
End If
utRS.Close
utDB.Close
Set utRS = Nothing
Set utDB = Nothing
Exit Function
GetERR:
EditSiteType = False
MsgBox "保存錯誤:" & Err.Description, vbCritical
End Function
Private Function AddSiteType(sName As String, sPrice As String, SupperPrice As String, NightPrice As String, sSQL As String) As Boolean
On Error GoTo GetERR
Dim utDB As Connection
Dim utRS As Recordset
Set utDB = CreateObject("ADODB.Connection")
Set utRS = CreateObject("ADODB.Recordset")
utDB.Open Constr
'首先查詢是否有重復
utRS.Open sSQL, utDB, adOpenStatic, adLockOptimistic, adCmdText
If Not (utRS.EOF And utRS.BOF) Then
AddSiteType = False
MsgBox "對不起,餐桌名稱【" & sName & "】已經存在,修改后繼續? ", vbExclamation
Else
utRS.AddNew
utRS("CLass") = sName
utRS("Price") = CCur(sPrice) '中午包廂費
utRS("SupperPrice") = CCur(SupperPrice) '下午包廂費
utRS("NightPrice") = CCur(NightPrice) '晚上包廂費
utRS("SiteStatus") = 0
utRS.Update
AddSiteType = True
End If
utRS.Close
utDB.Close
Set utRS = Nothing
Set utDB = Nothing
Exit Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -