예제 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            DataTable table = db.Read("SELECT COUNT(*) FROM psychiatric.dbo.customers WHERE Name = N'" + comboBox2.Text + "'");

            if (table.Rows[0][0].ToString() == "0")
            {
                MessageBox.Show("حدث خطأ ما", "خطأ");
                return;
            }
            int amount, number;

            try
            {
                amount = Convert.ToInt32(textBox2.Text);
                number = Convert.ToInt32(textBox1.Text);
            } catch (Exception x)
            {
                MessageBox.Show("حدث خطأ ما", "خطأ");
                return;
            }

            table = db.Read("SELECT COUNT(*) FROM psychiatric.dbo.sessionNumber WHERE Name = N'" + comboBox2.Text + "'");
            if (table.Rows[0][0].ToString() != "0")
            {
                MessageBox.Show("هذا العميل مسجل بالفعل ", "خطأ");
                return;
            }

            db.Write("INSERT INTO psychiatric.dbo.sessionNumber VALUES (N'" + comboBox2.Text + "', " + number + ", " + amount + ")");
            MessageBox.Show("تمت الأضافة");
            sessionNumber obj = (sessionNumber)Application.OpenForms["sessionNumber"];

            obj.Init();
            Close();
        }
        private void button4_Click(object sender, EventArgs e)
        {
            int price = 0, number = 0;

            try
            {
                price  = Convert.ToInt32(textBox1.Text);
                number = Convert.ToInt32(textBox2.Text);
            } catch (Exception x)
            {
                MessageBox.Show("حدث خطأ ما", "خطأ");
                return;
            }
            db.Write("UPDATE psychiatric.dbo.sessionNumber SET Number = Number + " + number + ", paidPrice = paidPrice + " + price + " WHERE Name = N'" + custName + "'");
            MessageBox.Show("تم الدفع");
            sessionNumber s = (sessionNumber)Application.OpenForms["sessionNumber"];

            s.Init();
            Close();
        }
        private void button10_Click(object sender, EventArgs e)
        {
            sessionNumber s = new sessionNumber();

            OpenForm(s);
        }