Exemplo n.º 1
0
        /// <summary>
        /// Addding a new entry in timesheet for a respective employee based
        /// on his punchIn and punchOut time for a day.
        /// </summary>
        /// <param name="employeeId"></param>
        /// <param name="strTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public bool InputHoursForDay(int employeeId, string strTime, string endTime)
        {
            // Empty employee book
            EmployeeBook employees = EmployeeBook.Instance();
            Employee     emp       = employees.GetEmployeeById(employeeId); // Fetching the particular employee for whom timecard entry needs to be added

            // If employee exists
            if (emp != null)
            {
                if (Util.ValidateDate(strTime, ref dayStartTime) && Util.ValidateDate(endTime, ref dayEndTime)) // validating start and end time is in correct format
                {
                    bool duplicateEntry = TimeSheetEntry.IsEntryExists(dayStartTime, timeSheet, emp);           // validating the duplicacy of the entry already done

                    // if no duplicate entry exists then creating new entry for the day for the respective user.
                    if (!duplicateEntry)
                    {
                        AddEntry(new TimeSheetEntry()
                        {
                            EmployeeID = emp.EmpId,
                            InTime     = dayStartTime,
                            OutTime    = dayEndTime
                        });

                        TimeSheetSave(timeSheetPath); // Saving the values in xml file
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 2
0
 public void AddEntry(TimeSheetEntry employee)
 {
     timeSheet.Add(employee);
 }