Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void setTeacherTable1(){
- //Sets Teacher Table to preselected class
- TeacherScreen ts = new TeacherScreen();
- try {
- String ncc1 = classroomCon1.getText();
- String sql = "select * from "+ncc1+"";
- pst = conn.prepareStatement(sql);
- rs = pst.executeQuery();
- ts.teacherTable1.setModel(DbUtils.resultSetToTableModel(rs));
- rs.close();
- pst.close();
- }
- catch (Exception e){
- JOptionPane.showMessageDialog(null, e);
- }
- }
- private void login(){
- loginDatabase();
- if (usernameCon1.getText().matches(Usr1.getText()) && passwordCon1.getText().matches(Pass1.getText()) && positionCon1.getText().equals("Administrator")){
- Admin();
- usernameCon1.setText("");
- passwordCon1.setText("");
- positionCon1.setText("");
- Usr1.setText("");
- Pass1.setText("");
- systemExit();
- }
- else if (usernameCon1.getText().matches(Usr1.getText()) && passwordCon1.getText().matches(Pass1.getText()) && positionCon1.getText().equals("Manager")){
- manager();
- usernameCon1.setText("");
- passwordCon1.setText("");
- positionCon1.setText("");
- Usr1.setText("");
- Pass1.setText("");
- systemExit();
- }
- else if (usernameCon1.getText().matches(Usr1.getText()) && passwordCon1.getText().matches(Pass1.getText()) && positionCon1.getText().equals("Teacher")){
- teacher();
- usernameCon1.setText("");
- passwordCon1.setText("");
- positionCon1.setText("");
- Usr1.setText("");
- Pass1.setText("");
- setTeacherTable1();
- closeLogin();
- }
- else {
- JOptionPane.showMessageDialog(null, "Invalid Login", "Invalid Login", JOptionPane.ERROR_MESSAGE);
- Usr1.requestFocus();
- }
- }
- private void loginDatabase(){
- //Checks to see if Login is Administrator and then sends him to his respective location
- String userName1 = Usr1.getText();
- String passWord1 = Pass1.getText();
- try{
- String query1 = "select * from LoginManager where Username='"+userName1+"' and Password='"+passWord1+"'";
- PreparedStatement pst1 = conn.prepareStatement(query1);
- ResultSet rs1 = pst1.executeQuery();
- if (rs1.next()){
- String add1 = rs1.getString("Username");
- usernameCon1.setText(add1);
- String add2 = rs1.getString("Password");
- passwordCon1.setText(add2);
- String add3 = rs1.getString("Position");
- positionCon1.setText(add3);
- String add4 = rs1.getString("Classroom");
- classroomCon1.setText(add4);
- }
- pst1.close();
- rs1.close();
- }catch(Exception e){
- JOptionPane.showMessageDialog(null, e);
- }
- }
Add Comment
Please, Sign In to add comment