Topic
  • 2 replies
  • Latest Post - ‏2010-01-18T14:10:55Z by Hadi Elmougi
SystemAdmin
SystemAdmin
210 Posts

Pinned topic plz help me in this code

‏2009-10-25T08:06:32Z |
i m making a project on Hospital ManagementSystem.
There are 3 users:
admin,
doctors,
front desk.

i want that aftr they login in the software same interface should appear in
front of all of them, but their functionalities are different.
according to their functions the buttons should be active or not.
how do i implement this in the software coding?

the login page which i hv designed is following:

package Hospital;
import javax.swing.*;

public class Login extends JFrame
{
JLabel l1,l2;
JLabel pic;
JButton b1,b2;
JTextField t1;
JPasswordField p1;

public Login()
{
setLayout(null);
this.setSize(500,500);
this.setResizable(false);

ImageIcon i=new ImageIcon("Picture 753.jpg");
pic=new JLabel(i);
pic.setBounds(0,0,500,500);
add(pic);

l1=new JLabel("Username");
l2=new JLabel("Password");
l1.setBounds(50, 30, 100, 50);
l2.setBounds(50, 80, 100, 50);

t1=new JTextField(30);
t1.setBounds(150, 50, 100, 20);

p1=new JPasswordField();
p1.setBounds(150, 100, 100, 20);

b1=new JButton("OK");
b2=new JButton("Exit");
b1.setBounds(150, 150, 70, 30);
b2.setBounds(225, 150, 70, 30);

pic.add(l1);
pic.add(l2);
pic.add(b1);
pic.add(b2);
pic.add(t1);
pic.add(p1);

b1.addActionListener(this);
b2.addActionListener(this);
}

public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc:Odbc:Hospital");
Statement stmt=con.createStatement();
String s1=t1.getText();
String s2=p1.getText();
String str="select * from Login";
ResultSet res=stmt.executeQuery(str);
while(res.next())
{
String user=res.getString(1);
String pass=res.getString(2);
if((user.equals(s1))&&(pass.equals(s2)))
{
Register r= new Register("LoggedIN",this);
r.setVisible(true);
this.setVisible(false);

}
}

}

catch(Exception e)
{
System.out.println("error" +e);
}
}

if(ae.getSource()==b2)
{
System.exit(0);
}
}
public static void main(String[] args)
{
new Login();
l.setVisible(true);
}

}
Updated on 2010-01-18T14:10:55Z at 2010-01-18T14:10:55Z by Hadi Elmougi
  • SystemAdmin
    SystemAdmin
    210 Posts

    Re: plz help me in this code

    ‏2009-10-26T16:10:57Z  
    One, I am not sure the program you submitted will compile. Depending on the type of user you can use a type of switch...case statements to determine how to load/configure the UI for each type of user.
  • Hadi Elmougi
    Hadi Elmougi
    1 Post

    Re: plz help me in this code

    ‏2010-01-18T14:10:55Z  
    Hi,

    Just use factories for you functions, the factory check the user roles to enable or disable the current features button.