admin completed
[RRRRHHHH_Code] / ruralHouses / src / gui / LoginGUI.java
index 7e8ec11..db04aff 100644 (file)
@@ -15,8 +15,12 @@ import javax.swing.SwingConstants;
 
 import businessLogic.LoginManager;
 import businessLogic.LoginManagerInterface;
+import domain.Account;
 import domain.Owner;
 
+import javax.swing.JRadioButton;
+import javax.swing.ButtonGroup;
+
 public class LoginGUI extends JFrame {
 
        private static final long serialVersionUID= 1L;
@@ -25,7 +29,7 @@ public class LoginGUI extends JFrame {
        private JPasswordField passwordField;
        private LoginManagerInterface loginManager = new LoginManager();
        private JLabel loginFeedback;
-
+       private final ButtonGroup buttonGroup = new ButtonGroup();
        public LoginGUI() {
                super();
                initialize();
@@ -80,19 +84,22 @@ public class LoginGUI extends JFrame {
        }
        
        private void jButton_ActionPerformed(ActionEvent e){
-               Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
-               if(owner==null){
-                       loginFeedback.setText("Incorrect username or password");
-               }else{
-                       
-                       
                        
+               Account acc = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
+               if (acc.getAdmin()) {
+                       this.setVisible(false);
+                       Frame a = new AdminMenuGUI();
+                       a.setVisible(true);
+               } else {
+                       if(acc.getOwner()==null){
+                               loginFeedback.setText("Incorrect username or password");
+                       }else{
                                this.setVisible(false);
-                               Frame a = new OwnerMenuGUI(owner);
-                               a.setVisible(true);
-               }       
-
+                               Frame a = new OwnerMenuGUI(acc.getOwner());
+                               a.setVisible(true);             
+                       }
+               }
+               
        }
-
 }  // @jve:decl-index=0:visual-constraint="222,33"