private void DeleteUserPB_Click(object sender, RoutedEventArgs e) { DataRecord record = (DataRecord)userXamDataGrid.ActiveRecord; if (record == null) { return; } if (record != null) { UserSimple user = (UserSimple)record.DataItem; string MsgStr = "Are you sure that you want to DELETE User: "******" " + user.Lastname + "?"; MessageBoxResult result = MessageBox.Show(MsgStr, "Delete Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { WaveguideDB wgDB = new WaveguideDB(); bool success = wgDB.RemoveUserFromUserProjectTable(user.UserID); if (success) { success = wgDB.DeleteUser(user.UserID); if (success) { UserVM.Refresh(); } } } } }
private void EditUserPB_Click(object sender, RoutedEventArgs e) { DataRecord record = (DataRecord)userXamDataGrid.ActiveRecord; if (record == null) { return; } if (record.DataItem.GetType() == typeof(ProjectFullname)) { DataRecord recordParent = record.ParentDataRecord; if (recordParent.DataItem.GetType() == typeof(UserSimple)) { record = recordParent; } } if (record.DataItem.GetType() != typeof(UserSimple)) { return; } UserSimple user = (UserSimple)record.DataItem; UserContainer u1 = new UserContainer(); u1.UserID = user.UserID; u1.Lastname = user.Lastname; u1.Firstname = user.Firstname; u1.Username = user.Username; u1.Password = user.Password; u1.Role = user.Role; EditUserDialog dlg = new EditUserDialog(u1); dlg.ShowDialog(); if (dlg.m_OK) { UserVM.Refresh(); } }
public void Refresh() { Users.Clear(); bool success = wgDB.GetAllUsers(); if (success) { for (int i = 0; i < wgDB.m_userList.Count(); i++) { UserSimple user = new UserSimple(); user.Firstname = wgDB.m_userList[i].Firstname; user.Lastname = wgDB.m_userList[i].Lastname; user.Username = wgDB.m_userList[i].Username; user.Role = wgDB.m_userList[i].Role; user.UserID = wgDB.m_userList[i].UserID; user.Password = wgDB.m_userList[i].Password; Users.Add(user); ObservableCollection <ProjectContainer> projects; success = wgDB.GetAllProjectsForUser(user.UserID, out projects); if (success) { for (int j = 0; j < projects.Count(); j++) { if (!projects[j].Archived) { ProjectFullname pfn = new ProjectFullname(); pfn.Fullname = projects[j].Description; user.Projects.Add(pfn); } } } } int count = Users.Count(); } }