⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 report.java

📁 This is basic hospital management system with essentials and is build on Java Swings."dscreen.java"
💻 JAVA
字号:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.util.*;

public class report extends JFrame implements ActionListener
{

	Connection conc;
        Statement stm;
        ResultSet res;
       	
	String xy,w;	
	Container you=getContentPane();
	JPanel pane1=new JPanel();
        JPanel pane=new JPanel();
	JLabel an;
	JLabel pr;
	JLabel pd;
	JLabel nm;	

	JLabel hp_lbl=new JLabel("HEALTH REPORT DETAILS");
	JButton home=new JButton("<<HOME");
	JButton hm=new JButton("<<HOME");
	JButton test=new JButton("CLINICAL TEST");
	JButton sub=new JButton("SUBMIT");
	JButton save=new JButton("SAVE");
	JButton rpt=new JButton("REPORT");
	JTextField a=new JTextField();
	JTextField c=new JTextField();
	JTextField b=new JTextField();
	JLabel id= new JLabel("PATIENT-ID");
	JLabel lab;
	JLabel ans= new JLabel("ANALYSIS");
        JLabel prc= new JLabel("PRESCRIPTION"); 

	JLabel lbl[]=new JLabel[8];
	JTextField txt[]=new JTextField[8];
	
	
	
	JComboBox tst;

	String col[]={"Temperature","Sputum Test","Blood Test","Widal Test","X-ray","Stool Test","Scanning","Urine Test"};

	ImageIcon func = new ImageIcon("kh.GIF");
	JLabel pc =new JLabel(new ImageIcon("kh.GIF"));
   
        
	public report(){
		
	
	
		super("HEALTH REPORT");
		setSize(1024,1024);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		pane.setLayout(null);	
		pane1.setLayout(null);
		you.setLayout(null);	


		lbl[0]= new JLabel("TEMPATURE");		
		lbl[1]= new JLabel("SPUTUM TEST");
        	lbl[2]= new JLabel("BLOOD TEST");
	        lbl[3]= new JLabel("WIDAL TEST");
        	lbl[4]= new JLabel("X-RAY");
	        lbl[5]= new JLabel("STOOL TEST");
        	lbl[6]= new JLabel("SCANNING");
	        lbl[7]= new JLabel("URINE TEST");
               

		txt[0]= new JTextField();		
		txt[1]= new JTextField();
        	txt[2]= new JTextField();        
	        txt[3]= new JTextField();
	        txt[4]= new JTextField();
        	txt[5]= new JTextField();
	        txt[6]= new JTextField();
	        txt[7]= new JTextField();  
		
		you.add(pane);
		you.add(pane1);
		for(int i=0;i<8;i++)
		{
		pane.add(lbl[i]);
		pane.add(txt[i]);
		}
		
		
		
		pane.add(home);
		pane1.add(hm);
		pane.add(hp_lbl);		
                pane.add(test);
		pane.add(id);
		pane.add(sub);
		pane.add(save);
		pane.add(rpt);
                pane.add(a);
		pane.add(b);
		pane.add(c);
		pane.add(ans);
		pane.add(prc);
		
		for(int i=0;i<8;i++)
		{
		lbl[i].setBounds(270,235+(i*47),100,25);
		txt[i].setBounds(365,245+(i*45),100,25);
		}
	
			
		
		sub.setBounds(600,100,100,30);
		test.setBounds(600,200,200,30);
		save.setBounds(600,300,100,30);
		home.setBounds(600,400,100,30);
		hm.setBounds(600,600,100,30);
		rpt.setBounds(600,500,100,30);
		hp_lbl.setBounds(300,5,200,30);
		prc.setBounds(165,185,100,50);
		id.setBounds(190,90,100,50);
        	ans.setBounds(190,135,100,50); 
    		c.setBounds(270,100,200,25);
		b.setBounds(270,190,200,25);
		a.setBounds(270,145,200,25);
		pane.setBounds(0,0,1024,768);

		
		hm.setVisible(false);
		setVisible(true);		
		pane1.setVisible(false);
	
		for(int i=0;i<8;i++)
		{
		lbl[i].setVisible(false);
		txt[i].setVisible(false);
		}
	
		hm.addActionListener(this);
		home.addActionListener(this);		
		test.addActionListener(this);
		sub.addActionListener(this);
		save.addActionListener(this); 
		rpt.addActionListener(this);
		
		try
        	{
			
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");		       
			conc = DriverManager.getConnection("jdbc:odbc:hos1");
			stm= conc.createStatement();
				         
                        tst=new JComboBox();
                }
                        catch(Exception b){System.out.println(""+b);}


 		try{
		
                  		res=stm.executeQuery("select * from pd ");		
				while(res.next()){
				tst.addItem(res.getString(2));
				}}
			catch(Exception r){
			System.out.println(""+r);}
			
			 pane.add(tst);
 	   	       	 tst.setBounds(200,40,150,20);
  			
	           }
	public void actionPerformed(ActionEvent event){
		Object data=event.getSource();
               		if(data==sub){				

	  
         					
			try{	

                                
 				res=stm.executeQuery("select * from pd where patname='"+tst.getSelectedItem()+"'");		
				res.next();
				w=res.getString("patname");
				a.setText(res.getString("analysis"));
				b.setText(res.getString("prescription"));
				xy=res.getString("patid");
				c.setText(xy);
				
		       	}
			catch(Exception y){
				System.out.println(""+y);
			}
                       }
		else if(data==home)
                    {
                      setVisible(false); 
                      dscreen dn=new dscreen();
                      dn.setSize(1024,1024);
                      dn.setVisible(true);
                    }   	

		else if(data==test)
		    {
	              
			for(int i=0;i<8;i++)
			{
			lbl[i].setVisible(true);
			txt[i].setVisible(true);
			}
	
        
	
       
         
                    }  	   

		else if(data==save)
		    {
			try
        	{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");		       
			conc = DriverManager.getConnection("jdbc:odbc:hos2");
			stm= conc.createStatement();
			
        	}catch(Exception t)  {System.out.println("error "+ t);} 
	try
	{
		stm.execute( "insert into rep values('"+c.getText()+"','"+a.getText()+"','"+b.getText()+"','"+txt[0].getText()+"','"+txt[1].getText()+"','"+txt[2].getText()+"','"+txt[3].getText()+"','"+txt[4].getText()+"','"+txt[5].getText()+ "','"+txt[6].getText()+"','"+txt[7].getText()+"')");	
			JOptionPane.showMessageDialog(null,"SAVED THE DETAILS SUCCESSFULLY");
			
			show(false);
			report rp=new report();
					
			}catch(Exception ts) {JOptionPane.showMessageDialog(null,"INVALID INPUTS");
							System.out.println(ts); }

		    }

   	 	
		else if(data==rpt)
		   {
				
		       try
        	{
			
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");		       
			conc = DriverManager.getConnection("jdbc:odbc:hos2");
			stm= conc.createStatement();
				         
                        
                }
                        catch(Exception b){System.out.println(""+b);}


 		
	  
         					
			try{	

                                
 				res=stm.executeQuery("select * from rep where pid='"+xy+"'");		
				res.next();
				nm=new JLabel("PATIENT NAME:    "+w+"\n\n");
				an=new JLabel("         ANALYSIS:     "+res.getString("analysis")+"\n\n");
				pr=new JLabel("PRESCRIPTION:     "+res.getString("prescription")+"\n\n");
				pd=new JLabel("      PATIENT-ID:    "+res.getString("pid")+"\n\n");

				
		       	}
			catch(Exception y){
				System.out.println(""+y);
			}
				String s2="";
			try{	
				
                                
 				res=stm.executeQuery("select * from rep where pid='"+xy+"'");		
				xy="";
				res.next();
				for(int i=0;i<8;i++)
				{s2=res.getString(col[i]);
				if(!s2.equals("Not needed"))
				xy=xy+"  "+col[i]+":     "+s2+"     ";
				}
			         
				
		       	}
			catch(Exception x){
				System.out.println(""+x);
			}

			
				lab= new JLabel(xy);
				pane1.add(nm);
				pane1.add(an);
				pane1.add(pr);
				pane1.add(pd);
				pane1.add(lab);
				pane1.add(pc);
				
				pc.setBounds(200,5,511,146);
				nm.setBounds(200,200,400,50);
				an.setBounds(200,300,400,50);
				pr.setBounds(200,550,400,50);
				pd.setBounds(200,250,400,50);
				lab.setBounds(200,350,500,50);
				pane1.setBounds(0,0,1024,768);
				pane.setVisible(false);
				pane1.setVisible(true);
				hm.setVisible(true);				             					
				
                       }

			else 
				{
				 setVisible(false);
	                         dscreen dsc=new dscreen();
 			 	 dsc.setVisible(true);
				}
	
			
    	 		
	}
	/* public static void main(String arg[])
{
 report qw=new report();
}*/
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -