Esempio n. 1
0
// This function gets the information of the client if this 
// is their first day as a customer.
// Also creates the file for the bank statement. Will insert
// the initial deposit into the statement.
void BankAccount::newAccount()
{
	cout << "Press enter to continue.\n";
	cin.get();
	cout << "Enter your name: ";
	getline(cin, acctInfo.name);
	cout << "Enter your address: ";
	getline(cin, acctInfo.address);
	cout << "Enter your city/state/zip: ";
	getline(cin, acctInfo.city);
	cout << "Enter your account type: ";
	getline(cin, acctInfo.accountType);
	cout << "Enter today's date: ";
	getline(cin, acctInfo.creationDate);
	cout << "Enter your phone number: ";
	getline(cin, acctInfo.phoneNumber);
	cout << "Enter the initial deposit: ";
	cin >> acctInfo.balance;
	acctInfo.lastDeposit = acctInfo.balance;
	acctInfo.lastWithdrawal = 0;
	saveFile();

	updateStatement("Initial Deposit", acctInfo.lastDeposit);
	BankAccountMenu();
}
Esempio n. 2
0
// Gets the newest deposit of the account.
// Will save the newest deposit to the account holders
// data file and then will save it to the user's
// bank statement text file.
void BankAccount::enterDeposit()
{
	cout << "\nEnter the amount of the deposit: $";
	cin >> newDeposit;
	acctInfo.lastDeposit = newDeposit;
	acctInfo.balance += acctInfo.lastDeposit;
	saveFile();
	cout << endl;

	updateStatement("Deposit", newDeposit);
}
Esempio n. 3
0
// Gets the newest withdrawal of the account.
// Will save the newest deposit to the account holders
// data file and then will save it to the user's
// bank statement text file.
void BankAccount::enterWithdrawal()
{
	cout << "\nEnter the amount of the withdrawal: $";
	cin >> newWithdrawal;
	acctInfo.lastWithdrawal = newWithdrawal;
	acctInfo.balance -= acctInfo.lastWithdrawal;
	saveFile();
	cout << endl;

	updateStatement("Withdraw", newWithdrawal);
}
Esempio n. 4
0
void DatabaseTracker::setDatabaseDetails(SecurityOrigin* origin, const String& name, const String& displayName, unsigned long estimatedSize)
{
    String originIdentifier = origin->databaseIdentifier();
    int64_t guid = 0;

    MutexLocker lockDatabase(m_databaseGuard);

    openTrackerDatabase(CreateIfDoesNotExist);
    if (!m_database.isOpen())
        return;
    SQLiteStatement statement(m_database, "SELECT guid FROM Databases WHERE origin=? AND name=?");
    if (statement.prepare() != SQLResultOk)
        return;

    statement.bindText(1, originIdentifier);
    statement.bindText(2, name);

    int result = statement.step();
    if (result == SQLResultRow)
        guid = statement.getColumnInt64(0);
    statement.finalize();

    if (guid == 0) {
        if (result != SQLResultDone)
            LOG_ERROR("Error to determing existence of database %s in origin %s in tracker database", name.ascii().data(), originIdentifier.ascii().data());
        else {
            // This case should never occur - we should never be setting database details for a database that doesn't already exist in the tracker
            // But since the tracker file is an external resource not under complete control of our code, it's somewhat invalid to make this an ASSERT case
            // So we'll print an error instead
            LOG_ERROR("Could not retrieve guid for database %s in origin %s from the tracker database - it is invalid to set database details on a database that doesn't already exist in the tracker",
                       name.ascii().data(), originIdentifier.ascii().data());
        }
        return;
    }

    SQLiteStatement updateStatement(m_database, "UPDATE Databases SET displayName=?, estimatedSize=? WHERE guid=?");
    if (updateStatement.prepare() != SQLResultOk)
        return;

    updateStatement.bindText(1, displayName);
    updateStatement.bindInt64(2, estimatedSize);
    updateStatement.bindInt64(3, guid);

    if (updateStatement.step() != SQLResultDone) {
        LOG_ERROR("Failed to update details for database %s in origin %s", name.ascii().data(), originIdentifier.ascii().data());
        return;
    }

    if (m_client)
        m_client->dispatchDidModifyDatabase(origin, name);
}
Esempio n. 5
0
bool Repository::push(StorageObject sObj)
{
    return updateStatement(sObj);
}