标题(自制)核酸预约系统(可做课设)(包数据库(java))
总述
系统总共分为两个部分,用户与后台管理:
- 用户部分:用户可以进行核酸预约(姓名,身份证,地点,采样方式)和预约结果查询打印
- 后台管理:医护人员可以先进行登录和注册进行身份验证,后可以对已经预约的结果进行查询和修改
3.数据库已经配置好,只需要修改相关参数即可
插入链接与图片
链接: [https://www.aliyundrive.com/s/f1bCsFYPQ3R](含数据库)
.
样图(用户部分):
管理部分:
数据库图样:
部分代码(管理登陆界面)
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
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;
public class Login {
JFrame f;
JLabel l1,l2,lv,l,lc,lt;
JTextField t1,tv;
JPasswordField t2;
JButton b1,b2,b3;
JPanel p1,p2,p3,p;
BufferedImage image;
String scode="";
void init() {
f=new JFrame("登录窗口");
l1=new JLabel("帐 号",JLabel.RIGHT);
lv=new JLabel("验证码");
lt=new JLabel("用户登录",JLabel.CENTER);
lt.setFont(new Font("宋体",Font.BOLD,18));
image=getImage();
l=new JLabel(new ImageIcon(image));
l2=new JLabel("密 码",JLabel.RIGHT);
t1=new JTextField(10);
tv=new JTextField(10);
t2=new JPasswordField(10);
b1=new JButton("登 录");
b2=new JButton("");
b3=new JButton("新用户注册");
MyListener ll=new MyListener();
b1.addActionListener(ll);
b3.addActionListener(ll);
p1=new JPanel(new FlowLayout(FlowLayout.LEFT));
p2=new JPanel(new FlowLayout(FlowLayout.LEFT));
p3=new JPanel();
p=new JPanel(new FlowLayout(FlowLayout.LEFT));
p1.add(l1);
p1.add(t1);
p2.add(l2);
p2.add(t2);
p3.add(b1);
p3.add(b3);
p.add(lv);
p.add(tv);
p.add(l);
lc=new JLabel("看不清,换一张");
lc.setFont(new Font("宋体", Font.ITALIC, 10));
lc.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent arg0) {
super.mouseClicked(arg0);
image=getImage();
l.setIcon(new ImageIcon("img/background.png"));
}
public void mouseEntered(MouseEvent arg0) {
super.mouseEntered(arg0);
lc.setForeground(Color.green);
}
});
p.add(lc);
f.setLayout(new GridLayout(5,1));
f.add(lt);
f.add(p1);
f.add(p2);
f.add(p);
f.add(p3);
f.setSize(400,300);
Dimension dim=Toolkit.getDefaultToolkit().getScreenSize();
int x=(int)((dim.getWidth()-f.getWidth())/2);
int y=(int)((dim.getHeight()-f.getHeight())/2);
f.setLocation(x, y);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
BufferedImage getImage() {
image=new BufferedImage(60, 20,BufferedImage.TYPE_INT_RGB);
Graphics g=image.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, 60, 20);
g.setColor(Color.red);
g.setFont(new Font("宋体", Font.BOLD, 15));
String st="";
for(int i=0;i<4;i++) {
int x=(int)(Math.random()*10);
st=String.valueOf(x);
scode+=st;
g.drawString(st, 15*i+5, 12);
}
for(int i=0;i<100;i++) {
g.setColor(new Color(50+(int)(Math.random()*100), 50+(int)(Math.random()*100), 50+(int)(Math.random()*100)));
g.drawOval((int)(Math.random()*60), (int)(Math.random()*20), 1, 1);
}
return image;
}
class MyListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if(e.getSource()==b1) {
String uName=t1.getText(); //用户输入的用户名
char s[]=t2.getPassword();
String uPass=String.valueOf(s); //用户输入的密码
String ucode = tv.getText();//用户输入的验证码
System.out.println("输入的账号"+uName+",密码:"+uPass+",验证码:"+ucode+",下面开始验证。。。");
if(ucode.equals(scode)) {
}else {
JOptionPane.showMessageDialog(null,"验证失败");
}
Connection con = null;
Statement st= null;
ResultSet rs= null;
try {
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://127.0.0.1:3306/yh";
con = DriverManager.getConnection(url, "root", "123456");
st = con.createStatement();
String sql = "select * from dl where 账号='"+uName+"'and 密码='"+uPass+"'";
rs = st.executeQuery(sql);
System.out.println(sql);
if(rs.next()) {
//System.out.println(rs.getRow()+":"+uName+"\t"+uPass);
JOptionPane.showMessageDialog(f,"登录成功");
f.setVisible(false);
new guanli();
}else {
JOptionPane.showMessageDialog(f,"登录失败\n账号或密码错误!!");
new Login();
}
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}finally {
if(rs!=null)
try {
rs.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
if(st!=null)
try {
st.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
if(con!=null)
try {
con.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
else if(e.getSource()==b3) {
f.dispose();
new zhuce();
}
else System.exit(0);
}
}
public static void main(String args[]) {
Login l=new Login();
l.init();
}
}