Exemplo n.º 1
0
        private void btnMultiply_Click(object sender, EventArgs e)
        {
            PhepTinh cal = new PhepTinh();

            try
            {
                cal.NumberA = Convert.ToDouble(txtNumberA.Text);
                cal.NumberB = Convert.ToDouble(txtNumberB.Text);
            }
            catch (Exception)
            {
                if (txtNumberA.Text == "")
                {
                    MessageBox.Show("Input A to calculate.");
                    txtNumberA.Focus();
                }
                else if (txtNumberB.Text == "")
                {
                    MessageBox.Show("Input B to calculate.");
                    txtNumberB.Focus();
                }
            }

            double result = cal.PhepNhan();

            lblOperator.Text = "*";

            txtResultNumA.Text = txtNumberA.Text;
            txtResultNumB.Text = txtNumberB.Text;
            txtResult.Text     = result.ToString();
            cal = null;
        }
Exemplo n.º 2
0
        private void btnMinus_Click(object sender, EventArgs e)
        {
            PhepTinh cal = new PhepTinh();

            try
            {
                cal.NumberA = Convert.ToDouble(txtNumberA.Text);
                cal.NumberB = Convert.ToDouble(txtNumberB.Text);
            }
            catch (Exception)
            {

                if (txtNumberA.Text == "")
                {
                    MessageBox.Show("Input A to calculate.");
                    txtNumberA.Focus();
                }
                else if (txtNumberB.Text == "")
                {
                    MessageBox.Show("Input B to calculate.");
                    txtNumberB.Focus();
                }
            }

            double result = cal.PhepTru();

            lblOperator.Text = "-";

            txtResultNumA.Text = txtNumberA.Text;
            txtResultNumB.Text = txtNumberB.Text;
            txtResult.Text = result.ToString();
            cal = null;
        }