Guest User

Untitled

a guest
Jul 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. int book_qty = 0;
  2. SqlCommand cmd2 = connection.CreateCommand();
  3. cmd2.CommandType = CommandType.Text;
  4. cmd2.CommandText = "SELECT * FROM Book_list WHERE BookName = '" + TextBoxBookName + "'";
  5. cmd2.ExecuteNonQuery();
  6. DataTable dt2 = new DataTable();
  7. SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
  8. da2.Fill(dt2);
  9.  
  10.  
  11. foreach (DataRow dr2 in dt2.Rows)
  12. {
  13. book_qty = Convert.ToInt32(dr2["book_qty"].ToString());
  14. }
  15.  
  16. if (book_qty > 0)
  17. {
  18.  
  19.  
  20.  
  21. SqlCommand cmd = connection.CreateCommand();
  22. cmd.CommandType = CommandType.Text;
  23. cmd.CommandText = "INSERT INTO Issue_book VALUES(" + TextBoxSearchMembers.Text + ",'" + TextBoxMemberName.Text + "','" + TextBoxMemberContact.Text + "','" + TextBoxMemberEmail.Text + "','" + TextBoxBookName.Text + "', '" + DateTimePicker1.Text + "')";
  24. cmd.ExecuteNonQuery();
  25.  
  26.  
  27. SqlCommand cmd1 = connection.CreateCommand();
  28. cmd1.CommandType = CommandType.Text;
  29. cmd1.CommandText = "UPDATE Book_list SET BookAvailability = BookAvailability-1 WHERE BookName ='" + TextBoxBookName.Text + "'";
  30. cmd1.ExecuteNonQuery();
  31.  
  32.  
  33. MessageBox.Show("successful issue");
  34. this.Close();
  35.  
  36.  
  37. else
  38. {
  39. MessageBox.Show("Book not available");
  40. }
Add Comment
Please, Sign In to add comment