示例#1
0
 /// <summary>
 /// An event to clear the display window and the textboxes, also sets the focus in the name textbox.
 /// </summary>
 /// <param name="sender">MnuClear_Click</param>
 /// <param name="e">Not Used</param>
 private void MnuClear_Click(object sender, EventArgs e)
 {
     RTxtDisplay.Clear();
     TxtName.Clear();
     TxtScore.Clear();
     TxtName.Focus();
 }//End MnuClear()
示例#2
0
 }//End BtnAdd()
 /// <summary>
 /// An event to advance to the next textbox
 /// </summary>
 /// <param name="sender">TxtName_KeyPress</param>
 /// <param name="e">Not Used</param>
 private void TxtName_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Enter)
     {
         TxtScore.Focus();
         TxtScore.SelectAll();
     }
 }//End TxtName()
示例#3
0
 // Method that clear all
 private void BtnClearScore_Click(object sender, EventArgs e)
 {
     scoreCount         = 0;
     scoreArr           = new decimal[20];
     TxtScore.Text      = "";
     TxtSoreTotal.Text  = "";
     TxtScoreCount.Text = "";
     TxtAverage.Text    = "";
     TxtScore.Focus();
 }
示例#4
0
        private void BtnClearScore_Click(object sender, EventArgs e)
        {
            total = 0;

            TxtScore.Text = "";

            TxtSoreTotal.Text = "";

            TxtScoreCount.Text = "";

            TxtAverage.Text = "";

            scoreList = new List <decimal>();
            TxtScore.Focus();
        }
示例#5
0
        private void BtnDisplayScore_Click(object sender, EventArgs e)
        {
            // sort the list
            scoreList.Sort();

            string scoresString = "";

            foreach (int i in scoreList)
            {
                if (i != 0)

                {
                    scoresString += i.ToString() + "\n";
                }
            }

            MessageBox.Show(scoresString, "Sorted Scores");

            TxtScore.Focus();
        }
示例#6
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                decimal score = Convert.ToDecimal(TxtScore.Text);
                //put score into the array
                scoreArr[scoreCount] = score;
                scoreCount++;

                // Calculate the total
                total += score;

                // emptied the score textbox
                TxtScore.Text = "";

                // Calculate the average score
                decimal average = (total / scoreCount);
                TxtAverage.Text = average.ToString();
            }
            catch (FormatException)
            {
                MessageBox.Show("invalid input, please enter a number");
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show("You cannot enter anymore score");
            }
            finally
            {
                // get score total
                TxtSoreTotal.Text = total.ToString();

                //get number counted so far
                TxtScoreCount.Text = scoreCount.ToString();

                // set the focuson the score textbox
                TxtScore.Focus();
            }
        }
示例#7
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            try

            {
                if (IsValidData())

                {
                    // get the number
                    decimal score = Convert.ToDecimal(TxtScore.Text);

                    // Add the number to the list
                    scoreList.Add(score);

                    //Calculate the total
                    total += score;

                    //Calculate the average
                    decimal average = total / scoreList.Count;

                    // Emptied the score text bosx
                    TxtScore.Text = "";

                    // Get all the string vakues
                    TxtSoreTotal.Text  = total.ToString();
                    TxtScoreCount.Text = scoreList.Count.ToString();
                    TxtAverage.Text    = average.ToString();

                    // Set the focus on score text box
                    TxtScore.Focus();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.GetType().ToString() + "\n" + ex.StackTrace, "Exception");
            }
        }