// delete an account void DeleteAccount(){ TableDataSet NewDataSet; stringstream is(""); ViewAccounts(); is << GetUserInput("Select an ID to delete", DB.GetMaxField(ACCOUNT_TABLE, "AcctID")); NewDataSet.push_back(make_pair("AcctID", is.str())); DB.Delete(ACCOUNT_TABLE, NewDataSet); // delete transactions matching this user and account id TableDataSet TransactionTableDataSet; stringstream AAID(""); // active account id stringstream AUID(""); // active user id AAID << ActiveAccountID; AUID << ActiveUserID; if(DB.FieldExists(USER_TABLE, "UserID", (char*)AUID.str().c_str()) == false){ ActiveUserID = -1; cout << "User ID selected does not exist."; return; } else if(DB.FieldExists(ACCOUNT_TABLE, "AcctID", (char*)AAID.str().c_str()) == false){ ActiveAccountID = -1; cout << "Account ID selected does not exist."; return; } TransactionTableDataSet.push_back(make_pair("AcctID", AAID.str().c_str())); TransactionTableDataSet.push_back(make_pair("UserID", AUID.str().c_str())); DB.Delete(TRANSACTION_TABLE, TransactionTableDataSet); ActiveAccountID = -1; }
// delete a profile void DeleteProfile(){ TableDataSet NewDataSet; stringstream is(""); ViewProfiles(); is << GetUserInput("Select an ID to delete", DB.GetMaxField(USER_TABLE, "UserID")); if(!validate::string::numeric(is.str())){ cout << "invalid id"; return; } NewDataSet.push_back(make_pair("UserID", is.str().c_str())); DB.Delete(USER_TABLE, NewDataSet); ActiveUserID=-1; }