/*Its the event handler triggered on pressing Change button, it gives * the user a chance to modify client's investment amount in the midway*/ private void ChangeButton_Click(object sender, EventArgs e) { HomeForm frm = new HomeForm(Utility.userAmount); this.Hide(); frm.ShowDialog(); this.Close(); }
/*Its the event handler on Click of Exit Button, it takes back to the home page*/ private void exitButton_Click(object sender, EventArgs e) { HomeForm form = new HomeForm(); this.Hide(); form.ShowDialog(); this.Close(); }
/*Its the event handler triggered on form load of the display details * form which shows up once client's investment amount is feeded into the system */ private void DisplayDetails_Load(object sender, EventArgs e) { this.investmentsListBox.Items.AddRange(new object[] { "1 month\t\t " + Utility.addCurrencySymbol(Utility.rateEvaluation(1)) + "\t " + Utility.rate, "3 month\t\t " + Utility.addCurrencySymbol(Utility.rateEvaluation(3)) + "\t " + Utility.rate, "6 month\t\t " + Utility.addCurrencySymbol(Utility.rateEvaluation(6)) + "\t " + Utility.rate, "12 month\t\t " + Utility.addCurrencySymbol(Utility.rateEvaluation(12)) + "\t " + Utility.rate }); baseValueLabel.Text = Utility.userAmount.ToString(); detailsGroupBox.Hide(); ProceedButton.Enabled = false; resetButton.Enabled = false; this.FormClosed += (s, args) => { HomeForm form = new HomeForm(); this.Hide(); this.Close(); form.ShowDialog(); }; }
/*Its the event handler on Form load of Summary Page, * where user can view transaction numbers of all the investment done and the total details*/ private void Summary_page_Load(object sender, EventArgs e) { if (!File.Exists(Utility.outputFileName)) { MessageBox.Show("Nothing to Display, No any investment Done", "NO Records Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); HomeForm form = new HomeForm(); this.Hide(); form.ShowDialog(); this.Close(); return; } this.FormClosed += (s, args) => { HomeForm form = new HomeForm(); this.Hide(); form.ShowDialog(); this.Close(); }; Search(); }
/*Its the event handler triggered on pressing confirm after * all the details of the client has been feeded into the application, * it has all the validation to restrict the user to make faulty input*/ private void confirmButton_Click(object sender, EventArgs e) { String name; int tel = 0; String email = ""; int transaction; try { name = nameTextBox.Text; if (name.Equals("")) { MessageBox.Show("Please fill the client's name to proceed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); nameTextBox.Focus(); return; } try { if (telephoneNumTextBox.Text.Equals("")) { MessageBox.Show("Please fill the client's phone number to proceed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); telephoneNumTextBox.Focus(); return; } tel = int.Parse(telephoneNumTextBox.Text); } catch (FormatException ex) { MessageBox.Show("Please insert a valid Telephone Number", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); telephoneNumTextBox.Focus(); telephoneNumTextBox.SelectAll(); return; } try { if (emailTextBox.Text.Equals("")) { MessageBox.Show("Please fill the client's email to proceed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); emailTextBox.Focus(); return; } email = (new System.Net.Mail.MailAddress(emailTextBox.Text)).ToString(); } catch (FormatException ex) { MessageBox.Show("Please insert a valid email address", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); emailTextBox.Focus(); emailTextBox.SelectAll(); return; } try { if (transactionTextBox.Text.Equals("")) { MessageBox.Show("Please fill a transaction number to proceed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); transactionTextBox.Focus(); return; } if (!(transactionTextBox.Text.Length == 6)) { MessageBox.Show("Please fill a transaction number of six digits to proceed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); transactionTextBox.Focus(); return; } transaction = int.Parse(transactionTextBox.Text); if (!Utility.uniqueTransactionNum(transaction)) { MessageBox.Show("Please fill a UNIQUE transaction number to proceed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); transactionTextBox.Focus(); transactionTextBox.SelectAll(); return; } } catch (FormatException ex) { MessageBox.Show("Transaction number suould be number", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); transactionTextBox.Focus(); transactionTextBox.SelectAll(); return; } if (MessageBox.Show("You are ready to go with this investments" + "\n" + "Name: " + name + "\n" + "Investment: " + Utility.addCurrencySymbol(Utility.userAmount) + "\n" + "Balance: " + Utility.addCurrencySymbol(Math.Round(balance, 2)) + "\n" + "Term: " + term + "\n" + "Interest: " + Utility.addCurrencySymbol(Math.Round(interest, 2)) + "\n" + "Telephone Number :" + tel + "\n" + "Email:" + email + "" + "\n" + "Transaction :" + transaction, "BOOK NOW", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (Utility.writeTofile(new ClientDetails(name, tel, email, transaction, term, Utility.userAmount, Math.Round(balance, 2)))) { MessageBox.Show("Investment has been done", "Congratulations!!", MessageBoxButtons.OK, MessageBoxIcon.Information); HomeForm frm = new HomeForm(); this.Hide(); frm.ShowDialog(); this.Close(); } else { Console.WriteLine("Something went wrong while writing to the file. Check console"); } investmentsListBox.SelectedIndex = -1; } detailsGroupBox.Hide(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }