一、系统介绍
本系统实现的以下功能
管理员功能:登录系统、病人信息的增删改查、就医档案的录入、医生信息的增删改查、科室信息的增删改查、收费统计功能、修改密码。
医生功能:登录系统、病人信息的增删改查、医生信息的增删改查、科室信息的增删改查、收费统计功能、修改密码。
收费员功能:价格管理、收费管理、修改密码。
JDK版本:1.8
数据库:Mysql8.0.13
数据库用到的表
cashier
charge
department
doctor
drugtable
manager
medical_records
patient
price
工程截图
二、系统展示
1.登录页
2.主页面
3.病人信息录入
4.病人信息操作
5.就医档案录入
6.处方单录入
7.就医档案操作
8.医生信息录入
9.医生信息操作
10.科室信息录入
11.科室信息操作
12.收费操作
13.收费统计
14.修改密码
15.医生主页面
16.收费员主页面
三、系统实现
Login.java
package com.sjsq; import java.awt.Color; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPasswordField; import javax.swing.JRadioButton; import javax.swing.JTextField; public class Login extends JFrame { public static String namew; // 输入的用户Id public static String userId; // 输入的用户名 public static String username; // 输入的密码 public static String password; // 验证标识 int loginFlag = 0; private static final long serialV<em>本文来源gao.dai.ma.com搞@代*码(网$</em>ersionUID = 1L; DBUtil dbUtil = new DBUtil(); Connection con = dbUtil.getConnection(); // 账号 JLabel accountJLabel = new JLabel("账号:"); // 错误提示标签 JLabel errorJLabel = new JLabel("用户名或者密码不对,请重新输入"); // 密码 JLabel passwordJLabel = new JLabel("密码:"); // r1:管理员 r2:收费员 r3:医生 public JRadioButton r1, r2, r3; ImageIcon bg = new ImageIcon("picture/login_bg.jpg"); JLabel bgJLabel = new JLabel(bg); JButton loginJButton = new JButton("登录"); JButton cancelJButton = new JButton("取消"); private boolean flag; static JTextField usernameJTextField = new JTextField(); static JPasswordField passwordJPasswordField = new JPasswordField(); Login(String sTitle) { super(sTitle); this.setLayout(null); this.add(errorJLabel); // 添加控件 this.add(accountJLabel); this.add(passwordJLabel); this.add(loginJButton); this.add(cancelJButton); this.add(usernameJTextField); this.add(passwordJPasswordField); final JRadioButton r1 = new JRadioButton("管理员"); final JRadioButton r2 = new JRadioButton("收费员"); final JRadioButton r3 = new JRadioButton("医生"); ButtonGroup rg = new ButtonGroup(); this.add(r2); rg.add(r1); this.add(r3); rg.add(r3); this.add(r1); rg.add(r2); r1.setBounds(150, 180, 80, 30); r2.setBounds(230, 180, 80, 30); r3.setBounds(310, 180, 80, 30); r1.setFocusPainted(false); r2.setFocusPainted(false); r3.setFocusPainted(false); r3.setContentAreaFilled(false); r1.setContentAreaFilled(false); r2.setContentAreaFilled(false); errorJLabel.setBounds(100, 130, 200, 50); errorJLabel.setForeground(Color.black); errorJLabel.setVisible(false); bgJLabel.setBounds(0, 0, 592, 350); // 登录监听 loginJButton.addActionListener(new ActionListener() { public boolean flag = false; public void actionPerformed(ActionEvent e) { // 医生 if (r3.isSelected()) { try { String usernameText = usernameJTextField.getText().toString(); // 获取帐号文本框内容 String passwordText = passwordJPasswordField.getText().toString(); // 获取密码文本框内容 Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from doctor"); // 执行SQL语句,返回结果集 while (rs.next()) { userId = rs.getString("DrId"); // 获取登录的用户编号, username = rs.getString("DrName");// 获取登录的用户姓名 password = rs.getString("Password"); // 获取数据库中的数据项的密码 if (userId.equals(usernameText) && password.equals(passwordText)) {// 判断数据库的用户编号以及密码是否与文本框的值相同 loginFlag = 1; break; } } if (loginFlag == 1) { JOptionPane.showMessageDialog(null, "登录成功"); // 显示系统主界面 MainPanelDoctor a = new MainPanelDoctor("医生界面"); a.setVisible(true); Login.this.setVisible(false);// 关闭登录按钮 } else { usernameJTextField.setText(""); // 错误的话则文本框内容设置为空,显示错误标签 passwordJPasswordField.setText(""); JOptionPane.showMessageDialog(null, "登陆错误"); } } catch (SQLException e2) { System.out.println(e2); } } // 管理员 else if (r1.isSelected()) { try { String usernameText = usernameJTextField.getText().toString(); // 获取帐号文本框内容 String passwordText = passwordJPasswordField.getText().toString(); // 获取密码文本框内容 Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from manager"); // 执行SQL语句,返回结果集 while (rs.next()) { userId = rs.getString("ManagerID"); // 获取登录的用户编号, username = rs.getString("ManagerName");// 获取登录的用户姓名 password = rs.getString("MaPassWord"); // 获取数据库中的数据项的密码 if (userId.equals(usernameText) && password.equals(passwordText)) {// 判断数据库的用户编号以及密码是否与文本框的值相同 loginFlag = 1; break; } } // 登录成功 if (loginFlag == 1) { JOptionPane.showMessageDialog(null, "登录成功"); new MainPanelManager("管理员界面"); // 显示系统主界面 Login.this.setVisible(false);// 关闭登录按钮 // 登录失败 } else { usernameJTextField.setText(""); // 错误的话则文本框内容设置为空,显示错误标签 passwordJPasswordField.setText(""); JOptionPane.showMessageDialog(null, "登陆错误"); } } catch (SQLException e3) { System.out.println(e3); } } // 收费员 else if (r2.isSelected()) { try { String usernameText = usernameJTextField.getText().toString(); // 获取帐号文本框内容 String passwordText = passwordJPasswordField.getText().toString(); // 获取密码文本框内容 Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from cashier"); // 执行SQL语句,返回结果集 while (rs.next()) { userId = rs.getString("cashierId"); // 获取登录的用户编号, username = rs.getString("cashierName");// 获取登录的用户姓名 password = rs.getString("cashierPassWord"); // 获取数据库中的数据项的密码 if (userId.equals(usernameText) && password.equals(passwordText)) {// 判断数据库的用户编号以及密码是否与文本框的值相同 loginFlag = 1; break; } } if (loginFlag == 1) { JOptionPane.showMessageDialog(null, "登录成功"); new MainPanelCashier("收费员页面"); // 显示系统主界面 Login.this.setVisible(false);// 关闭登录按钮 } else { usernameJTextField.setText(""); // 错误的话则文本框内容设置为空,显示错误标签 passwordJPasswordField.setText(""); JOptionPane.showMessageDialog(null, "登陆错误"); } } catch (SQLException e3) { System.out.println(e3); } } else if (r1.isSelected() == false && r2.isSelected() == false && r3.isSelected() == false) { JOptionPane.showMessageDialog(null, "请选择用户类型"); } } }); // 登录按钮添加功能事件 // 账号 accountJLabel.setBounds(150, 50, 100, 50); accountJLabel.setFont(new Font("", 1, 20)); // 密码 passwordJLabel.setBounds(150, 120, 100, 50); passwordJLabel.setFont(new Font("", 1, 20)); // 登录 loginJButton.setBounds(150, 220, 100, 40); loginJButton.setBackground(Color.CYAN); // 取消 cancelJButton.setBounds(280, 220, 100, 40); cancelJButton.setBackground(Color.CYAN); // 账号输入框 usernameJTextField.setBounds(250, 60, 150, 30); // 密码输入框 passwordJPasswordField.setBounds(250, 120, 150, 30); this.add(bgJLabel); this.setVisible(true); this.setSize(600, 350); // 设置窗口大小 this.setResizable(false); // 设置不可调整窗口大小 this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String args[]) { Login login = new Login("医院管理系统"); } }