C# Reading from .txt file (contains customer records, accounts etc.); For a Bank CMS - so stressed! C#
<p>Hi fellow programmers (although still a newbie here, help me to help others in my position in future?).  The following is essentially a small project/task to help further our programming skills, I have done as much as I can so far and require assistance to take it all the way...</p>

<p>Basically, I have a given text file with information already filled in.  This will be used to create my own CMS (Content Management System) for a fictional Bank.</p>

<p>The (example) contents of the text file are as follows (<strong>NOTE: Ignore the brackets, I've put them here in the post to outline what each field means</strong>):</p>

<pre><code>927459827         (Customer Number)
Mr                (Customer Title)
John              (Customer FirstName)
K                 (Customer Initials, -this is optional-)
Smith             (Customer Surname)
14/09/1990        (Customer Date of Birth)
51j               (Customer House Number/Name)
Railstone Road    (Customer Address)
Karredd Square    (Customer Address Area -optional-)
Kent              (Customer City/Town)
Cantubry          (Customer County)
KN127AA           (Customer Postcode)
gabby699          (Customer Password -must be minimum 8 characters-)
1                 (Customer's number of Accounts, e.g. in this case, 1)
91-41-23          (Account Sort-Code)
3.34785E+22       (Account Number)
mum's surprise    (Account Nickname -optional-)
14/02/2011        (Account Date Created)
1523.25           (Account Current Balance)
500               (Account Overdraft Limit)
10                (Account Number of Transactions)
24/02/2011        (Transaction Date)
D/D               (Transaction Type -possibly drop-down box of values?-)
Freshling Nursery (Transaction Description -e.g. what it was for)
650               (Transaction Amount)
2173.25           (Account Balance After Transaction)
</code></pre>

<p>Note: In the example above, there is one customer who has one account which has one transaction.  BUT - A customer can have many accounts and many accounts can have many transactions.... so consider this:</p>

<pre><code>Customer1
 Account1
  Transaction1
  Transaction2
 Account2
  Transaction1
Customer2
 Account1
  Transaction1
...
and so on.
</code></pre>

<p><strong>IMPORTANT NOTE:</strong> As shown above, Customers will ALWAYS have exactly <strong>14</strong> lines/fields.  Accounts will ALWAYS have <strong>7</strong> lines/fields.  Transactions will ALWAYS have <strong>5</strong> lines/fields.  So perhaps this is a good place to start with distinguishing between records? Only problem is that I have no idea how to relate one to another, or select specific lines and then display the whole record based on this <strong>(e.g. enter surname in a textbox, hit submit, a list box with matching surnames, highlight one and hit Go, another form pops up with that customer's details)</strong>.</p>

<p><strong>What I have so far:</strong> (NOTE: ArrayLists must be the only method of storing data - Ugh!, No other method of storing data is accepted! Classes should also be used)</p>

<ul>
<li>A Main Interface Form.  This form
contains a Customer Search textbox
and a List Box below.  When the user
enters a Surname, the program should
search through the text-file (or from an ArrayList would be easier?)</li>
<li>A Customer Form (this contains Labels
and Fields corresponding to the 14
lines in the text file for Customers,
when you select a customer from the
Main Interface form, it should
display that Customer's info in the
Customer Form) -- This Form also
contains fields and blank fields
corresponding to Accounts, in case
the user wants to add a new account
for this Customer.  This Form also
contains a list of accounts for the
current Customer in a small listbox,
you highlight a paticular entry and
click 'Go to account' to view the
Accounts Form for this Customer for
that particular account.</li>
<li>An Accounts Form - This contains
Labels and Fields corresponding to 7
lines in the text file for Accounts
which should populate with details
when opened from Customer Form - As
with the Customer Form, it contains
blank fields to add a new
Transaction, it also contains a
listbox with list of Transactions for
this Account, you can highlight one
then click on a button to take you to
that transaction.</li>
<li>A Transactions Form - same as above,
fields and labels corresponding to
the Transactions lines in the text
file.  Populates on opening from
Accounts Form, can edit fields and
save details back into the text file.</li>
</ul>

<p>From each form, should be able to update all fields and replace the current ones in the text file with the new ones? OR dump to an arraylist and replace the whole text file? I'm not sure, there are probably many ways...</p>

<p>Please can anyone help me in how I can bring all of this together and make it work? If only I could use SQL, I've worked a lot with MySQL in the past, but text-files have got me completely stumped.  I know how to read the whole thing and store it using Stream-Reader, but no website/tutorial/tutor/teacher is making it clear how to manipulate a text file as you can with a database! It's mind boggling... :(</p>

<p>To check for each account and transaction for each customer, I'm guessing Loops are involved? Mainly, interloops/nested loops dependant on the number of lines/fields:</p>

<p>e.g. for loops for customer (dump into arraylist), an interloop and interloop for accounts and transactions (dump into arraylist, dump into arraylist), close loop, close loop, close loop.</p>

<p>I just don't know.  Need pointing in the right direction.  Many for any help or basic template offered.</p>
