Anda di halaman 1dari 33

//main.

java package hospital;

import java.awt.*; import java.awt.event.*; import javax.swing.*;

class main extends JFrame implements ActionListener { static JFrame frame;

private String username; private String password; private static JFrame loginFrame; private static JPanel panel1; private static JPanel panel2; private static JPanel panel3; private JButton loginBtn; private JButton exitBtn; int dialogtype = JOptionPane.PLAIN_MESSAGE; String dialogmessage; String dialogs; private JLabel nameLbl; private JLabel userLbl; private JLabel passwordLbl; private static JTextField userTxt; // private static JTextField passwordTxt; private static JPasswordField passwordTxt; public String loginname; public String loginpass;

// class Veriables // clsConnection connect = new clsConnection(); //Connection variable

//

Connection conn; //for connecting database

Dimension screen

Toolkit.getDefaultToolkit().getScreenSize();

// static Date td

= new Date();

main() {

panel1 = new JPanel(); panel1.setLayout(new FlowLayout()); nameLbl = new JLabel("Hospital Managment ");

panel2 = new JPanel(); panel2.setLayout(new GridLayout(2,2)); userLbl = new JLabel("Username :"); userTxt = new JTextField(20);

passwordLbl = new JLabel("Password :"); // passwordTxt = new JTextField(20); passwordTxt = new JPasswordField(20); // passwordTxt.setEchoChar('?');

panel3 = new JPanel(); panel3.setLayout(new FlowLayout());

loginBtn = new JButton("Login", new ImageIcon("images/key.gif"));

loginBtn.addActionListener(this); exitBtn = new JButton("Exit", new ImageIcon("images/Keys.gif"));

exitBtn.addActionListener(this); panel1.add(nameLbl); panel1.setOpaque(true); panel2.add(userLbl); panel2.add(userTxt); panel2.add(passwordLbl); panel2.add(passwordTxt); panel2.setOpaque(true); panel3.add(loginBtn); panel3.add(exitBtn); panel3.setOpaque(true); frame = new JFrame("Hospital Managment"); frame.setSize(300,200);

Container pane = frame.getContentPane(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); //pane.setLayout(new GridLayout(3,1)); pane.add(panel1); pane.add(panel2);

pane.add(panel3); frame.setLocation((screen.width - 500)/2,((screen.height-350)/2)); frame.setVisible(true); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });

// //

public void actionPerformed(ActionEvent ae) {}

//

class submit implements ActionListener // { public void actionPerformed(ActionEvent event) { /* String user,pass; user=tfuser.getText(); pass=tfpass.getText(); if(user.equals("student") && pass.equals("student")) {

new studstart(); setVisible(false);

}*/

Object source = event.getSource(); if(source.equals(loginBtn)) { //login(); String loginname,loginpass; loginname = userTxt.getText().trim(); loginpass = passwordTxt.getText().trim(); if(loginname.equals("s") && loginpass.equals("s")) { dialogmessage = "Welcome - " +loginname; dialogtype = JOptionPane.INFORMATION_MESSAGE; JOptionPane.showMessageDialog((Component)null, dialogmessage, dialogs, dialogtype); userTxt.setText(""); new start(); setVisible(false); frame.dispose();

} else{ JOptionPane.showMessageDialog(null,"Invaild User name and password" , "WARNING!!!",JOptionPane.INFORMATION_MESSAGE);

userTxt.setText(""); passwordTxt.setText(""); }

} else if(source.equals(exitBtn)) { System.exit(0); } } // }

/* {

public void login()

loginname = userTxt.getText().trim(); loginpass = passwordTxt.getText().trim();

try{ if(userTxt.equals("admin") && passwordTxt.equals("admin")) { new studstart(); setVisible(false);

} catch(Exception ex) { JOptionPane.showMessageDialog(null,"GENERAL EXCEPTION" , "WARNING!!!",JOptionPane.INFORMATION_MESSAGE); }*/

/*

class exit implements ActionListener { public void actionPerformed(ActionEvent ae) { System.exit(0);

} }*/

// }

public static void main(String[] args) { new main(); } }

//docStart.java package hospital;

import java.awt.*; import java.awt.event.*; import javax.swing.*;

class docStart extends JFrame implements ActionListener { JButton badd,bmod,bview,bback,bexit; JLabel linfo,linfo1,linfo2,linfo3,linfo4;

docStart() { super("Doctor's Information"); setSize(1024,768); setVisible(true); setResizable(false); setLayout(null);

linfo=new JLabel("Doctor's Information"); linfo.setBounds(445,30,210,20); add(linfo);

linfo1=new JLabel("1. Add Doctors Information"); linfo1.setBounds(200,150,210,20); add(linfo1);

badd=new JButton("Add Data",new ImageIcon("images/add.gif")); badd.setBounds(350,180,180,30); add(badd);

linfo2=new JLabel("2. Modify Doctors Information"); linfo2.setBounds(200,250,210,20); add(linfo2);

bmod=new JButton("Modify Data",new ImageIcon("images/bModify.png")); bmod.setBounds(350,280,180,30); add(bmod);

linfo3=new JLabel("3. View Doctors Information"); linfo3.setBounds(200,350,210,20); add(linfo3);

bview=new JButton("View Data",new ImageIcon("images/search.png")); bview.setBounds(350,380,180,30); add(bview);

bback=new JButton("BACK",new ImageIcon("images/restore.png")); bback.setBounds(503,545,100,30); add(bback);

//bexit=new JButton("EXIT"); //bexit.setBounds(730,515,100,30); //add(bexit);

badd.addActionListener(new add()); bmod.addActionListener(new mod()); bview.addActionListener(new view()); //bexit.addActionListener(new exit()); bback.addActionListener(new back());

public void actionPerformed(ActionEvent ae) {}

class back implements ActionListener { public void actionPerformed(ActionEvent ae) { new start(); setVisible(false); } }

class add implements ActionListener { public void actionPerformed(ActionEvent ae) { new DoctorInfoAdd();

setVisible(false); } }

class mod implements ActionListener { public void actionPerformed(ActionEvent ae) { new DoctorInfomodify(); setVisible(false); } }

class view implements ActionListener { public void actionPerformed(ActionEvent ae) { new DoctorInfoView(); setVisible(false);

} }

/* class exit implements ActionListener { public void actionPerformed(ActionEvent ae) { System.exit(0); } } */ public static void main(String[] args) { new docStart(); } }

package hospital;

import javax.swing.JFrame; import javax.swing.JOptionPane;

class InvalidPassError {

InvalidPassError() { String message = "Patient Number is invalid."; JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!", JOptionPane.ERROR_MESSAGE); }

public static void main(String argv[]) { new InvalidPassError(); } }

//patStart.java package hospital;

import java.awt.*; import java.awt.event.*; import javax.swing.*;

class patStart extends JFrame implements ActionListener { JButton badd,bmod,bview,bback,bexit; JLabel linfo,linfo1,linfo2,linfo3,linfo4; patStart()

{ super("Patient's Information"); setSize(1024,768); setVisible(true); setLayout(null);

linfo=new JLabel("Patient's Information"); linfo.setBounds(445,30,210,20); add(linfo);

linfo1=new JLabel("1. Add Patients Information"); linfo1.setBounds(200,150,210,20); add(linfo1);

badd=new JButton("Add Data",new ImageIcon("images/add.gif")); badd.setBounds(340,180,180,30); add(badd);

linfo2=new JLabel("2. Modify Patients Information"); linfo2.setBounds(200,250,210,20); add(linfo2);

bmod=new JButton("Modify Data",new ImageIcon("images/bModify.png")); bmod.setBounds(340,280,180,30); add(bmod);

linfo3=new JLabel("3. View Patients Information"); linfo3.setBounds(200,350,210,20); add(linfo3);

bview=new JButton("View Data",new ImageIcon("images/search.png")); bview.setBounds(340,380,180,30); add(bview);

bback=new JButton("BACK",new ImageIcon("images/restore.png")); bback.setBounds(503,545,100,30); add(bback);

//bexit=new JButton("EXIT"); //bexit.setBounds(730,515,100,30); //add(bexit);

badd.addActionListener(new add()); bmod.addActionListener(new mod()); bview.addActionListener(new view()); //bexit.addActionListener(new exit()); bback.addActionListener(new back());

public void actionPerformed(ActionEvent ae) {}

class back implements ActionListener { public void actionPerformed(ActionEvent ae) { new start(); setVisible(false); } }

class add implements ActionListener { public void actionPerformed(ActionEvent ae) { new PatientInfo(); setVisible(false); } }

class mod implements ActionListener {

public void actionPerformed(ActionEvent ae) { new PatientInfomodify(); setVisible(false); } }

class view implements ActionListener { public void actionPerformed(ActionEvent ae) { new PatientInfoView(); setVisible(false); } }

/* class exit implements ActionListener { public void actionPerformed(ActionEvent ae) { System.exit(0); } } */

public static void main(String[] args) { new patStart(); System.out.println("Hello World!"); } }

//start.java package hospital;

import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*;

class start extends JFrame implements ActionListener { JButton bpat,bdoc,bbill,breport,bback,bexit; JLabel linfo,linfo1,linfo2,linfo3,linfo4; start() { super("Hospital Management System"); setSize(1024,768); setVisible(true); setLayout(null);

linfo=new JLabel("SELECT THE APPROPRIATE OPTION"); linfo.setBounds(30,137,210,20); add(linfo);

linfo1=new JLabel("1. For Inserting, Modifying, Retrieving Patients related Data"); linfo1.setBounds(50,205,335,20); add(linfo1);

linfo2=new JLabel("2. For Inserting, Modifying, Retrieving Doctors related Data"); linfo2.setBounds(50,275,335,20); add(linfo2);

linfo3=new JLabel("3. Billing Details"); linfo3.setBounds(50,345,150,20); add(linfo3);

linfo4=new JLabel("4. Patient and Doctor related Data"); linfo4.setBounds(50,413,250,20); add(linfo4);

bpat=new JButton("Patient", new ImageIcon("images/Advances.png")); bpat.setBounds(430,200,180,30); add(bpat);

bdoc=new JButton("Doctor",new ImageIcon("images/Advances.png")); bdoc.setBounds(430,270,180,30); add(bdoc);

bbill=new JButton("Billing",new ImageIcon("images/Attendance.png")); bbill.setBounds(430,340,180,30); add(bbill);

breport=new JButton("Reports",new ImageIcon("images/edit.png")); breport.setBounds(430,408,180,30); add(breport);

bback=new JButton("BACK" ,new ImageIcon("images/preview_Hover.png")); bback.setBounds(230,515,100,30); add(bback);

bexit=new JButton("EXIT" ,new ImageIcon("images/exits.png")); bexit.setBounds(730,515,100,30); add(bexit);

bpat.addActionListener(new patient()); bdoc.addActionListener(new doctor()); bbill.addActionListener(new billing()); bexit.addActionListener(new exit()); bback.addActionListener(new back());

breport.addActionListener(new report());

public void actionPerformed(ActionEvent ae) {}

class report implements ActionListener { public void actionPerformed(ActionEvent ae) { new Report(); setVisible(false); } };

class back implements ActionListener { public void actionPerformed(ActionEvent ae) { new main(); setVisible(false); } }

class patient implements ActionListener { public void actionPerformed(ActionEvent ae) { new patStart(); setVisible(false); } }

class doctor implements ActionListener { public void actionPerformed(ActionEvent ae) { new docStart(); setVisible(false); } }

class billing implements ActionListener { public void actionPerformed(ActionEvent ae) {

new Billing(); setVisible(false); } }

class exit implements ActionListener { public void actionPerformed(ActionEvent ae) { System.exit(0); } }

/*

public static void main(String[] args) { new start(); }*/

Anda mungkin juga menyukai