Guest User

Untitled

a guest
Aug 16th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.04 KB | None | 0 0
  1. @Override
  2. public void actionPerformed(ActionEvent evt) {
  3.     // TODO Auto-generated method stub
  4.    
  5.     String action = evt.getActionCommand();
  6.    
  7.     if(action.equals("first"))
  8.      {
  9.         firstNavigation();
  10.      }else if(action.equals("Prev"))
  11.      {
  12.          preNavigation();
  13.      }else if(action.equals("next"))
  14.      {
  15.          nextNavigation();
  16.      }else if(action.equals("last"))
  17.     {
  18.          lastNavigation();
  19.     }
  20. }
  21.  
  22.  
  23.  
  24.  
  25. private void firstNavigation()
  26. {
  27.         try{
  28.            
  29.             String url ="jdbc:mysql://localhost/opgavei";
  30.             Class.forName("com.mysql.jdbc.Driver");
  31.             Connection con = DriverManager.getConnection(url, "root", "" );
  32.             //Connection con = null;
  33.             if(rs == null)
  34.             {
  35.  
  36.                 String sql = ("SELECT * FROM tapijtbestelling");
  37.  
  38.             Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
  39.                     ResultSet.CONCUR_UPDATABLE);
  40.             rs = st.executeQuery(sql);
  41.             }
  42.             if(rs.first())
  43.             {
  44.                 populateValue();
  45.             }
  46.         }catch(Exception e)
  47.             {
  48.                 JOptionPane.showMessageDialog(null, e.getMessage(),"Error",
  49.                                 JOptionPane.ERROR_MESSAGE);
  50.             }
  51.     }
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. private void preNavigation()
  60. {
  61.         try{
  62.            
  63.             String url ="jdbc:mysql://localhost/opgavei";
  64.             Class.forName("com.mysql.jdbc.Driver");
  65.             Connection con = DriverManager.getConnection(url, "root", "" );
  66.             if(rs == null)
  67.             {
  68.                
  69.                 String sql = ("SELECT * FROM tapijtbestelling");
  70.  
  71.             Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
  72.                     ResultSet.CONCUR_UPDATABLE);
  73.             rs = st.executeQuery(sql);
  74.             }
  75.             if(rs.previous())
  76.             {
  77.                 populateValue();
  78.             }
  79.         }catch(Exception e)
  80.             {
  81.                 JOptionPane.showMessageDialog(null, e.getMessage(),"Error",
  82.                                 JOptionPane.ERROR_MESSAGE);
  83.             }
  84.     }
  85.  
  86.  
  87.  
  88. private void nextNavigation()
  89. {
  90.         try{
  91.            
  92.             String url ="jdbc:mysql://localhost/opgavei";
  93.             Class.forName("com.mysql.jdbc.Driver");
  94.             Connection con = DriverManager.getConnection(url, "root", "" );
  95.             if(rs == null)
  96.             {
  97.        
  98.                 String sql = ("SELECT * FROM tapijtbestelling");
  99.  
  100.             Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
  101.                     ResultSet.CONCUR_UPDATABLE);
  102.             rs = st.executeQuery(sql);
  103.             }
  104.             if(rs.next())
  105.             {
  106.                 populateValue();
  107.             }
  108.         }catch(Exception e)
  109.             {
  110.                 JOptionPane.showMessageDialog(null, e.getMessage(),"Error",
  111.                                 JOptionPane.ERROR_MESSAGE);
  112.             }
  113.     }
  114.  
  115.  
  116. private void lastNavigation()
  117. {
  118.         try{
  119.            
  120.             String url ="jdbc:mysql://localhost/opgavei";
  121.             Class.forName("com.mysql.jdbc.Driver");
  122.             Connection con = DriverManager.getConnection(url, "root", "" );
  123.            
  124.             if(rs == null)
  125.             {
  126.  
  127.                 String sql = ("SELECT * FROM tapijtbestelling");
  128.  
  129.             Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
  130.                     ResultSet.CONCUR_UPDATABLE);
  131.             rs = st.executeQuery(sql);
  132.             }
  133.             if(rs.last())
  134.             {
  135.                 populateValue();
  136.             }
  137.         }catch(Exception e)
  138.             {
  139.                 JOptionPane.showMessageDialog(null, e.getMessage(),"Error",
  140.                                 JOptionPane.ERROR_MESSAGE);
  141.             }
  142.     }
  143.  
  144.  
  145.  
  146. private void populateValue() throws Exception
  147.         {
  148.     txt1.setText(rs.getString("BestelCode"));
  149.     txt2.setText(rs.getString("BestelDatum"));
  150.     txt3.setText(rs.getString("Tapijtcode"));
  151.     txt4.setText(rs.getString("Lengte"));
  152.     txt5.setText(rs.getString("Breedte"));
  153.    
  154.    
  155.         }
Add Comment
Please, Sign In to add comment