frmcgshd.frm

来自「制造业产供销与往来系统源码,包括进销存及全部控件!」· FRM 代码 · 共 1,512 行 · 第 1/4 页

FRM
1,512
字号
            End If
         End If
      
   End Select
   
Exit Sub
Errorhandle:
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

Private Sub Flex_RowColChange(Index As Integer)
On Error GoTo Errorhandle

   Select Case Index
   Case FlexCgShdh
   
         If Flex(FlexCgShdh).Rows > 1 Then
            Set oCgShdh = oCgShdhs(CStr(Flex(FlexCgShdh).RowData(Flex(FlexCgShdh).Row)))
            SetValueToControl
         Else
            Set oCgShdh = Nothing
            Clearcontrol
         End If
   
   Case FlexCgShd
   
         If Flex(FlexCgShd).Row <> Flex(FlexCgShd).Rows - 1 Then
            Set oCgShd = oCgShdh.CgShds(CStr(Flex(FlexCgShd).RowData(Flex(FlexCgShd).Row)))
         Else
            Set oCgShd = Nothing
         End If
   
   End Select
   
Exit Sub
Errorhandle:
   MsgBox Err.Description
End Sub

Private Sub SetValueToControl()
On Error GoTo Errorhandle

   Text(TxtCgShdhDocno).Text = oCgShdh.CgShdhDocno
   Text(TxtCgShdhDat).Text = gPublicFunction.ConvStringToDate(oCgShdh.CgShdhDat)
   Text(TxtCgShdh_CwqjCode).Text = oCgShdh.CgShdh_CwQjCode
   Combo(CBxCgShdh_KhCode).Text = oCgShdh.Kh.KhCode
   Combo(CBxCgShdh_CwBzCode).Text = oCgShdh.CwBz.CwBzCode
   LoadDataIntoGrid
   
Exit Sub
Errorhandle:
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error GoTo Errorhandle

   Set oCgShdhs = Nothing
   Set oCgShdh = Nothing
   Set oCgShd = Nothing
   
   gPublicFunction.SaveFormSet Me
    
Exit Sub
Errorhandle:
   MsgBox Err.Description
End Sub

Private Sub muEdit_Click(Index As Integer)
   Dim mFrmCgshdGen As frmCgShdGen
On Error GoTo Errorhandle

Select Case muEdit(Index).Tag
Case "CGSHDGEN"
      If Tlbaction(TlbCgshd).Tag <> "" Then
         SetValueToObject
         Set mFrmCgshdGen = New frmCgShdGen
         Set mFrmCgshdGen.Cgshdh = oCgShdh
         mFrmCgshdGen.Show vbModal
         Set mFrmCgshdGen = Nothing
         LoadDataIntoGrid
      End If
End Select

Exit Sub
Errorhandle:
   Set mFrmCgshdGen = Nothing
   MsgBox Err.Description
End Sub

Private Sub Text_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error GoTo Errorhandle

gPublicFunction.FormKeyDown Me, KeyCode, Shift, Text(Index)

Exit Sub
Errorhandle:
   MsgBox Err.Description
End Sub

Private Sub Text_KeyPress(Index As Integer, KeyAscii As Integer)
On Error GoTo Errorhandle

   gPublicFunction.InputCheck Me, Text(Index), KeyAscii

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(TlbCgshd).Tag = "" Then
      Exit Sub
   End If

   mCurRow = Flex(FlexCgShd).Row
   mCurCol = Flex(FlexCgShd).Col
   
   Select Case Flex(FlexCgShd).ColKey(Flex(FlexCgShd).Col)
   Case "HWBMCODE"
         If oCgShd Is Nothing Then
            AddNewRecord
         Else
            oCgShd.CgShd_HwBmCode = Trim(Flex(FlexCgShd).TextMatrix(mCurRow, mCurCol))
            Flex(FlexCgShd).TextMatrix(mCurRow, Flex(FlexCgShd).ColIndex("HWBMMC")) = oCgShd.CgShd_HwBmMc
            Flex(FlexCgShd).TextMatrix(mCurRow, Flex(FlexCgShd).ColIndex("HWDWCODE")) = oCgShd.CgShd_HwDwCode
            Flex(FlexCgShd).TextMatrix(mCurRow, Flex(FlexCgShd).ColIndex("CGSHD_HWDWCONV")) = oCgShd.CgShd_HwDwConv
         End If
   
   Case "HWDWCODE"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShd_HwDwCode = Trim(Flex(FlexCgShd).TextMatrix(mCurRow, mCurCol))
         End If
         
   Case "CGSHD_HWDWCONV"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShd_HwDwConv = Val(Flex(FlexCgShd).TextMatrix(mCurRow, mCurCol))
         End If
         
   Case "HWCKMC"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShd_HwCkMc = Trim(Flex(FlexCgShd).TextMatrix(mCurRow, mCurCol))
         End If
   
   Case "CGSHDQTY"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShdQty = Val(Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, mCurCol))
            Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, Flex(FlexCgShd).ColIndex("CGSHDAMT")) = oCgShd.CgShdAmt
            Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, Flex(FlexCgShd).ColIndex("CGSHDTAMT")) = oCgShd.CgShdTAmt
         End If
   
   Case "CGSHDPRICE"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShdPrice = Val(Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, mCurCol))
            Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, Flex(FlexCgShd).ColIndex("CGSHDAMT")) = oCgShd.CgShdAmt
            Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, Flex(FlexCgShd).ColIndex("CGSHDTAMT")) = oCgShd.CgShdTAmt
         End If
   
   Case "CGSHDAMT"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShdAmt = Val(Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, mCurCol))
            Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, Flex(FlexCgShd).ColIndex("CGSHDTAMT")) = oCgShd.CgShdTAmt
         End If
   
   Case "CGSHDQAMT"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShdQAmt = Val(Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, mCurCol))
            Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, Flex(FlexCgShd).ColIndex("CGSHDTAMT")) = oCgShd.CgShdTAmt
         End If
   
   Case "CGSHDTAMT"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShdTAmt = Val(Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, mCurCol))
         End If
   
   Case "CWSMCODE"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShd_CwSmCode = Trim(Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, mCurCol))
         End If
   
   Case "CGSHDBZ"
         If Not oCgShd Is Nothing Then
            oCgShd.CgShdBz = Trim(Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, mCurCol))
         End If
   
   End Select
   
   If UCase(Flex(FlexCgShd).ColKey(Flex(FlexCgShd).Col)) = "CGSHDQTY" Or UCase(Flex(FlexCgShd).ColKey(Flex(FlexCgShd).Col)) = "CGSHDPRICE" Or UCase(Flex(FlexCgShd).ColKey(Flex(FlexCgShd).Col)) = "CGSHDAMT" Or UCase(Flex(FlexCgShd).ColKey(Flex(FlexCgShd).Col)) = "CGSHDQAMT" Or UCase(Flex(FlexCgShd).ColKey(Flex(FlexCgShd).Col)) = "CGSHDTAMT" Then
      gPublicFunction.SumFlexQtyAmt Flex(FlexCgShd), "CGSHDQTY,CGSHDAMT,CGSHDQAMT,CGSHDTAMT", Text(TxtTotalQty), Text(TxtTotalAmt), Text(TxtTotalQAmt), Text(TxtTotalTAmt)
   End If

Exit Sub
Errorhandle:
   Flex(FlexCgShd).TextMatrix(mCurRow, mCurCol) = mCurColOldValue
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

Private Sub AddNewRecord()
   Dim mCurRow As Integer
On Error GoTo Errorhandle

   mCurRow = Flex(FlexCgShd).Row

   If Trim(Flex(FlexCgShd).TextMatrix(mCurRow, Flex(FlexCgShd).Col)) <> "" Then
      Set oCgShd = New CgShd
      Set oCgShd.Cgshdh = oCgShdh
      oCgShd.CgShd_HwBmCode = Trim(Flex(FlexCgShd).TextMatrix(mCurRow, Flex(FlexCgShd).Col))
      Flex(FlexCgShd).TextMatrix(mCurRow, Flex(FlexCgShd).ColIndex("HWBMMC")) = oCgShd.CgShd_HwBmMc
      Flex(FlexCgShd).TextMatrix(mCurRow, Flex(FlexCgShd).ColIndex("HWDWCODE")) = oCgShd.CgShd_HwDwCode
      Flex(FlexCgShd).TextMatrix(mCurRow, Flex(FlexCgShd).ColIndex("CGSHD_HWDWCONV")) = oCgShd.CgShd_HwDwConv
      Flex(FlexCgShd).TextMatrix(mCurRow, Flex(FlexCgShd).ColIndex("CWSMCODE")) = oCgShdh.Kh.Kh_CwSmCode
      oCgShdh.CgShds.Add oCgShd, 0
      Flex(FlexCgShd).RowData(Flex(FlexCgShd).Rows - 1) = oCgShd.CgShdKey
      Flex(FlexCgShd).AddItem ""
   End If

Exit Sub
Errorhandle:
   Set oCgShd = Nothing
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

Private Sub Form_Resize()
On Error GoTo Errorhandle
   gPublicFunction.ResizeForm Me
Exit Sub
Errorhandle:
   MsgBox Err.Description
End Sub

Private Sub Text_LostFocus(Index As Integer)
On Error GoTo Errorhandle

   Select Case Index
   Case TxtCgShdhDat
         
         If Tlbaction(TlbCgshd).Tag <> "" And Trim(Text(TxtCgShdhDat).Text) <> "" Then
            Text(TxtCgShdhDat).Text = gPublicFunction.SetDateFormat(Text(TxtCgShdhDat).Text)
            oCgShdh.CgShdhDat = gPublicFunction.ConvDateToString(Text(TxtCgShdhDat).Text)
            Text(TxtCgShdh_CwqjCode).Text = oCgShdh.CgShdh_CwQjCode
         End If
         
   Case TxtCgShdhDocno
   
           If Tlbaction(TlbCgshd).Tag = "" Then
               If Trim(Text(Index).Text) = "" Then
                  Exit Sub
               End If
               
               If Not oCgShdh Is Nothing Then
                  If oCgShdh.CgShdhDocno = Text(TxtCgShdhDocno).Text Then
                     Exit Sub
                  End If
               End If
   
               Set oCgShdh = New Cgshdh
               If oCgShdh.Requery(Text(TxtCgShdhDocno).Text) = 1 Then
                   SetValueToControl
               Else
                   Set oCgShdh = Nothing
                   Dim vCgshddocno As String
                   vCgshddocno = Text(TxtCgShdhDocno).Text
                   AddRecord "ADD"
                   Text(TxtCgShdhDocno).Text = vCgshddocno
               End If
        End If

   End Select

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(FlexCgShd).EditText) <> "" Then
      Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, Flex(FlexCgShd).Col) = Trim(Flex(FlexCgShd).EditText)
   End If
   
    Select Case Action
        Case "ADD"
             AddRecord RecordName
        Case "CHG"
             ChgRecord RecordName
        Case "CAN"
             CancelRecord RecordName
        Case "SAV"
             SaveRecord RecordName
        Case "DEL", "DEF"
             DelRecord RecordName
        Case "EXI"
             Unload Me
        Case "FIN"
             ShowBmQuery
        Case Else
            
    End Select
    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 TlbCgshd, mButton
   End If
  
Exit Sub
Errorhandle:
   MsgBox Err.Description
End Sub

Private Sub ShowBmQuery()
   Dim mCodeType As String
   Dim mQueryValue As String
On Error GoTo Errorhandle

   If Tlbaction(TlbCgshd).Tag = "" Then
      Exit Sub
   End If

   If Me.ActiveControl Is Nothing Then
      Exit Sub
   End If
      
   If Me.ActiveControl Is Flex(FlexCgShd) Then
   
      Select Case UCase(Flex(FlexCgShd).ColKey(Flex(FlexCgShd).Col))
      Case "HWBMCODE", "HWDWCODE", "HWCKMC", "CWSMCODE"
            mCodeType = UCase(Flex(FlexCgShd).ColKey(Flex(FlexCgShd).Col))
      End Select
      
      If mCodeType <> "" Then
         mQueryValue = gPublicFunction.GetBmQueryValue(Me, mCodeType)
         If mQueryValue <> "" Then
            Flex(FlexCgShd).TextMatrix(Flex(FlexCgShd).Row, Flex(FlexCgShd).Col) = mQueryValue
            Flex(FlexCgShd).EditCell
            SetControlToFlex
         End If
      End If
      
   Else
   
      Select Case Mid(UCase(Me.ActiveControl.Tag), 4)
      Case "CWQJCODE", "GYSCODE|KHCODE", "CWBZCODE"
            mCodeType = Mid(UCase(Me.ActiveControl.Tag), 4)
      End Select
   
      If mCodeType <> "" Then
         mQueryValue = gPublicFunction.GetBmQueryValue(Me, mCodeType)
         If mQueryValue <> "" Then
            Me.ActiveControl.Text = mQueryValue
         End If
      End If
      
   End If
  
Exit Sub
Errorhandle:
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

⌨️ 快捷键说明

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