📄 frmhwpdrc.frm
字号:
Dim mCurColOldValue As String
Dim mOldHwPdRcYear As String
Dim OHwPdRc As HwPdRc
Dim OHwPdRcs As HwPdRcs
Private Sub Flex_AfterEdit(Index As Integer, ByVal Row As Long, ByVal Col As Long)
On Error GoTo Errorhandle
SetControlToFlex
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub Flex_BeforeEdit(Index As Integer, ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
On Error GoTo Errorhandle
mCurColOldValue = Trim(Flex(FlexHwPdRc).TextMatrix(Flex(FlexHwPdRc).Row, Flex(FlexHwPdRc).Col))
If Tlbaction(TlbHwPdRc).Tag = "" Then
Cancel = True
End If
If Tlbaction(TlbHwPdRc).Tag <> "" Then
Select Case Flex(FlexHwPdRc).ColKey(Col)
Case "HWPDRCCODE"
Case "HWPDRCMC"
If OHwPdRc Is Nothing Then
Cancel = True
End If
End Select
End If
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub Flex_Click(Index As Integer)
On Error GoTo Errorhandle
If Tlbaction(TlbHwPdRc).Tag = "" Then
Exit Sub
End If
If OHwPdRc Is Nothing Then
Exit Sub
End If
Select Case Index
Case FlexHwPdRc
If Flex(Index).Col = Flex(Index).ColIndex("HWPDRCISSTOP") Then
If Flex(Index).TextMatrix(Flex(Index).Row, Flex(FlexHwPdRc).Col) = "" Then
Flex(Index).TextMatrix(Flex(Index).Row, Flex(FlexHwPdRc).Col) = "√"
Else
Flex(Index).TextMatrix(Flex(Index).Row, Flex(FlexHwPdRc).Col) = ""
End If
End If
End Select
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub Flex_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error GoTo Errorhandle
gPublicFunction.FlexKeyDown Flex(Index), KeyCode
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub Flex_KeyDownEdit(Index As Integer, ByVal Row As Long, ByVal Col As Long, KeyCode As Integer, ByVal Shift As Integer)
On Error GoTo Errorhandle
gPublicFunction.FlexKeyDown Flex(Index), KeyCode
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub Flex_KeyPressEdit(Index As Integer, ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer)
On Error GoTo Errorhandle
gPublicFunction.FlexInputCheck Me, Flex(Index), KeyAscii
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub Flex_RowColChange(Index As Integer)
On Error GoTo Errorhandle
Select Case Index
Case FlexHwPdRc
If Flex(Index).Rows > 2 And Flex(FlexHwPdRc).Row <> Flex(FlexHwPdRc).Rows - 1 Then
Set OHwPdRc = OHwPdRcs(CStr(Flex(FlexHwPdRc).RowData(Flex(FlexHwPdRc).Row)))
Else
Set OHwPdRc = Nothing
End If
End Select
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub SetControlToFlex()
Dim mCurCol As Integer
Dim mCurRow As Integer
On Error GoTo Errorhandle
If Tlbaction(TlbHwPdRc).Tag = "" Then
Exit Sub
End If
mCurRow = Flex(FlexHwPdRc).Row
mCurCol = Flex(FlexHwPdRc).Col
Select Case Flex(FlexHwPdRc).ColKey(Flex(FlexHwPdRc).Col)
Case "HWPDRCCODE"
If OHwPdRc Is Nothing Then
AddNewRecord
Else
OHwPdRc.HwPdRcCode = Trim(Flex(FlexHwPdRc).TextMatrix(mCurRow, mCurCol))
End If
Case "HWPDRCMC"
If Not OHwPdRc Is Nothing Then
OHwPdRc.HwPdRcMc = Trim(Flex(FlexHwPdRc).TextMatrix(mCurRow, mCurCol))
End If
End Select
Exit Sub
Errorhandle:
Flex(FlexHwPdRc).TextMatrix(mCurRow, mCurCol) = mCurColOldValue
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub AddNewRecord()
On Error GoTo Errorhandle
If Trim(Flex(FlexHwPdRc).TextMatrix(Flex(FlexHwPdRc).Row, Flex(FlexHwPdRc).Col)) <> "" Then
Set OHwPdRc = New HwPdRc
OHwPdRc.HwPdRcCode = Trim(Flex(FlexHwPdRc).TextMatrix(Flex(FlexHwPdRc).Row, Flex(FlexHwPdRc).Col))
OHwPdRcs.Add OHwPdRc
Flex(FlexHwPdRc).RowData(Flex(FlexHwPdRc).Rows - 1) = OHwPdRc.HwPdRc_Key
Flex(FlexHwPdRc).AddItem ""
End If
Exit Sub
Errorhandle:
Set OHwPdRc = Nothing
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub Form_Load()
On Error GoTo Errorhandle
Flex(FlexHwPdRc).Editable = flexEDKbdMouse
Flex(FlexHwPdRc).ColKey(1) = "HWPDRCCODE"
Flex(FlexHwPdRc).ColKey(2) = "HWPDRCMC"
Flex(FlexHwPdRc).ColKey(3) = "HWPDRCISSTOP"
gPublicCommon.PublicFunction.LoadFormSet Me, Tlbaction(TlbHwPdRc), Img(ImgHwPdRc), SBar(SBarHwPdRc)
gPublicCommon.gForms(UCase(Me.Name)).ControlStatus.Add "", Flex(FlexHwPdRc)
gPublicCommon.PublicFunction.EnableControl Me, ""
LoadDataIntoGrid
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim mButton As Button
On Error GoTo Errorhandle
Set mButton = gPublicFunction.GetToolBarButton(Me, KeyCode)
If Not mButton Is Nothing Then
Tlbaction_ButtonClick TlbHwPdRc, mButton
End If
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub LoadDataIntoGrid()
Dim ItemStr As String
Dim m_HwPdRc As HwPdRc
On Error GoTo Errorhandle
Flex(FlexHwPdRc).Rows = 1
Flex(FlexHwPdRc).AddItem ""
Set OHwPdRcs = New HwPdRcs
OHwPdRcs.FillbyDb
For Each m_HwPdRc In OHwPdRcs
ItemStr = vbTab & m_HwPdRc.HwPdRcCode & vbTab & m_HwPdRc.HwPdRcMc & vbTab & IIf(m_HwPdRc.HwPdRcIsStop = 1, "√", "")
Flex(FlexHwPdRc).AddItem ItemStr, Flex(FlexHwPdRc).Rows - 1
Flex(FlexHwPdRc).RowData(Flex(FlexHwPdRc).Rows - 2) = m_HwPdRc.HwPdRc_Key
Next
If Flex(FlexHwPdRc).Rows > 2 Then
Flex(FlexHwPdRc).Row = 1
Set OHwPdRc = OHwPdRcs(CStr(Flex(FlexHwPdRc).RowData(1)))
Else
Set OHwPdRc = Nothing
End If
Exit Sub
Errorhandle:
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub AddRecord(RecordName As String)
On Error GoTo Errorhandle
Flex(FlexHwPdRc).Row = Flex(FlexHwPdRc).Rows - 1
Flex(FlexHwPdRc).Col = Flex(FlexHwPdRc).ColIndex("HWPDRCCODE")
gPublicFunction.SetToolbarStatu Me, Tlbaction(TlbHwPdRc), RecordName
Exit Sub
Errorhandle:
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub CancelRecord(RecordName As String)
On Error GoTo Errorhandle
If Tlbaction(TlbHwPdRc).Tag <> "" Then
gPublicFunction.SetToolbarStatu Me, Tlbaction(TlbHwPdRc), RecordName
LoadDataIntoGrid
End If
Exit Sub
Errorhandle:
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub Delrecord(RecordName As String)
On Error GoTo Errorhandle
If OHwPdRcs Is Nothing Then
Exit Sub
End If
If OHwPdRc Is Nothing Then
Exit Sub
End If
If Flex(FlexHwPdRc).Rows <= 2 Then
Exit Sub
End If
If MsgBox("您真的要删除吗?", vbYesNo) = vbYes Then
OHwPdRcs.Remove CStr(OHwPdRc.HwPdRc_Key)
gPublicFunction.RemoveFlexItem Flex(FlexHwPdRc).Row, Flex(FlexHwPdRc)
If Flex(FlexHwPdRc).Rows = 2 Then
Set OHwPdRc = Nothing
Else
Set OHwPdRc = OHwPdRcs(CStr(Flex(FlexHwPdRc).RowData(Flex(FlexHwPdRc).Row)))
End If
End If
Exit Sub
Errorhandle:
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub SaveRecord(RecordName As String)
On Error GoTo Errorhandle
SetValueToObject RecordName
OHwPdRcs.DbSave
gPublicFunction.SetToolbarStatu Me, Tlbaction(TlbHwPdRc), RecordName
Exit Sub
Errorhandle:
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub SetValueToObject(ObjectName As String)
Dim I As Integer
On Error GoTo Errorhandle
For I = 1 To Flex(FlexHwPdRc).Rows - 2
Set OHwPdRc = OHwPdRcs.Item(CStr(Flex(FlexHwPdRc).RowData(I)))
OHwPdRc.HwPdRcCode = Trim(Flex(FlexHwPdRc).TextMatrix(I, Flex(FlexHwPdRc).ColIndex("HWPDRCCODE")))
OHwPdRc.HwPdRcMc = Trim(Flex(FlexHwPdRc).TextMatrix(I, Flex(FlexHwPdRc).ColIndex("HWPDRCMC")))
OHwPdRc.HwPdRcIsStop = IIf(Trim(Flex(FlexHwPdRc).TextMatrix(I, Flex(FlexHwPdRc).ColIndex("HWPDRCISSTOP"))) <> "", 1, 0)
Next
Exit Sub
Errorhandle:
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error GoTo Errorhandle
Set OHwPdRc = Nothing
Set OHwPdRcs = Nothing
gPublicCommon.PublicFunction.SaveFormSet Me
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub Tlbaction_ButtonClick(Index As Integer, ByVal Button As MSComctlLib.Button)
Dim Action, RecordName As String
On Error GoTo Errorhandle
Action = (Mid(Button.Key, 1, 3))
RecordName = Button.Key
If Trim(Flex(FlexHwPdRc).EditText) <> "" Then
Flex(FlexHwPdRc).TextMatrix(Flex(FlexHwPdRc).Row, Flex(FlexHwPdRc).Col) = Trim(Flex(FlexHwPdRc).EditText)
End If
Select Case Action
Case "EDI"
AddRecord RecordName
Case "CAN"
CancelRecord RecordName
Case "SAV"
SaveRecord RecordName
Case "DEF"
Delrecord RecordName
Case "EXI"
Unload Me
End Select
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub Form_Resize()
On Error GoTo Errorhandle
gPublicCommon.PublicFunction.ResizeForm Me
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -