Пример #1
0
        //Sets the form to defaulr state for another input by setting the visible and enable accordingly.
        private void ClearButton_Click(object sender, EventArgs e)
        {
            SearchTrxNoGroupBox.Visible   = false;
            MailIdDisplayListView.Visible = false;
            DisplayButton.Enabled         = true;
            InvestAmountTextBox.Focus();
            TimeFrameListBox.Visible       = false;
            SummaryGroupBox.Visible        = false;
            SummaryButton.Enabled          = true;
            SummaryButton.Visible          = true;
            ClientDetailGroupBox.Visible   = false;;
            DetailsDisplayGroupBox.Visible = false;
            SearchDisplayGroupBox.Visible  = false;
            InvestAmountTextBox.Enabled    = true;
            SearchTrxNoGroupBox.Visible    = false;
            SearchMailIdGroupBox.Visible   = false;

            SearchOptionGroupBox.Visible = true;
            FirstProceedButton.Visible   = false;
            ConfirmButton.Visible        = false;
            FinalConfirmButton.Visible   = false;
            InvestAmountTextBox.Clear();
            InvestAmountTextBox.Focus();
            ClearButton.Enabled             = false;
            TrnxNoSearchRadioButton.Checked = false;
            MailIdSearchRadioButton.Checked = false;
        }
Пример #2
0
 //Handles Exception if values are too big or null.
 private void InvestAmountTextBox_TextChanged(object sender, EventArgs e)
 {
     try
     {   //Checks if the value is too big.
         int.Parse(InvestAmountTextBox.Text);
         //Sub checks for displaying bonus label.
         if (InvestAmountTextBox.Text != "" && int.Parse(InvestAmountTextBox.Text) > 1000001)
         {
             BonusDetailLabel.Visible = true;
             BonusDetailLabel.Text    = "Eligible for 25000 euro bonus if term is greater than 1";
         }
         else if ((InvestAmountTextBox.Text) == "" || (int.Parse(InvestAmountTextBox.Text) < 25000))
         {
             BonusDetailLabel.Visible = false;
         }
     }
     catch
     {
         //Exception is thrown.
         if (string.IsNullOrEmpty(InvestAmountTextBox.Text))
         {
             MessageBox.Show("Input Field", "Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             MessageBox.Show("Enter a Smaller/Numerical value");
             InvestAmountTextBox.SelectAll();
         }
     }
 }
Пример #3
0
        //Displays the available terms and interests rates in a list box according to the user investment value.
        private void DisplayButton_Click(object sender, EventArgs e)
        {
            //By-deafault checked=false may not work thus syntaxing it here.
            TrnxNoSearchRadioButton.Checked = false;
            decimal PrincipalAmount;

            try
            {
                //If value is parsed visibility is handled.
                PrincipalAmount = decimal.Parse(InvestAmountTextBox.Text);
                TimeFrameListBox.Items.Clear();
                ClearButton.Enabled         = true;
                SearchTrxNoGroupBox.Visible = false;
                DisplayButton.Enabled       = false;
                InvestAmountTextBox.Enabled = false;
                SummaryButton.Enabled       = false;
                TimeFrameListBox.Visible    = true;
                FirstProceedButton.Visible  = true;
                FirstProceedButton.Enabled  = false;
                SummaryGroupBox.Visible     = false;
                //Checks the condition and calls the meathod to calculate compound interest(C.I).
                if (PrincipalAmount <= 25000)
                {
                    EndAmount1 = CalculateInterest(PrincipalAmount, LINTERESTRATE1, TIMEFRAME1);
                    EndAmount2 = CalculateInterest(PrincipalAmount, LINTERESTRATE2, TIMEFRAME2);
                    EndAmount3 = CalculateInterest(PrincipalAmount, LINTERESTRATE3, TIMEFRAME3);
                    EndAmount4 = CalculateInterest(PrincipalAmount, LINTERESTRATE4, TIMEFRAME4);
                    //Stores if the listbox along with formatting.
                    TimeFrameListBox.Items.Add(TIMEFRAME1 + "\t" + LINTERESTRATE1.ToString("C3") + "%" + "\t" + EndAmount1.ToString("C4"));
                    TimeFrameListBox.Items.Add(TIMEFRAME2 + "\t" + LINTERESTRATE2.ToString("C3") + "%" + "\t" + EndAmount2.ToString("C4"));
                    TimeFrameListBox.Items.Add(TIMEFRAME3 + "\t" + LINTERESTRATE3.ToString("C3") + "%" + "\t" + EndAmount3.ToString("C4"));
                    TimeFrameListBox.Items.Add(TIMEFRAME4 + "\t" + LINTERESTRATE4.ToString("C3") + "%" + "\t" + EndAmount4.ToString("C4"));
                }
                //Checks the condition and calls the meathod to calculate compound interest(C.I).
                else if (PrincipalAmount > 25000)
                {
                    EndAmount1 = CalculateInterest(PrincipalAmount, GINTERESTRATE1, TIMEFRAME1);
                    EndAmount2 = CalculateInterest(PrincipalAmount, GINTERESTRATE2, TIMEFRAME2);
                    EndAmount3 = CalculateInterest(PrincipalAmount, GINTERESTRATE3, TIMEFRAME3);
                    EndAmount4 = CalculateInterest(PrincipalAmount, GINTERESTRATE4, TIMEFRAME4);
                    TimeFrameListBox.Items.Clear();
                    //Stores if the listbox along with formatting.
                    TimeFrameListBox.Items.Add(TIMEFRAME1 + "\t" + GINTERESTRATE1.ToString("C3") + "%" + "\t" + EndAmount1.ToString("C4"));
                    TimeFrameListBox.Items.Add(TIMEFRAME2 + "\t" + GINTERESTRATE2.ToString("C3") + "%" + "\t" + EndAmount2.ToString("C4"));
                    TimeFrameListBox.Items.Add(TIMEFRAME3 + "\t" + GINTERESTRATE3.ToString("C3") + "%" + "\t" + EndAmount3.ToString("C4"));
                    TimeFrameListBox.Items.Add(TIMEFRAME4 + "\t" + GINTERESTRATE4.ToString("C3") + "%" + "\t" + EndAmount4.ToString("C4"));
                }
            }
            //Throws exception if value is not numerical.
            catch
            {
                MessageBox.Show("Input Numerical Value ", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                InvestAmountTextBox.SelectAll();
                InvestAmountTextBox.Focus();
            }
        }
Пример #4
0
        //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;
        }
Пример #5
0
        private void DisplayButton_Click(object sender, EventArgs e)
        {
            string Str = InvestAmountTextBox.Text;

            double Num;

            bool isNum = double.TryParse(Str, out Num);

            if (isNum && InvestAmountTextBox.TextLength >= 5)
            {
                Month1RadioButton.Enabled  = true;
                Month3RadioButton.Enabled  = true;
                Month6RadioButton.Enabled  = true;
                Month12RadioButton.Enabled = true;
                ProceedButton.Enabled      = true;
                ClearButton.Enabled        = true;

                if (InvestAmountTextBox.Text != "" && InvestAmountTextBox.TextLength == 5 && InvestAmountTextBox.TextLength < 6)//check there aren't negatives, set max limit(max and min)
                {
                    //principal = decimal.Parse(InvestAmountTextBox.Text);

                    // Amount = (principal * (Math.Pow ((double)(1 + INTEREST_ON_AMOUNT_UPTO_100K_1MONTH, TERM_1)) - 1).ToString;

                    decimal principal = decimal.Parse(InvestAmountTextBox.Text);
                    //CalculateInterest(principal, 6m, 6m);
                    //label6.Text = Amount.ToString("C2");


                    CalculateInterest(principal, INTEREST_ON_AMOUNT_UPTO_100K_1MONTH, TERM_1);
                    Month1InterestWithPrincipal = (decimal)Amount;
                    Month1RadioButton.Text      = "1 month  " + Amount.ToString("C2");

                    CalculateInterest(principal, INTEREST_0N_AMOUNT_UPTO_100K_3MONTH, TERM_3);
                    Month3InterestWithPrincipal = (decimal)Amount;
                    Month3RadioButton.Text      = "3 months  " + Amount.ToString("C2");

                    CalculateInterest(principal, INTEREST_ON_AMOUNT_UPTO_100K_6MONTH, TERM_6);
                    Month6InterestWithPrincipal = (decimal)Amount;
                    Month6RadioButton.Text      = "6 months  " + Amount.ToString("C2");

                    CalculateInterest(principal, INTEREST_ON_AMOUNT_UPTO_100K_12MONTH, TERM_12);
                    Month12InterestWithPrincipal = (decimal)Amount;
                    Month12RadioButton.Text      = "12 months  " + Amount.ToString("C2");
                }
                else if (InvestAmountTextBox.Text != "" && InvestAmountTextBox.TextLength == 6 && InvestAmountTextBox.TextLength < 7)
                {
                    decimal principal = decimal.Parse(InvestAmountTextBox.Text);

                    CalculateInterest(principal, INTEREST_ON_AMOUNT_ABOVE_100K_1MONTH, TERM_1);
                    Month1InterestWithPrincipal = (decimal)Amount;
                    Month1RadioButton.Text      = "1 month  " + Amount.ToString("C2");

                    CalculateInterest(principal, INTEREST_ON_AMOUNT_ABOVE_100K_3MONTH, TERM_3);
                    Month3InterestWithPrincipal = (decimal)Amount;
                    Month3RadioButton.Text      = "3 months  " + Amount.ToString("C2");

                    CalculateInterest(principal, INTEREST_ON_AMOUNT_ABOVE_100K_6MONTH, TERM_6);
                    Month6InterestWithPrincipal = (decimal)Amount;
                    Month6RadioButton.Text      = "6 months  " + Amount.ToString("C2");

                    CalculateInterest(principal, INTEREST_ON_AMOUNT_ABOVE_100K_12MONTH, TERM_12);
                    Month12InterestWithPrincipal = (decimal)Amount;
                    Month12RadioButton.Text      = "12 months  " + Amount.ToString("C2");
                }
                else if (InvestAmountTextBox.Text != "" && InvestAmountTextBox.TextLength == 7 && InvestAmountTextBox.TextLength < 9)
                {
                    decimal principal = decimal.Parse(InvestAmountTextBox.Text);

                    CalculateInterest(principal, INTEREST_ON_AMOUNT_ABOVE_100K_1MONTH, TERM_1);
                    Month1InterestWithPrincipal = (decimal)Amount;
                    Month1RadioButton.Text      = "1 month  " + Amount.ToString("C2");

                    CalculateInterest(principal, INTEREST_ON_AMOUNT_ABOVE_100K_3MONTH, TERM_3);
                    Month3InterestWithPrincipal = (decimal)Amount;
                    Month3RadioButton.Text      = "3 months  " + Amount.ToString("C2");

                    CalculateInterest(principal, INTEREST_ON_AMOUNT_ABOVE_100K_6MONTH, TERM_6);
                    Month6InterestWithPrincipal = (decimal)(Amount + 5000);
                    Month6RadioButton.Text      = "6 months  " + "+ £5000 " + (Amount + 5000).ToString("C2");


                    CalculateInterest(principal, INTEREST_ON_AMOUNT_ABOVE_100K_12MONTH, TERM_12);
                    Month12InterestWithPrincipal = (decimal)(Amount + 5000);
                    Month12RadioButton.Text      = "12 months  " + "+ £5000 " + (Amount + 5000).ToString("C2");
                }
                else
                {
                    MessageBox.Show("Please enter a valid Number Not less than 5 digits", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    InvestAmountTextBox.Focus();
                    InvestAmountTextBox.SelectAll();
                }
            }
            else
            {
                MessageBox.Show("Please enter a valid Number Not Strings or Symbols", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                InvestAmountTextBox.Focus();
                InvestAmountTextBox.SelectAll();
            }
        }