Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(textBox3.Text))
            {
                MessageBox.Show("You should Enter book name and price");
            }
            else
            {
                con.Open();
                SqlCommand cm = new SqlCommand("check_book", con);
                cm.CommandType = CommandType.StoredProcedure;

                cm.Parameters.Add(new SqlParameter("@bookname", textBox1.Text));
                SqlParameter output = new SqlParameter("@@out", SqlDbType.NVarChar);
                output.Direction = ParameterDirection.Output;
                output.Size      = 50;
                cm.Parameters.Add(output);

                cm.ExecuteNonQuery();
                if (cm.Parameters["@@out"].Value is System.DBNull)
                {
                    SqlCommand   cmd = new SqlCommand(@"insert into book  (book_name,category,price)values(@name,@category,@price)", con);
                    SqlParameter nam = new SqlParameter("@name", textBox1.Text);
                    cmd.Parameters.Add(nam);
                    cmd.Parameters.Add(new SqlParameter("@category", textBox2.Text));
                    cmd.Parameters.Add(new SqlParameter("@price", textBox3.Text));
                    cmd.ExecuteNonQuery();
                }
                else if (cm.Parameters["@@out"].Value.ToString() == "true")
                {
                    MessageBox.Show("this book already exists ");
                    form5 f = new form5();
                    f.Show();
                    this.Hide();
                }



                con.Close();
            }
        }
Exemplo n.º 2
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     if (comboBox1.Text == "Book")
     {
         form5 fff = new form5();
         fff.Show();
     }
     else if (comboBox1.Text == "User")
     {
         Form6 f = new Form6();
         f.Show();
     }
     else if (comboBox1.Text == "Author")
     {
         Form8 f = new Form8();
         f.Show();
     }
     else if (comboBox1.Text == "Publisher")
     {
         Form7 f = new Form7();
         f.Show();
     }
 }