s1(java)项目实战(固定资产管理)(op_login )

 package op;

import java.awt.*;

import javax.swing.*;
import java.awt.Rectangle;
import java.awt.event.*;
import tools.*;
import java.util.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class login extends JDialog {
    JPanel panel1 = new JPanel();
    JComboBox jComboBox1;
    JPasswordField jPasswordField1 = new JPasswordField();
    JButton jButton1 = new JButton();
    JButton btn_ok = new JButton();
    DBConnection dcon = null;
    String name = null;

    public login(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        try {
            this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            jbInit();
            pack();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public login() {
        this(new Frame(), "login", false);
    }

    private void jbInit() throws Exception {
        panel1.setLayout(null);
        jComboBox1 = new JComboBox(getM());
        jComboBox1.setBounds(new Rectangle(55, 26, 130, 32));
        jPasswordField1.setText("");
        jPasswordField1.setBounds(new Rectangle(54, 85, 131, 37));
        jButton1.setBounds(new Rectangle(140, 144, 86, 37));
        jButton1.setText("关闭");
        btn_ok.setBounds(new Rectangle(20, 143, 89, 41));
        btn_ok.setText("确定");
        getContentPane().add(panel1);
        panel1.add(jComboBox1, null);
        panel1.add(jPasswordField1);
        panel1.add(btn_ok);
        panel1.add(jButton1);
        this.setResizable(false);
        jButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        btn_ok.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                loginW();
            }
        });
    }
public  void closed()
    {
        this.dispose();
    }

    private void loginW() {
        if (jPasswordField1.getPassword().length == 0) {
            JOptionPane.showMessageDialog(this, "密码没有输入");
        } else {
            dcon = new DBConnection();
            String strpass = new String(jPasswordField1.getPassword()).trim();
            String sql = "select * from Manager where  manager_username='" +
                         jComboBox1.getSelectedItem().toString().trim() +
                         "'  and manager_password='" + strpass + "'";
            if (!dcon.isNull(sql)) {
                jPasswordField1.setText("");
                JOptionPane.showMessageDialog(this, "密码错误");
                name = null;
            }else {
                this.setVisible(false);
                name =  jComboBox1.getSelectedItem().toString().trim();
                }
            }
    }

    private String[] getM() {
        dcon = new DBConnection();
        String sql = "select manager_username from Manager";
        Vector v = dcon.select(sql);
        String[] manger = new String[v.size()];
        for (int i = 0; i < v.size(); i++) {
            manger[i] = ((Vector) v.get(i)).get(0).toString().trim();
        }
        return manger;
    }
    public String username()
    {
        return   name;
    }
}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值