//*************************************************************************************************************************************************//
 private void Exit_Click_1(object sender, EventArgs e)
 //*************************************************************************************************************************************************//
 {   // tidy up after ourselves
     Bank.Dispose();
     Cust.Dispose();
     this.Close();
 }
Exemplo n.º 2
0
        public static int RebuildBankDataFromTextFiles( )
        //************************************************************************************************************************************************
        {
            // iterate thru reading bankaccount objects from disk and add them to our LinkedList and /BankArray
            int    count = 0;
            string dir   = BankAccount.ReadBankFilePath( );

            dir += "Textfiles\\";
            string[] files = Directory.GetFiles(dir);
            // clear the lists- JIC
            DataArray.ArrayClearBank( );                 // Clear ( );
            BankAccount.BankAccountsLinkedList.Clear( );

            foreach (var fi in files)
            {
                bool result = fi.Contains("BankObject");
                if (!result)
                {
                    continue;
                }
                else
                {
                    string      input = File.ReadAllText(fi);
                    char[]      ch    = { ',' };
                    string[]    items = input.Split(ch);
                    BankAccount B     = new BankAccount( );
                    B.BankAccountNumber = Convert.ToInt32(items[0]);
                    B.CustAccountNumber = Convert.ToInt32(items[1]);
                    B.AccountType       = Convert.ToInt16(items[2]);
                    B.Balance           = Convert.ToDecimal(items[3]);
                    B.DateOpened        = Convert.ToDateTime(items[4]);
                    B.DateClosed        = Convert.ToDateTime(items[5]);
                    B.Balance           = Convert.ToDecimal(items[6]);
                    B.Status            = Convert.ToInt16(items[7]);
                    //Write it back as OBj and TXT - yes even though we onlt just read it in.
                    SerializeData.WriteBankAccountToDiskAndText(B, B.FullFileName);
                    // add each one to our new List so we cna use the Enumeration later
                    try
                    {
                        BankAccount.BankAccountsLinkedList.AddLast(B);
                        DataArray.ArrayAddBank(B);
                        if (BankAccount.BankDict != null)
                        {
                            if (!BankAccount.BankDict.ContainsKey(B.BankAccountNumber))
                            {
                                BankAccount.BankDict.Add(B.BankAccountNumber, B);
                            }
                        }
                    }
                    catch
                    { new Exception(" Failed to update LinkeList or Bank array in RebuildBankDataFromTextFiles at line 311"); }
                    count++;
                    B.Dispose( );
                }
            }
            // This saves the bank LinkedList to both an object file and a Text file
            Lists.SaveAllBankAccountListData( );
            BankListChangedEvent?.Invoke(null, "ALLDATA REBUILT FROM TEXTFILES");
            return(count);
        }
Exemplo n.º 3
0
 // Cancel window
 private void Cancelbutton_Click(object sender, EventArgs e)
 {
     dirty = true;
     //clean up our memeory usage after ourselves so far
     Bank.Dispose( );                  // delete our file wide BankAccount object from memory
     Cust.Dispose( );                  // delete our file wide Customer object from memory
     Close( );
 }
Exemplo n.º 4
0
        //*************************************************************************************************************//
        private void Exit_Click_1(object sender, EventArgs e)


        //*************************************************************************************************************//
        {
            //	if ( dirty )    // we must reset customer # seed as it has already been incremented
            //	Customer . SetCustomerNumberSeed ( Convert . ToInt32 ( AccountNo . Text ) - 1 );
            Bank.Dispose( );
            Cust.Dispose( );
            Close( );
        }
Exemplo n.º 5
0
 //*************************************************************************************************************************************************//
 private void Exit_Click_2(object sender, EventArgs e)
 //*************************************************************************************************************************************************//
 {
     if (Cust != null)
     {
         Cust.Dispose( );
     }
     if (B != null)
     {
         B.Dispose( );
     }
     Close( );
 }
Exemplo n.º 6
0
        // Save the new customer data as an Object and add it to the Customer List
        // plus create a BankAccount object and add it to the BankAccount List
        private void SaveCustButton_Click_1(object sender, EventArgs e)
        {
            DateTime DOB;
            int      type = 0;

            try
            {
                int test = Convert.ToInt16(day.Text);
                test = Convert.ToInt16(day.Text);
                test = Convert.ToInt16(day.Text);
            }
            catch { new Exception("Date of Birth entry data is invalid..." + day + "/" + month + "/" + year); }

            if (AccountType.Text.Contains("Normal"))
            {
                type = 1;
            }
            if (AccountType.Text.Contains("Savings"))
            {
                type = 2;
            }
            if (AccountType.Text.Contains("Deposit"))
            {
                type = 3;
            }
            if (AccountType.Text.Contains("Business"))
            {
                type = 4;
            }
            if (day.Text == "" | month.Text == "" | year.Text == "")
            {
                MessageBox.Show("The DOB date you have entered is not valid... Please correct this", " New Customer entry System");
                return;
            }
            if (Convert.ToInt16(day.Text) < 0 | Convert.ToInt16(day.Text) > 31 | Convert.ToInt16(month.Text) < 0 | Convert.ToInt16(month.Text) > 12
                | Convert.ToInt16(year.Text) < 1920 | Convert.ToInt16(year.Text) > DateTime.Now.Year)
            {
                MessageBox.Show("The DOB date you have entered is not valid... Please correct this", " New Customer entry System"); return;
            }
            string dob = day.Text + "/" + month.Text + "/" + year.Text;

            /// make sure our DOB data is sound, else we crqash everywhere
            try { DOB = Convert.ToDateTime(dob); }
            catch
            { MessageBox.Show("The DOB date you have entered is not valid... Please correct this", " New Customer entry System"); return; }
            if (lname.Text == "")
            {
                MessageBox.Show("You must enter a valid Last Name... Please correct this", " New Customer entry System"); return;
            }
            if (town.Text == "")
            {
                MessageBox.Show("You must enter a valid Town... Please correct this", " New Customer entry System"); return;
            }
            if (county.Text == "")
            {
                MessageBox.Show("You must enter a valid County... Please correct this", " New Customer entry System"); return;
            }
            if (pcode.Text == "")
            {
                MessageBox.Show("You must enter a valid PostCode... Please correct this", " New Customer entry System"); return;
            }
            //============================================================
            BankAccount Ba = new BankAccount( );

            // this returns the Balance if we need it
            Ba = BankAccount.CreateNewBankAccount(Ba, AccountNo.Text, (Int16)type, Utils.stringToDecimal(AccountBalance.Text), Utils.stringToDecimal(Interest.Text));
            //========================CUSTOMER ACCOUNT================
            Customer cust = Customer.CreateNewCustomer(AccountNo.Text, fname.Text, lname.Text, tel.Text, mob.Text, addr1.Text, addr2.Text,
                                                       town.Text, county.Text, pcode.Text, type, Ba.BankAccountNumber, DOB);

            Ba.Dispose( );
            MessageBox.Show("Customer account has been opened successfully...,", "New Customer account creation");
            dirty = false;
            this.Close( );
        }
Exemplo n.º 7
0
        //=========================================================================//
        //EXTERNAL
        public Int16 LoadArraysFromDisk(out int Bcount, out int Ccount)
        //=========================================================================//
        {
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // We iterate through all Bank .BNK files cos we can also read the relevant
            // Customer #  from it, and then load that to the Customer array - Clever eh ?
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            Int16 count = 0;

            Bcount = 0;
            Ccount = 0;
            Int32[] custno     = new int[100];
            int     custcount  = 0;
            bool    duplicated = false;
            // start with BankAccounts
            string dir  = BankAccount.ReadBankFilePath();
            string dir2 = Customer.GetCustFilePath();

            string[] bankfiles = System.IO.Directory.GetFiles(dir, "Bankobject*.bnk");
            // initilaize our check array
            for (int i = 0; i < 100; i++)
            {
                custno[i] = 0;
            }
            // Iterate trhu them and handle as required
            foreach (var fi in bankfiles)
            {
                bool result = fi.Contains("BankObject");
                if (result)
                {
                    // Got a bank account object
                    BankAccount B = (BankAccount)SerializeData.ReadBankAccountFromDisk(fi);
                    if (B != null)
                    {
                        DataArray.ArrayAddBank(B);     // Add to bank ArrayList
                        Bcount++;
                        BankAccount.BankAccountsLinkedList.AddLast(B);
                        Customer C = (Customer)SerializeData.ReadCustomerDiskObject(dir2 + "Custobj" + B.CustAccountNumber + ".cust");
                        if (C != null)
                        {
                            // add to our test array
                            // check to see if it has been added before ?
                            for (int i = 0; i < custcount; i++)
                            {
                                if (custno[i] == C.CustomerNumber)
                                {
                                    duplicated = true;
                                    break;
                                }
                            }
                            custno[custcount++] = C.CustomerNumber;
                            if (!duplicated)
                            {
                                DataArray.ArrayAddCust(C);     // The one and only Customer ArrayList addition in this Fn()
                                Ccount++;
                                Customer.CustomersLinkedList.AddLast(C);
                            }

                            /*							// Handle multiple a/c's held by this customer
                             *                                                                                  if ( C . accountnums [ 1 ] != 0 )
                             *                                                                                  {
                             *                                                                                          BankAccount Bk = ( BankAccount ) SerializeData . ReadBankAccountFromDisk ( dir + "Bankobject" + C . accountnums [ 1 ] + ".bnk" );
                             *                                                                                          DataArray . ArrayAddBank ( Bk );// Add to bank ArrayList
                             *                                                                                          Bcount++;
                             *                                                                                          Bk . Dispose ( );
                             *                                                                                  }
                             *                                                                                  if ( C . accountnums [ 2 ] != 0 )
                             *                                                                                  {
                             *                                                                                          BankAccount Bk = ( BankAccount ) SerializeData . ReadBankAccountFromDisk ( dir + "Bankobject" + C . accountnums [ 2 ] + ".bnk" );
                             *                                                                                          DataArray . ArrayAddBank ( Bk );// Add to bank ArrayList
                             *                                                                                          Bcount++;
                             *                                                                                          Bk . Dispose ( );
                             *                                                                                  }
                             *                                                                                  if ( C . accountnums [ 3 ] != 0 )
                             *                                                                                  {
                             *                                                                                          BankAccount Bk = ( BankAccount ) SerializeData . ReadBankAccountFromDisk ( dir + "Bankobject" + C . accountnums [ 3 ] + ".bnk" );
                             *                                                                                          DataArray . ArrayAddBank ( Bk );// Add to bank ArrayList
                             *                                                                                          Bcount++;
                             *                                                                                          Bk . Dispose ( );
                             *                                                                                  }
                             */
                            if (C != null)
                            {
                                C.Dispose();
                            }
                        }
                        if (B != null)
                        {
                            B.Dispose();
                        }
                    }
                    count++;
                }
            }
            // save our Customer LinkedList to disk as binary and txt files
            Lists.SaveAllCustomerListData(Customer.CustomerFilePath + "CustSortedListData.cust");
            // sort the arrays in Ascending v0 - 9
            SortArray.SortBankArray(0);
            return(count);
        }