private void CreateAccount_Click(object sender, EventArgs e) { if (AccountBalance.Text == "" || Interest.Text == "") { info.Text = "Please fill out both Balance and Interest fields..."; AccountBalance.Focus( ); return; } char[] ch = { '-' }; BankAccount bank = new BankAccount( ); string custno = comboBox1.Text; string acctype = AccountType.Text; string[] temp = acctype.Split(ch); Int16 accounttype = Convert.ToInt16(temp[0]); string amnt = AccountBalance.Text; decimal amount = Convert.ToDecimal(amnt); decimal interest = Convert.ToDecimal(Interest.Text); // This call handles Linked List, ArrayList etc BankAccount.CreateNewBankAccount(bank, custno, accounttype, amount, interest, "Solo Bank Account created for Customer " + bank.BankAccountNumber); AccountNumber.Text = bank.BankAccountNumber.ToString( ); info.Text = "New Bank Account [" + bank.BankAccountNumber.ToString( ) + "] created for Customer " + custno; Customer.UpdateCustWithNewBankAccount(Convert.ToInt32(custno), bank.BankAccountNumber, accounttype); }
//**************************************************************************************************************** private void SaveCustButton_Click(object sender, EventArgs e) //**************************************************************************************************************** { // update the details // go get a customer object Customer C; if (AccountBalance.Text.Length == 0 || Interest.Text.Length == 0) { MessageBox.Show("Please complete the Account Balance & Interest Rate...", "Customer Update System"); return; } C = Customer.GetCustomerAccount(accountno.Text); if (C != null) { // go ahead and update the Customers details C.CustomerNumber = Convert.ToInt32(accountno.Text); C.FirstName = fname.Text; C.LastName = lname.Text; C.Address1 = addr1.Text; C.Address2 = addr2.Text; C.Town = town.Text; C.County = county.Text; C.PostCode = pcode.Text; C.MobileNumber = mob.Text; // Create the new bank account for this customer // and update the relevant fields BankAccount NewBAccount = BankAccount.CreateNewBankAccount(Bank, C.CustomerNumber.ToString( ), Convert.ToInt16(AccountType.SelectedIndex + 1), Convert.ToDecimal(AccountBalance.Text), Convert.ToDecimal(Interest.Text), "Secondary Bank account for Customer A/c " + Bank.CustAccountNumber.ToString( ) + " added :- "); // Sort out the array of bank account details for (int i = 0; i < 4; i++) { if (C.accounttypes[i] == 0) { if (AccountType.SelectedIndex != -1) { C.accounttypes[i] = Convert.ToInt16(AccountType.SelectedIndex + 1); // C.accountnums[i] = Convert.ToInt32(accountno.Text); // Now, finally, we store the correct data in th aCustomer record // The accountnums field SHOULD hold the BankAccount #, NOT the Customer # C.accountnums[i] = NewBAccount.BankAccountNumber; break; } } } // Update Customer Object on disk Customer.WriteCustObjectToDiskAndText(C, C.FullFileName); // update Customer List // foreach ( var L in Customer . CustomersLinkedList ) foreach (Customer L in DataArray.CustNo) { if (L.CustomerNumber == Convert.ToInt32(accountno.Text)) { // got it L.FirstName = C.FirstName; L.LastName = C.LastName; L.Address1 = C.Address1; L.Address2 = C.Address2; L.Town = C.Town; L.County = C.County; L.PostCode = C.PostCode; L.PhoneNumber = C.PhoneNumber; L.MobileNumber = C.MobileNumber; break; } } MessageBox.Show("The New Bank account has been created...", "Bank Account Maintenance System"); } Close( ); }
// 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( ); }