Пример #1
0
        public IBankAccount AddBankAccount(IBankAccount Account)
        {
            long   id    = 0;
            string query = @"INSERT INTO `bank_account` 
									(user_account_name, world_id, flags, flags2, description)
								  VALUES (@0, @1, @2, @3, @4);"                                ;

            if (string.IsNullOrEmpty(Account.UserAccountName) == true)
            {
                return(null);
            }

            try {
                if (Connection.QueryIdentity(query, out id, Account.UserAccountName, Account.WorldID,
                                             (int)Account.Flags, 0, Account.Description) < 0)
                {
                    return(null);
                }
            } catch (Exception ex) {
                TShock.Log.ConsoleError(" seconomy mysql: sql error adding bank account: " + ex.ToString());
                return(null);
            }

            Account.BankAccountK = id;
            lock (BankAccounts) {
                BankAccounts.Add(Account);
            }

            return(Account);
        }
Пример #2
0
 //
 ///
 ////
 /////Registration blank to register new account
 private static void Registration(BankAccounts accounts, List<Log> eventLog)  
 {
     BankAccount account = new BankAccount();
     Write("Please enter your first name: ");
     account.Name = ReadCredentials().UppercaseFirstLetter();
     Write("Please enter your last name: ");
     account.Surname = ReadCredentials().UppercaseFirstLetter(); //EXTENTION METHOD
     Write("Please enter your birth date dd-mm-yyyy: ");
     account.year = ReadDate();
     Random rnd = new Random();
     account.id = RandomNumber(rnd, 10000, 100000);
     account.pass = RandomNumber(rnd, 100000, 1000000);
     WriteLine($"Your id is: {0}", account.id);
     WriteLine($"Your password is: {account.pass}");
     account.GiveMoney();                                        //OPTIONAL ARGUMENT
     WriteLine("Please save this information!");
     if (account.Name == "admin" || account.Name == "Admin")
     {
         GivePermissions("admin", account);
     }
     else
     {
         GivePermissions("normal", account);
     }
     accounts.Add(account);
     eventLog.Add(new Log { id = account.id, debugTime = DateTime.Now, debug = "Registered new account" });
     Read();
 }
        public BankAccount ApplyForBankAccount()
        {
            BankAccount bankAccount = new BankAccount();

            BankAccounts.Add(bankAccount);

            return(bankAccount);
        }
Пример #4
0
 private DataStore()
 {
     BankAccounts.Add(new BankAccount {
         Id = 1001, Name = "Alice", Balance = 1000m
     });
     BankAccounts.Add(new BankAccount {
         Id = 1002, Name = "Bob", Balance = 1000m
     });
     BankAccounts.Add(new BankAccount {
         Id = 1003, Name = "Eve", Balance = 1000m
     });
 }
Пример #5
0
 public void createNewUser(String userName, String password)
 {
     if (checkIfUserIdExists(userName))
     {
         throw new Exception("Username already in use.");
     }
     else
     {
         BankAccount newAccount = new BankAccount(BankAccounts.Count, new User(userName, password));
         BankAccounts.Add(newAccount);
     }
 }
Пример #6
0
        private BankAccounts CreateObjects(IDataReader oReader)
        {
            BankAccounts oBankAccounts = new BankAccounts();
            NullHandler  oHandler      = new NullHandler(oReader);

            while (oReader.Read())
            {
                BankAccount oItem = CreateObject(oHandler);
                oBankAccounts.Add(oItem);
            }
            return(oBankAccounts);
        }
Пример #7
0
        private void LoadBankAccountList()
        {
            // load dictionary of BankAccount entities
            allBankAccounts.Clear();
            bankAccountRepository.ReadList().ToList().ForEach(a => allBankAccounts.Add(a.BankAccountId, a));

            // populate collection for View
            BankAccounts.Clear();
            allBankAccounts.Values.ToList().ForEach(a => BankAccounts.Add(new BankAccountItemViewModel(a)));

            // Flag selected items
            foreach (var cfa in this.entity.CashflowBankAccounts)
            {
                var a = this.BankAccounts.FirstOrDefault(ba => ba.BankAccountId == cfa.BankAccount.BankAccountId);
                if (a != null)
                {
                    a.IsSelected = true;
                }
            }
        }
Пример #8
0
 private void LoadBankAccountList()
 {
     BankAccounts.Clear();
     BankAccounts.Add(BankAccountItemViewModel.Elsewhere);
     bankAccountRepository.ReadList().ForEach(a => BankAccounts.Add(new BankAccountItemViewModel(a)));
 }
Пример #9
0
        protected void LoadBankAccounts()
        {
            long   bankAccountCount = 0, tranCount = 0;
            int    index = 0, oldPercent = 0;
            double percentComplete = 0;
            JournalLoadingPercentChangedEventArgs parsingArgs = new JournalLoadingPercentChangedEventArgs()
            {
                Label = "Loading"
            };

            try {
                if (JournalLoadingPercentChanged != null)
                {
                    JournalLoadingPercentChanged(this, parsingArgs);
                }

                bankAccounts     = new List <IBankAccount>();
                bankAccountCount = Connection.QueryScalar <long>("select count(*) from `bank_account`;");
                tranCount        = Connection.QueryScalar <long>("select count(*) from `bank_account_transaction`;");

                QueryResult bankAccountResult = Connection.QueryReader(@"select bank_account.*, sum(bank_account_transaction.amount) as balance
                                                                         from bank_account 
                                                                             inner join bank_account_transaction on bank_account_transaction.bank_account_fk = bank_account.bank_account_id 
                                                                         group by bank_account.bank_account_id;");

                Action <int> percentCompleteFunc = i => {
                    percentComplete = (double)i / (double)bankAccountCount * 100;

                    if (oldPercent != (int)percentComplete)
                    {
                        parsingArgs.Percent = (int)percentComplete;
                        if (JournalLoadingPercentChanged != null)
                        {
                            JournalLoadingPercentChanged(this, parsingArgs);
                        }
                        oldPercent = (int)percentComplete;
                    }
                };

                foreach (var acc in bankAccountResult.AsEnumerable())
                {
                    MySQLBankAccount sqlAccount = null;
                    sqlAccount = new MySQLBankAccount(this)
                    {
                        BankAccountK    = acc.Get <long>("bank_account_id"),
                        Description     = acc.Get <string>("description"),
                        Flags           = (BankAccountFlags)Enum.Parse(typeof(BankAccountFlags), acc.Get <int>("flags").ToString()),
                        UserAccountName = acc.Get <string>("user_account_name"),
                        WorldID         = acc.Get <long>("world_id"),
                        Balance         = acc.Get <long>("balance")
                    };

                    //sqlAccount.SyncBalance();
                    lock (BankAccounts) {
                        BankAccounts.Add(sqlAccount);
                    }

                    Interlocked.Increment(ref index);
                    percentCompleteFunc(index);
                }

                parsingArgs.Percent = 100;
                if (JournalLoadingPercentChanged != null)
                {
                    JournalLoadingPercentChanged(this, parsingArgs);
                }

                // CleanJournal(PurgeOptions.RemoveOrphanedAccounts | PurgeOptions.RemoveZeroBalanceAccounts);

                Console.WriteLine("\r\n");
                ConsoleEx.WriteLineColour(ConsoleColor.Cyan, " Journal clean: {0} accounts, {1} transactions", BankAccounts.Count(), tranCount);
            } catch (Exception ex) {
                TShock.Log.ConsoleError(" seconomy mysql: db error in LoadJournal: " + ex.Message);
                throw;
            }
        }
Пример #10
0
 public void AddBankAccount(Bank bank, string accountNum, string currency)
 {
     BankAccounts.Add(new BankAccount(this, bank, accountNum, currency));
 }
Пример #11
0
 public void AddAccount(BankAccount bankAccountToAdd)
 {
     BankAccounts.Add(bankAccountToAdd);
 }
Пример #12
0
        //
        ///
        ////
        /////Reads account information from files

        static void GetAccountInformation(BankAccounts accounts)
        {
            string temp = "accounts.txt";
            if (!File.Exists(temp))
            {
                File.Create(temp);
            }
            else
            {
                using (StreamReader file = new StreamReader("accounts.txt"))
                {

                    string line;
                    while ((line = file.ReadLine()) != null)
                    {
                        var words = line.Split(' ');
                        var account = new BankAccount
                        {
                            Name = words[0],
                            Surname = words[1],
                            year = words[2],
                            id = words[3],
                            pass = words[4],
                            money = Convert.ToDouble(words[5])
                        };
                        if (words[0] == "Admin" || words[1] == "Admin")
                        {
                            GivePermissions("Admin", account);
                        }
                        else
                        {
                            GivePermissions("normal", account);
                        }
                        accounts.Add(account);
                    }
                }
                    //file.Close();
            }
        }
Пример #13
0
 public void AddBank(BankAccount obj)
 {
     BankAccounts.Add(obj);
 }
 public int AddAccount(decimal bal, string owner)
 {
     return(BankAccounts.Add(bal, owner));
 }