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

📄 frmcwqj.frm

📁 制造业产供销与往来系统源码,包括进销存及全部控件!
💻 FRM
📖 第 1 页 / 共 2 页
字号:
    End Select
    
Exit Sub
Errorhandle:
   MsgBox Err.Description
End Sub

Private Sub SetControlToFlex()
   Dim mCurCol As Integer
   Dim mCurRow As Integer
   Dim mCurValue As String
On Error GoTo Errorhandle

   If Tlbaction(TlbCwQj).Tag = "" Then
      Exit Sub
   End If
   
   mCurRow = Flex(FlexCwQj).Row
   mCurCol = Flex(FlexCwQj).Col
   
   If Trim(Flex(FlexCwQj).EditText) = "" Then
      Exit Sub
   End If
   
   mCurValue = Trim(Flex(FlexCwQj).TextMatrix(mCurRow, mCurCol))
      
   Select Case Flex(FlexCwQj).ColKey(Flex(FlexCwQj).Col)
   Case "CWQJCODE"
         If OCwQj Is Nothing Then
            AddNewRecord
         Else
            OCwQj.CwqjCode = mCurValue
         End If
   
   Case "CWQJBEGDAT"
         If Not OCwQj Is Nothing Then
            Flex(FlexCwQj).TextMatrix(mCurRow, mCurCol) = gPublicFunction.SetDateFormat(mCurValue)
            OCwQj.CwqjBegDat = gPublicFunction.ConvDateToString(Trim(Flex(FlexCwQj).TextMatrix(mCurRow, mCurCol)))
         End If
            
   Case "CWQJENDDAT"
         If Not OCwQj Is Nothing Then
            Flex(FlexCwQj).TextMatrix(mCurRow, mCurCol) = gPublicFunction.SetDateFormat(mCurValue)
            OCwQj.CwqjEndDat = gPublicFunction.ConvDateToString(Trim(Flex(FlexCwQj).TextMatrix(Flex(FlexCwQj).Row, mCurCol)))
         End If
   
   End Select


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

Private Sub AddNewRecord()
On Error GoTo Errorhandle

   If Trim(Flex(FlexCwQj).TextMatrix(Flex(FlexCwQj).Row, Flex(FlexCwQj).Col)) <> "" Then
      Set OCwQj = New CwQj
      OCwQj.CwqjCode = Trim(Flex(FlexCwQj).TextMatrix(Flex(FlexCwQj).Row, Flex(FlexCwQj).Col))
      OCwQjs.Add OCwQj
      Flex(FlexCwQj).RowData(Flex(FlexCwQj).Rows - 1) = OCwQj.CwQj_Key
      Flex(FlexCwQj).AddItem ""
   End If

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

Private Sub Form_Activate()
On Error GoTo Errorhandle
   Text(txtCwQjYear).SetFocus
Exit Sub
Errorhandle:
    MsgBox Err.Description
End Sub

Private Sub Form_Load()
On Error GoTo Errorhandle
   
   Flex(FlexCwQj).Editable = flexEDKbdMouse
   
   Flex(FlexCwQj).ColKey(1) = "CWQJCODE"
   Flex(FlexCwQj).ColKey(2) = "CWQJBEGDAT"
   Flex(FlexCwQj).ColKey(3) = "CWQJENDDAT"
   
   gPublicFunction.LoadFormSet Me, Tlbaction(TlbCwQj), Img(ImgCwqj), SBar(SBarCwqj)
   
   gPublicCommon.gForms(UCase(Me.Name)).ControlStatus.Add "", Text(txtCwQjYear), Flex(FlexCwQj)
   gPublicCommon.gForms(UCase(Me.Name)).ControlStatus.Add "EDI", Text(txtCwQjYear)
   gPublicCommon.PublicFunction.EnableControl Me, ""
   
   If gPublicCommon.PublicSysDatas("SYSCPCW_CCWQJCODE").SysDataValue <> "" Then
      Dim mCurYear As Variant
      mCurYear = gPublicFunction.GetFieldValue("CWQJYEAR", "SELECT CWQJYEAR FROM CWQJREC WHERE CWQJCODE='" & gPublicCommon.PublicSysDatas("SYSCPCW_CCWQJCODE").SysDataValue & "'")
      If Not IsNull(mCurYear) Then
         Text(txtCwQjYear).Text = mCurYear
         LoadDataIntoGrid
      End If
   End If
   
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 TlbCwQj, mButton
   End If
  
Exit Sub
Errorhandle:
   MsgBox Err.Description
End Sub

Private Sub LoadDataIntoGrid()
    Dim ItemStr As String
    Dim m_CwQj As CwQj
On Error GoTo Errorhandle
      
   Flex(FlexCwQj).Rows = 1
   Flex(FlexCwQj).AddItem ""
   
   If Trim(Text(txtCwQjYear).Text) = "" Then
      Exit Sub
   End If
   
   Set OCwQjs = New CwQjs
   OCwQjs.FillbyDb " CWQJYEAR='" & Trim(Text(txtCwQjYear).Text) & "'"
   
   For Each m_CwQj In OCwQjs
      ItemStr = vbTab & m_CwQj.CwqjCode & vbTab & gPublicFunction.ConvStringToDate(m_CwQj.CwqjBegDat) & vbTab & gPublicFunction.ConvStringToDate(m_CwQj.CwqjEndDat)
      Flex(FlexCwQj).AddItem ItemStr, Flex(FlexCwQj).Rows - 1
      Flex(FlexCwQj).RowData(Flex(FlexCwQj).Rows - 2) = m_CwQj.CwQj_Key
   Next
   
   If Flex(FlexCwQj).Rows > 2 Then
     Flex(FlexCwQj).Row = 1
     Set OCwQj = OCwQjs(CStr(Flex(FlexCwQj).RowData(1)))
   Else
     Set OCwQj = Nothing
   End If
               
Exit Sub
Errorhandle:
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

Private Sub AddRecord(RecordName As String)
On Error GoTo Errorhandle
   
   If Trim(Text(txtCwQjYear).Text) = "" Then
      Err.Raise vbObjectError + 1, , "请输入财务年度!"
      Exit Sub
   End If
   
   gPublicFunction.SetToolbarStatu Me, Tlbaction(TlbCwQj), RecordName
   Flex(FlexCwQj).Row = Flex(FlexCwQj).Rows - 1
   Flex(FlexCwQj).Col = Flex(FlexCwQj).ColIndex("CWQJCODE")
    
Exit Sub
Errorhandle:
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

Private Sub CancelRecord(RecordName As String)
On Error GoTo Errorhandle

   If Tlbaction(TlbCwQj).Tag <> "" Then
      gPublicFunction.SetToolbarStatu Me, Tlbaction(TlbCwQj), 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 OCwQjs Is Nothing Then
       Exit Sub
   End If
   
   If OCwQj Is Nothing Then
       Exit Sub
   End If
   
   If Flex(FlexCwQj).Rows <= 2 Then
       Exit Sub
   End If
    
   If MsgBox("您真的要删除吗?", vbYesNo) = vbYes Then
      OCwQjs.Remove CStr(OCwQj.CwQj_Key)
      gPublicFunction.RemoveFlexItem Flex(FlexCwQj).Row, Flex(FlexCwQj)
      If Flex(FlexCwQj).Rows = 2 Then
          Set OCwQj = Nothing
      Else
          Set OCwQj = OCwQjs(CStr(Flex(FlexCwQj).RowData(Flex(FlexCwQj).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
   OCwQjs.DbSave
   gPublicFunction.SetToolbarStatu Me, Tlbaction(TlbCwQj), 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(FlexCwQj).Rows - 2
      Set OCwQj = OCwQjs.Item(CStr(Flex(FlexCwQj).RowData(I)))
      OCwQj.CwqjYear = Trim(Text(txtCwQjYear).Text)
      OCwQj.CwqjCode = Trim(Flex(FlexCwQj).TextMatrix(I, Flex(FlexCwQj).ColIndex("CWQJCODE")))
      OCwQj.CwqjBegDat = gPublicFunction.ConvDateToString(Trim(Flex(FlexCwQj).TextMatrix(I, Flex(FlexCwQj).ColIndex("CWQJBEGDAT"))))
      OCwQj.CwqjEndDat = gPublicFunction.ConvDateToString(Trim(Flex(FlexCwQj).TextMatrix(I, Flex(FlexCwQj).ColIndex("CWQJENDDAT"))))
   Next
   
Exit Sub
Errorhandle:
   Err.Raise vbObjectError + 1, , Err.Description
End Sub

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

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

    Set OCwQj = Nothing
    Set OCwQjs = Nothing
    
    gPublicFunction.SaveFormSet Me
    
    Exit Sub
Errorhandle:
    MsgBox Err.Description
End Sub

Private Sub Text_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error GoTo Errorhandle
   
   If Index = txtCwQjYear And KeyCode = 13 Then
      Text_LostFocus Index
   End If

Exit Sub
Errorhandle:
   MsgBox Err.Description
End Sub

Private Sub Text_LostFocus(Index As Integer)
On Error GoTo Errorhandle
   
   If Trim(Text(txtCwQjYear).Text) <> "" And Trim(Text(txtCwQjYear).Text) <> mOldCwqjYear Then
      LoadDataIntoGrid
      mOldCwqjYear = Trim(Text(txtCwQjYear).Text)
   End If

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(FlexCwQj).EditText) <> "" Then
      Flex(FlexCwQj).TextMatrix(Flex(FlexCwQj).Row, Flex(FlexCwQj).Col) = Trim(Flex(FlexCwQj).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


⌨️ 快捷键说明

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