Exemplo n.º 1
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()
Exemplo n.º 2
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();
 }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
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");
            }
        }