⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 repairitem.cls

📁 汽车维修管理软件。其中包含三个编辑控件。
💻 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 = "RepairItem"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
'保持属性值的局部变量
Private m_Id As Long '局部复制
Private m_Repair As TRepair '局部复制
Private m_Price As Double '局部复制
Private m_Memo As String '局部复制
Private m_IsChange As Boolean
Public Property Let Memo(ByRef vData As String)
If Len(vData) > 40 Then
   m_Memo = Left$(vData, 40)
Else
   m_Memo = vData
End If
m_IsChange = True
End Property

Public Property Get Memo() As String
Memo = m_Memo
End Property


Public Property Let Price(ByRef vData As Double)
m_Price = vData
m_IsChange = True
End Property

Public Property Get Price() As Double
Price = m_Price
End Property


Public Property Set Repair(ByRef vData As TRepair)
Set m_Repair = vData

m_IsChange = True
End Property

Public Property Get Repair() As TRepair
Set Repair = m_Repair
End Property

Public Property Let Id(ByVal vData As Long)
m_Id = vData
m_IsChange = True
End Property

Public Property Get Id() As Long
Id = m_Id
End Property
Public Function Save(ByRef pConn As ADODB.Connection, ByVal MainId As Long) As Boolean
If m_IsChange = False And m_Repair.IsChange = False Then
   If m_Id > 0 Then
        Save = True
   Else
        Save = False
   End If
   Exit Function
End If
If m_Repair.Id < 0 Or m_Price <= 0 Then
   Save = False
   Exit Function
End If
Dim SaveComString As String
Dim comm As ADODB.Command
If m_Id > 0 Then
   SaveComString = "UPDATE WorkSub_1 SET RepairId=" & CStr(m_Repair.Id) & ",Price=" _
                    & CStr(m_Price) & ", cMemo='" & m_Memo & "' WHERE AutoId=" & CStr(m_Id)
Else
   SaveComString = "INSERT INTO WorkSub_1 (MainId,RepairId,Price,cMemo) VALUES (" & CStr(MainId) _
                   & "," & CStr(m_Repair.Id) & "," & CStr(m_Price) & ",'" & m_Memo & "')"
End If
On Error GoTo RepSave
Set comm = New ADODB.Command
Set comm.ActiveConnection = pConn
'MsgBox SaveComString
comm.CommandType = adCmdText
comm.CommandText = SaveComString & vbNullString
comm.Execute , , adExecuteNoRecords

If m_Id < 0 Then
  Dim re As ADODB.Recordset
  Set re = pConn.Execute("SELECT MAX(AutoId) FROM WorkSub_1")
  m_Id = re.Fields(0)
  Set re = Nothing
End If
Set comm = Nothing
m_IsChange = False
Exit Function
RepSave:
MsgBox "数据保存错误", vbCritical Or vbOKOnly, "错误"
Set comm = Nothing
Save = False
End Function


Private Sub Class_Initialize()
m_IsChange = False
m_Id = -1
Set m_Repair = New TRepair
End Sub

Private Sub Class_Terminate()
Set m_Repair = Nothing
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -