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

📄 frmemployeeedit.frm

📁 考勤机管理软件,用于统计某段时间某个部门或者某个员工在某段内迟到与早退次数.
💻 FRM
📖 第 1 页 / 共 2 页
字号:

Private Sub cmbVac_BtnsClick(ByVal nIndex As Integer)
    rstVac.Requery
    bufVac.DataSource = rstVac

    Set cmbVac.DataSource = bufVac
End Sub

Private Sub cmbVac_Selected()
m_Changed = True
End Sub

Private Sub Form_Load()
    
    Me.Icon = MDI.Icon
    
    Set cmdPrevious.PictureNormal = MDI.Image.ListImages.Item("Previous").Picture
    Set cmdNext.PictureNormal = MDI.Image.ListImages.Item("Next").Picture
    Set cmdSaveExit.PictureNormal = MDI.Image.ListImages.Item("SaveExit").Picture
    Set cmdExit.PictureNormal = MDI.Image.ListImages.Item("Exit").Picture
    Set cmdSaveNew.PictureNormal = MDI.Image.ListImages.Item("SaveNew").Picture
    
'====================VacInfo=================================================
    
'    If rstVac.State = 1 Then rstVac.Close
'    Set rstVac = Nothing
'    rstVac.CursorLocation = adUseClient
'    rstVac.Open "select distinct VacName from VacInfo", con, adOpenStatic, adLockBatchOptimistic
'
'    cmbVac.ShowHeadScale = "0,20"
'    cmbVac.ShowHeadValue = "DataID,时间模式"
'    cmbVac.ShowIndex = 1
'    cmbVac.Type = tNormal
'    cmbVac.DropWidth = cmbVac.Width \ 15
'
'    If rstVac.RecordCount > 0 Then
'        rstVac.MoveFirst
'        While Not rstVac.EOF
'            cmbVac.AddString rstVac.Fields("VacName") + vbLf
'            rstVac.MoveNext
'        Wend
'    End If
    
    cmbVac.ShowHeadScale = "0,20"
    cmbVac.ShowHeadValue = "VacID,休假名称"
    cmbVac.ShowIndex = 1
    cmbVac.Type = tStatic
    cmbVac.SetBtns "刷新"
    cmbVac.ButtonHeight = 20
    cmbVac.DropWidth = cmbVac.Width \ 15
    Set cmbVac.DataSource = bufVac
    
    
'====================Class=================================================
    
    
'    If rstOnClass.State = 1 Then rstOnClass.Close
'    Set rstOnClass = Nothing
'    rstOnClass.CursorLocation = adUseClient
'    rstOnClass.Open "select * from Class", con, adOpenStatic, adLockBatchOptimistic
'
'    bufOnClass.Headers = "ClassID,ClassName"
'    bufOnClass.DataSource = rstOnClass
    
    cmbOnClass.ShowHeadScale = "0,20"
    cmbOnClass.ShowHeadValue = "OnClassID,排班名称"
    cmbOnClass.ShowIndex = 1
    cmbOnClass.Type = tStatic
    cmbOnClass.SetBtns "刷新"
    cmbOnClass.ButtonHeight = 20
    cmbOnClass.DropWidth = cmbOnClass.Width \ 15
    Set cmbOnClass.DataSource = bufOnClass
    
    txtCode.MaxTextLen = 20
    txtName.MaxTextLen = 20
    txtCard.MaxTextLen = 8
    txtCard.Type = sNumber
    
    
End Sub

Public Sub AddBill()
    If Check1 = False Then
        txtName.PutText ""
        txtCode.PutText ""
        txtCard.PutText ""
        cmbVac.SearchID 0
        cmbOnClass.SearchID 0
    End If
    m_Edit = False
    m_Changed = False
    
    Me.Caption = "员工编辑--新增"
End Sub

Public Sub EditBill(EmployeeID As Integer)
    
    If recExec.State = 1 Then recExec.Close
    Set recExec = Nothing
    recExec.CursorLocation = adUseClient
    recExec.Open "select * from Employee where EmployeeID=" & EmployeeID, con, adOpenStatic, adLockBatchOptimistic
    If recExec.RecordCount = 0 Then
        Message "该员工记录已不存在!"
        Exit Sub
    End If
    
    If IsNull(recExec.Fields("Code")) Then txtCode.Text = "" Else txtCode.Text = recExec.Fields("Code")
    If IsNull(recExec.Fields("Name")) Then txtName.Text = "" Else txtName.Text = recExec.Fields("Name")
    If IsNull(recExec.Fields("Card")) Then txtCard.Text = "" Else txtCard.Text = recExec.Fields("Card")
    If IsNull(recExec.Fields("OnClassID")) Then cmbOnClass.SearchID 0 Else cmbOnClass.SearchID recExec.Fields("OnClassID")
    If IsNull(recExec.Fields("VacID")) Then cmbVac.SearchID 0 Else cmbVac.SearchID recExec.Fields("VacID")
    
    m_EmployeeID = EmployeeID
    m_Edit = True
    m_Changed = False
    Me.Caption = "员工编辑--修改"
End Sub

Public Function SaveBill() As Boolean
On Error GoTo SaveErr

    SaveBill = False
    
    If Len(Trim(txtCard.Text)) <> 8 Then
        Message "员工卡号为八位!"
        txtCard.SetFocus
        Exit Function
    End If
    
    If Trim(txtCode.Text) = "" Then
        Message "请输入员工编号"
        txtCode.SetFocus
        Exit Function
    End If
    
'    If Trim(txtName.Text) = "" Then
'        Message "请输入员工名称"
'        txtName.SetFocus
'        Exit Function
'    End If
    
'    If Trim(cmbOnClass.Text) = "" Then
'        Message "请输入默认班次"
'        cmbOnClass.SetFocus
'        Exit Function
'    End If
    
'    If Trim(cmbVac.Text) = "" Then
'        Message "请输入默认休假"
'        cmbVac.SetFocus
'        Exit Function
'    End If
    
    
'    If recExec.State = 1 Then recExec.Close
'    Set recExec = Nothing
'    recExec.CursorLocation = adUseClient
'    recExec.Open "select * from ClassInfo where OnClassID=" & cmbOnClass.ID, con, adOpenStatic, adLockBatchOptimistic
'    If recExec.RecordCount < 1 Then
'        Message "所选班次已不存在!"
'        Exit Function
'    End If
'
'    If recExec.State = 1 Then recExec.Close
'    Set recExec = Nothing
'    recExec.CursorLocation = adUseClient
'    recExec.Open "select * from VacInfo where VacID=" & cmbVac.ID, con, adOpenStatic, adLockBatchOptimistic
'    If recExec.RecordCount < 1 Then
'        Message "所选休假已不存在!"
'        Exit Function
'    End If




    If m_Edit = False Then
    
'        If recExec.State = 1 Then recExec.Close
'        Set recExec = Nothing
'        recExec.CursorLocation = adUseClient
'        recExec.Open "select * from Employee where code= '" & txtCode.Text & "'", con, adOpenStatic, adLockBatchOptimistic
'        If recExec.RecordCount > 0 Then
'            Message "该员工编号已存在!"
'            Exit Function
'        End If
'
'        recExec.AddNew
'        recExec.Fields("Code") = txtCode.Text
'        recExec.Fields("Name") = txtName.Text
'        recExec.Fields("Card") = txtCard.Text
'        recExec.Fields("OnClassID") = cmbOnClass.ID
'        recExec.Fields("VacID") = cmbVac.ID
'        recExec.UpdateBatch
        
        Dim strSQL As String
        
        
        strSQL = "insert into Employee(Code,Name,Card,OnClassID,VacID) values(" _
        & "'" & txtCode.Text & "'," _
        & "'" & txtName.Text & "'," _
        & "'" & txtCard.Text & "'," _
        & cmbOnClass.ID & "," _
        & cmbVac.ID & ")"
        
        
        
        
        con.Execute strSQL
        
        
        
        
       
    Else
    
        If recExec.State = 1 Then recExec.Close
        Set recExec = Nothing
        recExec.CursorLocation = adUseClient
        recExec.Open "select * from Employee where EmployeeID=" & CStr(m_EmployeeID), con, adOpenStatic, adLockBatchOptimistic
        If recExec.RecordCount = 0 Then
            Message "该员工记录已不存在!"
            Exit Function
        End If
        
        recExec.Fields("Code") = txtCode.Text
        recExec.Fields("Name") = txtName.Text
        recExec.Fields("Card") = txtCard.Text
        recExec.Fields("OnClassID") = cmbOnClass.ID
        recExec.Fields("VacID") = cmbVac.ID
        recExec.UpdateBatch
    
    End If
    
    If FindWindow("frmEmployee") Then frmEmployee.RefreshBill
    SaveBill = True
    m_Changed = False
    Exit Function
    
SaveErr:

    If InStr(Err.Description, "创建重复的值") <> 0 Then
        Message "输入的员工编号或员工卡号有重复!"
        Err.Clear
        Exit Function
    Else
        Message Err.Description
    End If

End Function

Private Sub cmdNext_Click()
    If ChangedMsg = False Then Exit Sub
    If recExec.State = 1 Then recExec.Close
    Set recExec = Nothing
    recExec.CursorLocation = adUseClient
    recExec.Open "select top 1 * from Employee where EmployeeID>" & m_EmployeeID & "   order by EmployeeID ", con, adOpenStatic, adLockBatchOptimistic
    
    If recExec.RecordCount < 1 Then
'        Message "该单已是最后单!"
        Exit Sub
    End If
        
    EditBill (recExec.Fields("EmployeeID"))
End Sub

Private Sub cmdPrevious_Click()
    If ChangedMsg = False Then Exit Sub
    If recExec.State = 1 Then recExec.Close
    Set recExec = Nothing
    recExec.CursorLocation = adUseClient
    recExec.Open "select top 1 * from Employee where EmployeeID<" & m_EmployeeID & "   order by EmployeeID   desc", con, adOpenStatic, adLockBatchOptimistic
    
    If recExec.RecordCount < 1 Then
'        Message "该单已是最前单!"
        Exit Sub
    End If
        
    EditBill (recExec.Fields("EmployeeID"))
End Sub

Private Sub cmdSaveNew_Click()
    If SaveBill = False Then Exit Sub
    AddBill
End Sub

Private Sub cmdSaveExit_Click()
    If SaveBill = False Then Exit Sub
    Unload Me
    
End Sub

Private Sub cmdExit_Click()
    m_Changed = False
    Unload Me
End Sub

Private Sub cmbOnClass_BtnsClick(ByVal nIndex As Integer)
    Select Case nIndex
        Case 0

            rstOnClass.Requery
            bufOnClass.DataSource = rstOnClass
            Set cmbOnClass.DataSource = bufOnClass
            
    End Select
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Dim l As Long
    If m_Changed = True Then l = ChangedBox("记录已更改,是否保存?")
    If l = vbYes Then
        If SaveBill = False Then Cancel = 1
    ElseIf l = vbNo Then
        Cancel = 0
    ElseIf l = vbCancel Then
        Cancel = 1
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
   
    If recExec.State = 1 Then recExec.Close
    Set recExec = Nothing
End Sub

Private Sub STreeView1_RCLK()

End Sub

Private Sub txtCard_Change()
m_Changed = True
End Sub

Private Sub txtCode_Change()
m_Changed = True
End Sub

Private Sub txtName_Change()
m_Changed = True
End Sub

⌨️ 快捷键说明

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