//issue book private void btn_issue_Click(object sender, EventArgs e) { if (tb_studentName.Text == "") { MessageBox.Show("Please select student name"); } else { if (Convert.ToDateTime(date_issue.Text) < DateTime.Today || Convert.ToDateTime(date_issue.Text) > DateTime.Today) { MessageBox.Show("You can not issue book on previous or future dates!! Please select today's date!!"); } else { if (qty == 0) { MessageBox.Show("Books out of stock!"); } else { try { //insert in issue book table date = date_issue.Text; int id = Increment.issueBookIncrement(); SqlCommand cmd = new SqlCommand("Insert into issue_book values('" + id + "','" + tb_bookId.Text + "','" + cb_bookName.Text + "','" + cb_edition.Text + "','" + cb_publisher.Text + "','" + tb_studentId.Text + "','" + tb_enrollment.Text + "','" + tb_studentName.Text + "','" + tb_course.Text + "','" + tb_year.Text + "','" + tb_sem.Text + "','" + tb_contact.Text + "','" + date + "')", con); int result = cmd.ExecuteNonQuery(); //decrease quantity SqlCommand cmd1 = new SqlCommand("update book set available_qty=available_qty-1 where book_id='" + tb_bookId.Text + "'", con); cmd1.ExecuteNonQuery(); if (result == 1) { MessageBox.Show("Book Issued!"); cb_bookName.Items.Clear(); loadCombo(); tb_bookId.Text = ""; tb_enrollment.Text = ""; tb_studentName.Text = ""; tb_studentId.Text = ""; tb_course.Text = ""; tb_year.Text = ""; tb_sem.Text = ""; tb_contact.Text = ""; } else { MessageBox.Show("Something Went Wrong!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } }