利用JDBC,数据库,GUI设计Java课程设计的设备管理系统

登录界面

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.add(two);
        three.ad
  • 8
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值