dcsimg
Results 1 to 4 of 4
  1. #1

    Thread Starter
    Registered User
    Join Date
    Aug 2015
    Posts
    1

    How to time in/ time out with one button

    I'm currently making a payroll system for our thesis. One of our panel said that there should be one button and one textbox for time in/ timeout. I don't know what codes to enter and how. I have already connected it into a database. I has 4 columns (ID/Name/TimeIn/TimeOut). It is showed on the attachment. Thank you in advance.
    Attached Images Attached Images  

  2. #2
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,157

    Re: How to time in/ time out with one button

    vb.net Code:
    1. Public Class EmlployeeStatus
    2.  
    3.  
    4.     Private _EmployeeId As String '' or what ever type
    5.     Private _EmployeeName As String
    6.     Private _TimeIn As DateTime
    7.     Private _TimeOut As DateTime
    8.  
    9.  
    10.  
    11.  
    12.     Public Sub New(EmployeeId As String)
    13.  
    14.  
    15.         _EmployeeId = EmployeeId
    16.  
    17.  
    18.     End Sub
    19.  
    20.  
    21.     Public Sub New(EmployeeId As String, EmployeeName As String,
    22.                     TimeIn As DateTime, TimeOut As DateTime)
    23.  
    24.  
    25.         _EmployeeId = EmployeeId
    26.         _EmployeeName = EmployeeName
    27.         _TimeIn = TimeIn
    28.         _TimeOut = TimeOut
    29.  
    30.  
    31.     End Sub
    32.  
    33.  
    34.  
    35.  
    36.  
    37.  
    38.     Private Function GetEmployeeLastTimeIn() As DateTime
    39.  
    40.  
    41.         '' get the employee last TimeIn time from the database here
    42.         '' By using the _EmployeeId
    43.  
    44.  
    45.         Dim LastTimeIn As DateTime = Now() '' default
    46.  
    47.  
    48.  
    49.  
    50.         Return LastTimeIn
    51.  
    52.  
    53.     End Function
    54.  
    55.  
    56.     Private Function GetEmployeeLastTimeOut() As DateTime
    57.  
    58.  
    59.         '' get the employee last TimeIn time from the database here
    60.         ''  By using the _EmployeeId
    61.  
    62.  
    63.  
    64.  
    65.         Dim LastTimeOut As DateTime = Now() '' << default  it will be the database output
    66.  
    67.  
    68.  
    69.  
    70.         Return LastTimeOut
    71.  
    72.  
    73.     End Function
    74.  
    75.  
    76.     Private Function DecideEmployeeCurrentStatus() As String
    77.  
    78.  
    79.         '' Suppose last TIMEIN = 10:00 and last TIMEOUT = 20:00 then employee is out from factory
    80.         '' and reverse  TIMEOUT = 20:00 and TIMEIN = 10:00 then employee is TIMEIN and onduty
    81.         '' This is purely time tested pattern of working
    82.         ''
    83.  
    84.  
    85.         Dim CurrentStatus As String = "TIMEOUT" '' Or some thing
    86.  
    87.  
    88.         If GetEmployeeLastTimeIn() <= GetEmployeeLastTimeOut() Then
    89.             CurrentStatus = "TIMEOUT"
    90.         Else
    91.             CurrentStatus = "TIMEIN"
    92.         End If
    93.  
    94.  
    95.         Return CurrentStatus
    96.  
    97.  
    98.     End Function
    99.  
    100.  
    101.     Private Sub DoTimeIn()
    102.  
    103.  
    104.         '_EmployeeId
    105.         ' _EmployeeName
    106.         ' _TimeIn
    107.         ' for TIMEIN insert these values to your table
    108.  
    109.  
    110.  
    111.  
    112.     End Sub
    113.  
    114.  
    115.     Private Sub DoTimeOut()
    116.  
    117.  
    118.         '_EmployeeId
    119.         ' _EmployeeName
    120.         ' _TimeOut
    121.         ' for TIMEOUT insert these values to your table
    122.  
    123.  
    124.  
    125.  
    126.     End Sub
    127.  
    128.  
    129.     Public Sub PerformEmployeePunching()
    130.  
    131.  
    132.         '' On the click of TimeIn button call this subroutine
    133.         ''
    134.         ''
    135.         '' How ever your table design is upto you to decide
    136.         '' create calss like this and call it in your code
    137.  
    138.  
    139.         If DecideEmployeeCurrentStatus() = "TIMEIN" Then
    140.  
    141.  
    142.             Call DoTimeOut()
    143.  
    144.  
    145.         Else
    146.  
    147.  
    148.             Call DoTimeIn()
    149.  
    150.  
    151.         End If
    152.  
    153.  
    154.     End Sub
    155.  
    156.  
    157. End Class
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

  3. #3
    New Member
    Join Date
    Jan 2018
    Posts
    4

    Re: How to time in/ time out with one button

    can you pls help me. I dont understand how to make the program know if the database already has a "time-in" therefor the data should be places in "time-out".

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,048

    Re: How to time in/ time out with one button

    You need to start a new thread on this. The current thread may seem like it is related, but it is several years old, and is only superficially related to what you asked. You'll also need to provide more information. After all, it isn't even clear what the problem is. From that question, it could be one of database interaction, user input, or some combination of the two.
    My usual boring signature: Nothing

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.