?? fittings.cls
字號:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "fittings"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private mfname As String
Private mbrand As String
Private mftype As String
Private mPrice As Currency
Private mfcount As Long
Private mSTOREID As String
Property Get fname() As String
fname = mfname
End Property
Property Let fname(ByVal fname As String)
mfname = fname
End Property
Property Get brand() As String
brand = mbrand
End Property
Property Let brand(ByVal brand As String)
mbrand = brand
End Property
Property Get ftype() As String
ftype = mftype
End Property
Property Let ftype(ByVal ftype As String)
mftype = ftype
End Property
Property Get Price() As Currency
Price = mPrice
End Property
Property Let Price(ByVal Price As Currency)
If IsNumeric(Price) Then
mPrice = Price
Else
mPrice = 0
End If
End Property
Property Get fcount() As Long
fcount = mfcount
End Property
Property Let fcount(ByVal fcount As Long)
If IsNumeric(fcount) And InStr(1, CStr(fcount), ".", vbTextCompare) < 1 Then
mfcount = fcount
Else
mfcount = 0
End If
End Property
Property Get STOREID() As String
STOREID = mSTOREID
End Property
Property Let STOREID(ByVal STOREID As String)
mSTOREID = STOREID
End Property
Public Function AddNew() As Boolean
Dim intOldCount As Double
Dim rscount As ADODB.Recordset
Dim strCondition As String
strCondition = "fname='" & mfname & "' and FTYPE = '" & mftype & "' and brand='" & mbrand & "'"
If objDBOpt.IsRecordExist("fittings", strCondition) Then
'存在,數(shù)量增加
Set rscount = objDBOpt.getRecord("fittings", "*", strCondition)
If rscount Is Nothing Then
AddNew = False
Exit Function
End If
If IsNull(rscount.Fields("fcount").Value) Then
intOldCount = 0
Else
intOldCount = rscount.Fields("fcount").Value
End If
AddNew = objDBOpt.ModiRecord("fittings", "fcount", intOldCount + mfcount, strCondition)
AddNew = objDBOpt.ModiRecord("fittings", "Price", mPrice, strCondition)
AddNew = objDBOpt.ModiRecord("fittings", "Storeid", "'" & mSTOREID & "'", strCondition)
Else
'不存在,添加新記錄
AddNew = objDBOpt.AddRecord("fittings", "fname,brand,ftype,price,fcount,storeid", "'" & mfname & "','" & mbrand & "','" & mftype & "'," & mPrice & "," & mfcount & ",'" & mSTOREID & "'")
End If
End Function
Public Function Modify() As Boolean
Dim intOldCount As Double
Dim rscount As ADODB.Recordset
Dim strCondition As String
strCondition = "fname='" & mfname & "' and FTYPE = '" & mftype & "' and brand='" & mbrand & "'"
If objDBOpt.IsRecordExist("fittings", strCondition) Then
Modify = objDBOpt.ModiRecord("fittings", "fcount", mfcount, strCondition)
Modify = objDBOpt.ModiRecord("fittings", "Price", mPrice, strCondition)
Modify = objDBOpt.ModiRecord("fittings", "Storeid", "'" & mSTOREID & "'", strCondition)
Else
Modify = False
End If
End Function
Public Function Delete() As Boolean
Dim strCondition As String
strCondition = "fname='" & mfname & "' and FTYPE = '" & mftype & "' and brand='" & mbrand & "'"
Delete = objDBOpt.DelRecord("fittings", strCondition)
End Function
Public Function Use() As Boolean
Dim intOldCount As Double
Dim rscount As ADODB.Recordset
Dim strCondition As String
strCondition = "fname='" & mfname & "' and FTYPE = '" & mftype & "' and brand='" & mbrand & "'"
If objDBOpt.IsRecordExist("fittings", strCondition) Then
'存在,數(shù)量增加
Set rscount = objDBOpt.getRecord("fittings", "*", strCondition)
If rscount Is Nothing Then
Use = False
Exit Function
End If
If IsNull(rscount.Fields("fcount").Value) Then
intOldCount = 0
Else
intOldCount = rscount.Fields("fcount").Value
End If
If intOldCount - mfcount < 0 Then
MsgBox "庫存不足!"
Use = False
Exit Function
End If
Use = objDBOpt.ModiRecord("fittings", "fcount", intOldCount - mfcount, strCondition)
Else
'不存在,報錯
MsgBox "配件信息錯誤!"
Use = False
End If
End Function
Public Function ReturnBack() As Boolean
Dim intOldCount As Double
Dim rscount As ADODB.Recordset
Dim strCondition As String
strCondition = "fname='" & mfname & "' and FTYPE = '" & mftype & "' and brand='" & mbrand & "'"
If objDBOpt.IsRecordExist("fittings", strCondition) Then
'存在,數(shù)量增加
Set rscount = objDBOpt.getRecord("fittings", "*", strCondition)
If rscount Is Nothing Then
ReturnBack = False
Exit Function
End If
If IsNull(rscount.Fields("fcount").Value) Then
intOldCount = 0
Else
intOldCount = rscount.Fields("fcount").Value
End If
ReturnBack = objDBOpt.ModiRecord("fittings", "fcount", intOldCount + mfcount, strCondition)
Else
'不存在,報錯
MsgBox "配件信息錯誤!"
ReturnBack = False
End If
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -