fix: update children query

This commit is contained in:
kougyokugentou 2021-01-29 22:11:34 -08:00
parent 9c4fa611af
commit e2f50bec03

View File

@ -76,7 +76,7 @@ namespace GreatHomeChildcare
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{ {
string strQuery = "UPDATE Children SET FirstName = @First_Name, LastName = @Last_Name, " + string strQuery = "UPDATE Children SET FirstName = @First_Name, LastName = @Last_Name, " +
"DOB = @_dob, address = @_address, race = @_race, gender = @_gender, photo = @_photo" + "DOB = @_dob, address = @_address, race = @_race, gender = @_gender, photo = @_photo " +
"WHERE id = @_id;"; "WHERE id = @_id;";
cnn.Execute(strQuery, new cnn.Execute(strQuery, new
@ -333,21 +333,18 @@ WHERE Guardians.id = @id
// ***************** Read ******************* // ***************** Read *******************
/* Checks to see if this is the first time the application has run. /* Checks to see if this is the first time the application has run.
* by counting the number of guardians in the guardian table. * by counting the number of admins in the guardian table.
* INPUT: void from program, count of guardians from db. * INPUT: void from program, count of guardians from db.
* OUTPUT: boolean true/false. * OUTPUT: integer
*/ */
internal bool isFirstTimeRun() internal int GetNumAdmins()
{ {
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{ {
string strQuery = "SELECT COUNT(*) FROM Guardians"; string strQuery = "SELECT COUNT(*) FROM Guardians WHERE isAdmin = 1";
int num_guardians = cnn.Query<int>(strQuery).SingleOrDefault(); int num_admins = cnn.Query<int>(strQuery).SingleOrDefault();
if (num_guardians > 0) return num_admins;
return false;
else
return true;
} }
} }
// ***************** Update ***************** // ***************** Update *****************