登录界面
public class GUI_zhuyemian extends JFrame {
Box one,two,three,four;
JButton a1,a2,a3;
JLabel b1,b2;
JTextField c1;
JPasswordField c2;
GUI_zhuyemian () {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int height = screenSize.height;
int height1 = this.getHeight();
int width1 = this.getWidth();
int width = screenSize.width;
this.setLocation((width - width1 - 500) / 2, (height - height1 - 500) / 2);
setLayout(new FlowLayout());
three = Box.createVerticalBox();
one = Box.createHorizontalBox();
two = Box.createHorizontalBox();
four = Box.createHorizontalBox();
a3 = new JButton("清空");
a1 = new JButton("登录");
a2 = new JButton("取消");
b1 = new JLabel("工作人员");
b2 = new JLabel("工作号码");
c1 = new JTextField(10);
c2 = new JPasswordField(10);
b1.setFont(new Font("黑体",Font.BOLD,20));
b2.setFont(new Font("黑体",Font.BOLD,20));
c1.setFont(new Font("谐体",Font.BOLD,15));
a1.setFont(new Font("黑体",Font.BOLD,15));
a2.setFont(new Font("黑体",Font.BOLD,15));
a3.setFont(new Font("黑体",Font.BOLD,15));
a1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
SY_sxl sy = new SY_sxl();
Connection connection = DBUtils_one.getConnection();
String a = "select Worker_number from SY_1 where Worker_name='" + c1.getText() + "'";
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(a);
if (rs.next()) {
sy.setWorker_number(rs.getInt("Worker_number"));
}
if (c2.getText().equals(String.valueOf(sy.getWorker_number()))) {
int re = JOptionPane.showConfirmDialog(null, "登陆成功", "登录提示", JOptionPane.PLAIN_MESSAGE);
if (re == 0) {
GUI_jiemian.show(new GUI_next(), 500, 500);
setVisible(false);
}
} else {
JOptionPane.showMessageDialog(null, "登陆失败", "登录提示", JOptionPane.ERROR_MESSAGE);
}
DBUtils.release(connection);
DBUtils.release(statement);
DBUtils.release(rs);
} catch (ClassNotFoundException g) {
g.printStackTrace();
} catch (SQLException g) {
g.printStackTrace();
}
}
});
a2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
a3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
c1.setText(null);
c2.setText(null);
}
});
two.add(b1);
two.add(Box.createHorizontalStrut(20));
two.add(c1);
one.add(b2);
one.add(Box.createHorizontalStrut(20));
one.add(c2);
four.add(a1);
four.add(Box.createHorizontalStrut(20));
four.add(a2);
four.add(Box.createHorizontalStrut(20));
four.add(a3);
three.a