智慧医疗信息系统实训 病人注册、登录、查询科室 、挂号医生登录、注册、查询病人挂号、诊断病人、给病人开检查、开药

智慧医疗信息系统实训(面向对象版本)

一、总体功能设计

二、功能设计

病人注册(自己实现)

用户登录(实训基本功能)

病人用户登录

查询科室

罗列出医院所有的科室供病人选择。

查询医生

选择科室后,罗列出该科室出诊的医生。

挂号

选择对应医生进行挂号。

医生用户登录(实训升阶功能)

查询挂号病人

罗列出已经挂号且待诊的病人列表。

诊断(实训自己完成功能)

询问症状,填写病历

检查(实训自己完成功能)

给病人开各类检查,例如:查血、ct、心电图等检查。

开药(实训自己完成功能)

给病人开药,从待诊病人列表中移除。

  • 数据库设计

创建医疗信息数据库(his),注意数据库字符集使用UTF-8。

  1. 医生表(doctor)

Id,username,password,depart_id

  1. 病人表(patient)

Id,username,password

  1. 科室表(department)

Id,departname

  1. 挂号表(regestraion)

Id,patient_id,doctor_id,reg_Date,dia_date

  1. 诊断表(diagnose)(选做)

Id,patient_id,doctor_id,dia_text

  1. 药品表(medicine)(选做)

Id,med_name,price,pesticideeffect,med_text

  1. 处方表(prescribe)(选做)

Id,patient_id,doctor_id,med_id

  1. 检查项目表(examination)(选做)

Id,exam_name,price,exam_Content, exam_text,doc_id

  1. 做检查表(make_examination)(选做)

Id,patient_id,doctor_id,exam_id

1.创建数据库通用包DButile类。

1)导入Java-MySQL连接包。

将解压文件中的

导入到系统中。 

  1. 创建用于数据库连接、数据操作类DBUtile

Login_2------第一个界面用于选择医生或者病人身份oksix
LoginJfram----病人界面用于登录或者选择注册okfour
Regis-----病人注册界面okthird

P_Main----欢迎病人登录成功(挂号)oksecond

QueryDeparMentsFram----用于病人查询有几个科室okfour
QueryDoctor-----用于病人查询某个科室里有几个医生的界面okfour

DoctorRegisterFr-----医生界面用于登录或者选择注册okfour
ReginsDoctor-----医生注册界面oktird
Doctorlook----医生成功登录(查看挂号)ok
QueryDoctorFr---医生查询挂自己号的病人ok
Doctorzhen----医生诊断病人书写结果

first----开药

second----开检查
QueryDoctorzhen---用于医生诊断一个病人结束后的下一步操作

1、Login_2------第一个界面用于选择医生或者病人身份oksix

package his;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.cqcet.fram.LoginJfram;
import com.cqcet.fram.P_Main;
import com.cqcet.fram.QueryDeparMentsFram;
import java.util.*;
	public class Login_2 extends JFrame implements ActionListener, ItemListener {
		JLabel usertype = new JLabel("请选择您的身份");
		ButtonGroup buttongroup = new ButtonGroup();
		JRadioButton yisheng = new JRadioButton("医生");
		JRadioButton huanzhe = new JRadioButton("病人");
		JRadioButton guanliyuan = new JRadioButton("管理员");

		JTextField text1 = new JTextField(18);
		JPasswordField text2 = new JPasswordField(18);
		public Login_2() {
			
			super("欢迎来到智慧医院");
			ImageIcon img = new ImageIcon("src/picture/six.jpg");
			JLabel imgLabel = new JLabel(img);
			this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
			imgLabel.setBounds(10,0,800,600 );
			Container contain = this.getContentPane();
			((JPanel) contain).setOpaque(false); 
			setLayout(null);
			setBounds(600,300,800,600);
			setVisible(true);
			setResizable(false);
			setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
			
			add(usertype);
			add(yisheng);
			add(huanzhe);
			add(guanliyuan);
			buttongroup.add(yisheng);
			buttongroup.add(huanzhe);
			buttongroup.add(guanliyuan);
			yisheng.addItemListener(this);
			huanzhe.addItemListener(this);
			guanliyuan.addItemListener(this);
		}
		public void itemStateChanged(ItemEvent e) {//三种身份按钮
			if (e.getSource() == yisheng) {
				new DoctorRegisterFr();//医生窗口
				setVisible(false);
			} else if (e.getSource() == huanzhe) {
				new LoginJfram();//病人窗口
				setVisible(false);
			} else if
			(e.getSource() == guanliyuan)
			{
				new QueryDeparMentsFram(null, getTitle());//管理员窗口
				setVisible(false);
			}
		}
		public static void main(String args[]) {
			new Login_2();
		}
		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			
		}

	}

2、LoginJfram----病人界面用于登录或者选择注册okfour

package com.cqcet.fram;
import java.awt.*;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.*;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import com.cqcet.dao.Login;
public class LoginJfram  extends JFrame{
	public LoginJfram (){
		setTitle("智慧医疗信息系统---病人界面");
		ImageIcon img = new ImageIcon("src/picture/four.jpg");
		JLabel imgLabel = new JLabel(img);
		this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
		imgLabel.setBounds(0,0,800,500 );
		Container contain = this.getContentPane();
		((JPanel) contain).setOpaque(false); 
		setLayout(null);
		setBounds(600,300,800,600);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		Container c=getContentPane();
		JLabel l=new JLabel();
		JTextField jt=new JTextField();
		jt.setText("");
		JPasswordField jp=new JPasswordField();
		JButton b=new JButton("登录");
		JButton b1=new JButton("取消");
		JButton b2=new JButton("注册");
		jt.setBounds(80, 80, 200, 30);
		c.add(jt);
		jp.setBounds(80, 120, 200,30);
		c.add(jp);
		JLabel l1=new JLabel("Name:");
		JLabel l2=new JLabel("Password:");
		l1.setBounds(15, 75, 50, 50);
		l2.setBounds(15, 105, 80, 50);
		c.add(l1);
		c.add(l2);
		b.setBounds(90, 170, 80, 50);
		b.setFont(new Font("",Font.PLAIN,15));
		b1.setBounds(210, 170, 80, 50);
		b1.setFont(new Font("",Font.PLAIN,15));
		b2.setBounds(0,170,80,50);
		b2.setFont(new Font("",Font.PLAIN,15));
		c.add(b1);
		c.add(b);
		c.add(b2);
		c.setBackground(Color.WHITE);
		setResizable(false);
		setVisible(true);
		
		b.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent actionEvent) {
				// TODO Auto-generated method stub
			System.out.println("Value:"+"\t\t"+jt.getText());
			char a[]=jp.getPassword();
			String b=new String(a);
			String b1=new String(jt.getText());
			System.out.println("password"+"\t"+b);
			System.err.println("----end----");
			
			
			Login lg=new Login(b1,b);
			String p_id=lg.login();
			if((Integer.parseInt(p_id)>=1)){
				System.out.println("登录成功");
				setVisible(false);
				new P_Main(b1,p_id);//跳转
			}else{
				System.out.println("登录失败");
			}
			}
		});
		b1.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent actionEvent) {
				// TODO Auto-generated method stub
				System.exit(0);
			}
		});
		b2.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent  actionEvent) {
				// TODO Auto-generated method stub
				new Regis();
			}
		});
	}

}

3、Regis-----病人注册界面okthird

package com.cqcet.fram;
	import java.awt.Color;
	import java.awt.Container;
	import java.awt.Font;
	import java.awt.event.ActionEvent;
	import java.awt.event.ActionListener;
	import java.sql.SQLException;

import javax.swing.ImageIcon;
import javax.swing.JButton;
	import javax.swing.JFrame;
	import javax.swing.JLabel;
	import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
	import javax.swing.JTextField;

	import om.cqcet.com.DBUtile;
	import com.mysql.jdbc.Connection;
	import com.mysql.jdbc.PreparedStatement;

	
	public class Regis extends JFrame{
		public Regis() {
			setTitle("病人注册页面");
			ImageIcon img = new ImageIcon("src/picture/third.jpg");
			JLabel imgLabel = new JLabel(img);
			this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
			imgLabel.setBounds(0,0,800,500 );
			Container contain = this.getContentPane();
			((JPanel) contain).setOpaque(false); 
			setLayout(null);
			setDefaultCloseOperation(EXIT_ON_CLOSE);
			setBounds(600,300,800,600);
			
			Container c=getContentPane();
			JLabel jl0=new JLabel();
			JTextField jt=new JTextField();
			
			JPasswordField jp=new JPasswordField();
			JPasswordField jp1=new JPasswordField();
			JButton b0=new JButton("注册");
			
			jt.setBounds(80,90,200,23);
			c.add(jt);
			jp.setBounds(80,120,200,23);
			c.add(jp);
			jp1.setBounds(80,150,200,23);
			c.add(jp1);
			JLabel jl1=new JLabel("Name:");
			JLabel jl2=new JLabel("password:");
			JLabel jl3=new JLabel("confirmapassword:");
			jl1.setBounds(15,75,50,50);
			jl2.setBounds(15,105,80,50);
			jl3.setBounds(15,135,80,50);
			c.add(jl1);
			c.add(jl2);
			c.add(jl3);
			b0.setBounds(90,200,100,60);
			b0.setFont(new Font("",Font.PLAIN,15));
			
			c.add(b0);
			
			c.setBackground(Color.WHITE);
			setResizable(false);
			setVisible(true);
			b0.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					// TODO Auto-generated method stub
					 String username = jt.getText();
		             String password = new String(jp.getPassword());
		             String confirmPassword = new String(jp1.getPassword());

		                // 验证密码是否一致
		                if (password.equals(confirmPassword)) {
		                    // 创建数据库连接
		                    Connection conn = (Connection) DBUtile.getConnection();
		                    if (conn != null) {
		                        try {
		                            // 准备SQL语句
		                            String sql = "INSERT INTO patient (username, password) VALUES (?, ?)";
		                            PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(sql);
		                            pstmt.setString(1, username);
		                            pstmt.setString(2, password);

		                            // 执行SQL语句
		                            int rowsAffected = pstmt.executeUpdate();
		                            if (rowsAffected > 0) {
		                                System.out.println("注册成功,用户名: " + username + ", 密码: " + password);
		                                // 关闭注册窗口
		                                dispose();
		                            } else {
		                                JOptionPane.showMessageDialog(null, "注册失败,请重试!");
		                            }

		                            // 关闭数据库连接
		                            conn.close(); // 使用标准JDBC的close方法关闭连接
		                        } catch (SQLException se) {
		                            se.printStackTrace();
		                        }
		                    }
		                } else {
		                    JOptionPane.showMessageDialog(null, "两次输入的密码不一致,请重新输入!");
		                }

				}
			});
			}
}

4、P_Main----欢迎病人登录成功(挂号)oksecond

package com.cqcet.fram;

import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.cqcet.dao.QueryDepartment;

		public class P_Main extends JFrame {
			String p_id=null;
			public P_Main(String username,String p_id){
				this.p_id=p_id;
				setTitle("病人主界面");
				setLayout(null);
				setBounds(600,300,800,600);
				setDefaultCloseOperation(EXIT_ON_CLOSE);
				
		JPanel jp1=new JPanel();
		jp1.setLayout(null);
		jp1.setBounds(20, 20, 760, 560);
		
		JLabel jl1=new JLabel("欢迎"+username+"病友登录");
		jl1.setBounds(300, 80, 190, 50);
		jl1.setFont(new Font("",Font.PLAIN,20));
		
		jp1.add(jl1);
		JButton jb1=new JButton("请您挂号");
		jb1.setFont(new Font("",Font.PLAIN,20));
		jb1.setBounds(300, 250, 160, 60);
		jp1.add(jb1);	
		add(jp1);
		setVisible(true);
		
		jb1.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				QueryDepartment qd=new QueryDepartment();
				ResultSet rs=qd.queryDepartment();
				QueryDeparMentsFram qdm=new QueryDeparMentsFram(rs,p_id);
				
			}
			
		});
	}

}

5、QueryDeparMentsFram----用于病人查询有几个科室okfour

package com.cqcet.fram;

import java.awt.Container;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.ResultSet;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

import com.cqcet.dao.QueryDepartment;
import com.cqcet.dao.QueryDoctor;

import om.cqcet.com.DBUtile;

import java.sql.ResultSetMetaData;

public class QueryDeparMentsFram extends JFrame{
	JTable table=null;
	DefaultTableModel tableModel;
			
	private Object[][]data=null;
	ResultSet rs=null;
	Vector<Vector<Object>> dataVector=null;
	String p_id=null;		
	public QueryDeparMentsFram(ResultSet rs,String p_id){
		this.rs=rs;		
		setTitle("病人查询科室界面");
		ImageIcon img = new ImageIcon("src/picture/four.jpg");
		JLabel imgLabel = new JLabel(img);
		this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
		imgLabel.setBounds(0,0,800,500 );
		Container contain = this.getContentPane();
		((JPanel) contain).setOpaque(false); 
		setLayout(null);
		setBounds(600,300,800,600);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		table=new JTable();
		tableModel=new DefaultTableModel();
		
		table.setModel(tableModel);
		JScrollPane scrollPane=new JScrollPane(table);
		scrollPane.setBounds(0, 0, 700, 450);
		this.add(scrollPane);
		this.setVisible(true);
		try{
			queryData();
		}catch(Exception e){
			
		}
	
	table.addMouseListener(new MouseAdapter(){
		public void mouseClicked(MouseEvent e){
			int index=table.getSelectedRow();
			String id=(String)table.getValueAt(index, 0);
			String sql="select * from doctor where depart_id="+id;
			DBUtile dbu=new DBUtile();
			ResultSet rs=dbu.query(sql);
			new QueryDoctor(rs,p_id);
		}
	});
	}

	private void queryData()  throws Exception{
		// TODO Auto-generated method stub
		  System.out.println("just test!");
	        int count=0;
	        ResultSetMetaData rsmd=null;
	        
	        rsmd=rs.getMetaData();
	        count=rsmd.getColumnCount();
	        
	        for(int i=1; i<=count;i++){
	            tableModel.addColumn(rsmd.getColumnName(i));
	        }
	        String[] row=new String[count];
	        while(rs.next()){
	            for(int i =0;i<count;i++){
	                row[i]=rs.getString(i+1);
	            }
	            tableModel.addRow(row);
	        }
	    }
}

	
	

6、QueryDoctor-----用于病人查询某个科室里有几个医生的界面okfour

package com.cqcet.dao;

import java.awt.Container;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

import his.Login_2;
import om.cqcet.com.DBUtile;

public class QueryDoctor  extends JFrame{
	JTable table =null;
	DefaultTableModel  tableModel;
	ResultSet rs=null;
	String p_id=null;
	public QueryDoctor(ResultSet rs, String p_id){
		this.rs=rs;
		this.p_id=p_id;
		setTitle("病人查询医生界面");
		ImageIcon img = new ImageIcon("src/picture/four.jpg");
		JLabel imgLabel = new JLabel(img);
		this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
		imgLabel.setBounds(0,0,800,500 );
		Container contain = this.getContentPane();
		((JPanel) contain).setOpaque(false); 
		setLayout(null);
		setBounds(600,300,800,600);
		//setBounds(100,100,800,600);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		table=new JTable();
		tableModel=new DefaultTableModel();
		table.setModel(tableModel);
		JScrollPane scrollPane=new JScrollPane(table);
		scrollPane.setBounds(0, 0, 700, 450);
		this.add(scrollPane);
		this.setVisible(true);
		try{
			queryData();
		}catch(Exception e){
			
		}
		table.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				// TODO Auto-generated method stub
				int index=table.getSelectedRow();
				String id=(String)table.getValueAt(index, 0);
				String sql="insert into regestraion(patient_id,doctor_id,reg_Date)values('"+p_id+"','"+id+"',now())";
				DBUtile dbu=new DBUtile();
				if(dbu.update(sql)>=1){
					System.out.println("挂号成功");
					Login_2 regFrame = new Login_2();
				}
			}
		});
	}
	private void queryData() throws Exception{
		int count=0;
		ResultSetMetaData rsmd=null;
		rsmd=rs.getMetaData();
		count=rsmd.getColumnCount();
		for(int i=1;i<=count;i++){
			tableModel.addColumn(rsmd.getColumnName(i));
		}
		String[] row=new String[count];
		while(rs.next()){
			for(int i=0;i<count;i++){
				row[i]=rs.getString(i+1);
				
			}
			tableModel.addRow(row);
			
	}
	}
}

7、DoctorRegisterFr-----医生界面用于登录或者选择注册okfour

package his;

import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import com.cqcet.dao.Login;
import com.cqcet.fram.P_Main;
import com.cqcet.fram.ReginsDoctor;


public class DoctorRegisterFr  extends JFrame{
	public DoctorRegisterFr (){
		setTitle("智慧医疗系统——医生界面");
		ImageIcon img = new ImageIcon("src/picture/four.jpg");
		JLabel imgLabel = new JLabel(img);
		this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
		imgLabel.setBounds(0,0,800,500 );
		Container contain = this.getContentPane();
		((JPanel) contain).setOpaque(false); 
		setLayout(null);
		setBounds(600,300,800,600);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		Container c=getContentPane();
		JLabel l=new JLabel();
		JTextField jt=new JTextField();
		jt.setText("");
		JPasswordField jp=new JPasswordField();
		JButton b=new JButton("登录");
		JButton b1=new JButton("取消");
		JButton b2=new JButton("注册");
		jt.setBounds(80, 80, 200, 30);
		c.add(jt);
		jp.setBounds(80, 120, 200,30);
		c.add(jp);
		JLabel l1=new JLabel("Name:");
		JLabel l2=new JLabel("Password:");
		l1.setBounds(15, 75, 50, 50);
		l2.setBounds(15, 105, 80, 50);
		c.add(l1);
		c.add(l2);
		b.setBounds(90, 170, 80, 50);
		b.setFont(new Font("",Font.PLAIN,15));
		b1.setBounds(210, 170, 80, 50);
		b1.setFont(new Font("",Font.PLAIN,15));
		b2.setBounds(0,170,80,50);
		b2.setFont(new Font("",Font.PLAIN,15));
		c.add(b1);
		c.add(b);
		c.add(b2);
		c.setBackground(Color.WHITE);
		setResizable(false);
		setVisible(true);
		
		
		b.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent actionEvent) {
				// TODO Auto-generated method stub
			System.out.println("Value:"+"\t\t"+jt.getText());
			char a[]=jp.getPassword();
			String b=new String(a);
			String b1=new String(jt.getText());
			String b2=new String(jt.getText());
			System.out.println("password"+"\t"+b);
			System.err.println("----end----");
			
			
			DoctorRegister lg=new DoctorRegister(b1,b,null);
			String d_id=lg.register();
			if((Integer.parseInt(d_id)>=1)){
				System.out.println("登录成功");
				setVisible(false);
				
				new Doctorlook(b1,d_id);//跳转
			}else{
				System.out.println("登录失败");
			}
			}
		});
		b1.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent actionEvent) {
				// TODO Auto-generated method stub
				System.exit(0);
			}
		});
		b2.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent  actionEvent) {
				// TODO Auto-generated method stub
				new ReginsDoctor();
			}
		});
	}

}

8、ReginsDoctor-----医生注册界面oktird

package com.cqcet.fram;

import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;

import om.cqcet.com.DBUtile;

public class ReginsDoctor extends JFrame {
	public ReginsDoctor() {
		setTitle("医生注册页面");
		ImageIcon img = new ImageIcon("src/picture/third.jpg");
		JLabel imgLabel = new JLabel(img);
		this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
		imgLabel.setBounds(0,0,800,500 );
		Container contain = this.getContentPane();
		((JPanel) contain).setOpaque(false); 
		setLayout(null);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setBounds(600,300,800,600);
		
		Container c=getContentPane();
		
		JLabel jl0=new JLabel();
		JTextField jt=new JTextField();
		JTextField jt1=new JTextField();
		JPasswordField jp=new JPasswordField();
		JPasswordField jp1=new JPasswordField();
		
		JButton b0=new JButton("注册");

		
		jt.setBounds(80,90,200,23);//xingming
		c.add(jt);
		
		jp.setBounds(80,120,200,23);//mima
		c.add(jp);
		jp1.setBounds(80,150,200,23);
		c.add(jp1);
		jt1.setBounds(80,180,200,23);//depart——id
		c.add(jt1);

		
		JLabel jl4=new JLabel("depart_id:");
		JLabel jl1=new JLabel("Name:");
		JLabel jl2=new JLabel("password:");
		JLabel jl3=new JLabel("confirmapassword:");
		jl1.setBounds(15,75,50,50);
		jl2.setBounds(15,105,80,50);
		jl3.setBounds(15,135,80,50);
		jl4.setBounds(15,165,80,50);
		c.add(jl1);
		c.add(jl2);
		c.add(jl3);
		c.add(jl4);
		b0.setBounds(100,220,100,50);
		b0.setFont(new Font("",Font.PLAIN,15));
		
		c.add(b0);
		
		c.setBackground(Color.WHITE);
		setResizable(false);
		setVisible(true);
		b0.addActionListener(new ActionListener() {  
		    @Override  
		    public void actionPerformed(ActionEvent e) {  
		        String username = jt.getText();  
		        String password = new String(jp.getPassword());  
		        String confirmPassword = new String(jp1.getPassword());  
		        String depart_id = jt1.getText();  
		  
		        // 验证密码是否匹配  
		        if (!password.equals(confirmPassword)) {  
		            JOptionPane.showMessageDialog(ReginsDoctor.this, "密码不匹配!", "错误", JOptionPane.ERROR_MESSAGE);  
		            return;  
		        }  
		        try (Connection conn = DBUtile.getConnection(); // 有一个静态方法getConnection()  
		             PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement("INSERT INTO doctor "
		             		+ "(username, password, depart_id) VALUES (?, ?, ?)")) {  
		  
		            pstmt.setString(1, username);  
		            pstmt.setString(2, password); 
		            pstmt.setString(3, depart_id);  
		  
		            int rowsAffected = pstmt.executeUpdate();  
		            if (rowsAffected > 0) {  
		                JOptionPane.showMessageDialog(ReginsDoctor.this, "注册成功!", "成功", JOptionPane.INFORMATION_MESSAGE);  
		                dispose();
		            } else {  
		                JOptionPane.showMessageDialog(ReginsDoctor.this, "注册失败!", "错误", JOptionPane.ERROR_MESSAGE);  
		            }  
		        } catch (SQLException ex) {  
		            ex.printStackTrace(); 
		            JOptionPane.showMessageDialog(ReginsDoctor.this, "数据库错误:" + ex.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);  
		        }  
		    }  
		});  }}

9、Doctorlook----医生成功登录(查看挂号)ok

package his;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import com.cqcet.dao.QueryDepartment;
import com.cqcet.fram.QueryDeparMentsFram;

public class Doctorlook extends JFrame {
	String d_id=null;
	public Doctorlook(String username,String d_id){
		this.d_id=d_id;
		setTitle("医生主界面");
		
		setLayout(null);
		setBounds(600,300,800,600);
		//setBounds(100,100,800,600);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		
JPanel jp1=new JPanel();
jp1.setLayout(null);
jp1.setBounds(20, 20, 760, 560);
JLabel jl1=new JLabel("欢迎"+username+"医生登录");
jl1.setFont(new Font("",Font.PLAIN,20));
jl1.setBounds(300, 80, 190, 50);
jp1.add(jl1);

JButton jb1=new JButton("请查看挂号");
jb1.setFont(new Font("",Font.PLAIN,20));
jb1.setBounds(300, 250, 160, 60);
jp1.add(jb1);	
add(jp1);
setVisible(true);

jb1.addActionListener(new ActionListener(){

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		QueryDoctor qd=new QueryDoctor();
		ResultSet rs=qd.querydoctor(d_id);
		
		QueryDoctorFr qdm=new QueryDoctorFr(rs,d_id);
		
	}
	
});
}

}

10、QueryDoctorFr---医生查询挂自己号的病人ok

package his;
import java.awt.Container;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import com.cqcet.dao.QueryDoctor;
import com.cqcet.zhen.Doctorzhen;
import om.cqcet.com.DBUtile;


public class QueryDoctorFr extends JFrame{
		JTable table=null;
		DefaultTableModel tableModel;
				
		private Object[][]data=null;
		ResultSet rs=null;
		Vector<Vector<Object>> dataVector=null;
		String d_id=null;		
		public QueryDoctorFr(ResultSet rs,String d_id){
			this.rs=rs;		
			setTitle("医生查询病人挂号界面");
			ImageIcon img = new ImageIcon("src/picture/four.jpg");
			JLabel imgLabel = new JLabel(img);
			this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
			imgLabel.setBounds(0,0,800,500 );
			Container contain = this.getContentPane();
			((JPanel) contain).setOpaque(false); 
			setLayout(null);
			//setBounds(100,100,800,600);
			setBounds(600,300,800,600);
			setDefaultCloseOperation(EXIT_ON_CLOSE);
			table=new JTable();
			tableModel=new DefaultTableModel();
			
			table.setModel(tableModel);
			JScrollPane scrollPane=new JScrollPane(table);
			scrollPane.setBounds(0, 0, 700, 450);
			this.add(scrollPane);
			this.setVisible(true);
			try{
				queryData();
			}catch(Exception e){
				
			}
		
		table.addMouseListener(new MouseAdapter(){
			public void mouseClicked(MouseEvent e){
				int index=table.getSelectedRow();
				String id=(String)table.getValueAt(index, 0);
				String sql="select * from doctor where depart_id="+id;
				DBUtile dbu=new DBUtile();
				ResultSet rs=dbu.query(sql);
				new Doctorzhen();
			}
		});
		}



		private void queryData()  throws Exception{
			// TODO Auto-generated method stub
			  System.out.println("just test!");
		        int count=0;
		        ResultSetMetaData rsmd=null;
		        
		        rsmd=rs.getMetaData();
		        count=rsmd.getColumnCount();
		        
		        for(int i=1; i<=count;i++){
		            tableModel.addColumn(rsmd.getColumnName(i));
		        }
		        String[] row=new String[count];
		        while(rs.next()){
		            for(int i =0;i<count;i++){
		                row[i]=rs.getString(i+1);
		            }
		            tableModel.addRow(row);}}}

11、Doctorzhen----医生诊断病人书写结果

package com.cqcet.zhen;

import javax.swing.*;

import his.Login_2;
import his.QueryDoctorFr;
import om.cqcet.com.DBUtile;
import java.awt.*;  
import java.awt.event.ActionEvent;  
import java.awt.event.ActionListener;  
import java.sql.Connection;  
import java.sql.PreparedStatement;  
import java.sql.SQLException;    
public class Doctorzhen extends JFrame {  
    private JTextField patientIdField;  
    private JTextField doctorIdField;  
    private JTextField diaTextField;  
  
    public Doctorzhen() {  
  
    	ImageIcon img = new ImageIcon("src/picture/second.jpg");
	
		JLabel imgLabel = new JLabel(img);
		
		this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
	
		imgLabel.setBounds(0,0,800,500 );
	
		Container contain = this.getContentPane();
		((JPanel) contain).setOpaque(false); 

        setTitle("医生诊断页面");  
        setLayout(null);
		setBounds(600,300,800,600);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
        
       
		JLabel patientIdLabel1 = new JLabel("病人ID:");
		patientIdLabel1.setBounds(50, 50, 60, 25); 
		add(patientIdLabel1);
        patientIdField = new JTextField(10); 
        patientIdField.setBounds(120, 50, 200, 25);  
        add(patientIdField);  
  
        JLabel doctorIdLabel = new JLabel("医生ID:");  
        doctorIdLabel.setBounds(50, 80, 60, 25);  
        add(doctorIdLabel);  
        doctorIdField = new JTextField(10);   
        doctorIdField.setBounds(120, 80, 200, 25);  
        add(doctorIdField);  
  
        JLabel diaTextLabel = new JLabel("诊断结果:");  
        diaTextLabel.setBounds(50, 110, 60, 25);  
        add(diaTextLabel);  
        diaTextField = new JTextField(10); 
        diaTextField.setBounds(120, 110, 200, 50);   
        add(diaTextField);  
       
        JButton saveButton = new JButton("保存");  
        saveButton.setBounds(150, 200, 100, 30);  
        saveButton.addActionListener(new ActionListener() {  
            @Override  
            public void actionPerformed(ActionEvent e) {  
                String patient_id = patientIdField.getText();  
                String doctor_id = new String(doctorIdField.getText());  
                String dia_text = diaTextField.getText();
  
                saveDiagnose(patient_id, doctor_id , dia_text); 
            }  
        });  
        add(saveButton);  
  
        setVisible(true);  
    }  
  
    private void saveDiagnose(String patient_id, String doctor_id, String dia_text) {  
        Connection conn = null;  
        PreparedStatement pstmt = null;  
        PreparedStatement deleteStmt = null; 
        try {  
          
            conn = DBUtile.getConnection(); 
  
            String sql = "INSERT INTO diagnose (patient_id, doctor_id, dia_text) VALUES (?, ?, ?)";  
  
            pstmt = conn.prepareStatement(sql);  
            pstmt.setString(1, patient_id);  
            pstmt.setString(2, doctor_id);  
            pstmt.setString(3, dia_text);  
  
            pstmt.executeUpdate();  
  
            JOptionPane.showMessageDialog(null, "诊断结果保存成功!");  
            
//            String sqlDelete = "DELETE FROM regestraion WHERE patient_id = ?"; 
//            deleteStmt = conn.prepareStatement(sqlDelete);  
//            deleteStmt.setString(1, patient_id);  
//            deleteStmt.executeUpdate();    
//            JOptionPane.showMessageDialog(null, "病人ID已被移除待诊病人!");
        } catch (SQLException ex) {  
          
            ex.printStackTrace();  
            JOptionPane.showMessageDialog(null, "保存诊断信息时出错:" + ex.getMessage());  
        } finally {  
           
            try {  
            	if (deleteStmt != null) deleteStmt.close(); 
               if (pstmt != null) pstmt.close();  
                if (conn != null) conn.close();  
               
                Second nextFrame = new Second(); 
                nextFrame.setVisible(true); 
               this.setVisible(false); 
               this.dispose();
               
            } catch (SQLException ex) {  
                ex.printStackTrace();  
            }  
        }  
    }  
  
    public static void main(String[] args) {  
        new Doctorzhen();  
    }  
}

12、first-医生开药界面

package com.cqcet.zhen;
import javax.swing.*;

	import his.Login_2;
	import his.QueryDoctorFr;
	import om.cqcet.com.DBUtile;
	import java.awt.*;  
	import java.awt.event.ActionEvent;  
	import java.awt.event.ActionListener;  
	import java.sql.Connection;  
	import java.sql.PreparedStatement;  
	import java.sql.SQLException;    
	public class First extends JFrame {  
	    private JTextField patientIdField;  
	    private JTextField doctorIdField;  
	    private JTextField diaTextField; 
	    private JTextField jiaoge;
	    private JTextField Pesticideeffect;
	    public First() {  
	    	ImageIcon img = new ImageIcon("src/picture/first.jpg");
			JLabel imgLabel = new JLabel(img);
			this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
			imgLabel.setBounds(0,0,800,500 );
			Container contain = this.getContentPane();
			((JPanel) contain).setOpaque(false); 
	        setTitle("医生开药界面");  
	        setLayout(null);
			setBounds(600,300,800,600);
			setDefaultCloseOperation(EXIT_ON_CLOSE);
			
			JLabel patientIdLabel1 = new JLabel("病人ID:");
			patientIdLabel1.setBounds(50, 50, 60, 25); 
			add(patientIdLabel1);
	        patientIdField = new JTextField(10); 
	        patientIdField.setBounds(120, 50, 200, 25);  
	        add(patientIdField);  
	  
	        JLabel doctorIdLabel = new JLabel("医生ID:");  
	        doctorIdLabel.setBounds(50, 80, 60, 25);  
	        add(doctorIdLabel);  
	        doctorIdField = new JTextField(10);   
	        doctorIdField.setBounds(120, 80, 200, 25);  
	        add(doctorIdField);  
	  
	        JLabel diaTextLabel = new JLabel("药物名称:");  
	        diaTextLabel.setBounds(50, 110, 60, 25);  
	        add(diaTextLabel);  
	        diaTextField = new JTextField(10); 
	        diaTextField.setBounds(120, 110, 200, 50);   
	        add(diaTextField);  
	        
	        
	        JLabel doctorIdLabel1jiaoge = new JLabel("价格:");  
	        doctorIdLabel1jiaoge.setBounds(50, 170, 60, 25);  
	        add(doctorIdLabel1jiaoge);  
	        jiaoge = new JTextField(10);   
	        jiaoge.setBounds(120, 170, 200, 25);  
	        add(jiaoge);  
	        
	     
	        JLabel doctorIdLabel1pes = new JLabel("备注:");  
	        doctorIdLabel1pes.setBounds(50, 200, 60, 25);  
	        add(doctorIdLabel1pes);  
	        Pesticideeffect = new JTextField(10);   
	        Pesticideeffect.setBounds(120, 200, 200, 25);  
	        add(Pesticideeffect);  
	        
	       
	     
	  
	        JButton saveButton = new JButton("保存");  
	        saveButton.setBounds(150, 300, 100, 30);  
	        saveButton.addActionListener(new ActionListener() {  
	            @Override  
	            public void actionPerformed(ActionEvent e) {  
	                String patient_id = patientIdField.getText();  
	                String doctor_id = new String(doctorIdField.getText());  
	                String med_name = diaTextField.getText();
	                String price = jiaoge.getText();
	                String pesticideeffect = new String(Pesticideeffect.getText());
	                
	  
	                saveDiagnose(patient_id, doctor_id , med_name,price,pesticideeffect); 
	            }  
	        });  
	        add(saveButton);  
	  
	        setVisible(true);  
	    }  
	  
	    private void saveDiagnose(String patient_id, String doctor_id, String med_name, String price, String pesticideeffect) {  
	        Connection conn = null;  
	        PreparedStatement pstmt = null;  
	        PreparedStatement deleteStmt = null; 
	        try {  
	          
	            conn = DBUtile.getConnection(); 
	  
	            String sql = "INSERT INTO medicine (patient_id, doctor_id, med_name,price,pesticideeffect) VALUES (?, ?, ?,?,?)";  
	  
	            pstmt = conn.prepareStatement(sql);  
	            pstmt.setString(1, patient_id);  
	            pstmt.setString(2, doctor_id);  
	            pstmt.setString(3, med_name);
	            pstmt.setString(4, price);
	            pstmt.setString(5, pesticideeffect);
	  
	            pstmt.executeUpdate();  
	  
	            JOptionPane.showMessageDialog(null, "开药信息保存成功!");  
	            
	            String sqlDelete = "DELETE FROM regestraion WHERE patient_id = ?"; 
	            deleteStmt = conn.prepareStatement(sqlDelete);  
	            deleteStmt.setString(1, patient_id);  
	            deleteStmt.executeUpdate();    
	            JOptionPane.showMessageDialog(null, "病人ID已被移除待诊病人!");
	        } catch (SQLException ex) {  
	          
	            ex.printStackTrace();  
	            JOptionPane.showMessageDialog(null, "保存诊断信息时出错:" + ex.getMessage());  
	        } finally {  
	           
	            try {  
	            	if (deleteStmt != null) deleteStmt.close(); 
	               if (pstmt != null) pstmt.close();  
	                if (conn != null) conn.close();  
	               
	                
	                
	                
	                QueryDoctorzhen nextFrame = new QueryDoctorzhen(); 
	                nextFrame.setVisible(true); 
	               this.setVisible(false); 
	               this.dispose();
	               
	            } catch (SQLException ex) {  
	                ex.printStackTrace();  
	            }  
	        }  
	    }  
	  
	    public static void main(String[] args) {  
	        new First();  
	    }  
	}

13、second-----医生检查界面

package com.cqcet.zhen;
import javax.swing.*;

		import his.Login_2;
		import his.QueryDoctorFr;
		import om.cqcet.com.DBUtile;
		import java.awt.*;  
		import java.awt.event.ActionEvent;  
		import java.awt.event.ActionListener;  
		import java.sql.Connection;  
		import java.sql.PreparedStatement;  
		import java.sql.SQLException;   

	
	 
		public class Second extends JFrame {  
		    private JTextField patientIdField;  
		    private JTextField doctorIdField;  
		    private JTextField diaTextField; 
		    private JTextField jiaoge;
		    private JTextField Pesticideeffect;
		    public Second() {  
		        setTitle("医生检查界面");  
		        ImageIcon img = new ImageIcon("src/picture/five.jpg");
				JLabel imgLabel = new JLabel(img);
				this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
				imgLabel.setBounds(0,0,800,500 );
				Container contain = this.getContentPane();
				((JPanel) contain).setOpaque(false); 
		        setLayout(null);
				setBounds(600,300,800,600);
				setDefaultCloseOperation(EXIT_ON_CLOSE);
				
				JLabel patientIdLabel1 = new JLabel("病人ID:");
				patientIdLabel1.setBounds(50, 50, 60, 25); 
				add(patientIdLabel1);
		        patientIdField = new JTextField(10); 
		        patientIdField.setBounds(120, 50, 200, 25);  
		        add(patientIdField);  
		  
		        JLabel doctorIdLabel = new JLabel("医生ID:");  
		        doctorIdLabel.setBounds(50, 80, 60, 25);  
		        add(doctorIdLabel);  
		        doctorIdField = new JTextField(10);   
		        doctorIdField.setBounds(120, 80, 200, 25);  
		        add(doctorIdField);  
		  
		        JLabel diaTextLabel = new JLabel("检查名称:");  
		        diaTextLabel.setBounds(50, 110, 60, 25);  
		        add(diaTextLabel);  
		        diaTextField = new JTextField(10); 
		        diaTextField.setBounds(120, 110, 200, 50);   
		        add(diaTextField);  
		        
		        
		        JLabel doctorIdLabel1jiaoge = new JLabel("价格:");  
		        doctorIdLabel1jiaoge.setBounds(50, 170, 60, 25);  
		        add(doctorIdLabel1jiaoge);  
		        jiaoge = new JTextField(10);   
		        jiaoge.setBounds(120, 170, 200, 25);  
		        add(jiaoge);  
		        
		     
		        JLabel doctorIdLabel1pes = new JLabel("检查备注:");  
		        doctorIdLabel1pes.setBounds(50, 200, 60, 25);  
		        add(doctorIdLabel1pes);  
		        Pesticideeffect = new JTextField(10);   
		        Pesticideeffect.setBounds(120, 200, 200, 25);  
		        add(Pesticideeffect);  
		        
		       
		     
		  
		        JButton saveButton = new JButton("保存");  
		        saveButton.setBounds(150, 300, 100, 30);  
		        saveButton.addActionListener(new ActionListener() {  
		            @Override  
		            public void actionPerformed(ActionEvent e) {  
		                String patient_id = patientIdField.getText();  
		                String doctor_id = new String(doctorIdField.getText());  
		                String exam_name = diaTextField.getText();
		                String price = jiaoge.getText();
		                String exam_text = new String(Pesticideeffect.getText());
		                
		  
		                saveDiagnose(patient_id, doctor_id , exam_name,price,exam_text); 
		            }  
		        });  
		        add(saveButton);  
		  
		        setVisible(true);  
		    }  
		  
		    private void saveDiagnose(String patient_id, String doctor_id, String exam_name, String price, String exam_text) {  
		        Connection conn = null;  
		        PreparedStatement pstmt = null;  
		        PreparedStatement deleteStmt = null; 
		        try {  
		          
		            conn = DBUtile.getConnection(); 
		  
		            String sql = "INSERT INTO make_examination (patient_id, doctor_id, exam_name,price,exam_text) VALUES (?, ?, ?,?,?)";  
		  
		            pstmt = conn.prepareStatement(sql);  
		            pstmt.setString(1, patient_id);  
		            pstmt.setString(2, doctor_id);  
		            pstmt.setString(3, exam_name);
		            pstmt.setString(4, price);
		            pstmt.setString(5, exam_text);
		  
		            pstmt.executeUpdate();  
		  
		            JOptionPane.showMessageDialog(null, "检查信息保存成功!");  
		            
//		            String sqlDelete = "DELETE FROM regestraion WHERE patient_id = ?"; 
//		            deleteStmt = conn.prepareStatement(sqlDelete);  
//		            deleteStmt.setString(1, patient_id);  
//		            deleteStmt.executeUpdate();    
//		            JOptionPane.showMessageDialog(null, "病人ID已被移除待诊病人!");
		        } catch (SQLException ex) {  
		          
		            ex.printStackTrace();  
		            JOptionPane.showMessageDialog(null, "保存检查信息时出错:" + ex.getMessage());  
		        } finally {  
		           
		            try {  
		            	if (deleteStmt != null) deleteStmt.close(); 
		               if (pstmt != null) pstmt.close();  
		                if (conn != null) conn.close();  
		               
		                
		                
		                
		                First nextFrame = new First(); 
		                nextFrame.setVisible(true); 
		               this.setVisible(false); 
		               this.dispose();
		               
		            } catch (SQLException ex) {  
		                ex.printStackTrace();  
		            }  
		        }  
		    }  
		  
		    public static void main(String[] args) {  
		        new First();  
		    }  
		}


14、QueryDoctorzhen---用于医生诊断一个病人结束后的下一步操作

package com.cqcet.zhen;    
import java.awt.*;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;

import javax.*;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import com.cqcet.dao.Login;

import his.DoctorRegisterFr;
import his.Login_2;
import his.QueryDoctor;
import his.QueryDoctorFr;

public class QueryDoctorzhen  extends JFrame{
	public QueryDoctorzhen (){
		setTitle("智慧医疗信息系统---请选择你的下一步");
		ImageIcon img = new ImageIcon("src/picture/first.jpg");
		JLabel imgLabel = new JLabel(img);
		this.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
		imgLabel.setBounds(0,0,800,500 );
		Container contain = this.getContentPane();
		((JPanel) contain).setOpaque(false); 
		setLayout(null);
		setBounds(600,300,800,600);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		Container c=getContentPane();
		JLabel l=new JLabel();
		JTextField jt=new JTextField();
		jt.setText("");
		JPasswordField jp=new JPasswordField();
	//	JButton b=new JButton("返回待诊断病人界面");
		JButton b1=new JButton("就诊结束返回医生界面");
		JButton b2=new JButton("工作结束返回主界面");
	//	b.setBounds(90, 150, 100, 60);
	//	b.setFont(new Font("",Font.PLAIN,7));
		b1.setBounds(400, 150, 200, 100);
		b1.setFont(new Font("",Font.PLAIN,15));
		b2.setBounds(100,150,200,100);
		b2.setFont(new Font("",Font.PLAIN,15));
		c.add(b1);
	//	c.add(b);
		c.add(b2);
		c.setBackground(Color.WHITE);
		setResizable(false);
		setVisible(true);
		
//		b.addActionListener(new ActionListener() {
//			
//			@Override
//			public void actionPerformed(ActionEvent actionEvent) {
//				// TODO Auto-generated method stub
//				
//					// TODO Auto-generated method stub
//					QueryDoctor qd=new QueryDoctor();
//					String d_id = null;
//					ResultSet rs=qd.querydoctor(d_id);
//					QueryDoctorFr qdm=new QueryDoctorFr(rs,d_id);
//			}
//		});
		
		b1.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent actionEvent) {
				// TODO Auto-generated method stub
				new DoctorRegisterFr();
			}
		});
		b2.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent  actionEvent) {
				// TODO Auto-generated method stub
				new Login_2();
			}
		});
	}

}

15、Department

package com.cqcet.dao;

public class Department {

	public Department(String string) {
		// TODO Auto-generated constructor stub
	}
	

}

16、Login

package com.cqcet.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import om.cqcet.com.DBUtile;

public class Login {
	private String username;
	private String password;
	
	public Login(String username,String password){
		this.username=username;
		this.password = password;
	}				
	public String login(){
	String ret=null;
	String sql="SELECT id FROM patient WHERE username='"+username+"'and password = '"+password+"'";
	DBUtile dbu=new DBUtile();
	ResultSet rs=dbu.query(sql);
	try{
		while(rs.next())
			ret=rs.getString(1);					
			
		}catch(SQLException e){
		e.printStackTrace();
		}
	return ret;
}
	
}


17、QueryDepartment

package com.cqcet.dao;

import java.sql.ResultSet;



import om.cqcet.com.DBUtile;

public class QueryDepartment {

	public ResultSet queryDepartment() {
		// TODO Auto-generated method stub
		ResultSet rs=null;
		DBUtile dbu=new DBUtile();
		String sql="select * from department";
		rs=dbu.query(sql);
		
		return rs;
	}

}

18、DoctorRegister

package his;
import java.sql.Connection;  
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;  
import om.cqcet.com.DBUtile;

public class DoctorRegister {
	private String username;
	private String password;
	private String depart_id;
	
	public DoctorRegister(String username,String password,String depart_id ){
		this.username=username;
		this.password=password;
		this.depart_id=depart_id;
	}
	
//	public int register(){
//		int ret=-1;
//		String sql="insert into doctor(username,password,depart_id)values('"+username+"',"+"'"+password+"','"+depart_id+"')";
//		DBUtile dbu=new DBUtile();
//		ret=dbu.update(sql);
//		return ret;
//	}
//}
	public String register (){
		String ret=null;
		String sql="SELECT id FROM doctor WHERE username='"+username+"'and password = '"+password+"'";
		DBUtile dbu=new DBUtile();
		ResultSet rs=dbu.query(sql);
		try{
			while(rs.next())
				ret=rs.getString(1);	
			System.out.println(ret);
				
			}catch(SQLException e){
			e.printStackTrace();
			}
		return ret;
	}
		
	}





20、HisTest

package his;



import com.cqcet.fram.LoginJfram;
import com.cqcet.zhen.Doctorzhen;
import com.cqcet.zhen.First;
import com.cqcet.zhen.QueryDoctorzhen;
import com.cqcet.zhen.Second;



public class HisTest {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
			new Login_2();
	
		
		}
		
}

21、QueryDoctor

package his;

import java.sql.ResultSet;

import om.cqcet.com.DBUtile;

public class QueryDoctor {

	public ResultSet querydoctor(String d_id) {
		// TODO Auto-generated method stub
		ResultSet rs=null;
		
		DBUtile dbu=new DBUtile();
		String sql="select * from regestraion  where doctor_id='"+d_id +"'";
		rs=dbu.query(sql);
		
		return rs;
	}

}

22、DBUtile

//package om.cqcet.com;
//
//import java.sql.Connection;
//import java.sql.DriverManager;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.sql.Statement;
//
//public class DBUtile {
//	private Connection conn=null;
//	private Statement st=null;
//	private ResultSet rs=null;
//	
//	public DBUtile(){
//		
//		try{
//		Class.forName("com.mysql.jdbc.Driver");
//		}catch(ClassNotFoundException e){
//			e.printStackTrace();
//	}
//		
//	try{
//		conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/his1","root","root");
//	}
//	catch(SQLException e){
//		e.printStackTrace();
//}
//	try{
//		st=conn.createStatement();
//		}
//	catch(SQLException e){
//		e.printStackTrace();
//	}	
//}
//	public int update(String sql){
//		System.out.println(sql);
//		int ret=-1;
//		try{
//			ret=st.executeUpdate(sql);
//		}catch (SQLException e) {
//			// TODO: handle exception
//			e.printStackTrace();
//		}
//		return ret;
//	}
//	
//	
//	
//	public ResultSet query(String sql){
//		System.out.println(sql);
//		try{
//			rs=st.executeQuery(sql);
//		}catch(SQLException e){
//			e.printStackTrace();
//		}
//		return rs;
//		}
//	public void close(){
//		if(rs!=null){
//			try{
//				rs.close();
//			}catch(SQLException e){
//				e.printStackTrace();
//			}
//		}
//		if(st!=null){
//			try{
//				st.close();
//			}catch(SQLException e){
//				e.printStackTrace();
//			}
//		}
//		if(conn!=null){
//			try{
//				conn.close();}
//			catch(SQLException e){
//				e.printStackTrace();
//			}
//		}
//	}
//}

package om.cqcet.com;

	import java.sql.*;

import com.mysql.jdbc.Connection;
	public class DBUtile {
		private java.sql.Connection conn;
		//做连接
		private Statement st;
		private ResultSet rs;
	    public  DBUtile(){
	    	try{
	    	Class.forName("com.mysql.jdbc.Driver");
	    	}catch(ClassNotFoundException e){
	    		e.printStackTrace();
	    	}
	    	try{
	    		conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/his1?characterEncoding=utf-8", "root","root");
	    	}catch(SQLException e){
	    		e.printStackTrace();
	    	}
	    	
	    		try {
					st=conn.createStatement();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	    
	    } 
	    public int  update(String sql){
	    	System.out.println(sql);
	    	int ret=-1;
	    	try{
	    		ret=st.executeUpdate(sql);
	    	}catch(SQLException e){
	    		e.printStackTrace();
	    	}
	    	return ret;
	    }
	    public ResultSet query(String sql){
	    	System.out.println(sql);
	    	try{
	    		rs=st.executeQuery(sql);
	    	}catch(SQLException e){
	    		e.printStackTrace();
	    	}
	    	return rs;
	    }
	    public void close(){
	    	if(rs!=null){
	    		try{
	    			rs.close();
	    		}catch(SQLException e){
	    			e.printStackTrace();
	    		}
	    	}
	    	if(st!=null){
	    		try{
	    			st.close();
	    		}catch(SQLException e){
	    			e.printStackTrace();
	    		}
	    	}
	    	if(conn!=null){
	    		try{
	    			conn.close();
	    		}catch(SQLException e){
	    			e.printStackTrace();
	    		}
	    	}
	    }
//		public static Connection getConnection() {
//			// TODO Auto-generated method stub
//			return null;
//		}
		// 获取数据库连接的静态方法
	    public static Connection getConnection() {
	        Connection conn = null;
	        try {
	            Class.forName("com.mysql.jdbc.Driver");
	            conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/his1?characterEncoding=utf-8", "root", "root");
	        } catch (ClassNotFoundException | SQLException e) {
	            e.printStackTrace();
	        }
	        return conn;
	    }

	    // 关闭数据库连接的静态
	    public static void closeConnection(Connection conn) {
	        if (conn != null) {
	            try {
	                conn.close();
	            } catch (SQLException e) {
	                e.printStackTrace();
	            }
	        }
	        }

	}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值