Java Swing医院就诊预约系统

news2025/1/20 3:35:48

一、系统概述

本系统是一款使用Java Swing开发的医院就诊预约系统,面向医院的医务人员和患者使用。

系统功能:

患者管理:添加/编辑/查询/删除患者信息
医生管理:添加/编辑/查询/删除医生信息
科室管理:添加/编辑/查询/删除科室信息
预约登记:患者选择医生和日期进行预约
预约查询:查询已预约记录
预约确认:医生对预约记录进行确认
统计报表:就诊统计报表

二、数据库设计

  1. doctor表
  • did:医生id,主键
  • dname:姓名
  • dsex:性别
  • dage:年龄
  • dtel:电话
  • department:科室

用于存储医生基本信息。

  1. medical_records表
  • id:编号,主键
  • pid:病人id,外键关联patient表
  • pathogen:病原体

用于存储患者就诊记录。

  1. nurse表
  • username:用户名,主键
  • password:密码

存储护士用户信息。

  1. patient表
  • pid:病人id,主键
  • pname:姓名
  • psex:性别
  • page:年龄
  • ptel:电话

存储病人基本信息。

  1. queue表
  • visitnumber:就诊号,主键
  • did:医生id,外键关联doctor表
  • pid:病人id,外键关联patient表
  • starttime:开始时间
  • endtime:结束时间
  • paymoney:支付费用

存储就诊排队信息。

关系:

patient表与medical_records表一对多
queue表与patient表一对多
queue表与doctor表一对多

三、界面设计

##登录界面
包含用户名密码登录验证。
在这里插入图片描述

注册界面

在这里插入图片描述

挂号

在这里插入图片描述

排队

在这里插入图片描述

付款

在这里插入图片描述

统计

在这里插入图片描述

四、技术选型

开发工具:Eclipse
数据库:MySQL
前端框架:Java Swing
后端技术:Java,JDBC

五、代码

login.java

import util.JDBCCon;

import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.awt.*;
import java.awt.event.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;

public class Main {
    private String username;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Main() {
        JFrame frame = new JFrame("病人就医管理");//新建容器对象
        frame.setSize(600,500);//设置容器大小
        frame.setLocation(500,250);//设置位置
        JTabbedPane jTabbedPane = new JTabbedPane();
        //挂号
        JPanel registered = new JPanel();
        JPanel jPanel = new JPanel();
        jPanel.setLayout(new GridLayout(10,3,1,5));
        JLabel pid = new JLabel("身份证");
        JTextField pidtext = new JTextField(15);
        pidtext.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {

            }

            @Override
            public void keyPressed(KeyEvent e) {

            }

            @Override
            public void keyReleased(KeyEvent e) {
                if(pidtext.getText().length()>=18){
                    pidtext.setText(pidtext.getText().substring(0,18));
                }
            }
        });
        JLabel pname = new JLabel("姓名");
        JTextField pnametext = new JTextField(15);
        JLabel psex = new JLabel("性别");
        JComboBox<String> psexbox = new JComboBox<>();
        psexbox.addItem("男");
        psexbox.addItem("女");
        JLabel page = new JLabel("年龄");
        JTextField pagetext = new JTextField(15);
        JLabel ptel = new JLabel("联系电话");
        JTextField pteltext = new JTextField(15);
        pteltext.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {

            }

            @Override
            public void keyPressed(KeyEvent e) {

            }

            @Override
            public void keyReleased(KeyEvent e) {
                if(pteltext.getText().length()>=11){
                    pteltext.setText(pteltext.getText().substring(0,11));
                }
            }
        });
        JLabel pathogen = new JLabel("症状");
        JTextField pathogentext = new JTextField();
        JLabel department = new JLabel("科室");
        JComboBox<String> departmentbox = new JComboBox<>();
        JLabel doctor = new JLabel("医生");//联动效果
        JComboBox<String> doctorbox = new JComboBox<>();
        JDBCCon con = new JDBCCon();
        ResultSet query = con.query("select distinct department from doctor");
        ResultSet query2 = con.query("select dname from doctor where department='内科'");
        ArrayList<String> departments = new ArrayList<>();
        ArrayList<String> dnames = new ArrayList<>();
        while (true){
            try {
                if (!query.next() ||!query2.next()) break;
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                departments.add(query.getString("department"));
                dnames.add(query2.getString("dname"));
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        for (String s : departments) {
            departmentbox.addItem(s);
        }
        for (String dname : dnames) {
            doctorbox.addItem(dname);
        }
        departmentbox.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String nowdepartment = departmentbox.getItemAt(departmentbox.getSelectedIndex());
                doctorbox.removeAllItems();
                ResultSet query1 = con.query("select dname from doctor where department=?", nowdepartment);
                while (true){
                    try {
                        if (!query1.next()) break;
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                    try {
                        doctorbox.addItem(query1.getString("dname"));
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
            }
        });
        JButton regist = new JButton("挂号");
        JButton clear = new JButton("清空");
        jPanel.add(pid);
        jPanel.add(pidtext);
        jPanel.add(pname);
        jPanel.add(pnametext);
        jPanel.add(psex);
        jPanel.add(psexbox);
        jPanel.add(page);
        jPanel.add(pagetext);
        jPanel.add(ptel);
        jPanel.add(pteltext);
        jPanel.add(pathogen);
        jPanel.add(pathogentext);
        jPanel.add(department);
        jPanel.add(departmentbox);
        jPanel.add(doctor);
        jPanel.add(doctorbox);
        jPanel.add(regist);
        jPanel.add(clear);
        jPanel.add(new JLabel("这个本来是刷卡后获取数据的,由于"));
        jPanel.add(new JLabel("没有相应的设备,故采用人工填写"));
        registered.add(jPanel);
        //排队
        JPanel lineup = new JPanel();
        final String[] lineupmsg={"序号","科室","姓名","就诊医生"};
        ResultSet query1 = con.query("select visitnumber,department,pname,dname from queue,doctor,patient where doctor.did=queue.did and queue.pid=patient.pid and starttime is not null and endtime is null order by department,dname");
        //表格信息
        final Vector<Vector<Comparable>> vect = new Vector();//初始化向量
        //表格模型
        AbstractTableModel tm = new AbstractTableModel() {// 实现AbstractTableModel的抽象方法
            private static final long serialVersionUID = 1L;

            public int getColumnCount() {
                return lineupmsg.length;
            }

            public int getRowCount() {
                // TODO 自动生成的方法存根
                return vect.size();
            }

            public Object getValueAt(int row, int column) {
                // TODO 自动生成的方法存根
                if (!vect.isEmpty())
                    return (((Vector<?>) vect.elementAt(row)).elementAt(column));
                else
                    return null;
            }

            public String getColumnName(int column) {
                return lineupmsg[column];// 设置表格列名
            }

            public void setValueAt(Object value, int row, int column) {
            }

            public Class<? extends Object> getColumnClass(int c) {
                return getValueAt(0, c).getClass();
            }// 取得所属对象类

            public boolean isCellEditable(int row, int column) {

                return false;
            }// 设置单元格不可编辑
        };
        //新建排队信息表格类
        JTable queueTable = new JTable(tm);
        queueTable.setRowHeight(20);
        queueTable.setPreferredScrollableViewportSize(new Dimension(560,200));
        queueTable.setToolTipText("显示所有的排队信息");
        //排队信息表自动调整
        queueTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        //设置单元格分割线
        queueTable.setShowHorizontalLines(true);
        queueTable.setShowVerticalLines(true);
        //滚轮,将滚轮绑定表格
        JScrollPane scrollPane = new JScrollPane(queueTable);
        //将获取到的数据加进表格中
        vect.removeAllElements();// 初始化向量对象
        tm.fireTableStructureChanged();// 更新表格内容
        while (true) {
            try {
                if (!query1.next()) break;
            } catch (SQLException e) {
                e.printStackTrace();
            }
            @SuppressWarnings("rawtypes")
            Vector<Comparable> v = new Vector<Comparable>();
            try {
                v.add(query1.getInt(1));
                v.add(query1.getString(2));
                v.add(query1.getString(3));
                v.add(query1.getString(4));
                vect.add(v);
                tm.fireTableStructureChanged();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        JLabel label = new JLabel("科室");
        JComboBox<String> comboBox = new JComboBox<>();
        JLabel label1 = new JLabel("医生");
        JComboBox<String> comboBox1 = new JComboBox<>();
        ResultSet query3 = con.query("select distinct department from queue,doctor where queue.did=doctor.did and starttime is not null and endtime is null");
        while(true){
            try {
                if (!query3.next()) break;
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                comboBox.addItem(query3.getString("department"));
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        comboBox.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                comboBox1.removeAllItems();
                ResultSet query4 = con.query("select distinct dname from queue,doctor where queue.did=doctor.did and starttime is not null and endtime is null and department=?",comboBox.getItemAt(comboBox.getSelectedIndex()));
                while(true){
                    try {
                        if (!query4.next()) break;
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                    try {
                        comboBox1.addItem(query4.getString("dname"));
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
            }
        });
        JButton search = new JButton("查询");
        JLabel ceshi = new JLabel("测试");
        JLabel jLabel = new JLabel("  目前排队人数:");
        lineup.add(jLabel);
        lineup.add(ceshi);
        JLabel jLabel1 = new JLabel("人     ");
        lineup.add(jLabel1);
        jLabel.setVisible(false);
        jLabel1.setVisible(false);
        ceshi.setVisible(false);
        search.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String itemAt = comboBox1.getItemAt(comboBox1.getSelectedIndex());
                ResultSet query4 = con.query("select visitnumber,department,pname,dname from queue,doctor,patient where doctor.did=queue.did and queue.pid=patient.pid and starttime is not null and endtime is null and dname=?", itemAt);
                //刷新页面
                vect.removeAllElements();// 初始化向量对象
                tm.fireTableStructureChanged();// 更新表格内容
                while (true) {
                    try {
                        if (!query4.next()) break;
                    } catch (SQLException ec) {
                        ec.printStackTrace();
                    }
                    @SuppressWarnings("rawtypes")
                    Vector<Comparable> v = new Vector<Comparable>();
                    try {
                        v.add(query4.getInt(1));
                        v.add(query4.getString(2));
                        v.add(query4.getString(3));
                        v.add(query4.getString(4));
                        vect.add(v);
                        tm.fireTableStructureChanged();
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
                //新增组件查看排队的情况
                ResultSet query5 = con.query("select count(*) number from queue,doctor,patient where doctor.did=queue.did and queue.pid=patient.pid and starttime is not null and endtime is null and dname=?", itemAt);
                while (true){
                    try {
                        if (!query5.next()) break;
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                    try {
                        ceshi.setText(String.valueOf(query5.getInt("number")));
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
                jLabel.setVisible(true);
                jLabel1.setVisible(true);
                ceshi.setVisible(true);
            }
        });
        lineup.add(label);
        lineup.add(comboBox);
        lineup.add(label1);
        lineup.add(comboBox1);
        lineup.add(search);
        lineup.add(scrollPane);
        JLabel visitnumber = new JLabel("序号");
        JTextField visitnumbertext = new JTextField(10);
        JLabel keshi = new JLabel("科室");
        JTextField keshitext = new JTextField(10);
        JLabel xingming = new JLabel("姓名");
        JTextField xingmingtext = new JTextField(10);
        JLabel jiuzheng = new JLabel("就诊医生");
        JTextField jiuzhengtext = new JTextField(10);
        JButton seeAdoctor = new JButton("就诊");
        lineup.add(visitnumber);
        lineup.add(visitnumbertext);
        lineup.add(keshi);
        lineup.add(keshitext);
        lineup.add(xingming);
        lineup.add(xingmingtext);
        lineup.add(jiuzheng);
        lineup.add(jiuzhengtext);
        lineup.add(seeAdoctor);
        queueTable.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                if(e.getClickCount()==2){
                    //双击事件
                    int row = queueTable.getSelectedRow();
                    visitnumbertext.setText(String.valueOf(queueTable.getValueAt(row,0)));
                    keshitext.setText((String) queueTable.getValueAt(row,1));
                    xingmingtext.setText((String) queueTable.getValueAt(row,2));
                    jiuzhengtext.setText((String) queueTable.getValueAt(row,3));
                }
            }
        });

        //付款
        JPanel pay = new JPanel();
        final String[] paymsg={"序号","科室","姓名","就诊医生"};
        ResultSet query6 = con.query("select visitnumber,department,pname,dname from queue,doctor,patient where doctor.did=queue.did and queue.pid=patient.pid and starttime is not null and endtime is not null and paymoney is null order by department,dname");
        //表格信息
        final Vector<Vector<Comparable>> vect1 = new Vector();//初始化向量
        //表格模型
        AbstractTableModel tm1 = new AbstractTableModel() {// 实现AbstractTableModel的抽象方法
            private static final long serialVersionUID = 1L;

            public int getColumnCount() {
                return paymsg.length;
            }

            public int getRowCount() {
                // TODO 自动生成的方法存根
                return vect1.size();
            }

            public Object getValueAt(int row, int column) {
                // TODO 自动生成的方法存根
                if (!vect.isEmpty())
                    return (((Vector<?>) vect1.elementAt(row)).elementAt(column));
                else
                    return null;
            }

            public String getColumnName(int column) {
                return paymsg[column];// 设置表格列名
            }

            public void setValueAt(Object value, int row, int column) {
            }

            public Class<? extends Object> getColumnClass(int c) {
                return getValueAt(0, c).getClass();
            }// 取得所属对象类

            public boolean isCellEditable(int row, int column) {

                return false;
            }// 设置单元格不可编辑
        };
        //新建排队信息表格类
        JTable payTable = new JTable(tm1);
        payTable.setRowHeight(20);
        payTable.setPreferredScrollableViewportSize(new Dimension(560,200));
        payTable.setToolTipText("显示所有的排队信息");
        //排队信息表自动调整
        payTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        //设置单元格分割线
        payTable.setShowHorizontalLines(true);
        payTable.setShowVerticalLines(true);
        //滚轮,将滚轮绑定表格
        JScrollPane scrollPane1 = new JScrollPane(payTable);
        //将获取到的数据加进表格中
        vect1.removeAllElements();// 初始化向量对象
        tm1.fireTableStructureChanged();// 更新表格内容
        while (true) {
            try {
                if (!query6.next()) break;
            } catch (SQLException e) {
                e.printStackTrace();
            }
            @SuppressWarnings("rawtypes")
            Vector<Comparable> v = new Vector<Comparable>();
            try {
                v.add(query6.getInt(1));
                v.add(query6.getString(2));
                v.add(query6.getString(3));
                v.add(query6.getString(4));
                vect1.add(v);
                tm1.fireTableStructureChanged();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        pay.add(scrollPane1);
        JLabel visitnumber1 = new JLabel("序号");
        JTextField visitnumbertext1 = new JTextField(10);
        JLabel keshi1 = new JLabel("科室");
        JTextField keshitext1 = new JTextField(10);
        JLabel xingming1 = new JLabel("姓名");
        JTextField xingmingtext1 = new JTextField(10);
        JLabel jiuzheng1 = new JLabel("就诊医生");
        JTextField jiuzhengtext1 = new JTextField(10);
        JLabel payLabel = new JLabel("付款金额:");
        JTextField paytext = new JTextField(10);
        JButton paymoney = new JButton("付款");
        pay.add(visitnumber1);
        pay.add(visitnumbertext1);
        pay.add(keshi1);
        pay.add(keshitext1);
        pay.add(xingming1);
        pay.add(xingmingtext1);
        pay.add(jiuzheng1);
        pay.add(jiuzhengtext1);
        pay.add(payLabel);
        pay.add(paytext);
        pay.add(paymoney);
        payTable.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                if(e.getClickCount()==2){
                    int row = payTable.getSelectedRow();
                    visitnumbertext1.setText(String.valueOf(payTable.getValueAt(row,0)));
                    keshitext1.setText(String.valueOf(payTable.getValueAt(row,1)));
                    xingmingtext1.setText(String.valueOf(payTable.getValueAt(row,2)));
                    jiuzhengtext1.setText(String.valueOf(payTable.getValueAt(row,3)));
                }
            }
        });
        JPanel tongji = new JPanel();
        final String[] tongjimsg={"科室","花费","总看病人数"};
        ResultSet query9 = con.query("select department,sum(paymoney),count(*) from queue,doctor where doctor.did=queue.did group by department");
        //表格信息
        final Vector<Vector<Comparable>> vect3 = new Vector();//初始化向量
        //表格模型
        AbstractTableModel tm3 = new AbstractTableModel() {// 实现AbstractTableModel的抽象方法
            private static final long serialVersionUID = 1L;

            public int getColumnCount() {
                return tongjimsg.length;
            }

            public int getRowCount() {
                // TODO 自动生成的方法存根
                return vect3.size();
            }

            public Object getValueAt(int row, int column) {
                // TODO 自动生成的方法存根
                if (!vect3.isEmpty())
                    return (((Vector<?>) vect3.elementAt(row)).elementAt(column));
                else
                    return null;
            }

            public String getColumnName(int column) {
                return tongjimsg[column];// 设置表格列名
            }

            public void setValueAt(Object value, int row, int column) {
            }

            public Class<? extends Object> getColumnClass(int c) {
                return getValueAt(0, c).getClass();
            }// 取得所属对象类

            public boolean isCellEditable(int row, int column) {

                return false;
            }// 设置单元格不可编辑
        };
        //新建排队信息表格类
        JTable tongjiTable = new JTable(tm3);
        tongjiTable.setRowHeight(20);
        tongjiTable.setPreferredScrollableViewportSize(new Dimension(560,200));
        tongjiTable.setToolTipText("显示所有的统计信息");
        //排队信息表自动调整
        tongjiTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        //设置单元格分割线
        tongjiTable.setShowHorizontalLines(true);
        tongjiTable.setShowVerticalLines(true);
        //滚轮,将滚轮绑定表格
        JScrollPane scrollPane3 = new JScrollPane(tongjiTable);
        //将获取到的数据加进表格中
        vect3.removeAllElements();// 初始化向量对象
        tm3.fireTableStructureChanged();// 更新表格内容
        while (true) {
            try {
                if (!query9.next()) break;
            } catch (SQLException e) {
                e.printStackTrace();
            }
            @SuppressWarnings("rawtypes")
            Vector<Comparable> v = new Vector<Comparable>();
            try {
                v.add(query9.getString(1));
                v.add(query9.getDouble(2));
                v.add(query9.getInt(3));
                vect3.add(v);
                tm3.fireTableStructureChanged();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        tongji.add(scrollPane3);
        paymoney.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String visitnumber = visitnumbertext1.getText();
                double money=0.0;
                if(!paytext.getText().equals("")){
                    //输入金额不为空
                    money= Double.parseDouble(paytext.getText());
                    con.update("update queue set paymoney=? where visitnumber=?",visitnumber,money);
                    JOptionPane.showMessageDialog(null,"付款成功","成功",JOptionPane.INFORMATION_MESSAGE);
                    //更新表格3
                    ResultSet query8 = con.query("select visitnumber,department,pname,dname from queue,doctor,patient where doctor.did=queue.did and queue.pid=patient.pid and starttime is not null and endtime is not null and paymoney is null order by department,dname");
                    vect1.removeAllElements();// 初始化向量对象
                    tm1.fireTableStructureChanged();// 更新表格内容
                    while (true) {
                        try {
                            if (!query8.next()) break;
                        } catch (SQLException ec) {
                            ec.printStackTrace();
                        }
                        @SuppressWarnings("rawtypes")
                        Vector<Comparable> v = new Vector<Comparable>();
                        try {
                            v.add(query8.getInt(1));
                            v.add(query8.getString(2));
                            v.add(query8.getString(3));
                            v.add(query8.getString(4));
                            vect1.add(v);
                            tm1.fireTableStructureChanged();
                        } catch (SQLException ex) {
                            ex.printStackTrace();
                        }
                    }
                    //更新表格4
                    ResultSet query10 = con.query("select department,sum(paymoney),count(*) from queue,doctor where doctor.did=queue.did group by department");
                    vect3.removeAllElements();// 初始化向量对象
                    tm3.fireTableStructureChanged();// 更新表格内容
                    while (true) {
                        try {
                            if (!query10.next()) break;
                        } catch (SQLException ec) {
                            ec.printStackTrace();
                        }
                        @SuppressWarnings("rawtypes")
                        Vector<Comparable> v = new Vector<Comparable>();
                        try {
                            v.add(query10.getString(1));
                            v.add(query10.getDouble(2));
                            v.add(query10.getInt(3));
                            vect3.add(v);
                            tm3.fireTableStructureChanged();
                        } catch (SQLException ex) {
                            ex.printStackTrace();
                        }
                    }
                }else{
                    JOptionPane.showMessageDialog(null,"没有输入金额","错误",JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        jTabbedPane.addTab("挂号",registered);
        jTabbedPane.addTab("排队",lineup);
        jTabbedPane.addTab("付款",pay);
        jTabbedPane.addTab("统计",tongji);
        frame.add(jTabbedPane);
        frame.setVisible(true);//可见
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //就诊按钮监听事件
        seeAdoctor.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int visitnumber = Integer.parseInt(visitnumbertext.getText());
                //获取当前时间写入endtime中
                Date date = new Date();//获得系统时间
                SimpleDateFormat sdf = new SimpleDateFormat( " yyyy-MM-dd HH:mm:ss " );
                String nowTime = sdf.format(date);
                con.update("update queue set endtime=? where visitnumber=?",visitnumber,nowTime);
                ResultSet query3 = con.query("select visitnumber,department,pname,dname from queue,doctor,patient where doctor.did=queue.did and queue.pid=patient.pid and starttime is not null and endtime is null order by department,dname");
                ResultSet query7 = con.query("select visitnumber,department,pname,dname from queue,doctor,patient where doctor.did=queue.did and queue.pid=patient.pid and starttime is not null and endtime is not null and paymoney is null order by department,dname");
                JOptionPane.showMessageDialog(null,"就诊成功","成功",JOptionPane.INFORMATION_MESSAGE);
                //刷新页面1
                vect.removeAllElements();// 初始化向量对象
                tm.fireTableStructureChanged();// 更新表格内容
                while (true) {
                    try {
                        if (!query3.next()) break;
                    } catch (SQLException ec) {
                        ec.printStackTrace();
                    }
                    @SuppressWarnings("rawtypes")
                    Vector<Comparable> v = new Vector<Comparable>();
                    try {
                        v.add(query3.getInt(1));
                        v.add(query3.getString(2));
                        v.add(query3.getString(3));
                        v.add(query3.getString(4));
                        vect.add(v);
                        tm.fireTableStructureChanged();
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
                //刷新页面2
                vect1.removeAllElements();// 初始化向量对象
                tm1.fireTableStructureChanged();// 更新表格内容
                while (true) {
                    try {
                        if (!query7.next()) break;
                    } catch (SQLException ec) {
                        ec.printStackTrace();
                    }
                    @SuppressWarnings("rawtypes")
                    Vector<Comparable> v = new Vector<Comparable>();
                    try {
                        v.add(query7.getInt(1));
                        v.add(query7.getString(2));
                        v.add(query7.getString(3));
                        v.add(query7.getString(4));
                        vect1.add(v);
                        tm1.fireTableStructureChanged();
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
                ResultSet query5 = con.query("select distinct department from queue,doctor where queue.did=doctor.did and starttime is not null and endtime is null");
                ResultSet query4 = con.query("select distinct dname from queue,doctor where queue.did=doctor.did and starttime is not null and endtime is null");
                while(true){
                    try {
                        if (!query5.next()||!query4.next()) break;
                    } catch (SQLException e1) {
                        e1.printStackTrace();
                    }
                    try {
                        comboBox.removeAllItems();
                        comboBox.addItem(query5.getString("department"));
                        comboBox1.removeAllItems();
                        comboBox1.addItem(query4.getString("dname"));
                    } catch (SQLException e1) {
                        e1.printStackTrace();
                    }
                }
//                //刷新标签人数
                jLabel.setVisible(false);
                jLabel1.setVisible(false);
                ceshi.setVisible(false);
//                String dname = jiuzhengtext.getText();
//                ResultSet query6 = con.query("select count(*) number from queue,doctor,patient where doctor.did=queue.did and queue.pid=patient.pid and starttime is not null and endtime is null and dname=?", dname);
//                while(true){
//                    try {
//                        if (!query6.next()) break;
//                    } catch (SQLException ex) {
//                        ex.printStackTrace();
//                    }
//                    try {
//                        ceshi.setText(String.valueOf(query6.getInt("number")));
//                    } catch (SQLException ex) {
//                        ex.printStackTrace();
//                    }
//                }
            }
        });
        //挂号
        regist.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String pid=pidtext.getText();
                String pname = pnametext.getText();
                String psex = psexbox.getItemAt(psexbox.getSelectedIndex());
                int page = 0;
                if(pagetext.getText().equals("")){
                    page=0;
                }else{
                    page= Integer.parseInt(pagetext.getText());
                }
                String ptel = pteltext.getText();
                String pathogen = pathogentext.getText();
                ResultSet query5 = con.query("select pid from patient");
                ArrayList<String> pids = new ArrayList<>();
                while (true){
                    try {
                        if (!query5.next()) break;
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                    try {
                        pids.add(query5.getString("pid"));
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
                if(!pids.contains(pid)){
                    //添加唯一的病人信息
                    con.add("insert into patient(pid,pname,psex,page,ptel) values(?,?,?,?,?)",pid,pname,psex,page,ptel);
                }
                con.add("insert into medical_records(pid,pathogen) values(?,?)",pid,pathogen);
                JOptionPane.showMessageDialog(null,"就诊成功","成功",JOptionPane.INFORMATION_MESSAGE);
                //获取当前时间写入starttime中
                Date date = new Date();//获得系统时间
                SimpleDateFormat sdf = new SimpleDateFormat( " yyyy-MM-dd HH:mm:ss " );
                String nowTime = sdf.format(date);
                String didname = doctorbox.getItemAt(doctorbox.getSelectedIndex());
                ResultSet query3 = con.query("select did from doctor where dname=?", didname);
                int did=0;
                while(true){
                    try {
                        if (!query3.next()) break;
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                    try {
                        did=query3.getInt("did");
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
                con.add("insert into queue(did,pid,starttime) values(?,?,?)",did,pid,nowTime);
                ResultSet query4 = con.query("select visitnumber,department,pname,dname from queue,doctor,patient where doctor.did=queue.did and queue.pid=patient.pid and starttime is not null and endtime is null");
                //刷新页面
                vect.removeAllElements();// 初始化向量对象
                tm.fireTableStructureChanged();// 更新表格内容
                while (true) {
                    try {
                        if (!query4.next()) break;
                    } catch (SQLException ec) {
                        ec.printStackTrace();
                    }
                    @SuppressWarnings("rawtypes")
                    Vector<Comparable> v = new Vector<Comparable>();
                    try {
                        v.add(query4.getInt(1));
                        v.add(query4.getString(2));
                        v.add(query4.getString(3));
                        v.add(query4.getString(4));
                        vect.add(v);
                        tm.fireTableStructureChanged();
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
            }
        });
        //清空填写数据
        clear.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                pnametext.setText("");
                psexbox.setSelectedIndex(0);
                pagetext.setText("");
                pteltext.setText("");
                pathogentext.setText("");
                //热部署JLabel测试:System.out.println("测试");
            }
        });
    }

    public static void main(String[] args) {
        new Main();
    }
}

六、联系与沟通

q:969060742 完整代码、sql、程序资源

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1095561.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【文档智能】多模态预训练模型及相关数据集汇总

前言 大模型时代&#xff0c;在现实场景中或者企业私域数据中&#xff0c;大多数数据都以文档的形式存在&#xff0c;如何更好的解析获取文档数据显得尤为重要。文档智能也从以前的目标检测&#xff08;版面分析&#xff09;阶段转向多模态预训练阶段&#xff0c;本文将介绍目…

分享项目管理软件排行榜!

无论是大型企业还是小型团队&#xff0c;项目管理是企业不可或缺的一部分。一个好的项目管理软件可以帮助企业有效地规划和实施项目&#xff0c;对于团队成员来说&#xff0c;也可以更好地分配任务、查看进度和提高团队合作能力。面对众多的项目管理软件&#xff0c;如何选择适…

JMM模型与并发三大特性

如何学&#xff1a; 分理解并发的三大特性&#xff0c;JMM工作内存和主内存关系&#xff0c;知道多线程之间如何通信的&#xff0c;掌握volatile能保证可见性和有序性&#xff0c;CAS就可以了 并发和并行 目标都是最大化CPU的使用率 并行(parallel)&#xff1a;指在同一时刻&a…

Arcgis对图像重采样、打开查看运行结果的窗口、逐像元提取数值

1、Arcgis对图像重采样 然后打开数据管理工具-栅格-栅格处理-重采样 打开后&#xff0c;此处我们输入数据用导入的影像&#xff0c;X和Y代表重采样的大小为8*8 注意&#xff1a;输出文件需要有文件后缀&#xff0c;否则报错。 采样后&#xff0c;像元就变成了8*8一个像元。 2…

安装gymnasium[box2d]的问题

安装时总会报错 Building wheels for collected packages: box2d-pyBuilding wheel for box2d-py (setup.py) ... errorerror: subprocess-exited-with-error python setup.py bdist_wheel did not run successfully.│ exit code: 1╰─> [16 lines of output]Using setup…

gitlab自编译 源码下载

网上都是怎么用 gitlab&#xff0c;但是实际开发中有需要针对 gitlab 进行二次编译自定义实现功能的想法。 搜索了网上的资料以及在官网的查找&#xff0c;查到了如下 gitlab 使用 ruby 开发。 gitlab 下载包 gitlab/gitlab-ce - Packages packages.gitlab.com gitlab/gitl…

leetcode做题笔记174. 地下城游戏

恶魔们抓住了公主并将她关在了地下城 dungeon 的 右下角 。地下城是由 m x n 个房间组成的二维网格。我们英勇的骑士最初被安置在 左上角 的房间里&#xff0c;他必须穿过地下城并通过对抗恶魔来拯救公主。 骑士的初始健康点数为一个正整数。如果他的健康点数在某一时刻降至 0…

21GA-ELM,遗传算法优化ELM预测,并和优化前后以及真实数值进行对比,确定结果,基于MATLAB平台,程序已经调通,可以直接运行,需要直接拍下。

GA-ELM&#xff0c;遗传算法优化ELM预测&#xff0c;并和优化前后以及真实数值进行对比&#xff0c;确定结果&#xff0c;基于MATLAB平台&#xff0c;程序已经调通&#xff0c;可以直接运行&#xff0c;需要直接拍下。 21matlab时间序列预测极限学习遗传优化算 (xiaohongshu.co…

2023年(2024届)双非保研历程(中南、东南、浙大、信工所、国防科大、北邮)

个人情况 学校层次&#xff1a;双非 专业&#xff1a;信息安全&#xff08;投的基本都是网安&#xff09; 排名&#xff1a;2/66 英语&#xff1a;六级565&#xff0c;四级560 竞赛&#xff1a;大英赛国三、美赛H、蓝桥杯省一、数竞省一、词达人省一、数模国赛省三。 论文&…

【LeetCode刷题(数据结构与算法)】:二叉树之左叶子之和

给定二叉树的根节点 root &#xff0c;返回所有左叶子之和 输入: root [3,9,20,null,null,15,7] 输出: 24 解释: 在这个二叉树中&#xff0c;有两个左叶子&#xff0c;分别是 9 和 15&#xff0c;所以返回 24 示例 2: 输入: root [1] 输出: 0 这都题目用递归的方法就可以解决…

牛客周赛 Round 15

A、 题目描述 游游拿到了一个正整数&#xff0c;她希望将它切割成两部分&#xff0c;使得它们的和为偶数。游游想知道有多少种合法的切割方案&#xff1f; 注&#xff1a;切割后的正整数允许出现前导零。 输入描述: 一个正整数&#xff0c;大小不超过10^100000 输出描述: 一个整…

参数解析(牛客)

目录 一、题目 二、代码 一、题目 二、代码 #include <iostream> #include <vector> using namespace std;int main() {string s;getline(cin, s);int i 0;vector<string>ret;while (i < s.size()){if (s[i] )//遇到空格直接跳过{i;}else if (s[i] …

[部署网站]01安装宝塔面板搭建WordPress

宝塔面板安装WordPress&#xff08;超详细&#xff09;_Wordpress主题网 参考教程 宝塔面板 - 简单好用的Linux/Windows服务器运维管理面板 官网 1.首先你需要一个服务器或者主机 &#xff08;Windows系统或者Linux系统都可以&#xff09; 推荐Linux系统更稳定&#xff0c;…

基于Java的个人健康管理系统设计与实现(源码+lw+部署文档+讲解等)

文章目录 前言具体实现截图论文参考详细视频演示为什么选择我自己的网站自己的小程序&#xff08;小蔡coding&#xff09;有保障的售后福利 代码参考源码获取 前言 &#x1f497;博主介绍&#xff1a;✌全网粉丝10W,CSDN特邀作者、博客专家、CSDN新星计划导师、全栈领域优质创作…

LeetCode 1095. 山脉数组中查找目标值【数组,二分】1827

本文属于「征服LeetCode」系列文章之一&#xff0c;这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁&#xff0c;本系列将至少持续到刷完所有无锁题之日为止&#xff1b;由于LeetCode还在不断地创建新题&#xff0c;本系列的终止日期可能是永远。在这一系列刷题文章…

CEC2013(MATLAB):霸王龙优化算法(Tyrannosaurus optimization)求解CEC2013

一、霸王龙优化算法TROA 霸王龙优化算法&#xff08;Tyrannosaurus optimization&#xff0c;TROA&#xff09;由Venkata Satya Durga Manohar Sahu等人于2023年提出&#xff0c;该算法模拟霸王龙的狩猎行为&#xff0c;具有搜索速度快等优势。 参考文献&#xff1a;Venkata S…

CEC2013(MATLAB):螳螂搜索算法(Mantis Search Algorithm,MSA)求解CEC2013

一、螳螂搜索算法 螳螂搜索算法&#xff08;Mantis Search Algorithm&#xff0c;MSA&#xff09;由Mohamed Abdel-Basset等人于2023年提出&#xff0c;该算法模拟螳螂独特的狩猎和性同类相食行为。MSA由三个优化阶段组成&#xff0c;包括寻找猎物&#xff08;探索&#xff09…

The normalized eigenfunction may not be uniformly bounded

See Article The Uniform Lipschitz Continuity of Eigenvalues of Sturm–Liouville Problems with Respect to the Weighted Function Jing Xu , Zhiwen Liu and Jiangang Qi https://doi.org/10.3390/sym15040911

Android Framework通信:Binder

文章目录 前言一、Linux传统跨进程通信原理二、Android Binder跨进程通信原理1、动态内核可加载模块2、内存映射3、Binder IPC 实现原理 三、Android Binder IPC 通信模型1、Client/Server/ServiceManager/驱动Binder与路由器之间的角色关系 2、Binder通信过程3、Binder通信中的…

Kibana安装、配置

天行健&#xff0c;君子以自强不息&#xff1b;地势坤&#xff0c;君子以厚德载物。 每个人都有惰性&#xff0c;但不断学习是好好生活的根本&#xff0c;共勉&#xff01; 文章均为学习整理笔记&#xff0c;分享记录为主&#xff0c;如有错误请指正&#xff0c;共同学习进步。…