——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明



基于java的Swing医院挂号管理系统控制台(java+mysql+jdbc)
分为病人和医生
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| String time=formater.format(regTime); this.id=patientId+deptId+time; this.patientId=patientId; this.deptId=deptId; this.regTime=regTime; this.price=price; } public String getId() { return id; } public String getPatientId() { return patientId; } public String getDeptId() { return deptId; } public Date getRegTime() { return regTime; } public int getPrice() { return price; } public void setId(String id) { this.id = id; } public void setPatientId(String patientId) { this.patientId = patientId; } public void setDeptId(String deptId) { this.deptId = deptId; } public void setRegTime(Date regTime) { this.regTime = regTime; } public void setPrice(int price) { this.price = price; } @Override public String toString() { return "id:"+getId()+" 病人编号:"+getPatientId()+ " 部门编号:"+getDeptId()+" 挂号时间:"+getRegTime()+" 费用:"+getPrice(); } }
public class DoctorData { private String id,name,dept_id,sex,password; public DoctorData() { id=null;name=null;dept_id=null;password=null;sex=null; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| 医院部门数据库操作 */
public class DeptOperationDAOImpl implements OperationDAO<DeptData> { private static String sql; private static Connection conn; private static DeptOperationDAOImpl operation; private DeptOperationDAOImpl(Connection conn) { this.conn = conn; } public static DeptOperationDAOImpl getInstance(Connection conn) { if (operation == null) operation = new DeptOperationDAOImpl(conn); return operation; } public boolean insertData(DeptData data) { try { sql = "INSERT INTO Dept VALUES(?,?,?,?,?)"; PreparedStatement pst = conn.prepareStatement(sql); pst.setString(1, data.getId()); pst.setString(2, data.getName()); pst.setString(3, data.getType()); pst.setString(4, data.getDiscription()); pst.setString(5, data.getAdress()); int i = pst.executeUpdate(); System.out.printf("插入数据成功,影响了%d行数据\n", i); } catch (SQLException e) { System.out.println("插入失败,或许该科室已存在,请检查科室编号"); return false; } return true; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| return true; } public boolean queryData() { ResultSet result; try { PreparedStatement pst=conn.prepareStatement(sql); result=pst.executeQuery(); System.out.println("启动查询......"); while(result.next()) { System.out.println("id:"+result.getString(1)+' '+ "名称:"+result.getString(2)+' '+ "类型:"+result.getString(3)+' '+ "描述:"+result.getString(4)+' '+ "病区或地址:"+result.getString(5)); } } catch(SQLException e) { e.printStackTrace(); return false; } return true; }
public boolean queryDataAll() { sql="SELECT * FROM Dept"; return queryData(); } public boolean readData(DeptData newDept) { ResultSet result; try { PreparedStatement pst=conn.prepareStatement(sql); result=pst.executeQuery(); System.out.println("读取数据......"); while(result.next()) { newDept.setId(result.getString(1)); newDept.setName(result.getString(2)); newDept.setType(result.getString(3)); newDept.setDiscription(result.getString(4)); newDept.setAdress(result.getString(5));
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| return instance; } public boolean signUp(DoctorData newDoctor) { doctor=newDoctor; return doctorOperationDAO.insertData(newDoctor); } public boolean logIn(String id,String password) { doctor=new DoctorData(); if(doctorOperationDAO.findData(id,doctor)) if(doctor.getPassword().equals(password)) return true; else System.out.println("密码错误"); return false; } public void showReg() { regOperationDAO.queryRegByDept(doctor.getDept_id()); }
public void showPatient() { PatientOperationDAOImpl.getInstance(conn).queryPatientByDept(doctor.getDept_id()); }
public boolean showRegByDate(String date) { java.text.SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd"); Date regTime; try{ regTime=formatter.parse(date); } catch(java.text.ParseException e) { e.getErrorOffset(); return false; } return regOperationDAO.queryRegByDate(regTime); }
public boolean dealReg(String id) { System.out.println("挂号已被受理"); return regOperationDAO.deleteData(id); } public void logOut() { doctorOperationDAO=null; regOperationDAO=null;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| PreparedStatement pst=conn.prepareStatement(sql); result=pst.executeQuery(); System.out.println("启动查询......"); while(result.next()) { System.out.println("id:"+result.getString(1)+' '+ "名称:"+result.getString(2)+' '+ "类型:"+result.getString(3)+' '+ "描述:"+result.getString(4)+' '+ "病区或地址:"+result.getString(5)); } } catch(SQLException e) { e.printStackTrace(); return false; } return true; }
public boolean queryDataAll() { sql="SELECT * FROM Dept"; return queryData(); } public boolean readData(DeptData newDept) { ResultSet result; try { PreparedStatement pst=conn.prepareStatement(sql); result=pst.executeQuery(); System.out.println("读取数据......"); while(result.next()) { newDept.setId(result.getString(1)); newDept.setName(result.getString(2)); newDept.setType(result.getString(3)); newDept.setDiscription(result.getString(4)); newDept.setAdress(result.getString(5)); } } catch(SQLException e) { e.printStackTrace(); return false;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| this.id=id; this.name=name; this.type=type; this.discription=discription; this.adress=adress; } public void setId(String newId) { id=newId; } public void setName(String newName) { name=newName; } public void setType(String type) { this.type=type; } public void setDiscription(String newDiscription) { discription=newDiscription; } public void setAdress(String adress) { this.adress = adress; } public String getId() { return id; } public String getName() { return name; } public String getType() { return type; } public String getDiscription() { return discription; } public String getAdress() { return adress; } }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=472024432907201mb
https://javayms.pages.dev?id=472024432907201mb