//************************************************************************ public static void contra_Click(object sender, EventArgs e) //************************************************************************ { // Sort Bank array reversed if (Bank._badirection == 0) { a[0] = 1; string msg = "Bank ArrayList Sort Order has been changed to Reverse (Descending)\r\n"; SortArray.SortBankArray(1); Bank.form1.ShowText(msg, a, 0); //the method defined in Bank } }
//************************************************************************ private void Contra_Click_1(object sender, EventArgs e) //************************************************************************ { // Sort Bank array reversed if (Bank._badirection == 0) { Bank._badirection = 1; a[0] = 1; string msg = "Bank ArrayList Sort Order has been changed to Reverse (Descending)\r\n"; SortArray.SortBankArray(1); Info.Text = "Reverse ( Descending)"; Info.ForeColor = Color.Red; Bank.form1.ShowText(msg, a, 0); //the method defined in Bank Alpha.Enabled = true; Contra.Enabled = false; Alpha.Focus( ); } }
//************************************************************************ //************************************************************************ //THESE ARE THE DIRECT CONTROL FROM SORTARRAY.CS //************************************************************************ //************************************************************************ //************************************************************************ private void Alpha_Click_1(object sender, EventArgs e) //************************************************************************ { // Sort Bank array normal if (Bank._badirection == 1) { Bank._badirection = 0; a[0] = 0; string msg = "Bank ArrayList Sort Order has been changed to Normal (Ascending)\r\n"; SortArray.SortBankArray(0); Info.Text = "Normal ( Ascending)"; Info.ForeColor = Color.Black; Bank.form1.ShowText(msg, a, 0); //the method defined in Bank Alpha.Enabled = false; Contra.Enabled = true; Contra.Focus( ); } }
//=========================================================================// //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 if (BankAccount.BankDict != null) { if (!BankAccount.BankDict.ContainsKey(B.BankAccountNumber)) { BankAccount.BankDict.Add(B.BankAccountNumber, B); } } 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() if (Customer.CustDict != null) { if (!Customer.CustDict.ContainsKey(C.CustomerNumber)) { Customer.CustDict.Add(C.CustomerNumber, C); } } 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); }