private ShiftEntity BuildShift() { string shiftname = textBox_ShiftName.Text; int validityDays = (int)numericUpDown_validity.Value; if (checkBox_AlwaysValid.Checked) { validityDays = 0; } var key = teams.Keys.OfType <object>().FirstOrDefault(s => teams[s].ToString() == comboBox_team.Text); string teamindex = key.ToString(); ShiftEntity temp; if (this.currentShift != null) { temp = currentShift; } else { temp = new ShiftEntity(); } // temp.ID = pn; temp.shiftName = shiftname; temp.ValidityInDays = validityDays; temp.teamIndex = teamindex; return(temp); }
public AddShift(Hashtable teams, ShiftEntity shift) { InitializeComponent(); this.teams = teams; this.currentShift = shift; PopulateFields(); }
public bool IsShiftBeingExectued(ShiftEntity shift) { foreach (Assignation assign in this.Assignations) { if (assign.IsPartOfShift(shift.ID) && assign.status == AssignationStatus.Executing) { if (DateTime.Now.Date >= assign.startDate && DateTime.Now.Date <= assign.endDate) { return(true); } } } return(false); }
public DateTime GetLastDateOfShift(ShiftEntity shift) { DateTime max = new DateTime(); foreach (Assignation assign in this.Assignations) { if (assign.IsPartOfShift(shift.ID) && assign.status == AssignationStatus.Executed) { if (assign.endDate > max) { max = assign.endDate; } } } return(max); }
public void PopulateCheckboxlist(ReserveDutyEntity man) { checkedListBox_Tasks.Items.Clear(); foreach (string item in man.qualifiedShiftsIndexes) { ShiftEntity s = this.shifts.Where(sh => sh.ID == item).FirstOrDefault(); if (s != null) { checkedListBox_Tasks.Items.Add(s.shiftName); } else { checkedListBox_Tasks.Items.Add("לא מזוהה"); } } }
public void PopulateCheckboxlist(ReserveDutyEntity man, string[] shiftIndexes) { checkedListBox_Tasks.Items.Clear(); foreach (string item in man.qualifiedShiftsIndexes) { ShiftEntity s = this.shifts.Where(sh => sh.ID == item).FirstOrDefault(); int i; if (s == null) { i = checkedListBox_Tasks.Items.Add("לא מזוהה"); } else { i = checkedListBox_Tasks.Items.Add(s.shiftName); } if (shiftIndexes.Contains(item)) { checkedListBox_Tasks.SetItemChecked(i, true); } } }
public string[] GetTeamAffiliationIndexes(List <ShiftEntity> shifts) { List <string> teamIndexes = new List <string>() { "0" }; foreach (string index in qualifiedShiftsIndexes) { try { ShiftEntity s = shifts.Where(id => id.ID == index).FirstOrDefault(); if (!teamIndexes.Contains(s.teamIndex)) { teamIndexes.Add(s.teamIndex); } } catch (Exception) { continue; } } return(teamIndexes.ToArray()); }
public DateTime GetNextDateOfShift(ShiftEntity shift) { DateTime min = new DateTime(); foreach (Assignation assign in this.Assignations) { if (assign.IsPartOfShift(shift.ID) && (assign.status == AssignationStatus.Approved || assign.status == AssignationStatus.Executing)) { if (assign.startDate < DateTime.Now.Date) { continue; } if (min == new DateTime()) { min = assign.endDate; } else if (assign.startDate < min) { min = assign.endDate; } } } return(min); }