Breaking News
Loading...
Monday, 15 February 2016

Employee Management (s5)

07:14:00
EmployeeForm.java
                                 --------    btninsert -------------
 String Code=txtempCode.getText();
        String Name=txtName.getText();
        String CellNum=txtCellNum.getText();
        String Adress=txtAdress.getText();
        String query="INSERT INTO Employee VALUES ('"+Code+"','"+Name+"','"+CellNum+"','"+Adress+"')";
        try{
           // Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
       Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb, *.accdb)} ;DBQ=E:\\Advanced OOP\\EmployeeManagement\\Employee.accdb");
       Statement stmt = conn.createStatement();
       stmt.execute(query);
       JOptionPane.showMessageDialog(null, "Inserted Successfully");
       conn.close();
           
        }
   catch (Exception ex)
        {
          JOptionPane.showMessageDialog(null, ex.getMessage());
         
        }
    }        
              --------------------btndelete--------------------------
 String Code=txtempCode.getText();
        // TODO add your handling code here:
       
        String query="Delete from Employee where empCode='"+ Code+"'";
        try{
      Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb, *.accdb)} ;DBQ=E:\\Advanced OOP\\EmployeeManagement\\Employee.accdb");
       Statement stmt = conn.createStatement();
       stmt.execute(query);
       JOptionPane.showMessageDialog(null, "delete Successfully");
       conn.close();
           
        }
   catch (Exception ex)
        {
          JOptionPane.showMessageDialog(null, ex.getMessage());
         
        }
    }                                        
 String Code=txtempCode.getText();
        // TODO add your handling code here:
       
        String query="Delete from Employee where empCode='"+ Code+"'";
        try{
      Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb, *.accdb)} ;DBQ=E:\\Advanced OOP\\EmployeeManagement\\Employee.accdb");
       Statement stmt = conn.createStatement();
       stmt.execute(query);
       JOptionPane.showMessageDialog(null, "delete Successfully");
       conn.close();
           
        }
   catch (Exception ex)
        {
          JOptionPane.showMessageDialog(null, ex.getMessage());
         
        }
    }                         
                                     ------------btnsearch---------------
 String Code=txtempCode.getText();
       
        String query="select * from Employee where empCode='"+ Code+"'";
        try{
      Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb, *.accdb)} ;DBQ=E:\\Advanced OOP\\EmployeeManagement\\Employee.accdb");
       Statement stmt = conn.createStatement();
       stmt.execute(query);
       ResultSet rs=stmt.getResultSet();
       if(rs.next())
       {
         JOptionPane.showMessageDialog(null, "found");
         txtempCode.setText(rs.getString("empCode"));
          txtName.setText(rs.getString("empName"));
           txtCellNum.setText(rs.getString("empCellnum"));
            txtAdress.setText(rs.getString("empAdress"));
       }
      else
    {
        JOptionPane.showMessageDialog(null, "not found"); 
    }
   
   
      JOptionPane.showMessageDialog(null, "search Successfully");
       conn.close();
           
        }
   catch (Exception ex)
        {
          JOptionPane.showMessageDialog(null, ex.getMessage());
         
        }
    }                                                
                                 ----btnupdate

String Code=txtempCode.getText();
        String Name=txtName.getText();
        String CellNum=txtCellNum.getText();
        String Adress=txtAdress.getText();
       
        String query="update  Employee set empName='"+Name+"',empCellNum='"+CellNum+"',empAdress='"+Adress+"' where empCode='"+Code+"'";
        try{
      Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb, *.accdb)} ;DBQ=E:\\Advanced OOP\\EmployeeManagement\\Employee.accdb");
       Statement stmt = conn.createStatement();
       stmt.execute(query);
       JOptionPane.showMessageDialog(null, "Inserted Successfully");
       conn.close();
           
        }
   catch (Exception ex)
        {
          JOptionPane.showMessageDialog(null, ex.getMessage());
         
        }
    }                                       

 


                                               
Newer Post
Previous
This is the last post.

0 comments:

Post a Comment

 
Toggle Footer