📄 cwsm.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 = "Cwsm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Dim M_CwsmCode As String
Dim M_CwsmMc As String
Dim M_CwsmSl As Double
Dim M_CwsmNo As Double
Dim M_Cwsm_id As Integer
Dim M_Cwsm_Key As Long
Private Sub Class_Initialize()
M_Cwsm_id = -1
End Sub
Public Property Get CwsmCode() As String
CwsmCode = M_CwsmCode
End Property
Public Property Get CwsmMc() As String
CwsmMc = M_CwsmMc
End Property
Public Property Get CwsmSl() As Double
CwsmSl = M_CwsmSl
End Property
Public Property Get CwsmNo() As Double
CwsmNo = M_CwsmNo
End Property
Public Property Get Cwsm_id() As Integer
Cwsm_id = M_Cwsm_id
End Property
Public Property Get Cwsm_Key() As Long
Cwsm_Key = M_Cwsm_Key
End Property
Public Property Let CwsmCode(VCwsmCode As String)
If Trim(VCwsmCode) = "" Then
Err.Raise Number:=vbObjectError + 1, Description:="税码不能为空!"
Exit Property
End If
M_CwsmCode = VCwsmCode
End Property
Public Property Let CwsmMc(VCwsmMc As String)
If Trim(VCwsmMc) = "" Then
Err.Raise vbObjectError + 1, , "税码名称不能为空!"
Exit Property
End If
If VCwsmMc <> M_CwsmMc Then
If M_Cwsm_id = -1 Or VCwsmMc <> M_CwsmMc Then
If gPublicFunction.ExistFlg("FROM CWSMREC WHERE CWSMMc='" + VCwsmMc + "'") = 1 Then
Err.Raise Number:=vbObjectError + 1, Description:="已有税码:" & VCwsmMc
Exit Property
End If
End If
M_CwsmMc = VCwsmMc
End If
End Property
Public Property Let CwsmSl(VCwsmSl As Double)
If VCwsmSl < 0 Then
Err.Raise vbObjectError + 1, , "税率不能小于零!"
Exit Property
End If
M_CwsmSl = VCwsmSl
End Property
Public Property Let Cwsm_id(vCwsm_id As Integer)
M_Cwsm_id = vCwsm_id
End Property
Public Property Let Cwsm_Key(vCwsm_Key As Long)
M_Cwsm_Key = vCwsm_Key
End Property
Public Sub DbSave()
Dim Cmd As ADODB.Command
Dim mSqlStr As String
On Error GoTo ErrorHandle
Set Cmd = New ADODB.Command
Set Cmd.ActiveConnection = gDbCommon.Conn
If M_Cwsm_id = -1 Then
Cmd.CommandText = "{CALL CwsmREC_INSERT(?,?,?,?)}"
Cmd.Parameters(0) = M_CwsmCode
Cmd.Parameters(1) = M_CwsmMc
Cmd.Parameters(2) = M_CwsmSl
Cmd.Parameters(3).Direction = adParamOutput
Cmd.Execute
M_Cwsm_id = 1
M_CwsmNo = Cmd.Parameters(3)
Else
Cmd.CommandText = "{CALL CwsmREC_UPDATE(?,?,?,?)}"
Cmd(0) = M_CwsmNo
Cmd(1) = M_CwsmCode
Cmd(2) = M_CwsmMc
Cmd(3) = M_CwsmSl
Cmd.Execute
End If
Set Cmd = Nothing
Exit Sub
ErrorHandle:
Set Cmd = Nothing
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Public Sub DbDel()
Dim Cmd As ADODB.Command
gPublicFunction.CheckCanBeDelete "CWSMREC", "CWSMNO", CStr(M_CwsmNo)
On Error GoTo ErrorHandle
Set Cmd = New ADODB.Command
Set Cmd.ActiveConnection = gDbCommon.Conn
Cmd.CommandText = "{call Cwsmrec_delete(?)}"
Cmd.Parameters(0) = M_CwsmNo
gDbCommon.Conn.BeginTrans
Cmd.Execute
gDbCommon.Conn.CommitTrans
Set Cmd = Nothing
Exit Sub
ErrorHandle:
Set Cmd = Nothing
gDbCommon.Conn.RollbackTrans
End Sub
Public Function Requery(VCwsmCode As String) As Integer
Dim Rs As DbRs
On Error GoTo ErrorHandle
Set Rs = New DbRs
Rs.Fillbydb ("select CwsmCode,CwsmMc,CwsmSl,CwsmNo from Cwsmrec where CwsmCode='" + VCwsmCode + "'")
Requery = -1
If Not Rs.EOF Then
Requery = 1
BatchLet Rs!CwsmCode, Rs!CwsmMc, Rs!CwsmSl, Rs!CwsmNo
End If
Set Rs = Nothing
Exit Function
ErrorHandle:
Set Rs = Nothing
End Function
Public Sub BatchLet(ParamArray Properties())
M_CwsmCode = Properties(0)
M_CwsmMc = Properties(1)
M_CwsmSl = Properties(2)
M_CwsmNo = Properties(3)
M_Cwsm_id = 1
End Sub
Public Property Get Name() As String
Name = "Cwsm"
End Property
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -