Académique Documents
Professionnel Documents
Culture Documents
Code /* * To change this template, choose Tools | Templates * and open the template in the editor. */
/* * frmLogin.java *
package hospitalmanagement;
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); txtUserId = new java.awt.TextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); txtPassword = new javax.swing.JPasswordField(); lblmsg = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("User Id");
jLabel2.setText("Password");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(33, 33, 33) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1) .addComponent(jLabel2)) .addGap(33, 33, 33) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE) .addComponent(jButton1) .addGap(18, 18, 18) .addComponent(jButton2) .addGap(32, 32, 32)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(txtPassword, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtUserId, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))) .addContainerGap(55, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(164, Short.MAX_VALUE) .addComponent(lblmsg) .addGap(194, 194, 194)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(lblmsg)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtUserId, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addContainerGap()) );
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if(txtUserId.getText().equals("H") && txtPassword.getText().equals("H")) { frmMain frm=new frmMain();
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.setVisible(false); }
/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new frmLogin().setVisible(true); } }); }
// Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel lblmsg; private javax.swing.JPasswordField txtPassword; private java.awt.TextField txtUserId; // End of variables declaration
Main
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
package hospitalmanagement;
* initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenu2 = new javax.swing.JMenu(); jMenu4 = new javax.swing.JMenu(); jMenu5 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}); jMenuBar1.add(jMenu1);
jMenu2.setText("Patient"); jMenu2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jMenu2MouseClicked(evt); } }); jMenuBar1.add(jMenu2);
jMenu4.setText("Billing"); jMenu4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jMenu4MouseClicked(evt); } }); jMenuBar1.add(jMenu4);
jMenu5.setText("Report");
} }); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenuItem1.addMenuKeyListener(new javax.swing.event.MenuKeyListener() { public void menuKeyPressed(javax.swing.event.MenuKeyEvent evt) { jMenuItem1MenuKeyPressed(evt); } public void menuKeyReleased(javax.swing.event.MenuKeyEvent evt) { } public void menuKeyTyped(javax.swing.event.MenuKeyEvent evt) { } }); jMenu5.add(jMenuItem1);
jMenuItem2.setText("Search Patient"); jMenuItem2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jMenuItem2MouseClicked(evt); } }); jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
jMenuItem3.setText("Bill Report"); jMenuItem3.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jMenuItem3MouseClicked(evt); } }); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); jMenu5.add(jMenuItem3);
jMenuBar1.add(jMenu5);
} }); jMenu3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenu3ActionPerformed(evt); } }); jMenuBar1.add(jMenu3);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 279, Short.MAX_VALUE) );
private void jMenu1MouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: frmDoctor frm=new frmDoctor(); frm.setVisible(true); }
private void jMenu2MouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: frmPatient frm=new frmPatient(); frm.show(); }
private void jMenu4MouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: frmBilling frm=new frmBilling(); frm.show(); }
private void jMenu3MouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: this.hide(); }
private void jMenuItem1MouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here:
private void jMenuItem2MouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: frmPatientSearch frm =new frmPatientSearch(); frm.show(); }
private void jMenuItem3MouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: frmReport frm=new frmReport(); frm.show(); }
private void jMenuItem1MenuKeyPressed(javax.swing.event.MenuKeyEvent evt) { // TODO add your handling code here: frmDoctorSearch frm=new frmDoctorSearch(); frm.setVisible(true); }
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: frmDoctorSearch frm=new frmDoctorSearch();
frm.setVisible(true); }
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: frmPatientSearch frm=new frmPatientSearch(); frm.setVisible(true); }
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: frmReport frm=new frmReport(); frm.setVisible(true); }
private void jMenu3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() {
// Variables declaration - do not modify private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenu jMenu4; private javax.swing.JMenu jMenu5; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JMenuItem jMenuItem3; // End of variables declaration
Doctor
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
/* * frmDoctor.java * */
package hospitalmanagement;
/** * * @author Administrator */ import java.sql.*; public class frmDoctor extends javax.swing.JFrame {
/** Creates new form frmDoctor */ static public final String driver = "com.mysql.jdbc.Driver"; static public final String connection = "jdbc:mysql://localhost:3306/hospital"; static public final String user = "root"; static public final String password = "";
Connection con; public frmDoctor() { initComponents(); try { Class.forName(driver); con = DriverManager.getConnection(connection, user, password);
getList();
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
jLabel1 = new javax.swing.JLabel(); txtId = new java.awt.TextField(); jLabel2 = new javax.swing.JLabel(); txtDoctor = new java.awt.TextField(); jLabel3 = new javax.swing.JLabel(); txtAddress = new java.awt.TextField(); jLabel4 = new javax.swing.JLabel(); txtPhone = new java.awt.TextField(); jLabel5 = new javax.swing.JLabel(); cmbSpecialist = new javax.swing.JComboBox(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); lst = new java.awt.List();
jLabel1.setText("Doctor ID");
jLabel2.setText("Doctor Name");
jLabel3.setText("Address");
jLabel4.setText("Phone");
jLabel5.setText("Specialist");
cmbSpecialist.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Eye", "Heart", "Nose", " ", " " }));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jLabel1) .addComponent(jLabel3) .addComponent(jLabel4) .addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txtPhone, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE) .addComponent(txtAddress, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE) .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtDoctor, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE) .addComponent(cmbSpecialist, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2) .addGap(18, 18, 18) .addComponent(jButton3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton4) .addGap(18, 18, 18) .addComponent(jButton5)) .addComponent(lst, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(41, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(43, 43, 43) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(txtDoctor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3) .addComponent(txtAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4) .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5) .addComponent(cmbSpecialist, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2) .addComponent(jButton3) .addComponent(jButton4) .addComponent(jButton5)) .addGap(19, 19, 19) .addComponent(lst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(48, Short.MAX_VALUE)) );
pack();
}// </editor-fold>
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.hide();
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { int id=1; Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select max(id) from Doctor"); if(rs.next()) { id=rs.getInt(1); } txtId.setText(Integer.toString(id));
} }
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { Statement st=con.createStatement(); st.execute("insert into Doctor(DoctorName,Address,Phone,Specialist) values('" + txtDoctor.getText() + "', '" + txtAddress.getText() + "', '"+txtPhone.getText()+"','"+cmbSpecialist.getName()+"')" ); getList();
} }
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if(lst.getSelectedItem()==null) { return;
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { Statement st=con.createStatement(); st.execute("Update Doctor set DoctorName='"+txtDoctor.getText()+"',Address='"+txtAddress.getText()+"',Phone='"+txtPhone.getText() +"',Specialist='"+cmbSpecialist.getName()+"' where DoctorName='"+lst.getSelectedItem()+"'"); getList(); }
private void lstActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select * from Doctor where DoctorName='"+lst.getSelectedItem()+"'"); if(rs.next()) { txtId.setText(rs.getString("id")); txtDoctor.setText(rs.getString("DoctorName")); txtAddress.setText(rs.getString("Address")); txtPhone.setText(rs.getString("Phone"));
} void getList(){ try{ lst.removeAll(); Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select * from Doctor order by DoctorName"); while(rs.next()){ lst.add(rs.getString("DoctorName")); } } catch(Exception ex){ System.out.println(ex.getMessage()); } } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new frmDoctor().setVisible(true); } });
// Variables declaration - do not modify private javax.swing.JComboBox cmbSpecialist; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private java.awt.List lst; private java.awt.TextField txtAddress; private java.awt.TextField txtDoctor; private java.awt.TextField txtId; private java.awt.TextField txtPhone; // End of variables declaration
Patient
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
package hospitalmanagement;
public class frmPatient extends javax.swing.JFrame { static public final String driver = "com.mysql.jdbc.Driver"; static public final String connection = "jdbc:mysql://localhost:3306/hospital";
static public final String user = "root"; static public final String password = ""; Connection con; /** Creates new form frmPatient */ public frmPatient() { initComponents(); try { Class.forName(driver); con = DriverManager.getConnection(connection, user, password); getList(); } catch(Exception ex) { System.out.println(ex.getMessage()); } }
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">
jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); txtId = new javax.swing.JTextField(); txtPatientName = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); txtAddress = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); txtPhone = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); txtDisease = new javax.swing.JTextField(); jLabel6 = new javax.swing.JLabel(); cmbDoctor = new java.awt.Choice(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); msg = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("ID");
jLabel2.setText("Patient Name");
jLabel3.setText("Address");
jLabel4.setText("Phone");
jLabel5.setText("Disease");
jLabel6.setText("Doctor");
jButton3ActionPerformed(evt); } });
msg.setText("-");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4) .addComponent(jLabel5) .addComponent(jLabel6)) .addGap(26, 26, 26) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jButton1) .addGap(26, 26, 26) .addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton3)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txtPatientName, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE) .addComponent(txtAddress, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE) .addComponent(txtPhone, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE) .addComponent(txtDisease, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE) .addComponent(cmbDoctor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(msg) .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(75, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addComponent(msg) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup()
.addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(txtPatientName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel2))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(24, 24, 24) .addComponent(jLabel3)) .addGroup(layout.createSequentialGroup() .addGap(18, 18, 18) .addComponent(txtAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4) .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(txtDisease, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5))
.addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel6) .addComponent(cmbDoctor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2) .addComponent(jButton3)) .addContainerGap()) );
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { int id=1; Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select max(id) from patient"); if(rs.next()) {
id=rs.getInt(1); } txtId.setText(Integer.toString(id));
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { Statement st=con.createStatement(); st.execute("insert into Patient(patientName,Address,Phone,Disease,Doctor) values('" + txtPatientName.getText() + "', '" + txtAddress.getText() + "', '"+txtPhone.getText()+"','"+txtDisease.getText()+"','"+cmbDoctor.getName()+"')" );
msg.setText("Save"); }
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.hide(); }
/** * @param args the command line arguments */ void getList(){ try{ cmbDoctor.removeAll(); Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select * from Doctor order by DoctorName"); while(rs.next()){ cmbDoctor.add(rs.getString("DoctorName")); } } catch(Exception ex){ System.out.println(ex.getMessage()); } }
public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new frmPatient().setVisible(true); } }); }
// Variables declaration - do not modify private java.awt.Choice cmbDoctor; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel msg; private javax.swing.JTextField txtAddress; private javax.swing.JTextField txtDisease; private javax.swing.JTextField txtId; private javax.swing.JTextField txtPatientName; private javax.swing.JTextField txtPhone;
Search Doctor
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
package hospitalmanagement;
/** * * @author Administrator */ import java.sql.*; public class frmDoctorSearch extends javax.swing.JFrame {
/** Creates new form frmDoctorSearch */ Connection con; static public final String driver = "com.mysql.jdbc.Driver"; static public final String connection = "jdbc:mysql://localhost:3306/hospital";
static public final String user = "root"; static public final String password = ""; public frmDoctorSearch() { initComponents(); try { Class.forName(driver); con = DriverManager.getConnection(connection, user, password); getList();
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
jLabel1 = new javax.swing.JLabel(); txtSearch = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); lst = new java.awt.List(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(69, 69, 69) .addComponent(lst, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup() .addGap(104, 104, 104) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButton4) .addGroup(layout.createSequentialGroup() .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(73, 73, 73) .addComponent(jButton1)))) .addGroup(layout.createSequentialGroup() .addGap(153, 153, 153) .addComponent(jLabel1))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(184, 184, 184) .addComponent(jButton2) .addContainerGap(232, Short.MAX_VALUE))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(241, Short.MAX_VALUE) .addComponent(jButton3) .addGap(175, 175, 175))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGap(27, 27, 27) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lst, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(22, 22, 22) .addComponent(jButton4) .addContainerGap(25, Short.MAX_VALUE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(152, 152, 152) .addComponent(jButton2) .addContainerGap(156, Short.MAX_VALUE))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(162, Short.MAX_VALUE) .addComponent(jButton3) .addGap(146, 146, 146))) );
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if(txtSearch.getText().equals("")) { System.out.println("Please Enter valid Doctor Name"); return;
} lst.removeAll(); try { Statement st=con.createStatement(); ResultSet rs= st.executeQuery("select * from Doctor where DoctorName='"+txtSearch.getText()+"'"); while(rs.next()) { lst.add(rs.getString("DoctorName")); } } catch(Exception ex) { System.out.println(ex.getMessage()); }
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.hide(); }
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.hide(); }
/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new frmDoctorSearch().setVisible(true); } });
} void getList(){ try{ lst.removeAll(); Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select * from Doctor order by DoctorName"); while(rs.next()){ lst.add(rs.getString("DoctorName")); } } catch(Exception ex){ System.out.println(ex.getMessage()); } } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JLabel jLabel1; private java.awt.List lst; private javax.swing.JTextField txtSearch; // End of variables declaration
Search Patient
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
package hospitalmanagement;
/** * * @author Administrator */ import java.sql.*; public class frmPatientSearch extends javax.swing.JFrame {
/** Creates new form frmPatientSearch */ static public final String driver = "com.mysql.jdbc.Driver"; static public final String connection = "jdbc:mysql://localhost:3306/hospital"; static public final String user = "root";
static public final String password = ""; Connection con; public frmPatientSearch() { initComponents(); try { Class.forName(driver); con = DriverManager.getConnection(connection, user, password); getList();
/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
jLabel1 = new javax.swing.JLabel(); txtSearch = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); lst = new java.awt.List(); jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(96, 96, 96) .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(331, Short.MAX_VALUE) .addComponent(jButton2) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(65, Short.MAX_VALUE) .addComponent(lst, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(56, 56, 56)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(154, Short.MAX_VALUE) .addComponent(jLabel1) .addGap(131, 131, 131)) ); layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(27, 27, 27) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1)) .addGap(29, 29, 29) .addComponent(lst, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE) .addComponent(jButton2)) );
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if(txtSearch.getText().equals("")) { System.out.println("Please Enter valid patient Name"); return;
lst.removeAll(); try { Statement st=con.createStatement(); ResultSet rs= st.executeQuery("select * from patient where patientName='"+txtSearch.getText()+"'"); while(rs.next()) { lst.add(rs.getString("PatientName")); } } catch(Exception ex) { System.out.println(ex.getMessage()); } }
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: this.hide(); }
/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new frmPatientSearch().setVisible(true); }
}); } void getList(){ try{ lst.removeAll(); Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select * from patient order by patientName"); while(rs.next()){ lst.add(rs.getString("patientName")); } } catch(Exception ex){ System.out.println(ex.getMessage()); } }
// Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private java.awt.List lst; private javax.swing.JTextField txtSearch; // End of variables declaration