public bool addItem(string name, string category, string picture, string description, string date, string location) { itemID = DatabaseHandler.Select("Item", "").Rows.Count + 1; this.name = name; this.category = category; this.pictureString = picture; this.description = description; this.date = date; this.location = location; if (Login.loginUser) { userID = Login.loginUserID; } if (SignUp.signUpUser) { userID = SignUp.signUpUserID; } bool success; try { DatabaseHandler.Insert("Item", new string[] { itemID.ToString(), name, category, picture, description, date, location, userID.ToString() }); success = true; } catch (Exception e) { Console.WriteLine("Exception thrown"); success = false; throw e; } if (success) { return(true); } else { return(false); } }
public bool addUser(string firstName, string lastName, string email, string mobileNumber, string gender, int age, string password) { userID = DatabaseHandler.Select("Users", "").Rows.Count + 1; this.firstName = firstName; this.lastName = lastName; this.email = email; this.mobileNumber = mobileNumber; this.gender = gender; this.age = age; this.password = password; string clause = "WHERE email = '" + email + "';"; DataTable dt = DatabaseHandler.Select("Users", clause); if (dt.Rows.Count == 0) { try { int count = DatabaseHandler.Select("Users", "").Rows.Count + 1; DatabaseHandler.Insert("Users", new string[] { count.ToString(), firstName, lastName, email, mobileNumber.ToString(), age.ToString(), gender.ToString(), password, }); return(true); } catch (Exception e) { Console.WriteLine("Exception thrown"); throw e; } } else { return(false); } }