Advertisement
Guest User

issue_book1

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