Advertisement
Guest User

issue_book

a guest
Jan 14th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.79 KB | None | 0 0
  1. package bookshelf;
  2. ...
  3.  
  4.  private void SearchBookBtnMouseClicked(java.awt.event.MouseEvent evt) {                                      
  5.         try {
  6.             Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Bookshelf", "root", "apple2473");
  7.             Statement st = con.createStatement();
  8.             int id = Integer.parseInt(B_search.getText());
  9.             String q1 = "Select * from basic where BID=" + id + ";";
  10.             ResultSet rs = st.executeQuery(q1);
  11.             while (rs.next()) {
  12.                 BID3.setText(rs.getString(1));
  13.                 BN3.setText(rs.getString(2));
  14.                 CATECB3.setSelectedItem(rs.getString(6));
  15.                 CLASSCB3.setSelectedItem(rs.getString(5));
  16.             }
  17.         } catch (Exception e) {
  18.             JOptionPane.showMessageDialog(null, "" + e);
  19.         }
  20.     }
  21.  
  22. private void SearchIdMouseClicked(java.awt.event.MouseEvent evt) {                                      
  23.         try {
  24.             Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Bookshelf", "root", "apple2473");
  25.             Statement st = con.createStatement();
  26.             int id = Integer.parseInt(S_search.getText());
  27.             String q1 = "Select * from lbc_card where LBCNO=" + id + ";";
  28.             ResultSet rs = st.executeQuery(q1);
  29.             while (rs.next()) {
  30.                 name.setText(rs.getString(2));
  31.                 lbc_no.setText(rs.getString(1));
  32.                 year.setText(rs.getString(4));
  33.             }
  34.         } catch (Exception e) {
  35.             JOptionPane.showMessageDialog(null, "" + e);
  36.         }
  37.     }
  38.  
  39. private void issueBtnMouseClicked(java.awt.event.MouseEvent evt) {                                      
  40.         try {
  41.             Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Bookshelf", "root", "apple2473");
  42.             Statement st = con.createStatement();
  43.             int bid = Integer.parseInt(BID3.getText());
  44.             int sid = Integer.parseInt(lbc_no.getText());
  45.             String qq = "Select * from basic where BID=" + bid + ";";
  46.             ResultSet rs = st.executeQuery(qq);
  47.             while (rs.next()) {
  48.                 String inf = rs.getString(8);
  49.                 if (inf.equals("Not Issued")) {
  50.                     String to = "Issued";
  51.                     String q1 = "Update basic set ISSUE = '" + to + "' where BID=" + bid + ";";
  52.                     String q2 = "insert into issue_check values(" + sid + "," + bid + ");";
  53.                     st.executeUpdate(q1);
  54.                     st.executeUpdate(q2);
  55.                     JOptionPane.showMessageDialog(null, "Issued for 7 days");
  56.                 } else if (inf.equals("Issued")) {
  57.                     JOptionPane.showMessageDialog(null, "Already Issued");
  58.                 }
  59.                 break;
  60.             }
  61.         } catch (Exception e) {
  62.             JOptionPane.showMessageDialog(null, "" + e);
  63.         }
  64.     }
  65.  
  66. private void ReturnBtnMouseClicked(java.awt.event.MouseEvent evt) {                                      
  67.         try {
  68.             Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Bookshelf", "root", "apple2473");
  69.             Statement st = con.createStatement();
  70.             int bid = Integer.parseInt(BID3.getText());
  71.             int sid = Integer.parseInt(lbc_no.getText());
  72.             String to = "Not Issued";
  73.             String q1 = "Update basic set ISSUE = '" + to + "' where BID=" + bid + ";";
  74.             String q2 = "Delete from issue_check where LBCNO=" + sid + ";";
  75.             st.executeUpdate(q1);
  76.             st.executeUpdate(q2);
  77.             JOptionPane.showMessageDialog(null, "You can issue new book");
  78.         } catch (Exception e) {
  79.             JOptionPane.showMessageDialog(null, "" + e);
  80.         }
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement