// Inserts the data into the database table Activity public void sqlDataInsert(ComboBox combo, System.Data.SQLite.SQLiteConnection db) { // Activity ID was changed from combo.selectedindex +1 to a random number becuase activity IDs have to be unique. sqlInsert = ("Insert into Activity (Name, Duration, CaloriesBurned, Date, FK_USERID) " + "values ('" + activityName + "', " + duration + ", " + totalCalories + ", date('now')" + ", " + FitThisHUB.currentUserID + ")"); dbm.ExecuteNonQuery(sqlInsert, db); }
/// <summary> /// Method to add a newly created user to the database. /// </summary> /// <param name="user1"></param> public void AddUserToDB(User user1) { // Insert all user information into the user table. string sqlUserInsert = "INSERT INTO USER" + "(FName, LName, Height, StartingWeight, GoalWeight, Age, Gender," + "ActivityLevel, RecommendIntake)" + "VALUES (" + "'" + user1.FName + "','" + user1.LName + "'," + user1.Height + "," + user1.CurrentWeight + "," + user1.GoalWeight + "," + user1.Age + ",'" + user1.Gender + "','" + user1.ActivityLevel + "'," + user1.RecommendIntake + ")"; SQLiteConnection db = new SQLiteConnection("Data Source=FitThis.sqlite"); // Open the databse & send the sql command. dbm.ExecuteNonQuery(sqlUserInsert, db); //Must send new connection becuase old one is sent for the trash after //it has been opened this.UpdateLastLogin(user1); }