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

📄 frmattendance.frm

📁 VB开发的毕业设计,绝对不是网上下载的,大家可以去看看,作为参考
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Alignment       =   2  'Center
      Caption         =   "添加员工上下班信息"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   375
      Left            =   2160
      TabIndex        =   0
      Top             =   120
      Width           =   3495
   End
End
Attribute VB_Name = "FrmAttendance"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private ilate As Integer                                  '迟到次数
Private iearly As Integer                                 '早退次数
Private aflag As String                                   '出入标志
Private addflag As Boolean                                '添加标志
Private firstID As String                                 '第一个员工编号

Private Sub ASID_KeyDown(KeyCode As Integer, Shift As Integer)
    TabToEnter KeyCode
End Sub

Private Sub ASID_LostFocus()
On Error Resume Next
    Dim SQL As String
    Dim rs As New ADODB.Recordset
    SQL = "select SName from StuffInfo where SID='" & Me.ASID.Text & "'"
    Set rs = TransactSQL(SQL)
    If rs.EOF = False Then
        Me.ASName = rs(0)                           '初始化员工姓名
    Else
        MsgBox "员工编号输入错误,或者没有这个员工!", vbOKOnly + vbExclamation, "警告!"
        Me.ASID = ""
        Me.ASID.SetFocus
        Me.ASID.ListIndex = 0
    End If
    rs.Close
End Sub

Private Sub cmdCancel_Click()
    Unload Me
    Exit Sub
End Sub

Private Sub CheckRecord()
On Error Resume Next
'判断是否存在记录
    Dim SQL As String
    Dim rs As New ADODB.Recordset
    SQL = "select * from AttendanceInfo where AStuffID='" & Me.ASID.Text & "'"
    SQL = SQL & " and AFlag='" & aflag & "' and ADate=#" & Me.NowDate & "#"
        Set rs = TransactSQL(SQL)
        If rs.EOF = False Then
            MsgBox "已经存在这条记录!", vbOKOnly + vbExclamation, "警告!"
            addflag = True
        Else
            addflag = False
        End If
        rs.Close
End Sub

Private Sub in_add()
On Error Resume Next '添加上班记录
    Dim SQL As String
    Dim rs As New ADODB.Recordset
    SQL = "select * from AttendanceInfo"
    Set rs = TransactSQL(SQL)
    rs.AddNew
    rs.Fields(1) = Me.ASID
    rs.Fields(2) = Me.ASName
    rs.Fields(3) = Me.NowDate
    rs.Fields(4) = aflag
    rs.Fields(5) = Me.intime
    rs.Fields(7) = ilate
    rs.Update
    rs.Close
End Sub

Private Sub out_add()
On Error Resume Next
'添加下班记录
    Dim SQL As String
    Dim rs As New ADODB.Recordset
    SQL = "select * from AttendanceInfo"
    Set rs = TransactSQL(SQL)
    rs.AddNew
    rs.Fields(1) = Me.ASID
    rs.Fields(2) = Me.ASName
    rs.Fields(3) = Me.NowDate
    rs.Fields(4) = aflag
    rs.Fields(6) = Me.OutTime
    rs.Fields(8) = iearly
    rs.Update
    rs.Close
End Sub

Private Sub cmdOK_Click()
On Error Resume Next
    Dim SQL As String
    Dim sql2 As String
    Dim rs As New ADODB.Recordset
    Dim rsTime As New ADODB.Recordset
    sql2 = "select * from AttendanceInfo order by ID desc"
    SQL = "select * from TimeSetting"
    Set rsTime = TransactSQL(SQL)
    If flag = 1 Then
    ilate = 0
    iearly = 0
    If Me.InFlag = False And Me.OutFlag = False Then
        MsgBox "请选择上下班!", vbOKOnly + vbExclamation, "警告!"
    Else
    If Me.InFlag = True Then                         '添加上班记录
        aflag = "入"
        If Me.intime = "" Or IsDate(Me.intime) = False Then
            MsgBox "请输入正确的时间!", vbOKOnly + vbExclamation, "警告!"
            Me.intime = ""
            Me.intime.SetFocus
        Else
            If DateDiff("s", Me.intime, rsTime(0)) < 0 Then
                ilate = 1
            End If
            Call CheckRecord
            If addflag = False Then
                Call in_add
                MsgBox "已经添加上班记录!", vbOKOnly + vbExclamation, "添加结果!"
                Call init
                Me.InFlag = False
            Else
                Call init
                Me.InFlag = False
            End If
        End If
    End If
    If Me.OutFlag = True Then                        '添加下班记录
        aflag = "出"
        If Me.OutTime = "" Or IsDate(Me.OutTime) = False Then
            MsgBox "请输入正确的时间!", vbOKOnly + vbExclamation, "警告!"
            Me.OutTime = ""
            Me.OutTime.SetFocus
        Else
            If DateDiff("s", Me.OutTime, rsTime(1)) > 0 Then
                iearly = 1
            End If
            Call CheckRecord
            If addflag = False Then
                Call out_add
                MsgBox "已经添加下班记录!", vbOKOnly + vbExclamation, "添加结果!"
                Call init
                Me.OutFlag = False
            Else
                Call init
                Me.OutFlag = False
            End If
        End If
    End If
    End If
        Call frmAResult.ListTopic
        Call frmAResult.ShowData(sql2)
        frmAResult.Show
        frmAResult.ZOrder 0
        Me.ZOrder 0
    Else                                             '修改记录
        If MsgBox("确定修改编号为" & Me.ASID & "的员工信息?", vbOKCancel, "提示!") _
                                                                = vbOK Then
            If Me.InFlag = True Then
                If DateDiff("s", Me.intime, rsTime(0)) < 0 Then
                    ilate = 1
                End If
                SQL = "update AttendanceInfo set AInTime=#" & Me.intime & "#,"
                SQL = SQL & "ALate=" & ilate & " where ID=" & ArecordID
                TransactSQL (SQL)                     '修改上班记录
                Call frmAResult.ListTopic
                Call frmAResult.ShowData(sql2)
                frmAResult.Show
                MsgBox "信息已经修改!", vbOKOnly + vbExclamation, "修改结果!"
                Unload Me
            ElseIf Me.OutFlag = True Then
                If DateDiff("s", Me.OutTime, rsTime(1)) > 0 Then
                    iearly = 1
                End If
                SQL = "update AttendanceInfo set AOutTime=#" & Me.OutTime & "#,"
                SQL = SQL & "AEarly=" & iearly & " where ID=" & ArecordID
                TransactSQL (SQL)                     '修改下班记录
                Call frmAResult.ListTopic
                Call frmAResult.ShowData(sql2)
                frmAResult.Show
                MsgBox "信息已经修改!", vbOKOnly + vbExclamation, "修改结果!"
                Unload Me
            End If
        Else
        Unload Me
        End If
    End If
    rsTime.Close
End Sub

Private Sub Form_Load()
On Error Resume Next
    Dim SQL As String
    Dim rs As New ADODB.Recordset
    If flag = 1 Then
    SQL = "select SID from StuffInfo order by SID"
    Set rs = TransactSQL(SQL)
    If rs.EOF = False Then
        rs.MoveFirst
        firstID = rs(0)
    While Not rs.EOF
        Me.ASID.AddItem rs(0)                     '初始化员工编号
        rs.MoveNext
    Wend
        rs.Close
    Else
        MsgBox "目前没有员工!", vbOKOnly + vbExclamation, "警告!"
    End If
    Me.NowDate = Date
    Me.ASID.ListIndex = 0
    SQL = "select SName from StuffInfo where SID='" & firstID & "'"
    Set rs = TransactSQL(SQL)
    Me.ASName = rs(0)                             '初始化员工姓名
    rs.Close
    Me.OutTime = ""
    Me.intime = ""
    Else
        Me.topic = "修改员工上下班信息"
        Set rs = TransactSQL(kqsql)
     'SQL = "select * from AttendanceInfo where AstuffID= '" & ArecordID & "' "
     ' Set rs = TransactSQL(SQL)
       If rs.EOF = False Then
        With rs
            Me.ASID = rs(1)
            Me.ASName = rs(2)
            Me.NowDate = rs(3)
            If IsNull(rs(5)) = True Then
            Me.intime = ""
            Me.OutFlag = True
            Else
            Me.intime = rs(5)
            End If
            If IsNull(rs(6)) = True Then
            Me.OutTime = ""
            Me.InFlag = True
            Else
            Me.OutTime = rs(6)
            End If
        End With
       End If
    End If
End Sub
Private Sub init()
On Error Resume Next
'初始化
    Dim SQL As String
    Dim rs As New ADODB.Recordset
    SQL = "select SName from StuffInfo where SID='" & firstID & "'"
    Set rs = TransactSQL(SQL)
    Me.ASID.ListIndex = 0
    Me.ASName = rs(0)
    Me.intime = ""
    Me.OutTime = ""
End Sub


⌨️ 快捷键说明

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