📄 hwdw.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 = "HwDw"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Dim M_HwDwCode As String
Dim M_HwDwMc As String
Dim M_HwDwIsStop As Integer
Dim M_HwDwNo As Double
Dim M_HwDw_id As Integer
Dim M_HwDw_Key As Long
Private Sub Class_Initialize()
M_HwDw_id = -1
End Sub
Public Property Get HwDwCode() As String
HwDwCode = M_HwDwCode
End Property
Public Property Get HwDwMc() As String
HwDwMc = M_HwDwMc
End Property
Public Property Get HwDwIsStop() As Integer
HwDwIsStop = M_HwDwIsStop
End Property
Public Property Get HwDwNo() As Double
HwDwNo = M_HwDwNo
End Property
Public Property Get HwDw_id() As Integer
HwDw_id = M_HwDw_id
End Property
Public Property Get HwDw_Key() As Long
HwDw_Key = M_HwDw_Key
End Property
Public Property Let HwDwCode(VHwDwCode As String)
If Trim(VHwDwCode) = "" Then
Err.Raise Number:=vbObjectError + 1, Description:="计量单位码不能为空!"
Exit Property
End If
If VHwDwCode <> M_HwDwCode Then
If M_HwDw_id = -1 Or VHwDwCode <> M_HwDwCode Then
If gPublicFunction.ExistFlg("FROM HwDwREC WHERE HwDwCode='" + VHwDwCode + "'") = 1 Then
Err.Raise Number:=vbObjectError + 1, Description:="已有计量单位码:" & VHwDwCode
Exit Property
End If
End If
End If
M_HwDwCode = VHwDwCode
End Property
Public Property Let HwDwMc(VHwDwMc As String)
If Trim(VHwDwMc) = "" Then
Err.Raise vbObjectError + 1, , "计量单位说明不能为空!"
Exit Property
End If
If VHwDwMc <> M_HwDwMc Then
If M_HwDw_id = -1 Or VHwDwMc <> M_HwDwMc Then
If gPublicFunction.ExistFlg("FROM HwDwREC WHERE HwDwMc='" + VHwDwMc + "'") = 1 Then
Err.Raise Number:=vbObjectError + 1, Description:="已有计量单位说明:" & VHwDwMc
Exit Property
End If
End If
M_HwDwMc = VHwDwMc
End If
End Property
Public Property Let HwDwIsStop(VHwDwIsStop As Integer)
If VHwDwIsStop <> 0 And VHwDwIsStop <> 1 Then
Err.Raise vbObjectError + 1, , "停用标志只能为0或1!"
Exit Property
End If
M_HwDwIsStop = VHwDwIsStop
End Property
Public Property Let HwDw_id(vHwDw_id As Integer)
M_HwDw_id = vHwDw_id
End Property
Public Property Let HwDw_Key(vHwDw_Key As Long)
M_HwDw_Key = vHwDw_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_HwDw_id = -1 Then
Cmd.CommandText = "{CALL HwDwREC_INSERT(?,?,?,?)}"
Cmd.Parameters(0) = M_HwDwCode
Cmd.Parameters(1) = M_HwDwMc
Cmd.Parameters(2) = M_HwDwIsStop
Cmd.Parameters(3).Direction = adParamOutput
Cmd.Execute
M_HwDw_id = 1
M_HwDwNo = Cmd.Parameters(3)
Else
Cmd.CommandText = "{CALL HwDwREC_UPDATE(?,?,?,?)}"
Cmd(0) = M_HwDwNo
Cmd(1) = M_HwDwCode
Cmd(2) = M_HwDwMc
Cmd(3) = M_HwDwIsStop
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 "HWDWREC", "HWDWNO", CStr(M_HwDwNo)
On Error GoTo ErrorHandle
Set Cmd = New ADODB.Command
Set Cmd.ActiveConnection = gDbCommon.Conn
Cmd.CommandText = "{call HwDwrec_delete(?)}"
Cmd.Parameters(0) = M_HwDwNo
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(VHwDwCode As String) As Integer
Dim Rs As DbRs
On Error GoTo ErrorHandle
Set Rs = New DbRs
Rs.Fillbydb ("select HwDwCode,HwDwMc,HwDwISSTOP,HwDwNo from HwDwrec where HwDwCode='" + VHwDwCode + "'")
Requery = -1
If Not Rs.EOF Then
Requery = 1
BatchLet Rs!HwDwCode, Rs!HwDwMc, Rs!HwDwIsStop, Rs!HwDwNo
End If
Set Rs = Nothing
Exit Function
ErrorHandle:
Set Rs = Nothing
End Function
Public Sub BatchLet(ParamArray Properties())
M_HwDwCode = Properties(0)
M_HwDwMc = Properties(1)
M_HwDwIsStop = Properties(2)
M_HwDwNo = Properties(3)
M_HwDw_id = 1
End Sub
Public Property Get Name() As String
Name = "HwDw"
End Property
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -