public int GetWeekNumber(DateTime date) { int weekNo = 0; while (date >= mFirstSunday.AddDays(7 * weekNo)) { weekNo++; } if (weekNo == 0) { Year year = new Year(date.AddYears(-1).Year); return(year.GetWeekNumber(date)); } return(weekNo); }
public void GetPayrollWeek() { Year currentYear = new Year(mCurrentYear); DateTime now = DateTime.Now; int weekNo = currentYear.GetWeekNumber(now); mCurrentWeek = weekNo; List <PayrollData> employeesPayrollData = new List <PayrollData>(); foreach (Employee emp in mEmployees) { employeesPayrollData.Add(emp.GetEmployeePayroll(weekNo, currentYear)); } mPayrollData = employeesPayrollData; NotifyPayrollObserver(); }