Пример #1
0
 private void DisplayData(CDAccount account)
 {
     accountNumberLabel.Text = account.AccountNumber;
     interestRateLabel.Text  = account.InterestRate.ToString("p");
     balanceLabel.Text       = account.Balance.ToString("c");
     maturityDateLabel.Text  = account.MaturityDate.ToShortDateString();
 }
Пример #2
0
        /// The GetCDData method accepts a CDAccount object
        /// as an argument. It assigns the data entered by
        /// the user to the object's properties.
        private void GetCDData(CDAccount account)
        {
            //Temporary variables to hold interest rate
            // and balance.
            decimal interestRate;
            decimal balance;

            // Get the account number.
            account.AccountNumber = accountNumberTextBox.Text;

            // Get the maturity date.
            account.MaturityRate = maturityDateTextBox.Text;

            // Get the interest rate.
            if (decimal.TryParse(interestRateTextBox.Text, out interestRate))
            {
                account.InterestRate = interestRate;

                // Get the balance.
                if (decimal.TryParse(balanceTextBox.Text, out balance))
                {
                    account.Balance = balance;
                }
                else
                {
                    //Display error Message
                    MessageBox.Show("Invalid balance");
                }// end of balance
            }
            else
            {
                //Display error message.
                MessageBox.Show("Invalid interest rate");
            }//end of interest rate
        }
Пример #3
0
        private void GetCDData(CDAccount account)
        {
            decimal interestRate;
            decimal balance;

            account.AccountNumber = accountNumberTextBox.Text;
            account.MaturityDate  = maturityDateTextBox.Text;

            if (decimal.TryParse(interestRateTextBox.Text, out interestRate))
            {
                account.InterestRate = interestRate;

                if (decimal.TryParse(balanceTextBox.Text, out balance))
                {
                    account.Balance = balance;
                }
                else
                {
                    MessageBox.Show("Invalid balance");
                }
            }
            else
            {
                MessageBox.Show("Invalid interest rate");
            }
        }
Пример #4
0
        //getCDData method accepts CDAccount object as an argument. Assjigns data entered by the user to the object's properties
        private void GetCDData(CDAccount account)
        {
            //Temporary variables to hold interest rate and balance
            decimal interestRate;
            decimal balance;

            //Get account number
            account.AccountNumber = accountNumberTextBox.Text;

            //Get maturity date
            account.MaturityDate = maturityDateTextBox.Text;

            //Get interest rate
            if (decimal.TryParse(interestRateTextBox.Text, out interestRate))
            {
                account.InterestRate = interestRate;

                //get the balance
                if (decimal.TryParse(balanceTextBox.Text, out balance))
                {
                    account.Balance = balance;
                }
                else
                {
                    //display an error message
                    MessageBox.Show("Invalid balance");
                }
            }
            else
            {
                //display an error message
                MessageBox.Show("Invalid interest rate");
            }
        }
Пример #5
0
        private void GetCDData(CDAccount account)
        {
            decimal interestRate;
            decimal balance;

            account.AccountNumber = accountNumberTextBox.Text;

            account.MaturityDate = maturityDateTextBox.Text;

            if (decimal.TryParse(interestRateTextBox.Text, out interestRate))
            {
                account.InterestRate = interestRate;

                if (decimal.TryParse(balanceTextBox.Text, out balance))
                {
                    account.Balance = balance;
                }
                else
                {
                    MessageBox.Show("Niepoprawne saldo.");
                }
            }
            else
            {
                MessageBox.Show("Niepporpawna wysokość stopy procentowej.");
            }
        }
Пример #6
0
        //the GetCDDAta method accepts a CDAccount object
        // as an argument. It assigns the data entered by
        // the user to the object's props

        private void GetCDData(CDAccount account)
        {
            //temp values to hold the interest rate and balance
            decimal interestRate;
            decimal balance;

            //get the accoutn number.
            account.AccountNumber = accountNumberTextBox.Text;

            //get the maturity date
            account.MaturityDate = maturityDateTextBox.Text;

            //get the interest rate
            if (decimal.TryParse(interestRateTextBox.Text, out interestRate))
            {
                account.InterestRate = interestRate;

                //get the balance.
                if (decimal.TryParse(balanceTextBox.Text, out balance))
                {
                    account.Balance = balance;
                }
                else
                {
                    //display the error message
                    MessageBox.Show("Invalid balance");
                }
            }
            else
            {
                //display the erro message
                MessageBox.Show("invalid interest rate");
            }
        }
Пример #7
0
        private void createObjectButton_Click(object sender, EventArgs e)
        {
            CDAccount userAcct = new CDAccount();

            if (GetData(userAcct))
            {
                DisplayData(userAcct);
            }
        }
Пример #8
0
        private void createObjectButton_Click(object sender, EventArgs e)
        {
            CDAccount myAccount = new CDAccount();

            GetData(myAccount);

            accountNumberLabel.Text = myAccount.AccountNumber;
            interestRateLabel.Text  = myAccount.InterestRate.ToString("n2");
            balanceLabel.Text       = myAccount.Balance.ToString("c");
            maturityDateLabel.Text  = myAccount.MaturityDate.ToString();
        }
Пример #9
0
        private void createObjectButton_Click(object sender, EventArgs e)
        {
            // Create a CDAccount object.
            CDAccount myAccount = new CDAccount();

            // Get the CD account data.
            GetCDData(myAccount);
            // Display the CD account data.
            accountNumberLabel.Text = myAccount.AccountNumber;
            interestRateLabel.Text  = myAccount.InterestRate.ToString("n2");
            balanceLabel.Text       = myAccount.Balance.ToString("c");
            maturityDateLabel.Text  = myAccount.MaturityDate;
        }
Пример #10
0
        private void createObjectButton_Click(object sender, EventArgs e)
        {
            // create a cdaccoutn object
            CDAccount myAccount = new CDAccount();

            //get the cdaccount data
            GetCDData(myAccount);

            //display the data
            accountNumberLabel.Text = myAccount.AccountNumber;
            interestRateLabel.Text  = myAccount.InterestRate.ToString("n2");
            balanceLabel.Text       = myAccount.Balance.ToString("c");
            maturityDateLabel.Text  = myAccount.MaturityDate;
        }
Пример #11
0
        private bool GetData(CDAccount account)
        {
            bool valid = false;

            decimal interestRate;
            decimal balance;

            if (accountNumberTextBox.Text != "" && accountNumberTextBox.Text != null)
            {
                account.AccountNumber = accountNumberTextBox.Text;

                if (decimal.TryParse(interestRateTextBox.Text, out interestRate) && interestRate > 0m)
                {
                    account.InterestRate = interestRate;

                    if (decimal.TryParse(balanceTextBox.Text, out balance) && balance >= 0m)
                    {
                        account.Balance = balance;

                        if (maturityDateTextBox.Text != "" && maturityDateTextBox.Text != null && GetDate(maturityDateTextBox.Text))
                        {
                            DateTime dateTime = new DateTime(year, month, day);
                            account.MaturityDate = dateTime.Date;
                            valid = true;
                        }
                        else
                        {
                            MessageBox.Show("Maturity date is invalid.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Balance is invalid.");
                    }
                }
                else
                {
                    MessageBox.Show("Interest rate is invalid.");
                }
            }
            else
            {
                MessageBox.Show("Account number is invalid.");
            }

            return(valid);
        }