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

📄 productivity.frm

📁 gps 源码.GPS工作原理,对开发GPS软件有帮助
💻 FRM
📖 第 1 页 / 共 2 页
字号:
        MyButtonAction = ""
        ClearAllFields
        Display
        DisableFields
    End If
    
End Sub
' This control event is to Display the first record
Private Sub cmdFirst_Click()
    cmdSave.Enabled = False
    RSProductivity.MoveFirst
    ClearAllFields
    Display
End Sub
' This control event is to Display the last record
Private Sub cmdLast_Click()
    cmdSave.Enabled = False
    RSProductivity.MoveLast
    ClearAllFields
    Display
End Sub

' This control event is to get the record to be modified
Private Sub cmdModify_Click()
    EnableFields
    MyQueryModify = "select * from Productivity where ID= " & CLng(txtID.Text)
    Set RSProductivityModify = New ADODB.Recordset
    RSProductivityModify.Open MyQueryModify, CnProductivity, adOpenKeyset, adLockOptimistic
    If RSProductivityModify.RecordCount > 0 Then
        OrganizationType = RSProductivityModify(1)
        AreaOfFocus = RSProductivityModify(2)
        MyButtonAction = "Modify"
        cmdExit.Caption = "&Cancel"
        DisablecmdButtons
        cmdSave.Enabled = True
        cboOrgType.Clear
        OrganizationTypesToCboOrgType
         i = 0
        For i = 0 To 2
            If cboOrgType.List(i) = OrganizationType Then
                cboOrgType.Text = cboOrgType.List(i)
                Exit For
            End If
        Next
       cboAreaOfFocus.Clear
       AreaOfFocusTocboAreaOfFocus
       i = 0
       For i = 0 To 4
            If cboAreaOfFocus.List(i) = AreaOfFocus Then
                cboAreaOfFocus.Text = cboAreaOfFocus.List(i)
                Exit For
            End If
        Next
    Else
        MsgBox "NO Record"
    End If
    RSProductivityModify.Close
    Set RSProductivityModify = Nothing
    cboOrgType.SetFocus
End Sub

' This control event is to enter data for new record.
Private Sub cmdNew_Click()
   EnableFields
   ClearAllFields
   MyButtonAction = "New"
   cmdExit.Caption = "&Cancel"
   DisablecmdButtons
   cmdSave.Enabled = True
   MyQueryNew = "select max(ID) from Productivity"
    Set RSProductivityNew = New ADODB.Recordset
    RSProductivityNew.Open MyQueryNew, CnProductivity, adOpenKeyset, adLockOptimistic
    If RSProductivityNew.RecordCount > 0 Then
        If Not RSProductivityNew.Fields(0) Then
            txtID.Text = RSProductivityNew.Fields(0) + 1
        Else
            txtID.Text = "1"
        End If
    End If
    RSProductivityNew.Close
    Set RSProductivityNew = Nothing
    OrganizationTypesToCboOrgType
    cboOrgType.ListIndex = 0
    AreaOfFocusTocboAreaOfFocus
    cboAreaOfFocus.ListIndex = 0
End Sub
'This control event is to display the next record
Private Sub cmdNext_Click()
    cmdSave.Enabled = False
    ClearAllFields
    RSProductivity.MoveNext
    If RSProductivity.EOF Then
        MsgBox "Last Record"
        RSProductivity.MovePrevious
    End If
    Display
End Sub
'This control event is to display the previous record
Private Sub cmdPrevious_Click()
    cmdSave.Enabled = False
    ClearAllFields
    RSProductivity.MovePrevious
    If RSProductivity.BOF Then
        MsgBox "First Record"
        RSProductivity.MoveNext
    End If
    Display
End Sub
'This control event is to display report
Private Sub cmdReport_Click()
    DataEnvironment1.Command1
    DataReport1.Show
    
End Sub

'This control event is to add new record or update existing record
Private Sub cmdSave_Click()
    If MyButtonAction = "New" Then
            RSProductivity.AddNew
            RSProductivity.Fields("OrganizationType") = Trim(cboOrgType.Text)
            RSProductivity.Fields("AreaOfFocus") = Trim(cboAreaOfFocus.Text)
            RSProductivity.Fields("AnnualTurnover") = Trim(txtAnnualTurnover.Text)
            RSProductivity.Fields("NoOfPeople") = Trim(txtNoOfPeople.Text)
            RSProductivity.Update
            EnablecmdButtons
            cmdExit.Caption = "E&xit"
            MyButtonAction = ""
            ClearAllFields
            Display
            DisableFields

    ElseIf MyButtonAction = "Modify" Then
            RSProductivity.Fields("OrganizationType") = Trim(cboOrgType.Text)
            RSProductivity.Fields("AreaOfFocus") = Trim(cboAreaOfFocus.Text)
            RSProductivity.Fields("AnnualTurnover") = Trim(txtAnnualTurnover.Text)
            RSProductivity.Fields("NoOfPeople") = Trim(txtNoOfPeople.Text)
            RSProductivity.Update
            EnablecmdButtons
            cmdExit.Caption = "E&xit"
            MyButtonAction = ""
            ClearAllFields
            Display
            DisableFields
    
    End If

End Sub



'This form event is to display first record data while the application is loading.
Private Sub Form_Load()
    txtID.Enabled = False
    ClearAllFields
    EnablecmdButtons
    Set CnProductivity = New ADODB.Connection
    CnProductivity.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & App.Path & "/" & "Productivity.mdb"
    'CnProductivity.Open "DSN=Productivity"
    MyQuery = "Select * From Productivity"
    Set RSProductivity = New ADODB.Recordset
    RSProductivity.Open MyQuery, CnProductivity, adOpenKeyset, adLockOptimistic
    If RSProductivity.RecordCount > 0 Then
        RSProductivity.MoveFirst
        Display
    Else
        MsgBox "No Records In the Database"
        cmdModify.Enabled = False
        cmdSave.Enabled = False
        cmdDelete.Enabled = False
        cmdFirst.Enabled = False
        cmdLast.Enabled = False
        cmdNext.Enabled = False
        cmdPrevious.Enabled = False
    End If
    DisableFields
End Sub
'This control event is to close the record set, connection and application
Private Sub Form_Unload(Cancel As Integer)
    RSProductivity.Close
   Set RSProductivity = Nothing
   CnProductivity.Close
   Set CnProductivity = Nothing
   End
End Sub

'This procedure is to clear all the text boxes
Private Sub ClearAllFields()
    txtID.Text = ""
    cboOrgType.Clear
    cboAreaOfFocus.Clear
    txtAnnualTurnover.Text = ""
    txtNoOfPeople.Text = ""
End Sub
'This procedure is to assigning database fields data to text fields
Private Sub Display()
    If (RSProductivity.BOF) Or (RSProductivity.EOF) Then
        Exit Sub
    End If
    txtID.Text = RSProductivity.Fields("ID")
    cboOrgType.Clear
    cboOrgType.AddItem RSProductivity.Fields("OrganizationType")
    cboOrgType.ListIndex = 0
    cboAreaOfFocus.Clear
    cboAreaOfFocus.AddItem RSProductivity.Fields("AreaOfFocus")
    cboAreaOfFocus.ListIndex = 0
    txtAnnualTurnover.Text = RSProductivity.Fields("AnnualTurnover")
    txtNoOfPeople.Text = RSProductivity.Fields("NoOfPeople")
End Sub

'This procedure is to add Organization types to combobox
Private Sub OrganizationTypesToCboOrgType()
    cboOrgType.AddItem ("Small Enterprises")
    cboOrgType.AddItem ("Medium Enterprises")
    cboOrgType.AddItem ("Multi National Company")
End Sub

'This procedure is to add Area Of Focus to combobox
Private Sub AreaOfFocusTocboAreaOfFocus()
    cboAreaOfFocus.AddItem ("Embedded Software")
    cboAreaOfFocus.AddItem ("Networking")
    cboAreaOfFocus.AddItem ("E -Commerce")
    cboAreaOfFocus.AddItem ("Telecom")
    cboAreaOfFocus.AddItem ("Business Applications")
End Sub
'This procedure is to enable all text fields
Private Sub EnableFields()
    cboOrgType.Enabled = True
    cboAreaOfFocus.Enabled = True
    txtAnnualTurnover.Enabled = True
    txtNoOfPeople.Enabled = True
End Sub
'This procedure is to disable all text fields
Private Sub DisableFields()
    cboOrgType.Enabled = False
    cboAreaOfFocus.Enabled = False
    txtAnnualTurnover.Enabled = False
    txtNoOfPeople.Enabled = False
End Sub
'This procedure is to enable the command buttons
Private Sub EnablecmdButtons()
    cmdSave.Enabled = False
    cmdNew.Enabled = True
    cmdModify.Enabled = True
    cmdDelete.Enabled = True
    cmdFirst.Enabled = True
    cmdLast.Enabled = True
    cmdNext.Enabled = True
    cmdPrevious.Enabled = True
End Sub
'This procedure is to disable the command buttons
Private Sub DisablecmdButtons()
    cmdSave.Enabled = True
    cmdNew.Enabled = False
    cmdModify.Enabled = False
    cmdDelete.Enabled = False
    cmdFirst.Enabled = False
    cmdLast.Enabled = False
    cmdNext.Enabled = False
    cmdPrevious.Enabled = False
End Sub

' This event is to validate for numeric values
Private Sub txtAnnualTurnover_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 8, 46, 48 To 57
        
        Case Else
            KeyAscii = 0
            MsgBox "Enter Numbers only"
        
    End Select
End Sub


' This event is to validate for numeric values
Private Sub txtNoOfPeople_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 8, 48 To 57
        
        Case Else
            KeyAscii = 0
            MsgBox "Enter Numbers only"
        End Select
End Sub
' This event is to validate for null.
Private Sub txtAnnualTurnover_LostFocus()
    If txtAnnualTurnover.Text = "" Then
        MsgBox "This field is manditory"
        txtAnnualTurnover.SetFocus
    End If
End Sub

' This event is to validate for null.
Private Sub txtNoOfPeople_LostFocus()
    If txtNoOfPeople.Text = "" Then
        MsgBox "This field is manditory"
        txtNoOfPeople.SetFocus
    End If
End Sub

⌨️ 快捷键说明

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