📄 history.java
字号:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.util.*;
public class history extends JFrame implements ActionListener
{
Connection conc;
Statement stm;
ResultSet res;
JPanel pane=new JPanel();
JLabel id_lbl=new JLabel("SELECT THE PATIENT-ID");
JButton home=new JButton("<<HOME");
JButton sub=new JButton("SUBMIT");
JTextField a=new JTextField();
JTextField b=new JTextField();
JTextField c=new JTextField();
JTextField d=new JTextField();
JTextField e=new JTextField();
JTextField f=new JTextField();
JTextField g=new JTextField();
JTextField h=new JTextField();
JTextField i=new JTextField();
JLabel pn= new JLabel("PATIENT's NAME");
JLabel age= new JLabel("AGE");
JLabel doa= new JLabel("DATE OF ARRIVAL");
JLabel gen= new JLabel("GENDER");
JLabel oc= new JLabel("OCCUPATION");
JLabel addr= new JLabel("ADDRESS");
JLabel ph= new JLabel("PHONE_NO.");
JLabel ans= new JLabel("ANALYSIS");
JLabel prc= new JLabel("PRESCRIPTION");
JComboBox hist;
ImageIcon func = new ImageIcon("history.JPG");
JLabel pic =new JLabel(new ImageIcon("history.JPG"));
int xy=0;
public history(){
super("PATIENY HISTORY");
setSize(1024,1024);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pane.setLayout(null);
pane.add(home);
pane.add(id_lbl);
pane.add(a);
pane.add(b);
pane.add(c);
pane.add(d);
pane.add(e);
pane.add(f);
pane.add(g);
pane.add(h);
pane.add(i);
pane.add(sub);
pane.add(pic);
pane.add(pn);
pane.add(age);
pane.add(doa);
pane.add(gen);
pane.add(oc);
pane.add(addr);
pane.add(ph);
pane.add(ans);
pane.add(prc);
pic.setBounds(450,150,300,286);
pn.setBounds(165,90,100,50);
age.setBounds(235,135,80,50);
doa.setBounds(160,180,120,50);
gen.setBounds(210,225,80,50);
oc.setBounds(185,270,80,50);
addr.setBounds(205,310,80,50);
ph.setBounds(195,360,80,50);
prc.setBounds(175,450,100,50);
ans.setBounds(205,405,80,50);
home.setBounds(400,500,100,30);
sub.setBounds(200,500,100,30);
id_lbl.setBounds(300,5,200,30);
a.setBounds(270,100,100,25);
b.setBounds(270,145,100,25);
c.setBounds(270,190,100,25);
d.setBounds(270,235,100,25);
e.setBounds(270,280,100,25);
f.setBounds(270,325,100,25);
g.setBounds(270,370,100,25);
h.setBounds(270,415,100,25);
i.setBounds(270,460,100,25);
getContentPane().add(pane);
setVisible(true);
home.addActionListener(this);
sub.addActionListener(this);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conc = DriverManager.getConnection("jdbc:odbc:hos1");
stm= conc.createStatement();
hist=new JComboBox();
}
catch(Exception b){System.out.println(""+b);}
try{
res=stm.executeQuery("select * from pd ");
while(res.next()){
hist.addItem(res.getString(1));
}}
catch(Exception r){
System.out.println(""+r);}
pane.add(hist);
hist.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 patid='"+hist.getSelectedItem()+"'");
res.next();
a.setText(res.getString("patname"));
b.setText(res.getString("age"));
c.setText(res.getString("doa"));
d.setText(res.getString("gender"));
e.setText(res.getString("occupation"));
f.setText(res.getString("address"));
g.setText(res.getString("phonenum"));
h.setText(res.getString("analysis"));
i.setText(res.getString("prescription"));
}
catch(Exception y){
System.out.println(""+y);
}
}
else
{
setVisible(false);
dscreen dn=new dscreen();
dn.setSize(1024,1024);
dn.setVisible(true);
}
}
/*public static void main(String arg[])
{
history qw=new history();
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -