private void DeleteProjectPB_Click(object sender, RoutedEventArgs e) { DataRecord record = (DataRecord)projectXamDataGrid.ActiveRecord; if (record == null) { return; } if (record != null) { ProjectSimple project = (ProjectSimple)record.DataItem; string MsgStr = "Are you sure that you want to DELETE Project: " + project.Description + "?"; MessageBoxResult result = MessageBox.Show(MsgStr, "Delete Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { WaveguideDB wgDB = new WaveguideDB(); bool success = wgDB.RemoveProjectFromUserProjectTable(project.ProjectID); if (success) { success = wgDB.DeleteProject(project.ProjectID); if (success) { ProjectVM.Refresh(); } } } } }
public void Refresh() { Projects.Clear(); bool success = wgDB.GetAllProjects(ShowArchivedProjects); if (success) { for (int i = 0; i < wgDB.m_projectList.Count(); i++) { ProjectSimple project = new ProjectSimple(); project.Description = wgDB.m_projectList[i].Description; project.ProjectID = wgDB.m_projectList[i].ProjectID; project.Archived = wgDB.m_projectList[i].Archived; project.TimeStamp = wgDB.m_projectList[i].TimeStamp; Projects.Add(project); List <UserContainer> users; success = wgDB.GetAllUsersForProject(project.ProjectID, out users); if (success) { for (int j = 0; j < users.Count(); j++) { UserFullname ufn = new UserFullname(); ufn.Fullname = users[j].Lastname + ", " + users[j].Firstname; project.Users.Add(ufn); } } } } }
private void EditProjectPB_Click(object sender, RoutedEventArgs e) { DataRecord record = (DataRecord)projectXamDataGrid.ActiveRecord; if (record == null) { return; } if (record.DataItem.GetType() == typeof(UserFullname)) { DataRecord recordParent = record.ParentDataRecord; if (recordParent.DataItem.GetType() == typeof(ProjectSimple)) { record = recordParent; } } if (record.DataItem.GetType() != typeof(ProjectSimple)) { return; } ProjectSimple ps = (ProjectSimple)record.DataItem; ProjectContainer pc = new ProjectContainer(); pc.Description = ps.Description; pc.ProjectID = ps.ProjectID; EditProjectDialog dlg = new EditProjectDialog(pc.ProjectID); dlg.ShowDialog(); if (dlg.m_OK) { ProjectVM.Refresh(); } }