import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Login extends JFrame {
public Login() {
this.setTitle("登录界面");
this.setBounds(100, 100, 500, 450);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);//设置关闭子窗口但是不关闭父类窗口
this.setLayout(null);
JLabel jLabel = new JLabel("社区医院管理服务系统");
JLabel jLabel1 = new JLabel("账号:");
JLabel jLabel2 = new JLabel("密码:");
JButton jb1 = new JButton("登录");
JButton jb2 = new JButton("退出");
JRadioButton adminButton = new JRadioButton("管理员");
JRadioButton doctorButton = new JRadioButton("医生");
JRadioButton patientButton = new JRadioButton("病人");
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(adminButton);
buttonGroup.add(doctorButton);
buttonGroup.add(patientButton);
JTextField field1 = new JTextField(18);
JTextField field2 = new JTextField(18);
JPanel jPanel = new JPanel();
JPanel jPanel0 = new JPanel();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
JPanel gapPanel = new JPanel();
gapPanel.setPreferredSize(new Dimension(60, 20));
jPanel.add(jLabel);
jPanel1.add(jLabel1);
jPanel1.add(field1);
jPanel2.add(jLabel2);
jPanel2.add(field2);
jPanel3.add(adminButton);
jPanel3.add(doctorButton);
jPanel3.add(patientButton);
jPanel0.add(jb1);
jPanel0.add(gapPanel);
jPanel0.add(jb2);
jPanel.setBounds(10, 40, 450, 50);
jPanel1.setBounds(0, 110, 450, 50);
jPanel2.setBounds(0, 180, 450, 50);
jPanel3.setBounds(0, 250, 450, 50);
jPanel0.setBounds(0, 320, 450, 50);
jLabel.setFont(new Font("微软雅黑", Font.PLAIN, 30));
jLabel1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
jLabel2.setFont(new Font("微软雅黑", Font.PLAIN, 20));
adminButton.setFont(new Font("微软雅黑", Font.PLAIN, 20));
patientButton.setFont(new Font("微软雅黑", Font.PLAIN, 20));
doctorButton.setFont(new Font("微软雅黑", Font.PLAIN, 20));
jb1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
jb2.setFont(new Font("微软雅黑", Font.PLAIN, 20));
this.add(jPanel);
this.add(jPanel1);
this.add(jPanel2);
this.add(jPanel3);
this.add(jPanel0);
this.setVisible(true);
UIManager.put("OptionPane.messageFont", new Font("微软雅黑", Font.PLAIN, 15));
jb1.addActionListener (new ActionListener() {
public void actionPerformed(ActionEvent e) {
try{
//获取单选框的值
String type ="";
for(Component c:jPanel3.getComponents()){
if(c instanceof JRadioButton){
if(((JRadioButton) c).isSelected()){
type += ((JRadioButton)c).getText();
}
}
}
//连接数据库校验
Connection conn =JDBCUtils.getConnection();
String sql = "select * from user where username=?";
PreparedStatement pstm = conn.prepareStatement(sql);
pstm.setString(1, field1.getText());
// 执行查询
ResultSet rs = pstm.executeQuery();
rs.next();
String passwordDB= rs.getString("password");
String typeDB = rs.getString("type");
//判断账号密码和类型是否一致
if (passwordDB.equals(field2.getText())&&typeDB.equals(type)){
JOptionPane.showMessageDialog(null, "登录成功");
if (typeDB.equals("医生")){
new DoctorMain();
dispose();
}else if(typeDB.equals("管理员")){
new AdminMain();
dispose();
}else if(typeDB.equals("病人")){
new PatientMain();
dispose();
}
}else{
JOptionPane.showMessageDialog(null, "账号或密码错误");
}
}catch(SQLException sqle){
sqle.printStackTrace();
JOptionPane.showMessageDialog(null,"操作错误","错误",JOptionPane.ERROR_MESSAGE);
}
}
});
jb2.addActionListener (new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();//关闭原来窗口
}
});
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
社区医院管理服务系统【GUI/Swing+MySQL】(Java课设)
共147个文件
class:83个
java:28个
png:23个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 143 浏览量
2024-03-26
16:02:26
上传
评论
收藏 603KB ZIP 举报
温馨提示
运行效果展示地址:https://saodai.blog.csdn.net/article/details/137041094 部署教程地址:https://blog.csdn.net/qq_50954361/article/details/129525252?spm=1001.2014.3001.5502 购买后有三天售后服务!!!购买前先看运行效果展示!!!以下还有内容要展开才可以看到~ 每个付费系统资源压缩包都包含源代码+数据库脚本sql!!! 这些系统是我接单的时候留下的源码,现在挂在CSDN的付费资源上作为一个睡后收益!这些系统都是可以正常运行的!因为这些系统之前都交付给顾客了!顾客们也都跑起来了! 无论是用IDEA还是用eclipse跑都是可以跑起来的!只需要根据我写的部署教程即可在自己的电脑上把系统运行起来! 我接单开发的系统的界面风格都是最原始的!也就是没有去美化!因为这样更符合顾客的水平!做太好太漂亮老师会怀疑甚至挂科!这就得不偿失了! 据我接单的经验,通常这样的系统对于过Java课设来说是完全够了!
资源推荐
资源详情
资源评论
收起资源包目录
社区医院管理服务系统【GUI/Swing+MySQL】(Java课设) (147个子文件)
SelectDepartmentDoctor.class 4KB
SelectPatientByName.class 4KB
SelectAllPatientByName.class 4KB
SelectDoctor.class 4KB
SelectClinicByName.class 4KB
SelectAllPatient.class 3KB
SelectAllDept.class 3KB
PatientMain.class 3KB
Login$1.class 3KB
PatientUpdate.class 3KB
DoctorUpdate.class 3KB
PatientAdd.class 3KB
DoctorAdd.class 3KB
Login.class 3KB
PatientUpdate$1.class 3KB
DoctorUpdate$1.class 3KB
DepartmentUpdate.class 3KB
DepartmentAdd.class 3KB
Registration.class 3KB
Diagnose.class 3KB
PatientAdd$1.class 3KB
DoctorAdd$1.class 3KB
DepartmentUpdate$1.class 3KB
DepartmentAdd$1.class 3KB
Registration$1.class 3KB
Diagnose$1.class 3KB
DeleteRegistration$1.class 2KB
DepartmentDelete$1.class 2KB
PatientDelete$1.class 2KB
DoctorDelete$1.class 2KB
DepartmentMenu.class 2KB
DoctorMain.class 2KB
PatientMenu.class 2KB
DoctorMenu.class 2KB
AdminMain.class 2KB
DeleteRegistration.class 2KB
DepartmentDelete.class 2KB
PatientDelete.class 2KB
DoctorDelete.class 2KB
JDBCUtils.class 1KB
Start.class 1KB
SelectAllPatientByName$2.class 842B
SelectDepartmentDoctor$2.class 842B
SelectPatientByName$2.class 824B
SelectAllPatient$2.class 806B
SelectDoctor$2.class 782B
SelectDepartmentDoctor$1.class 721B
SelectAllPatientByName$1.class 721B
SelectPatientByName$1.class 703B
SelectClinicByName$1.class 697B
SelectAllPatient$1.class 685B
DepartmentMenu$4.class 669B
SelectAllDept$1.class 667B
PatientMain$8.class 665B
DepartmentMenu$3.class 663B
DepartmentMenu$2.class 663B
SelectDoctor$1.class 661B
DepartmentMenu$1.class 660B
DoctorMain$5.class 659B
AdminMain$4.class 653B
PatientMain$3.class 648B
PatientMenu$4.class 648B
PatientMain$2.class 647B
PatientMain$6.class 647B
DoctorMain$4.class 645B
PatientMain$7.class 642B
PatientMain$4.class 642B
PatientMenu$3.class 642B
PatientMenu$2.class 642B
PatientMain$5.class 641B
PatientMain$1.class 641B
DoctorMain$2.class 639B
PatientMenu$1.class 639B
DoctorMenu$3.class 635B
DoctorMenu$4.class 635B
DoctorMain$1.class 635B
DoctorMenu$2.class 635B
DoctorMenu$1.class 632B
AdminMain$1.class 631B
DoctorMain$3.class 631B
AdminMain$2.class 628B
AdminMain$3.class 627B
Login$2.class 601B
.gitignore 184B
社区医院管理服务系统.iml 710B
Login.java 5KB
PatientAdd.java 5KB
DoctorAdd.java 5KB
DoctorUpdate.java 5KB
PatientUpdate.java 5KB
DepartmentAdd.java 5KB
Diagnose.java 5KB
Registration.java 5KB
DepartmentUpdate.java 5KB
PatientMain.java 4KB
SelectDepartmentDoctor.java 4KB
SelectPatientByName.java 4KB
SelectDoctor.java 4KB
SelectAllPatientByName.java 4KB
SelectClinicByName.java 4KB
共 147 条
- 1
- 2
资源评论
骚戴
- 粉丝: 1w+
- 资源: 144
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功