//Search by Transaction ID. private void TransactionIDSearchButton_Click(object sender, EventArgs e) { bool Status = false; StreamReader InvestMeFile; InvestMeFile = File.OpenText("InvestMeTransactionDetails.txt"); while (!InvestMeFile.EndOfStream) { string x1 = InvestMeFile.ReadLine(); string TempTrxnNo = InvestMeFile.ReadLine(); string TempEmailId = InvestMeFile.ReadLine(); string TempClientName = InvestMeFile.ReadLine(); string TempTelNo = InvestMeFile.ReadLine(); string TempPrincipalAmount = InvestMeFile.ReadLine(); string TempTerm = InvestMeFile.ReadLine(); string TempInterestRate = InvestMeFile.ReadLine(); string TempFinalAmount = InvestMeFile.ReadLine(); //Checks if Transaction No is there or not. if (TempTrxnNo == TransactionNoSearchTextBox.Text) { //bool is set to true if transaction id if found and calls meathod to display the details. Status = true; SearchDisplayGroupBox.Visible = true; //Calls the Meathod to display NoSearchDisplay(TempTrxnNo, TempEmailId, TempClientName, TempTelNo, decimal.Parse(TempPrincipalAmount), decimal.Parse(TempInterestRate), decimal.Parse(TempFinalAmount), TempTerm); } } if (Status == false) { MessageBox.Show("Transaction ID not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } InvestMeFile.Close(); }
//Search by MailId. private void MailIdSearchButton_Click(object sender, EventArgs e) { MailIdDisplayListView.Items.Clear(); bool Status = false; StreamReader InvestMeFile; InvestMeFile = File.OpenText("InvestMeTransactionDetails.txt"); while (!InvestMeFile.EndOfStream) { string temp = InvestMeFile.ReadLine(); string TempTrxnNo = InvestMeFile.ReadLine(); string TempEmailId = InvestMeFile.ReadLine(); string TempClientName = InvestMeFile.ReadLine(); string TempTelNo = InvestMeFile.ReadLine(); string TempPrincipalAmount = InvestMeFile.ReadLine(); string TempTerm = InvestMeFile.ReadLine(); string TempInterestRate = InvestMeFile.ReadLine(); string TempFinalAmount = InvestMeFile.ReadLine(); //If mail ID matches. if (TempEmailId == MailIdSearchTextBox.Text) { Status = true; ClearButton.Enabled = true; MailIdDisplayListView.Visible = true; //Calls a meathod to display in a listview. IdSearchDisplay(TempTrxnNo, TempClientName, TempTelNo, decimal.Parse(TempPrincipalAmount), decimal.Parse(TempInterestRate), decimal.Parse(TempFinalAmount), TempTerm); } } if (Status == false) { MessageBox.Show("Email ID not found", "Invalid Entry", MessageBoxButtons.OK, MessageBoxIcon.Error); } InvestMeFile.Close(); }
//When users confirms his final details and books his investment. private void FinalConfirmButton_Click(object sender, EventArgs e) { InvestedAmount = decimal.Parse(InvestAmountTextBox.Text); //If all the fields are are there and valid then it will write it in the file. if (ClientName != "" && ClientTelNo != "" && EmailStatus == true) { //Creates object for writing in file StreamWriter InvestMeFile; //Opens the file in append mode and writes. InvestMeFile = File.AppendText("InvestMeTransactionDetails.txt"); InvestMeFile.WriteLine("xxxxxxxx"); InvestMeFile.WriteLine(TransactionNo); InvestMeFile.WriteLine(ClientMailId); InvestMeFile.WriteLine(ClientName); InvestMeFile.WriteLine(ClientTelNo); InvestMeFile.WriteLine(InvestedAmount); InvestMeFile.WriteLine(Term); InvestMeFile.WriteLine(InterestRate); InvestMeFile.WriteLine(FinalAmount); InvestMeFile.Close(); } //Sets the value back to 0 if user wishes to view the summary in process after confirmation. SummaryListView.Items.Clear(); TotalTerm = 0; TotalAmount = 0; FinalInterest = 0; MessageBox.Show("Transaction No:" + TransactionNo + "\n\nBOOKING IS CONFIRMED", "Thankyou For Investing with us.", MessageBoxButtons.OK, MessageBoxIcon.Information); //Visibility is set if user wants to proceed with another transaction/Summary/Search. TimeFrameListBox.Visible = false; InvestAmountTextBox.Enabled = true; DetailsDisplayGroupBox.Visible = false; ClientDetailGroupBox.Visible = false; FirstProceedButton.Visible = false; ConfirmButton.Visible = false; FinalConfirmButton.Visible = false; InvestAmountGroupBox.Enabled = true; InvestAmountTextBox.Clear(); InvestAmountTextBox.Focus(); DisplayButton.Enabled = true; SummaryButton.Enabled = true; }
//Summary box is displayed with the summary of all the transactions. private void SummaryButton_Click(object sender, EventArgs e) { SummaryButton.Enabled = false; ClearButton.Enabled = true; // decimal TempInterest = 0m; SummaryGroupBox.Visible = true; SummaryListView.Items.Clear(); //Opens the file in read mode. StreamReader InvestMeFile; InvestMeFile = File.OpenText("InvestMeTransactionDetails.txt"); while (!InvestMeFile.EndOfStream) { //Stores all the data in temp variables if it has to be used to display. string x1 = InvestMeFile.ReadLine(); string TempTrxnNo = InvestMeFile.ReadLine(); string TempEmailId = InvestMeFile.ReadLine(); string TempClientName = InvestMeFile.ReadLine(); string TempTelNo = InvestMeFile.ReadLine(); string TempPrincipalAmount = InvestMeFile.ReadLine(); string TempTerm = InvestMeFile.ReadLine(); string TempInterestRate = InvestMeFile.ReadLine(); string TempFinalAmount = InvestMeFile.ReadLine(); //Checks and increments for total number of transactions. if (TempTrxnNo != "") { TotalTransaction++; } //Increments the global variable value for summary display. TotalAmount += decimal.Parse(TempPrincipalAmount); TotalTerm += int.Parse(TempTerm); FinalValue += decimal.Parse(TempFinalAmount); //Calls meathod to add items and display the summary listview. SummaryDisplay(TempTrxnNo); } //Closes File. InvestMeFile.Close(); FinalInterest = FinalValue - TotalAmount; InvestedAmountSummaryDisplayLabel.Text = TotalAmount.ToString("C4"); TotalTermsSummaryDisplayLabel.Text = TotalTerm.ToString(); InterestSummaryDisplayLabel.Text = FinalInterest.ToString("C4"); TotalTransactionsDisplaySummaryLabel.Text = TotalTransaction.ToString(); }
//After a term is selected from list box. private void FirstProceedButton_Click(object sender, EventArgs e) { TimeFrameListBox.Visible = false; FirstProceedButton.Enabled = false; ClientDetailGroupBox.Visible = true; ConfirmButton.Visible = true; ConfirmButton.Enabled = true; int Number = 0; string temp; //Random 6 character Transaction ID is generated. temp = RandomGenerate(Number).ToString(); ClientDetailGroupBox.Visible = true; Email = ClientMailIdTextBox.Text; if (InvestedAmount <= 250000) { //Stores the value according to the above if condition. switch (TimeFrameListBox.SelectedIndex) { case 0: Term = TIMEFRAME1; InterestRate = LINTERESTRATE1; FinalAmount = EndAmount1; break; case 1: Term = TIMEFRAME2; InterestRate = LINTERESTRATE2; FinalAmount = EndAmount2; break; case 2: Term = TIMEFRAME3; InterestRate = LINTERESTRATE3; FinalAmount = EndAmount3; break; case 3: Term = TIMEFRAME4; InterestRate = LINTERESTRATE4; FinalAmount = EndAmount4; break; } } else { switch (TimeFrameListBox.SelectedIndex) { case 0: Term = TIMEFRAME1; InterestRate = GINTERESTRATE1; FinalAmount = EndAmount1; break; case 1: Term = TIMEFRAME2; InterestRate = GINTERESTRATE2; FinalAmount = EndAmount2; break; case 2: Term = TIMEFRAME3; InterestRate = GINTERESTRATE3; FinalAmount = EndAmount3; break; case 3: Term = TIMEFRAME4; InterestRate = GINTERESTRATE4; FinalAmount = EndAmount4; break; } } //Checks if the file exists already. if (File.Exists("InvestMeTransactionDetails.txt")) { //Reads the file and Checks if the transaction ID is unique or not. StreamReader InvestMeFile; InvestMeFile = File.OpenText("InvestMeTransactionDetails.txt"); while (!InvestMeFile.EndOfStream) { InvestMeFile.ReadLine(); string x = InvestMeFile.ReadLine(); InvestMeFile.ReadLine(); InvestMeFile.ReadLine(); InvestMeFile.ReadLine(); string TempInterestRate = InvestMeFile.ReadLine(); string TempFinalAmount = InvestMeFile.ReadLine(); //If transaction ID exists meathod is called again to generate another ID; if (x == temp) { temp = RandomGenerate(Number).ToString(); } } TransactionNoDisplayLabel.Text = temp; InvestMeFile.Close(); } //If file doesnt exists it will just create a file for future use. else { int TransactionNo = RandomGenerate(Number); ClientDetailGroupBox.Visible = true; TransactionNoDisplayLabel.Text = TransactionNo.ToString(); StreamWriter InvestMeFile; InvestMeFile = File.CreateText("InvestMeTransactionDetails.txt"); } ClientNameTextBox.Clear(); ClientMailIdTextBox.Clear(); ClientTelNoTextBox.Clear(); ClientNameTextBox.Focus(); }