Ejemplo n.º 1
0
        private void SaveFinalBalance(long balance)
        {
            _dbconnect = new DatabaseConnectivity();
            string query = $@"update @tableName set Balance=@newBalance where account_number=@accountNo";
            var    cmd   = new MySqlCommand(query, _dbconnect.Connect());

            cmd.Parameters.AddWithValue("@tableName", _dbconnect.DatabaseName);
            cmd.Parameters.AddWithValue("@newBalance", balance.ToString());
            cmd.Parameters.AddWithValue("@accountNo", AccountNumber);
            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 2
0
        private long GetCurrentBalance()
        {
            long balance = 0;

            _dbconnect = new DatabaseConnectivity();
            string query = $@"select Balance from @tableName where account_number=@accountNo";
            var    cmd   = new MySqlCommand(query, _dbconnect.Connect());

            cmd.Parameters.AddWithValue("@tableName", _dbconnect.DatabaseName);
            cmd.Parameters.AddWithValue("@accountNo", AccountNumber);
            var reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                balance = (long)reader["Balance"];
            }

            return(balance);
        }