📄 frmpsbm.frm
字号:
Const ImgPsBm = 0
Const SBarPsBm = 0
Const FlexPsBm = 0
Dim mCurColOldValue As String
Dim mOldPsBmYear As String
Dim OPsBm As PsBm
Dim OPsBms As PsBms
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(FlexPsBm).TextMatrix(Flex(FlexPsBm).Row, Flex(FlexPsBm).Col))
If Tlbaction(TlbPsBm).Tag = "" Then
Cancel = True
End If
If Tlbaction(TlbPsBm).Tag <> "" Then
Select Case UCase(Flex(FlexPsBm).ColKey(Col))
Case "PSBMCODE"
Case "PSBMMC"
If OPsBm Is Nothing Then
Cancel = True
End If
Case "PSBMTYPE"
If OPsBm Is Nothing Then
Cancel = True
End If
If Flex(FlexPsBm).ColComboList(Col) = "" Then
Flex(FlexPsBm).ColComboList(Col) = "1-管理部门|2-生产部门"
End If
End Select
End If
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 FlexPsBm
If Flex(Index).Rows > 2 And Flex(FlexPsBm).Row <> Flex(FlexPsBm).Rows - 1 Then
Set OPsBm = OPsBms(CStr(Flex(FlexPsBm).RowData(Flex(FlexPsBm).Row)))
Else
Set OPsBm = 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(TlbPsBm).Tag = "" Then
Exit Sub
End If
mCurRow = Flex(FlexPsBm).Row
mCurCol = Flex(FlexPsBm).Col
Select Case Flex(FlexPsBm).ColKey(Flex(FlexPsBm).Col)
Case "PSBMCODE"
If OPsBm Is Nothing Then
AddNewRecord
Else
OPsBm.PsBmCode = Trim(Flex(FlexPsBm).TextMatrix(mCurRow, mCurCol))
End If
Case "PSBMMC"
If Not OPsBm Is Nothing Then
OPsBm.PsBmMc = Trim(Flex(FlexPsBm).TextMatrix(mCurRow, mCurCol))
End If
Case "PSBMTYPE"
If Not OPsBm Is Nothing Then
OPsBm.PsBmType = Val(gPublicFunction.GetSubString(Flex(FlexPsBm).TextMatrix(mCurRow, mCurCol)))
End If
End Select
Exit Sub
Errorhandle:
Flex(FlexPsBm).TextMatrix(mCurRow, mCurCol) = mCurColOldValue
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub AddNewRecord()
On Error GoTo Errorhandle
If Trim(Flex(FlexPsBm).TextMatrix(Flex(FlexPsBm).Row, Flex(FlexPsBm).Col)) <> "" Then
Set OPsBm = New PsBm
OPsBm.PsBmCode = Trim(Flex(FlexPsBm).TextMatrix(Flex(FlexPsBm).Row, Flex(FlexPsBm).Col))
OPsBms.Add OPsBm
Flex(FlexPsBm).RowData(Flex(FlexPsBm).Rows - 1) = OPsBm.PsBm_Key
Flex(FlexPsBm).AddItem ""
End If
Exit Sub
Errorhandle:
Set OPsBm = Nothing
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub Form_Load()
On Error GoTo Errorhandle
Flex(FlexPsBm).Editable = flexEDKbdMouse
Flex(FlexPsBm).ColKey(1) = "PSBMCODE"
Flex(FlexPsBm).ColKey(2) = "PSBMMC"
Flex(FlexPsBm).ColKey(3) = "PSBMTYPE"
gPublicCommon.PublicFunction.LoadFormSet Me, Tlbaction(TlbPsBm), Img(ImgPsBm), SBar(SBarPsBm)
gPublicCommon.gForms(UCase(Me.Name)).ControlStatus.Add "", Flex(FlexPsBm)
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 TlbPsBm, mButton
End If
Exit Sub
Errorhandle:
MsgBox Err.Description
End Sub
Private Sub LoadDataIntoGrid()
Dim ItemStr As String
Dim m_PsBm As PsBm
On Error GoTo Errorhandle
Flex(FlexPsBm).Rows = 1
Flex(FlexPsBm).AddItem ""
Set OPsBms = New PsBms
OPsBms.FillbyDb
For Each m_PsBm In OPsBms
ItemStr = vbTab & m_PsBm.PsBmCode & vbTab & m_PsBm.PsBmMc & vbTab & Choose(m_PsBm.PsBmType, "1-管理部门", "2-生产部门")
Flex(FlexPsBm).AddItem ItemStr, Flex(FlexPsBm).Rows - 1
Flex(FlexPsBm).RowData(Flex(FlexPsBm).Rows - 2) = m_PsBm.PsBm_Key
Next
If Flex(FlexPsBm).Rows > 2 Then
Flex(FlexPsBm).Row = 1
Set OPsBm = OPsBms(CStr(Flex(FlexPsBm).RowData(1)))
Else
Set OPsBm = 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(FlexPsBm).Row = Flex(FlexPsBm).Rows - 1
Flex(FlexPsBm).Col = Flex(FlexPsBm).ColIndex("PSBMCODE")
gPublicFunction.SetToolbarStatu Me, Tlbaction(TlbPsBm), RecordName
Exit Sub
Errorhandle:
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub CancelRecord(RecordName As String)
On Error GoTo Errorhandle
If Tlbaction(TlbPsBm).Tag <> "" Then
gPublicFunction.SetToolbarStatu Me, Tlbaction(TlbPsBm), 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 OPsBms Is Nothing Then
Exit Sub
End If
If OPsBm Is Nothing Then
Exit Sub
End If
If Flex(FlexPsBm).Rows <= 2 Then
Exit Sub
End If
If MsgBox("您真的要删除吗?", vbYesNo) = vbYes Then
OPsBms.Remove CStr(OPsBm.PsBm_Key)
gPublicFunction.RemoveFlexItem Flex(FlexPsBm).Row, Flex(FlexPsBm)
If Flex(FlexPsBm).Rows = 2 Then
Set OPsBm = Nothing
Else
Set OPsBm = OPsBms(CStr(Flex(FlexPsBm).RowData(Flex(FlexPsBm).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
OPsBms.DbSave
gPublicFunction.SetToolbarStatu Me, Tlbaction(TlbPsBm), 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(FlexPsBm).Rows - 2
Set OPsBm = OPsBms.Item(CStr(Flex(FlexPsBm).RowData(I)))
OPsBm.PsBmCode = Trim(Flex(FlexPsBm).TextMatrix(I, Flex(FlexPsBm).ColIndex("PSBMCODE")))
OPsBm.PsBmMc = Trim(Flex(FlexPsBm).TextMatrix(I, Flex(FlexPsBm).ColIndex("PSBMMC")))
OPsBm.PsBmType = Val(gPublicFunction.GetSubString(Flex(FlexPsBm).TextMatrix(I, Flex(FlexPsBm).ColIndex("PSBMTYPE"))))
Next
Exit Sub
Errorhandle:
Err.Raise vbObjectError + 1, , Err.Description
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error GoTo Errorhandle
Set OPsBm = Nothing
Set OPsBms = 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(FlexPsBm).EditText) <> "" Then
Flex(FlexPsBm).TextMatrix(Flex(FlexPsBm).Row, Flex(FlexPsBm).Col) = Trim(Flex(FlexPsBm).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 + -