Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2016
    Posts
    6

    Unanswered: In correct message in VB using ms access

    Im using VB 2008. Im trying to create 5 schedule for the DTR. The following schedules are:
    7 TO 3
    8 TO 5
    8 TO 4
    3 TO 11
    11 TO 7

    8 To 5 schedule is working. Wherein if you are late it prompt like "Hurry up you're late" otherwise " you're on time". On this schedule you need to have AM_IN, AM_OUT,PM_IN,PM_OUT. Im using four public Overload Function AMIN,AMOUT,PMIN,PMOUT

    While the other schedule like 7 TO 3 and 8 TO 4 you only need to have AM_IN, PM_OUT
    in 3 TO 11 you need to have PM_IN,PM_OUT
    in 11 to 7 , you need to have PM_IN, AM_OUT

    Im trying to revise my code in 8 to 5 schedule to use it in 8 to 4 schedule.
    Im using this code for my DTRCLASS
    Code:
     Dim mDataPath As String
        Public Shared DataModule As DTRCLASS
    Code:
    Public Overloads Function EightToFourIN(ByVal sortfield As String) As DataSet
            Dim conn As OleDb.OleDbConnection = GetConnection()
            Dim sql As String
            Dim sql1 As String
            Dim A As Integer
            Dim result = Nothing
    
            Dim amlate1 As String = "8:01:00 AM"
            Dim remm1 As String
    
            If Form8to4.LBLTIME.Text >= amlate1 Then
                remm1 = "LATE"
            Else
                remm1 = "ON TIME"
            End If
    
    
            Try
    
                sql1 = "SELECT * FROM DTR_REC WHERE MEM_CODES LIKE '" & Form8to4.txtinput.Text & "' AND SDATE LIKE '" & Form8to4.LBLDATE.Text & "'"
                Dim DA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sql1, conn)
                Dim DS As New DataSet
                DA.Fill(DS, "dtrdb")
                A = DS.Tables("dtrdb").Rows.Count
                If A > 0 Then
    
                    MessageBox.Show("Sorry you Already finished Log in!")
    
                Else
                    sql = "INSERT INTO DTR_REC (MEM_CODES, AM_IN, FIRST_AM_REMARK, SDATE) VALUES (@MEM_CODES, @AM_IN, @FIRST_AM_REMARK, @SDATE)"
                    Dim cmd As New OleDb.OleDbCommand(sql, conn)
                    cmd.Parameters.Add(New OleDb.OleDbParameter("@MEM_CODES", Form8to4.txtinput.Text))
                    cmd.Parameters.Add(New OleDb.OleDbParameter(" @AM_IN", Form8to4.LBLTIME.Text))
                    cmd.Parameters.Add(New OleDb.OleDbParameter("@FIRST_AM_REMARK", remm1))
                    cmd.Parameters.Add(New OleDb.OleDbParameter("@SDATE", Form8to4.LBLDATE.Text))
    
                    conn.Open()
                    cmd.ExecuteNonQuery()
                    If remm1 = "LATE" Then
                        MessageBox.Show("Hurry up your Late")
                    ElseIf remm1 = "ON TIME" Then
                        MessageBox.Show("Very good you come on time!")
                    End If
                End If
    
                clear()
    
    
            Catch ex As Exception
                Dim dgresult As DialogResult
                Dim ms As String
                ms = "Contact your Administrator! Maybe your not registered."
                MessageBox.Show(ms, "Error in connection", MessageBoxButtons.OKCancel, _
                                MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2)
    
                If dgresult = DialogResult.Yes Then
                    Form1.Show()
                End If
    
            End Try
            Return result
        End Function

    Code:
    Public Overloads Function EightToFourOut(ByVal SORTFIELD As String) As DataSet
    
            Dim CONN As OleDb.OleDbConnection = GetConnection()
            Dim PMOUT As String = "4:00:00 PM"
            Dim REMM As String
            Dim result = Nothing
    
            Dim SQL As String
            If Form8to4.LBLTIME.Text >= PMOUT Then
                REMM = "OVERTIME"
            Else
                REMM = "UNDERTIME"
            End If
            Try
                Dim sql1 As String
                Dim A As Integer
                sql1 = "SELECT * FROM DTR_REC WHERE MEM_CODES LIKE '" & Form8to4.txtinput.Text & "' AND SDATE LIKE '" & Form8to4.LBLDATE.Text & "' AND PM_OUT IS NOT NULL"
                Dim DA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sql1, CONN)
                Dim DS As New DataSet
                DA.Fill(DS, "dtrdb")
                A = DS.Tables("dtrdb").Rows.Count
                If A > 0 Then
    
                    MessageBox.Show("Sorry you Already finished Log out!")
    
    
                Else
                    SQL = "UPDATE DTR_REC SET  PM_OUT=@PM_OUT, SEC_PM_REMARK=@SEC_PM_REMARK " & _
                      "WHERE MEM_CODES= '" & Form8to4.txtinput.Text & "'AND SDATE LIKE  '" & Form8to4.LBLDATE.Text & "'"
    
                    Dim cmd As New OleDb.OleDbCommand(SQL, CONN)
                    cmd.Parameters.Add(New OleDb.OleDbParameter("@PM_OUT", Form8to4.LBLTIME.Text))
                    cmd.Parameters.Add(New OleDb.OleDbParameter("@SEC_PM_REMARK", REMM))
    
                    CONN.Open()
                    cmd.ExecuteNonQuery()
    
                    If REMM = "OVERTIME" Then
                        MessageBox.Show("You have already little Overtime!")
                    ElseIf REMM = "UNDERTIME" Then
                        MessageBox.Show("Your Undertime")
                    End If
                End If
                clear()
            Catch ex As Exception
                Dim dgresult As DialogResult
                Dim ms As String
                ms = "Contact your Administrator! Maybe your not registered."
                MessageBox.Show(ms, "Error in connection", MessageBoxButtons.OKCancel, _
                                MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2)
    
                If dgresult = DialogResult.Yes Then
                    Form1.Show()
                End If
            End Try
            Return result
        End Function
    My problem is when i try to time in at 10:00 AM, i got a message saying " Very good you come on time!"
    It shud be "Hurry up your late"

    can anyone help with this codes...Thanks in advance

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    So you have various shifts
    You need to know who is allocated to those shifts
    When defining a shift pattern you also store the clock on(s) clock off(s) for that shift.
    Having done that you can compare an employees daily clock on off events agaibst what shift they are actually allocated on
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2016
    Posts
    6
    I have a combobox on the first form, a 2 timer for the date and time. On the combobox, the employee must select first their shifting/schedule , then a new form will appear to enter their emp_id before clicking the AM_in/Pm Out.Button..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •