Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form20 form20 = new Form20();

            form20.Show();
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            String          connection = "Provider=OraOLEDB.Oracle;Data Source=localhost;User Id=system;Password=system;OLEDB.NET=True";
            OleDbConnection obj3       = new OleDbConnection(connection);
            String          query1     = "select count(*) from book where c_id=(select c_id from category where cname='" + textBox1.Text + "')";
            OleDbCommand    cm4        = new OleDbCommand(query1, obj3);

            obj3.Open();
            OleDbDataReader rd    = cm4.ExecuteReader();
            Int64           count = 0;

            while (rd.Read())
            {
                count = int.Parse(rd[0].ToString());
            }
            obj3.Close();


            if (count == 0)
            {
                String query = "delete from category where cname = '" + textBox1.Text + "'";
                obj3.Open();
                try
                {
                    OleDbCommand cm = new OleDbCommand(query, obj3);
                    cm.ExecuteNonQuery();
                    MessageBox.Show("Category Deleted from Database");
                }
                catch (Exception ee)
                {
                    MessageBox.Show("Error...Category not Deleted");
                }
                obj3.Close();
            }
            else
            {
                MessageBox.Show("Please Delete all records of this '" + textBox1.Text + "' category in books table ");
                this.Hide();
                Form20 form20 = new Form20();
                form20.Show();
            }
        }