예제 #1
0
        private void button12_Click(object sender, EventArgs e)
        {
            // Обрабатываем клик
            try
            {
                if ((firstDrob.Ch == 0) && (firstDrob.Chisl == 0) && (textBox1.Text != "") &&
                    (textBox2.Text != "") && (textBox3.Text != ""))
                {
                    // Запоминание первой дроби
                    firstDrob.SetDrob(ch: Convert.ToInt32(textBox1.Text.Trim()),
                                      chisl: Convert.ToInt32(textBox2.Text),
                                      znam: Convert.ToInt32(textBox3.Text));

                    // Очистка текстбоксов

                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox3.Text = "";

                    currentoper = button12.Text;

                    Enb();
                    DopF();
                    Tr();
                    button14.Enabled = false;
                    textBox1.Focus();
                }
            }
            catch (Exception InputE)
            {
                MessageBox.Show("Ошибка");
            }
        }
예제 #2
0
        private void button14_Click(object sender, EventArgs e)
        {
            try
            {
                if ((textBox1.Text != "") && (textBox2.Text != "") && (textBox3.Text != ""))
                {
                    secondDrob.SetDrob(ch: Convert.ToInt32(textBox1.Text),
                                       chisl: Convert.ToInt32(textBox2.Text),
                                       znam: Convert.ToInt32(textBox3.Text));

                    // Запоминание операции
                    switch (currentoper)
                    {
                    case "+":
                        result = firstDrob.Plus(secondDrob);
                        break;

                    case "-":
                        result = firstDrob.Minus(secondDrob);
                        break;

                    case "/":
                        result = firstDrob.Division(secondDrob);
                        break;

                    case "*":
                        result = firstDrob.Multiplication(secondDrob);
                        break;

                    default: break;
                    }
                    // Очистка информации об операции
                    currentoper = "";
                    //Вывод результата
                    textBox1.Text = result.Ch.ToString();
                    textBox2.Text = result.Chisl.ToString();
                    textBox3.Text = result.Znam.ToString();
                    //Чистим информацию о дробях
                    firstDrob.CleanDrob();
                    secondDrob.CleanDrob();
                    result.CleanDrob();



                    textBox1.Focus();
                    button14.Enabled = false;
                }
            }
            catch (Exception b)
            {
                MessageBox.Show("Ошибка");
            }
        }