//___________________________Deletes item(User or test) at the accepted key from the relevant table in db_________________________________________ public bool DeleteSelectedItem(int key, bool delUser) { bool deleteSuccess = false; //__________________Deletes a User if delUser bool is true_________________________________ if (delUser) { if (MessageBox.Show("This will permenantly delete User: "******" " + UserObjDictionary[key].Surname + ", as well as all Tests the user has created and all marks associated to the tests.", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { UserObjDictionary.Remove(key); DatabaseUtilities.DeleteFromDB("Users", "userID", key); deleteSuccess = true; } } //__________________Deletes a Test if delUser bool is false_________________________________ else { if (MessageBox.Show("This will permenantly delete " + TestObjDictionary[key].TestName + ", as well as all Questions and Marks associated with the test.", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { TestObjDictionary.Remove(key); DatabaseUtilities.DeleteFromDB("Tests", "testID", key); deleteSuccess = true; } } return(deleteSuccess); }
public async Task PopulateUsers() { foreach (String nextLine in DatabaseUtilities.ReadDB(@"Users")) { String[] singleUser = nextLine.Split('#'); UsersDictionary.Add(int.Parse(singleUser[0]), singleUser[1] + " " + singleUser[2]); UserObjDictionary.Add(int.Parse(singleUser[0]), (new AllUsersObj { Name = singleUser[1], Surname = singleUser[2], Password = singleUser[3], AccessGroup = int.Parse(singleUser[4]) })); UserID = int.Parse(singleUser[0]); } }