You are required to design and implement (in Java) a program to manage the detai
ID: 3701031 • Letter: Y
Question
You are required to design and implement (in Java) a program to manage the details of a Healthcare Information System (HIS). The objective of the system is to manage the details of patients, doctors, medicine, treatments and reports. ? Administrator has the rights to access the HIS. ? The system should be able to reduce the manual administration in managing the HIS information. ? The system should be able to track and manage the information about patient, doctors, treatments/diagnosis, lab test results, medicine and payment (including made by insurance). ? The system should be able to keep information of walk-in patients and patients with appointments. Keep track the doctors’ availability. ? Pharmacists will only give controlled medicine as prescribed by doctors only. However, non-controlled medicine can be bought over the counter. All medicine can be claimed by providing prove of payment. Payment has to be made at discharge counter. ? The system should provide a necessary reporting. You may model your design based on the scenario given above. The quality of your product will be based on how much detail you model the design as well as the level of completeness of your design and the actual product. a) Design and implement class(es) (in Java) enough functionality to allow the operation of the following test program (which you also design, implement, test and document).
Explanation / Answer
main.java
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();
}
}
doctorinfoView
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class DoctorInfoView extends JFrame implements ActionListener
{
static Connection cn=null;
static Connection cn2=null;
Statement st=null;
Statement st2=null;
ResultSet rs=null;
ResultSet rs2=null;
JLabel lmain,ldi,lname,ladd,ltel,lspecial,ldid,ldspec,lwork,lworkfrom,lworkto,lpatlist;
JTextField tfname,tftel,tfdid,tfworkf,tfworkt;
TextArea taadd,taspecial,tapatlist;
JButton bsub,bclr,bback;
DoctorInfoView()
{
super("Doctor Information");
setSize(1024,768);
setVisible(true);
setLayout(null);
lmain=new JLabel("Doctor Information");
lmain.setBounds(440,35,107,15);
add(lmain);
ldi=new JLabel("Doctor Information");
ldi.setBounds(40,70,120,15);
add(ldi);
lname=new JLabel("Name :");
lname.setBounds(104,97,70,25);
add(lname);
tfname=new JTextField(30);
tfname.setBounds(270,97,250,20);
add(tfname);
ladd=new JLabel("Address :");
ladd.setBounds(104,138,70,15);
add(ladd);
taadd=new TextArea();
taadd.setBounds(270,138,250,100);
add(taadd);
ltel=new JLabel("Contact :");
ltel.setBounds(575,138,50,25);
add(ltel);
ldid=new JLabel("Doctor ID:");
ldid.setBounds(570,97,70,25);
add(ldid);
tfdid=new JTextField(30);
tfdid.setBounds(643,97,50,20);
add(tfdid);
tftel=new JTextField(30);
tftel.setBounds(640,138,200,20);
add(tftel);
ldspec=new JLabel("Specialization :");
ldspec.setBounds(104,310,100,25);
add(ldspec);
taspecial=new TextArea();
taspecial.setBounds(270,310,250,100);
add(taspecial);
lwork=new JLabel("Working hours :");
lwork.setBounds(570,200,100,15);
add(lwork);
lworkfrom=new JLabel("From :");
lworkfrom.setBounds(670,200,37,25);
add(lworkfrom);
tfworkf=new JTextField(30);
tfworkf.setBounds(710,200,30,20);
add(tfworkf);
lworkto=new JLabel("to :");
lworkto.setBounds(747,200,20,25);
add(lworkto);
tfworkt=new JTextField(30);
tfworkt.setBounds(775,200,30,20);
add(tfworkt);
lpatlist=new JLabel("Patient List");
lpatlist.setBounds(570,290,80,25);
add(lpatlist);
tapatlist=new TextArea();
tapatlist.setBounds(570,310,250,100);
add(tapatlist);
bsub=new JButton("SEARCH",new ImageIcon("images/search.png"));
bsub.setBounds(300,643,110,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(470,643,100,30);
add(bclr);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(580,643,100,30);
add(bback);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:doc");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn2=DriverManager.getConnection("Jdbc:Odbc:pat");
}
catch(Exception e)
{
System.out.println(e);
}
bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bback.addActionListener(new back());
}
class clear implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tftel.setText("");
tfdid.setText("");
tfworkf.setText("");
tfworkt.setText("");
taadd.setText("");
taspecial.setText("");
tapatlist.setText("");
}
}
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new docStart();
setVisible(false);
}
}
public void actionPerformed(ActionEvent ae)
{}
class patinfo implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
}
};
class submit implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try{
tapatlist.setText("");
Integer num=Integer.parseInt(tfdid.getText());
String name;
String addr;
String contact;
String spec;
String workf;
String workt;
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM DOC WHERE did="+num);
if(rs.next())
{
num=rs.getInt("did");
name=rs.getString("name");
addr=rs.getString("address");
contact=rs.getString("contact");
spec=rs.getString("specialization");
workf=rs.getString("workfrom");
workt=rs.getString("workto");
tfname.setText(name);
taadd.setText(addr);
tftel.setText(contact);
taspecial.setText(spec);
tfworkf.setText(workf);
tfworkt.setText(workt);
}
}
catch(SQLException sq)
{
System.out.println(sq);
}
try{
String docname=tfname.getText();
System.out.println(docname);
Statement st2=cn2.createStatement();
ResultSet rs2=st2.executeQuery("SELECT patientno,name FROM PAT WHERE docname='"+docname+"'");
ResultSetMetaData rsmt=rs2.getMetaData();
int ctr=rsmt.getColumnCount();
while(rs2.next())
{
for(int i=1;i<=ctr;i++)
{
tapatlist.append(rs2.getString(i)+" ");
}
tapatlist.append(" ");
}
}
catch(SQLException sq)
{
System.out.println(sq);
}
}
}
public static void main(String[] args)
{
new DoctorInfoView();
System.out.println("Doctors Info Add");
}
}
..............................
import java.awt.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
class DoctorTableFromDatabase extends JFrame
{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
DoctorTableFromDatabase()
{
Vector columnNames = new Vector();
Vector data = new Vector();
try
{
// Connect to the Database
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:doc");
}
catch(Exception e)
{
System.out.println(e);
}
// Read data from a table
String sql = "Select * from DOC";
Statement stmt = cn.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
// Get column names
for (int i = 1; i <= columns; i++)
{
columnNames.addElement(md.getColumnName(i));
}
// Get row data
while (rs.next())
{
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++)
{
row.addElement(rs.getObject(i));
}
data.addElement( row );
}
// rs.close();
//stmt.close();
}
catch(Exception e)
{
System.out.println( e );
}
// Create table with database data
JTable table = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add( scrollPane );
JPanel buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
}
public static void main(String[] args)
{
DoctorTableFromDatabase frame = new DoctorTableFromDatabase();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
..............................................................................................
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class DoctorInfomodify extends JFrame implements ActionListener
{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
JLabel lmain,ldi,lname,ladd,ltel,lspecial,ldid,ldspec,lwork,lworkfrom,lworkto;
JTextField tfname,tftel,tfdid,tfworkf,tfworkt;
TextArea taadd,taspecial;
JButton bsub,bclr,bmod,bback;
int x,y;
String str;
clsSettings settings = new clsSettings();
DoctorInfomodify()
{
super("Doctor Information");
setSize(1024,768);
setVisible(true);
setLayout(null);
lmain=new JLabel("Doctor Information");
lmain.setBounds(440,35,107,15);
add(lmain);
ldi=new JLabel("Doctor Information");
ldi.setBounds(40,70,120,15);
add(ldi);
lname=new JLabel("Name :");
lname.setBounds(104,97,70,25);
add(lname);
tfname=new JTextField(30);
tfname.setBounds(270,97,250,20);
add(tfname);
ladd=new JLabel("Address :");
ladd.setBounds(104,138,70,15);
add(ladd);
taadd=new TextArea();
taadd.setBounds(270,138,250,100);
add(taadd);
ltel=new JLabel("Contact :");
ltel.setBounds(575,138,50,25);
add(ltel);
ldid=new JLabel("Doctor ID:");
ldid.setBounds(570,97,70,25);
add(ldid);
tfdid=new JTextField(30);
tfdid.setBounds(643,97,50,20);
add(tfdid);
tftel=new JTextField(30);
tftel.setBounds(640,138,200,20);
add(tftel);
settings.Numvalidator(tftel);
ldspec=new JLabel("Specialization :");
ldspec.setBounds(104,310,100,25);
add(ldspec);
taspecial=new TextArea();
taspecial.setBounds(270,310,250,100);
add(taspecial);
lwork=new JLabel("Working hours :");
lwork.setBounds(570,310,100,15);
add(lwork);
lworkfrom=new JLabel("From :");
lworkfrom.setBounds(670,305,37,25);
add(lworkfrom);
tfworkf=new JTextField(30);
tfworkf.setBounds(710,310,30,20);
add(tfworkf);
settings.Numvalidator(tfworkf);
lworkto=new JLabel("to :");
lworkto.setBounds(747,305,20,25);
add(lworkto);
tfworkt=new JTextField(30);
tfworkt.setBounds(775,310,30,20);
add(tfworkt);
settings.Numvalidator(tfworkt);
bsub=new JButton("SEARCH",new ImageIcon("images/search.png"));
bsub.setBounds(250,643,110,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(390,643,100,30);
add(bclr);
bmod=new JButton("MODIFY",new ImageIcon("images/modify.png"));
bmod.setBounds(530,643,100,30);
add(bmod);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(700,643,100,30);
add(bback);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:doc");
}
catch(Exception e)
{
System.out.println(e);
}
bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bmod.addActionListener(new modify());
bback.addActionListener(new back());
}
public void actionPerformed(ActionEvent ae)
{}
class clear implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tftel.setText("");
tfdid.setText("");
tfworkf.setText("");
tfworkt.setText("");
taadd.setText("");
taspecial.setText("");
}
}
public static void main(String[] args)
{
new DoctorInfomodify();
System.out.println("Doctors Info Mod");
}
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new docStart();
setVisible(false);
}
}
class submit implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try{
Integer num=Integer.parseInt(tfdid.getText());
String name;
String addr;
String contact;
String spec;
String workf;
String workt;
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM DOC WHERE did="+num);
if(rs.next())
{
num=rs.getInt("did");
name=rs.getString("name");
addr=rs.getString("address");
contact=rs.getString("contact");
spec=rs.getString("specialization");
workf=rs.getString("workfrom");
workt=rs.getString("workto");
tfname.setText(name);
taadd.setText(addr);
tftel.setText(contact);
taspecial.setText(spec);
tfworkf.setText(workf);
tfworkt.setText(workt);
}
}
catch(SQLException sq)
{
System.out.println(sq);
}
}
}
class modify implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try{
Integer num1=Integer.parseInt(tfdid.getText());
if(num1.equals(null))
{
System.out.println("num");
throw new BlankException();
}
String name1=tfname.getText();
int a;
a=name1.charAt(0);
if(name1.equals("") || a==32)
{
throw new BlankException();
}
else
{
for(int i=0; i<name1.length(); i++)
{
boolean check = Character.isLetter(name1.charAt(i));
a=name1.charAt(i);
System.out.print(" "+a);
if(!((a>=65 && a<=90) || (a>=97 && a<=122) || (a==32) ||(a==46)))
{
throw new NameEx();
}
}
}
String addr1=taadd.getText();
if(addr1.equals(null))
{
System.out.println("addr");
throw new BlankException();
}
String contact1=tftel.getText();
String spec1=taspecial.getText();
String workf1=tfworkf.getText();
String workt1=tfworkt.getText();
//Statement st1=cn.createStatement();
String str="UPDATE DOC SET name=?,address=?,contact=?,specialization=?,workfrom=?,workto=? WHERE did=?";
Statement st1= cn.createStatement();
PreparedStatement psmt=cn.prepareStatement(str);
psmt.setString(1,name1);
psmt.setString(2,addr1);
psmt.setString(3,contact1);
psmt.setString(4,spec1);
psmt.setString(5,workf1);
psmt.setString(6,workt1);
psmt.setInt(7,num1);
psmt.executeUpdate();
new SuccessDialog2();
}catch(SQLException sq)
{
String message = "Enter Valid Doctor ID and Contact.";
JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!",
JOptionPane.ERROR_MESSAGE);
System.out.println(sq);
}
catch(BlankException be)
{
new ErrorDialog2();
}
catch(NumberFormatException nfe)
{
new ErrorDialog();
}
catch(NameEx ne)
{
new ErrorDialog1();
}
catch(Exception e)
{
System.out.println(e);
new EDt();
}
}
}
}
...............................................................
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class DoctorInfoAdd extends JFrame implements ActionListener
{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
JLabel lmain,ldi,lname,ladd,ltel,lspecial,ldid,ldspec,lwork,lworkfrom,lworkto,lfee;
JTextField tfname,tftel,tfdid,tfworkf,tfworkt,tffee;
TextArea taadd,tacur,taspecial;
JButton bsub,bclr,bback;
int x,y;
String str;
clsSettings settings = new clsSettings();
DoctorInfoAdd()
{
super("Doctor Information");
setSize(1024,768);
setVisible(true);
setLayout(null);
lmain=new JLabel("Doctor Information");
lmain.setBounds(440,35,107,15);
add(lmain);
ldi=new JLabel("Doctor Information");
ldi.setBounds(40,70,120,15);
add(ldi);
lname=new JLabel("Name :");
lname.setBounds(104,97,70,25);
add(lname);
tfname=new JTextField(30);
tfname.setBounds(270,97,250,20);
add(tfname);
ladd=new JLabel("Address :");
ladd.setBounds(104,138,70,15);
add(ladd);
taadd=new TextArea();
taadd.setBounds(270,138,250,100);
add(taadd);
ltel=new JLabel("Contact :");
ltel.setBounds(575,138,50,25);
add(ltel);
ldid=new JLabel("Doctor ID:");
ldid.setBounds(570,97,70,25);
add(ldid);
tfdid=new JTextField(30);
tfdid.setBounds(643,97,50,20);
add(tfdid);
tftel=new JTextField(30);
tftel.setBounds(640,138,200,20);
add(tftel);
settings.Numvalidator(tftel);
ldspec=new JLabel("Specialization :");
ldspec.setBounds(104,310,100,25);
add(ldspec);
taspecial=new TextArea();
taspecial.setBounds(270,310,250,100);
add(taspecial);
lwork=new JLabel("Working hours :");
lwork.setBounds(570,310,100,15);
add(lwork);
lworkfrom=new JLabel("From :");
lworkfrom.setBounds(670,305,37,25);
add(lworkfrom);
tfworkf=new JTextField(30);
tfworkf.setBounds(710,310,30,20);
add(tfworkf);
settings.Numvalidator(tfworkf);
lworkto=new JLabel("to :");
lworkto.setBounds(747,305,20,25);
add(lworkto);
tfworkt=new JTextField(30);
tfworkt.setBounds(775,310,30,20);
add(tfworkt);
settings.Numvalidator(tfworkt);
bsub=new JButton("ADD",new ImageIcon("images/add.gif"));
bsub.setBounds(362,643,100,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(470,643,100,30);
add(bclr);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(580,643,100,30);
add(bback);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:doc");
}
catch(Exception e)
{
System.out.println(e);
}
bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bback.addActionListener(new back());
}
class clear implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tftel.setText("");
tfdid.setText("");
tfworkf.setText("");
tfworkt.setText("");
taadd.setText("");
taspecial.setText("");
}
}
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new docStart();
setVisible(false);
}
}
class submit implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try{
String num=tfdid.getText();
if(num.equals(null))
{
System.out.println("num");
throw new BlankException();
}
String name=tfname.getText();
int a;
a=name.charAt(0);
if(name.equals("") || a==32)
{
throw new BlankException();
}
else
{
for(int i=0; i<name.length(); i++)
{
boolean check = Character.isLetter(name.charAt(i));
a=name.charAt(i);
System.out.print(" "+a);
if(!((a>=65 && a<=90) || (a>=97 && a<=122) || (a==32) ||(a==46)))
{
throw new NameEx();
}
}
}
String addr=taadd.getText();
if(addr.equals(null))
{
System.out.println("addr");
throw new BlankException();
}
String contact=tftel.getText();
String spec=taspecial.getText();
String workf=tfworkf.getText();
String workt=tfworkt.getText();
Statement st=cn.createStatement();
st.executeUpdate("INSERT INTO DOC VALUES('"+num+"','"+name+"','"+addr+"','"+contact+"','"+spec+"','"+workf+"','"+workt+"');");
new SuccessDialog();
}
catch(SQLException sq)
{
String message = "Enter Valid Doctor ID and Contact.";
JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!",
JOptionPane.ERROR_MESSAGE);
System.out.println(sq);
}
catch(BlankException be)
{
new ErrorDialog2();
}
catch(NumberFormatException nfe)
{
new ErrorDialog();
}
catch(NameEx ne)
{
new ErrorDialog1();
}
catch(Exception e)
{
System.out.println(e);
new EDt();
}
}
}
public void actionPerformed(ActionEvent ae)
{}
public static void main(String[] args)
{
new DoctorInfoAdd();
}
}
......................................................................................................
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();
}
}
...................................................................
import java.util.*;
class datenew
{
datenew()
{
Date today = new Date();
}
public static void main(String[] args)
{
new datenew();
}
.................................................................
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class clsSettings
{
/* public JLabel setJLabel(JLabel lbl, int sLeft, int sTop, int sWidth, int sHeight, boolean setBool)
{
lbl.setBounds(sLeft,sTop,sWidth, sHeight);
lbl.setFont(new Font("Dialog",Font.PLAIN,12));
if(setBool == true){lbl.setForeground(new Color(166,0,0));}
else{lbl.setForeground(java.awt.Color.BLACK);}
return lbl;
}//Set-up in JLabel
public JTextField setJTextField(JTextField txtfield, int sLeft, int sTop, int sWidth, int sHeight)
{
txtfield.setBounds(sLeft,sTop,sWidth, sHeight);
txtfield.setFont(new Font("Dialog",Font.PLAIN,12));
txtfield.setSelectionColor(new Color(200,150,150));
txtfield.setSelectedTextColor(new Color(0,0,0));
return txtfield;
}//Set-up in JTextField
public JMenu setJMenu(JMenu menu)
{
menu.setFont(new Font("Dialog", Font.BOLD, 16));
menu.setCursor(new Cursor(Cursor.HAND_CURSOR));
menu.setForeground(new Color(0,0,0));
return menu;
}//Create a Menu
public JMenuItem setJMenuItem(JMenuItem mnuitem, String sCaption, String imgLocation)
{
mnuitem.setText(sCaption);
mnuitem.setIcon(new ImageIcon(imgLocation));
mnuitem.setCursor(new Cursor(Cursor.HAND_CURSOR));
mnuitem.setFont(new Font("Dialog", Font.PLAIN, 12));
mnuitem.setForeground(new Color(0,0,0));
return mnuitem;
}//Create a MenuItem
public JTabbedPane setJTabbedPane( JTabbedPane setTabbed, String setTitle, String setIcon, JPanel setPanel, int sLeft, int sTop, int sWidth, int sHeight)
{
setTabbed.setBounds(sLeft,sTop,sWidth, sHeight);
setTabbed.setCursor(new Cursor(Cursor.HAND_CURSOR));
setTabbed.setFont(new Font("Dialog", Font.CENTER_BASELINE, 12));
setTabbed.setForeground(new Color(166,0,0));
setTabbed.addTab(setTitle, new ImageIcon(setIcon), setPanel);
return setTabbed;
}//Create a JTabbedPane
public JButton CreateJToolbarButton(String srcToolTipText,String srcImageLocation,String srcActionCommand, ActionListener JToolBarActionListener)
{
JButton bttnToolbar = new JButton(new ImageIcon(srcImageLocation));
bttnToolbar.setActionCommand(srcActionCommand);
bttnToolbar.setToolTipText(srcToolTipText);
bttnToolbar.setCursor(new Cursor(Cursor.HAND_CURSOR));
bttnToolbar.setFont(new Font("Dialog", Font.PLAIN, 12));
bttnToolbar.addActionListener(JToolBarActionListener);
return bttnToolbar;
}//Create JToolbarButton*/
public void Numvalidator(JTextField txtField)
{
txtField.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) { //Generated when input is received from the keyboard
char c = e.getKeyChar();//which returns the character that was entered
if (!(Character.isDigit(c) ||
(c == KeyEvent.VK_BACK_SPACE) ||
(c == KeyEvent.VK_DELETE))) {
// getToolkit().beep();
e.consume();
}
}
});
}
}
....................................................................................
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.text.*;
class Billing extends JFrame implements ActionListener
{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
JLabel lmain,lpname,lpno,ldad,lddis,lrt,ltamt,temp;
JTextField tfname,tfno,tfdateadd,tfrtype,tftamt;
JButton bsub,bclr,bback;
Billing()
{
super("Billing Information");
setSize(1024,768);
setVisible(true);
setLayout(null);
lmain=new JLabel("Billing Information");
lmain.setBounds(440,35,107,15);
add(lmain);
lpname=new JLabel("Patient Name :");
lpname.setBounds(104,97,85,25);
add(lpname);
tfname=new JTextField(30);
tfname.setBounds(230,100,225,20);
add(tfname);
lpno=new JLabel("Patient No. :");
lpno.setBounds(570,97,70,25);
add(lpno);
tfno=new JTextField(30);
tfno.setBounds(694,100,70,20);
add(tfno);
ldad=new JLabel("Date of Admission :");
ldad.setBounds(104,175,120,25);
add(ldad);
tfdateadd=new JTextField(20);
tfdateadd.setBounds(230,178,80,20);
add(tfdateadd);
lddis=new JLabel("Date of Discharge :");
lddis.setBounds(570,175,120,25);
add(lddis);
lrt=new JLabel("Room Type :");
lrt.setBounds(104,242,70,25);
add(lrt);
tfrtype=new JTextField(20);
tfrtype.setBounds(230,242,80,20);
add(tfrtype);
ltamt=new JLabel("Total Amount :");
ltamt.setBounds(104,380,85,25);
add(ltamt);
tftamt=new JTextField(20);
tftamt.setBounds(230,380,120,20);
add(tftamt);
bsub=new JButton("SEARCH" ,new ImageIcon("images/setting.png"));
bsub.setBounds(300,643,110,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(470,643,100,30);
add(bclr);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(580,643,100,30);
add(bback);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:pat");
}
catch(Exception e)
{
System.out.println(e);
}
bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bback.addActionListener(new back());
try
{
Calendar cal=Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
df.setLenient(false);
System.out.println(df.format(cal.getTime()));
String dd1=df.format(cal.getTime());
temp=new JLabel(dd1);
temp.setBounds(694,178,80,20);
add(temp);
}
catch (Exception e)
{
new ErrorDialog2();
}
}
public void actionPerformed(ActionEvent ae)
{}
class clear implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tfno.setText("");
tfdateadd.setText("");
tfrtype.setText("");
tftamt.setText("");
}
}
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new start();
setVisible(false);
}
}
class submit extends Frame implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try
{
Integer no,num=Integer.parseInt(tfno.getText());
String name,room,dateadd,rtype;
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM PAT WHERE patientno="+num);
if(rs.next())
{
no=rs.getInt("patientno");
name=rs.getString("name");
dateadd=rs.getString("dateadd");
System.out.println(dateadd);
//d=rs.getString("dateadd");
rtype=rs.getString("rtype");
tfname.setText(name);
tfdateadd.setText(dateadd);
tfrtype.setText(rtype);
}
try
{
Calendar cal=Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
df.setLenient(false);
int dnow=cal.get(Calendar.DAY_OF_MONTH);
int mnow=cal.get(Calendar.MONTH);
int ynow=cal.get(Calendar.YEAR);
int mnowF=mnow+1;
//cal.setTime(df.parse(tfdateadd.getText()));
Calendar cal1=Calendar.getInstance();
cal1.setTime(df.parse(tfdateadd.getText()));
SimpleDateFormat sf2=new SimpleDateFormat("yyyy,MM,dd");
sf2.setLenient(false);
int daddd=cal1.get(Calendar.DAY_OF_MONTH);
int daddMM=cal1.get(Calendar.MONTH);
int daddYY=cal1.get(Calendar.YEAR);
int daddMMF=daddMM+1;
long from = new java.util.GregorianCalendar(ynow,mnowF,dnow).getTime().getTime();
long to = new java.util.GregorianCalendar(daddYY,daddMMF,daddd).getTime().getTime();
double difference = from-to;
long days = Math.round((difference/(1000*60*60*24)));
long bill=0;
String rt=tfrtype.getText();
if(rt.equals("Deluxe"))
{
System.out.println(tfrtype.getText());
int m=2000;
System.out.println(m);
bill=days*m;
System.out.println("total bill = "+bill);
}
if(rt.equals("Private"))
{
int m=800;
System.out.println(m);
bill=days*m;
System.out.println("total bill = "+bill);
}
if(rt.equals("Semi-Private"))
{
int m=600;
System.out.println(m);
bill=days*m;
System.out.println("total bill = "+bill);
}
if(rt.equals("General"))
{
int m=400;
System.out.println(m);
bill=days*m;
System.out.println("total bill = "+bill);
}
//Final Bill
String FinalBill=(new Long(bill)).toString();
tftamt.setText(FinalBill);
}
catch (Exception e)
{
//new ErrorDialog2();
System.out.println(e);
}
}
catch (SQLException sq)
{
System.out.println(sq);
}
}
}
public static void main(String[] args)
{
new Billing();
}
}
..............................................................
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class EDt
{
EDt()
{
String message ="Enter Valid Date";
JOptionPane.showMessageDialog(new JFrame(), message, "Error",
JOptionPane.ERROR_MESSAGE);
}
public static void main(String argv[])
{
new EDt();
}
}
.............................................
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class ErrorDialog
{
ErrorDialog()
{
String message = "Patient Number and Contact Number Must Contain Digits.";
JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!",
JOptionPane.ERROR_MESSAGE);
}
public static void main(String argv[])
{
new ErrorDialog();
}
}
................................................
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class ErrorDialog1
{
ErrorDialog1()
{
String message = "Invalid Name";
JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!",
JOptionPane.ERROR_MESSAGE);
}
public static void main(String argv[])
{
new ErrorDialog1();
}
}
.................................................................................
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class ErrorDialog2
{
ErrorDialog2()
{
String message = "Please Enter All The Fields";
JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!",
JOptionPane.ERROR_MESSAGE);
}
public static void main(String argv[])
{
new ErrorDialog2();
}
}
..........................................................................
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class ErrorDialog3
{
ErrorDialog3()
{
String message = "One of the field is Blank";
JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!",
JOptionPane.ERROR_MESSAGE);
}
public static void main(String argv[])
{
new ErrorDialog3();
}
}
...................................................................
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class InvalidPassError
{
InvalidPassError()
{
String message = "Invalid Username/Password";
JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!",
JOptionPane.ERROR_MESSAGE);
}
public static void main(String argv[])
{
new InvalidPassError();
}
}
.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.