public void CheckifIDinTable() { FunctionsForAllProgram funcs = new FunctionsForAllProgram(); // existing user bool IDExists = funcs.ifIDinTable(3233, "Users"); Assert.IsTrue(IDExists); // not existing user IDExists = funcs.ifIDinTable(99999, "Users"); Assert.IsFalse(IDExists); }
public void CheckUsernameExists() { FunctionsForAllProgram funcs = new FunctionsForAllProgram(); // existing user bool IDExists = funcs.ifUserInDatabase("roni"); Assert.IsTrue(IDExists); // not existing user IDExists = funcs.ifUserInDatabase("Dudu Aharon"); Assert.IsFalse(IDExists); }
public void CheckUserIDExists() { FunctionsForAllProgram funcs = new FunctionsForAllProgram(); // existing user bool IDExists = funcs.ifUserIDinDatabase(3233); Assert.IsTrue(IDExists); // not existing user IDExists = funcs.ifUserIDinDatabase(99999); Assert.IsFalse(IDExists); }
public void CheckifIDinEvents() { FunctionsForAllProgram funcs = new FunctionsForAllProgram(); // existing user bool IDExists = funcs.ifIDinEvents(1); Assert.IsTrue(IDExists); // not existing user IDExists = funcs.ifIDinEvents(99999); Assert.IsFalse(IDExists); }
private void addStudentToDatabase_Click(object sender, EventArgs e) { User newAssociate; FunctionsForAllProgram funcs = new FunctionsForAllProgram(); String username = this.username_box.Text; String id = this.id_box.Text; int id_int = -1; if (checkFields() == false) { return; } try { id_int = Convert.ToInt32(id); } catch { MessageBox.Show("ID field contains non-digit symbols this field is empty!"); return; } bool userExists = funcs.ifUserInDatabase(username) || funcs.ifUserIDinDatabase(id_int); if (userExists == false) { string email = this.email_Box.Text; bool emailExists = funcs.ifEmailInDatabase(email); if (emailExists) { MessageBox.Show("User with email " + email + " already exists"); return; } String Name = this.firstname_box.Text, surename = this.secondName_box.Text, password = this.password_box.Text; newAssociate = new User(id, username, Name, surename, password, email); DBconnect db = new DBconnect(); try { db.addUserToDB(newAssociate); MessageBox.Show("New Associate member been added to database!"); } catch { MessageBox.Show("Something went wrong, user not been added! \ncheck your database connection and fields correctness and try again!"); } } }
private void deleteMessageButton_Click(object sender, EventArgs e) { DBconnect db = new DBconnect(); int id; try { id = Convert.ToInt32(this.globalMessageId_box.Text); } catch { MessageBox.Show("Empty ID field or non-digit symbol been inputed."); return; } String query = "DELETE FROM GlobalMEssages WHERE ID=" + id; FunctionsForAllProgram func = new FunctionsForAllProgram(); bool existCheck = func.ifIDinTable(id, "GlobalMessages"); if (existCheck) { try { bool result = db.executionQuery(query); if (result) { MessageBox.Show("Global message with id : " + id + " removed from database"); } } catch { MessageBox.Show("Cannot delete message with id : " + id); } } else { MessageBox.Show("Message with this id does not exists"); } }