Exemple #1
0
        ///<summary>Will throw an exception if already clocked in.</summary>
        public static void ClockIn(long employeeNum)
        {
            //we'll get this again, because it may have been a while and may be out of date
            ClockEvent clockEvent = ClockEvents.GetLastEvent(employeeNum);

            if (clockEvent == null)           //new employee clocking in
            {
                clockEvent             = new ClockEvent();
                clockEvent.EmployeeNum = employeeNum;
                clockEvent.ClockStatus = TimeClockStatus.Home;
                ClockEvents.Insert(clockEvent);                       //times handled
            }
            else if (clockEvent.ClockStatus == TimeClockStatus.Break) //only incomplete breaks will have been returned.
            //clocking back in from break
            {
                clockEvent.TimeEntered2   = MiscData.GetNowDateTime();
                clockEvent.TimeDisplayed2 = clockEvent.TimeEntered2;
                ClockEvents.Update(clockEvent);
            }
            else                                           //normal clock in/out
            {
                if (clockEvent.TimeDisplayed2.Year < 1880) //already clocked in
                {
                    throw new Exception(Lans.g("ClockEvents", "Error.  Already clocked in."));
                }
                else                  //clocked out for home or lunch.  Need to clock back in by starting a new row.
                {
                    TimeClockStatus tcs = clockEvent.ClockStatus;
                    clockEvent             = new ClockEvent();
                    clockEvent.EmployeeNum = employeeNum;
                    clockEvent.ClockStatus = tcs;
                    ClockEvents.Insert(clockEvent);                    //times handled
                }
            }
        }
Exemple #2
0
        ///<summary></summary>
        public static bool IsClockedIn(long employeeNum)
        {
            ClockEvent clockEvent = ClockEvents.GetLastEvent(employeeNum);

            if (clockEvent == null)           //new employee
            {
                return(false);
            }
            else if (clockEvent.ClockStatus == TimeClockStatus.Break)           //only incomplete breaks will have been returned.
            //so currently on break
            {
                return(false);
            }
            else                                           //normal clock in/out row found
            {
                if (clockEvent.TimeDisplayed2.Year < 1880) //already clocked in
                {
                    return(true);
                }
                else                  //clocked out for home or lunch.
                {
                    return(false);
                }
            }
        }
Exemple #3
0
        ///<summary>Will throw an exception if already clocked out.</summary>
        public static void ClockOut(long employeeNum, TimeClockStatus clockStatus)
        {
            ClockEvent clockEvent = ClockEvents.GetLastEvent(employeeNum);

            if (clockEvent == null)           //new employee never clocked in
            {
                throw new Exception(Lans.g("ClockEvents", "Error.  New employee never clocked in."));
            }
            else if (clockEvent.ClockStatus == TimeClockStatus.Break)           //only incomplete breaks will have been returned.
            {
                throw new Exception(Lans.g("ClockEvents", "Error.  Already clocked out for break."));;
            }
            else                                              //normal clock in/out
            {
                if (clockEvent.TimeDisplayed2.Year < 1880)    //clocked in.
                {
                    if (clockStatus == TimeClockStatus.Break) //clocking out on break
                    //leave the half-finished event alone and start a new one
                    {
                        clockEvent             = new ClockEvent();
                        clockEvent.EmployeeNum = employeeNum;
                        clockEvent.ClockStatus = TimeClockStatus.Break;
                        ClockEvents.Insert(clockEvent); //times handled
                    }
                    else                                //finish the existing event
                    {
                        clockEvent.TimeEntered2   = MiscData.GetNowDateTime();
                        clockEvent.TimeDisplayed2 = clockEvent.TimeEntered2;
                        clockEvent.ClockStatus    = clockStatus;                   //whatever the user selected
                        ClockEvents.Update(clockEvent);
                    }
                }
                else                  //clocked out for home or lunch.
                {
                    throw new Exception(Lans.g("ClockEvents", "Error.  Already clocked out."));
                }
            }
        }