public static void AssignTimes(List <EmployeePlanningWeek> planningemployee, List <WorkingTimePlanning> worktimes, List <AbsenceTimePlanning> absencetimes) { Dictionary <long, EmployeePlanningWeek> dict = ListToDictionary(planningemployee); EmployeePlanningWeek currentWeekEmployee = null; EmployeePlanningDay currentDayEmployee = null; if (worktimes != null) { foreach (WorkingTimePlanning wtp in worktimes) { if (dict.TryGetValue(wtp.EmployeeID, out currentWeekEmployee)) { if (currentWeekEmployee.Days.TryGetValue(wtp.Date, out currentDayEmployee)) { if (currentDayEmployee.WorkingTimeList == null) { currentDayEmployee.WorkingTimeList = new List <WorkingTimePlanning> (); } currentDayEmployee.WorkingTimeList.Add(wtp); } } } } if (absencetimes != null) { foreach (AbsenceTimePlanning atp in absencetimes) { if (dict.TryGetValue(atp.EmployeeID, out currentWeekEmployee)) { if (currentWeekEmployee.Days.TryGetValue(atp.Date, out currentDayEmployee)) { if (currentDayEmployee.AbsenceTimeList == null) { currentDayEmployee.AbsenceTimeList = new List <AbsenceTimePlanning>(); } currentDayEmployee.AbsenceTimeList.Add(atp); } } } } }
/*public EmployeePlanningWeek(Employee empl, DateTime from,DateTime to) { Debug.Assert(from.DayOfWeek == DayOfWeek.Monday); Debug.Assert(to.DayOfWeek == DayOfWeek.Sunday); _employee = empl; BeginDate = from; EndDate = to; DateTime d = BeginDate ; while (d <= EndDate) { _dictionDays[d] = new EmployeePlanningDay(this, PlanningEmployee, d); d = d.AddDays(1); } }*/ public EmployeePlanningWeek(long id, string fullname, DateTime from, DateTime to) { Debug.Assert(from.DayOfWeek == DayOfWeek.Monday); Debug.Assert(to.DayOfWeek == DayOfWeek.Sunday); _EmployeeId = id; _EmployeeFullName = fullname; BeginDate = from; EndDate = to; DateTime d = BeginDate; while (d <= EndDate) { _dictionDays[d] = new EmployeePlanningDay(this, d); d = d.AddDays(1); } }
/*public EmployeePlanningWeek(Employee empl, DateTime from,DateTime to) * { * Debug.Assert(from.DayOfWeek == DayOfWeek.Monday); * Debug.Assert(to.DayOfWeek == DayOfWeek.Sunday); * * _employee = empl; * BeginDate = from; * EndDate = to; * * DateTime d = BeginDate ; * while (d <= EndDate) * { * _dictionDays[d] = new EmployeePlanningDay(this, PlanningEmployee, d); * d = d.AddDays(1); * } * }*/ public EmployeePlanningWeek(long id, string fullname, DateTime from, DateTime to) { Debug.Assert(from.DayOfWeek == DayOfWeek.Monday); Debug.Assert(to.DayOfWeek == DayOfWeek.Sunday); _EmployeeId = id; _EmployeeFullName = fullname; BeginDate = from; EndDate = to; DateTime d = BeginDate; while (d <= EndDate) { _dictionDays[d] = new EmployeePlanningDay(this, d); d = d.AddDays(1); } }
public static void AssignTimes(List <EmployeePlanningWeek> planningemployee, long employeeid, DateTime date, List <WorkingTimePlanning> worktimes, List <AbsenceTimePlanning> absencetimes) { Dictionary <long, EmployeePlanningWeek> dict = ListToDictionary(planningemployee); EmployeePlanningWeek currentWeekEmployee = null; EmployeePlanningDay currentDayEmployee = null; if (dict.TryGetValue(employeeid, out currentWeekEmployee)) { if (currentWeekEmployee.Days.TryGetValue(date, out currentDayEmployee)) { currentDayEmployee.WorkingTimeList = worktimes; currentDayEmployee.AbsenceTimeList = absencetimes; } } }
public static void ResetTimesForDate(List <EmployeePlanningWeek> planningemployee, DateTime date) { if (planningemployee != null) { EmployeePlanningDay epd = null; foreach (EmployeePlanningWeek epw in planningemployee) { if (epw.Days.ContainsKey(date)) { epd = epw.Days[date]; if (epd.WorkingTimeList != null) { epd.WorkingTimeList.Clear(); } if (epd.AbsenceTimeList != null) { epd.AbsenceTimeList.Clear(); } } } } }
public bool IsHasWorldByDate(long id, DateTime date) { EmployeePlanningDay epd = Days[date]; return(epd.WorldId == id); }