private void GoalCombo_SelectedIndexChanged(object sender, EventArgs e) { GoalComboItem item = GoalCombo.SelectedItem as GoalComboItem; if (item == null) { return; } SelectedGoalID = item.ID; RefreshRows(); }
private void RefreshGoalCombo() { GoalComboItem prevItem = GoalCombo.SelectedItem as GoalComboItem; int prevSelectedID = 0; if (prevItem != null) { prevSelectedID = prevItem.ID; } GoalCombo.Items.Clear(); GoalCombo.Items.Add(new GoalComboItem("None", 0)); // go up the chain looking for goals which have been assigned to this person // at root goal is the title of the goal List <PlanGoal> rootList = new List <PlanGoal>(); List <int> assigned = new List <int>(); // foreach self & higher List <ulong> ids = Trust.GetUplinkIDs(UserID, ProjectID); ids.Add(UserID); foreach (ulong id in ids) { OpPlan plan = Plans.GetPlan(id, true); if (plan == null) { continue; } // goals we have been assigned to foreach (List <PlanGoal> list in plan.GoalMap.Values) { foreach (PlanGoal goal in list) { if (goal.Project != ProjectID) { break; } if (goal.Person == UserID && !assigned.Contains(goal.Ident)) { assigned.Add(goal.Ident); } if (goal.BranchDown == 0) { if (!goal.Archived) { rootList.Add(goal); } } } } } // update combo GoalComboItem prevSelected = null; foreach (PlanGoal goal in rootList) { if (assigned.Contains(goal.Ident)) { GoalComboItem item = new GoalComboItem(goal.Title, goal.Ident); if (goal.Ident == prevSelectedID) { prevSelected = item; } GoalCombo.Items.Add(item); } } if (prevSelected != null) { GoalCombo.SelectedItem = prevSelected; } else { GoalCombo.SelectedIndex = 0; } }
private void RefreshGoalCombo() { GoalComboItem prevItem = GoalCombo.SelectedItem as GoalComboItem; int prevSelectedID = 0; if (prevItem != null) prevSelectedID = prevItem.ID; GoalCombo.Items.Clear(); GoalCombo.Items.Add(new GoalComboItem("None", 0)); // go up the chain looking for goals which have been assigned to this person // at root goal is the title of the goal List<PlanGoal> rootList = new List<PlanGoal>(); List<int> assigned = new List<int>(); // foreach self & higher List<ulong> ids = Trust.GetUplinkIDs(UserID, ProjectID); ids.Add(UserID); foreach (ulong id in ids) { OpPlan plan = Plans.GetPlan(id, true); if (plan == null) continue; // goals we have been assigned to foreach (List<PlanGoal> list in plan.GoalMap.Values) foreach (PlanGoal goal in list) { if (goal.Project != ProjectID) break; if (goal.Person == UserID && !assigned.Contains(goal.Ident)) assigned.Add(goal.Ident); if (goal.BranchDown == 0) if (!goal.Archived) rootList.Add(goal); } } // update combo GoalComboItem prevSelected = null; foreach (PlanGoal goal in rootList) if (assigned.Contains(goal.Ident)) { GoalComboItem item = new GoalComboItem(goal.Title, goal.Ident); if (goal.Ident == prevSelectedID) prevSelected = item; GoalCombo.Items.Add(item); } if (prevSelected != null) GoalCombo.SelectedItem = prevSelected; else GoalCombo.SelectedIndex = 0; }