コード例 #1
0
 internal void newAccount(Holder h, Account a)
 {
     masterHolder.Add(h);
     h.setID(bankResources.getNextHolderID());
     h.addNewAccount(a);
     a.addNewAccountHolder(h);
     a.setOpenDate(DateTime.Now);
     a.setAccountNumber(bankResources.nextAccountNumber());
 }
コード例 #2
0
            internal void start()
            {
                List <string[]> lineCollection = new List <string[]>();

                holderCollection = new List <Holder>();
                string[] filePaths = Directory.GetFiles(directory, "*.txt");

                /* Get file information from directory to array */
                foreach (string file in filePaths)
                {
                    string[] newFile = File.ReadAllLines(file);
                    lineCollection.Add(newFile);
                }

                /* Get all customer information from each file */
                foreach (string[] l in lineCollection)
                {
                    Holder holder = new Holder();
                    holder.setID(long.Parse(l[0]));
                    holder.setPersonDetails(l[1], l[2], l[3], l[4]);
                    holder.setAddress(l[5], l[6], l[7], l[8], l[9]);

                    for (int i = 11; i < l.Length; i++)
                    {
                        var      acct_num            = l[i];
                        string[] accountInfoFromFile = File.ReadAllLines(account_directory + acct_num + "acct_file.txt");

                        /* Get file and open */
                        if (int.Parse(accountInfoFromFile[1]) == 1)
                        {
                            account = new Checking();
                        }
                        if (int.Parse(accountInfoFromFile[1]) == 2)
                        {
                            account = new Savings();
                        }
                        if (int.Parse(accountInfoFromFile[0]) == 0)
                        {
                            account.closeAccount(true);
                        }
                        if (int.Parse(accountInfoFromFile[0]) == 1)
                        {
                            account.closeAccount(false);
                        }

                        account.setAccountNumber(long.Parse(accountInfoFromFile[2]));
                        string[] openDate = accountInfoFromFile[3].Split(',');
                        account.setOpenDate(new DateTime(int.Parse(openDate[0]), int.Parse(openDate[1]), int.Parse(openDate[2])));

                        for (int z = 6; z < accountInfoFromFile.Length; z++)
                        {
                            string[] activityLine = accountInfoFromFile[z].Split(',');
                            var      activity     = new Activity(new DateTime(int.Parse(activityLine[0]), int.Parse(activityLine[1]), int.Parse(activityLine[2])), (Type)Enum.Parse(typeof(Type), activityLine[3].ToUpper()), decimal.Parse(activityLine[4]));
                            activity.adjustActivity(Boolean.Parse(activityLine[5]));
                            account.newActivity(activity);
                        }
                        account.addNewAccountHolder(holder);
                        holder.addNewAccount(account);
                    }
                    holderCollection.Add(holder);
                }
            }