Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bookshelf;
- ...
- private void SearchBookBtnMouseClicked(java.awt.event.MouseEvent evt) {
- try {
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Bookshelf", "root", "apple2473");
- Statement st = con.createStatement();
- int id = Integer.parseInt(B_search.getText());
- String q1 = "Select * from basic where BID=" + id + ";";
- ResultSet rs = st.executeQuery(q1);
- while (rs.next()) {
- BID3.setText(rs.getString(1));
- BN3.setText(rs.getString(2));
- CATECB3.setSelectedItem(rs.getString(6));
- CLASSCB3.setSelectedItem(rs.getString(5));
- }
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "" + e);
- }
- }
- private void SearchIdMouseClicked(java.awt.event.MouseEvent evt) {
- try {
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Bookshelf", "root", "apple2473");
- Statement st = con.createStatement();
- int id = Integer.parseInt(S_search.getText());
- String q1 = "Select * from lbc_card where LBCNO=" + id + ";";
- ResultSet rs = st.executeQuery(q1);
- while (rs.next()) {
- name.setText(rs.getString(2));
- lbc_no.setText(rs.getString(1));
- year.setText(rs.getString(4));
- }
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "" + e);
- }
- }
- private void issueBtnMouseClicked(java.awt.event.MouseEvent evt) {
- try {
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Bookshelf", "root", "apple2473");
- Statement st = con.createStatement();
- int bid = Integer.parseInt(BID3.getText());
- int sid = Integer.parseInt(lbc_no.getText());
- String qq = "Select * from basic where BID=" + bid + ";";
- ResultSet rs = st.executeQuery(qq);
- while (rs.next()) {
- String inf = rs.getString(8);
- if (inf.equals("Not Issued")) {
- String to = "Issued";
- String q1 = "Update basic set ISSUE = '" + to + "' where BID=" + bid + ";";
- String q2 = "insert into issue_check values(" + sid + "," + bid + ");";
- st.executeUpdate(q1);
- st.executeUpdate(q2);
- JOptionPane.showMessageDialog(null, "Issued for 7 days");
- } else if (inf.equals("Issued")) {
- JOptionPane.showMessageDialog(null, "Already Issued");
- }
- break;
- }
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "" + e);
- }
- }
- private void ReturnBtnMouseClicked(java.awt.event.MouseEvent evt) {
- try {
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Bookshelf", "root", "apple2473");
- Statement st = con.createStatement();
- int bid = Integer.parseInt(BID3.getText());
- int sid = Integer.parseInt(lbc_no.getText());
- String to = "Not Issued";
- String q1 = "Update basic set ISSUE = '" + to + "' where BID=" + bid + ";";
- String q2 = "Delete from issue_check where LBCNO=" + sid + ";";
- st.executeUpdate(q1);
- st.executeUpdate(q2);
- JOptionPane.showMessageDialog(null, "You can issue new book");
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "" + e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement