/// <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); }
/// <summary> /// This method calculate the weekly wages for a particular employee based on Weeknumber of the year /// </summary> /// <param name="employeeName"></param> /// <param name="weekNumber"></param> /// <returns></returns> public WorkWeekDetails CalculateWeeklyWages(int employeeId, int weekNumber) { EmployeeBook employees = EmployeeBook.Instance(); Employee emp = employees.GetEmployeeById(employeeId); if (emp != null) { return(Payables(emp, weekNumber)); } return(null); }
/// <summary> /// This is an overloaded method which calculates weekly wages for a particular employee /// based on dates if presen in the same week /// </summary> /// <param name="employeeName"></param> /// <param name="weekStartDate"></param> /// <param name="weekEndDate"></param> /// <returns></returns> public WorkWeekDetails CalculateWeeklyWages(int employeeId, DateTime weekStartDate, DateTime weekEndDate) { EmployeeBook employees = EmployeeBook.Instance(); Employee emp = employees.GetEmployeeById(employeeId); if (emp != null) { int StartWeek = Util.GetWeekNumber(weekStartDate); int EndWeek = Util.GetWeekNumber(weekEndDate); if (StartWeek == EndWeek) { return(Payables(emp, StartWeek)); } } return(null); }