private void gridSprints_TitleAddClick(object sender, EventArgs e) { JobSprint jobSprintNew = new JobSprint(); jobSprintNew.Title = "Version"; jobSprintNew.Note = ""; jobSprintNew.DateStart = DateTime.Today; jobSprintNew.DateEndTarget = DateTime.Today.AddDays(70);//Add 10 weeks jobSprintNew.DateEndActual = DateTime.MinValue; jobSprintNew.JobPercent = 0.173; jobSprintNew.HoursAverageDevelopment = 9.43; jobSprintNew.HoursAverageBreak = 0.85; JobSprints.Insert(jobSprintNew); FillGridSprints(); userControlSprintManager.LoadSprint(jobSprintNew, _listJobsAll); FillGridEngineers(userControlSprintManager.JobSprintCur); }
private void gridSprints_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) { return; } ContextMenu menu = new ContextMenu(); menu.MenuItems.Add("Remove Sprint", (o, arg) => { int selectedIndex = gridSprints.GetSelectedIndex(); if (selectedIndex == -1) { return; //Nothing to remove. } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will permanently delete this sprint. Continue?")) { return; } long sprintNum = ((JobSprint)gridSprints.ListGridRows[selectedIndex].Tag).JobSprintNum; userControlSprintManager.Enabled = false; JobSprints.Delete(sprintNum); FillGridSprints(); }); menu.MenuItems.Add("Copy Sprint", (o, arg) => { int selectedIndex = gridSprints.GetSelectedIndex(); if (selectedIndex == -1) { return; //Nothing to copy. } JobSprint sprint = ((JobSprint)gridSprints.ListGridRows[selectedIndex].Tag); sprint.Title += "_Copy"; List <JobSprintLink> listSprintLinks = JobSprintLinks.GetForSprint(sprint.JobSprintNum); JobSprints.Insert(sprint); foreach (JobSprintLink sprintLink in listSprintLinks) { sprintLink.JobSprintNum = sprint.JobSprintNum; JobSprintLinks.Insert(sprintLink); } FillGridSprints(); userControlSprintManager.LoadSprint(sprint, _listJobsAll); }); menu.MenuItems.Add("End Sprint", (o, arg) => { int selectedIndex = gridSprints.GetSelectedIndex(); if (selectedIndex == -1) { return; //Nothing to end. } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will set the sprints actual end date to today. Continue?")) { return; } JobSprint sprint; //This gets the most recent sprint instance to save and unloads it so we can load it in if (!userControlSprintManager.Enabled || !userControlSprintManager.UnloadSprint(out sprint)) { return; } else { sprint = ((JobSprint)gridSprints.ListGridRows[selectedIndex].Tag); } sprint.DateEndActual = DateTime.Today; JobSprints.Update(sprint); FillGridSprints(); userControlSprintManager.LoadSprint(sprint, _listJobsAll); FillGridEngineers(userControlSprintManager.JobSprintCur); }); menu.Show(gridSprints, gridSprints.PointToClient(Cursor.Position)); }