📄 hwpdrc.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 = "HwPdRc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'QQ:75347626
'MSN:whailin2000@hotmail.com
Option Explicit
Dim m_HwPdRcMc As String
Dim m_HwPdRcIsStop As Integer
Dim m_HwPdRcNo As Double
Dim m_HwPdRcId As Integer
Dim m_HwPdRcKey As Integer
Private Sub Class_Initialize()
m_HwPdRcId = -1
End Sub
Public Property Get Name() As String
Name = "HwPdRc"
End Property
Public Property Get HwPdRcId() As Integer
HwPdRcId = m_HwPdRcId
End Property
Public Property Get HwPdRcKey() As Integer
HwPdRcKey = m_HwPdRcKey
End Property
Public Property Get HwPdRcMc() As String
HwPdRcMc = m_HwPdRcMc
End Property
Public Property Get HwPdRcIsStop() As Integer
HwPdRcIsStop = m_HwPdRcIsStop
End Property
Public Property Get HwPdRcNo() As Double
HwPdRcNo = m_HwPdRcNo
End Property
Public Property Let HwPdRcId(vHwPdRcId As Integer)
m_HwPdRcId = vHwPdRcId
End Property
Public Property Let HwPdRcKey(vHwPdRcKey As Integer)
m_HwPdRcKey = vHwPdRcKey
End Property
Public Property Let HwPdRcMc(vHwPdRcMc As String)
If Trim(vHwPdRcMc) = "" Then
Err.Raise vbObjectError + 1, , "盘点原因名称不能为空!"
Exit Property
End If
If m_HwPdRcMc <> vHwPdRcMc Then
Dim Rs As ADODB.Recordset
Set Rs = Conn.Execute("SELECT * FROM HwPdRcREC WHERE HwPdRcMc='" & vHwPdRcMc & "'")
If Not Rs.EOF Then
Rs.Close
Set Rs = Nothing
Err.Raise vbObjectError + 1, , "盘点原因名称已经存在!"
Exit Property
End If
Rs.Close
Set Rs = Nothing
End If
m_HwPdRcMc = vHwPdRcMc
End Property
Public Property Let HwPdRcIsStop(vHwPdRcIsStop As Integer)
If vHwPdRcIsStop <> 0 And vHwPdRcIsStop <> 1 Then
Err.Raise vbObjectError + 1, , "停用标志只能为0或1!"
Exit Property
End If
m_HwPdRcIsStop = vHwPdRcIsStop
End Property
Public Sub Save()
On Error GoTo Errorhandle
If m_HwPdRcId = -1 Then
Cmd.CommandText = "{CALL HwPdRcREC_INSERT(?,?,?)}"
Cmd(0) = m_HwPdRcMc
Cmd(1) = m_HwPdRcIsStop
Cmd(2).Direction = adParamOutput
Else
Cmd.CommandText = "{CALL HwPdRcREC_UPDATE(?,?,?)}"
Cmd(0) = m_HwPdRcNo
Cmd(1) = m_HwPdRcMc
Cmd(2) = m_HwPdRcIsStop
End If
Conn.BeginTrans
Cmd.Execute
Conn.CommitTrans
If m_HwPdRcId = -1 Then
m_HwPdRcNo = Cmd(2)
m_HwPdRcId = 1
End If
Exit Sub
Errorhandle:
Conn.RollbackTrans
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Public Sub Del()
On Error GoTo Errorhandle
Cmd.CommandText = "{CALL HwPdRcREC_DELETE(?)}"
Cmd(0) = m_HwPdRcNo
Conn.BeginTrans
Cmd.Execute
Conn.CommitTrans
Exit Sub
Errorhandle:
Conn.RollbackTrans
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Public Function Requery(vHwPdRcCode As String, Optional vHwPdrcNo As Double = 0) As Integer
Dim mRs As ADODB.Recordset
On Error GoTo Errorhandle
Requery = -1
Set mRs = Conn.Execute("SELECT HwPdRcMC,HwPdRcISSTOP,HwPdRcNO FROM HwPdRcREC WHERE (HwPdRcmc='" & vHwPdRcCode & "' OR HWPDRCNO=" & CStr(vHwPdrcNo) & ")")
If Not mRs.EOF Then
BatchLet mRs!HwPdRcMc, mRs!HwPdRcIsStop, mRs!HwPdRcNo
Requery = 1
End If
Set mRs = Nothing
Exit Function
Errorhandle:
Set mRs = Nothing
Err.Raise vbObjectError + 1, , Err.Description
End Function
Public Sub BatchLet(ParamArray Properties() As Variant)
m_HwPdRcMc = Properties(0)
m_HwPdRcIsStop = Properties(1)
m_HwPdRcNo = Properties(2)
m_HwPdRcId = 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -