コード例 #1
0
ファイル: Form3.cs プロジェクト: vokhanhan25/Trigonequation
        private void button1_Click(object sender, EventArgs e)
        {
            ngh1         = "";
            ngh2         = "";
            ngh3         = "";
            label8.Text  = "";
            label9.Text  = "";
            label10.Text = "";
            label7.Text  = "";
            soa          = ""; sob = ""; soc = ""; sod = "";
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập đủ bốn số a,b,c,d!");
            }
            else
            {
                Docdulieu doc = new Docdulieu();
                a = doc.chuyen(textBox1.Text);
                b = doc.chuyen(textBox2.Text);
                c = doc.chuyen(textBox3.Text);
                d = doc.chuyen(textBox4.Text);
                if (a == d)
                {
                    ngh1 = "x = π/2 + kπ";
                    kt   = true;
                }

                giai.radioButton3.Checked = true;
                giai.textBox2.Text        = (a - d).ToString();
                giai.textBox3.Text        = b.ToString();
                giai.textBox4.Text        = (c - d).ToString();
                giai.button1_Click(button1, e);
                ngh2 = giai.ngh1;
                ngh3 = giai.ngh3;

                kq[1] = ngh1;
                kq[2] = ngh2;
                kq[3] = ngh3;

                for (int i = 1; i < 5; i++)
                {
                    for (int j = i + 1; j < 5; j++)
                    {
                        if (kq[i] == "" && kq[j] != "")
                        {
                            kq[i] = kq[j];
                            kq[j] = "";
                        }
                    }
                }

                if (ngh1 == "" && ngh2 == "" && ngh3 == "")
                {
                    label7.Text = "Phương trình vô nghiệm";
                }
                else
                {
                    label7.Text  = "Phương trình có nghiệm:";
                    label8.Text  = kq[1];
                    label9.Text  = kq[2];
                    label10.Text = kq[3];
                    label11.Text = "(với k là số nguyên)";
                }

                Button button2 = new Button();
                button2.Text     = "Lời giải chi tiết";
                button2.Font     = button1.Font;
                button2.Location = new Point(300, 265);
                button2.AutoSize = true;
                this.Controls.Add(button2);
                button2.Click    += Button2_Click;
                this.AcceptButton = button2;

                button4.Text     = "Đồ thị";
                button4.Font     = button1.Font;
                button4.Location = new Point(300, 305);
                button4.Size     = new Size(128, 36);
                this.Controls.Add(button4);
                button4.Click += Button4_Click;
            }
        }