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;
}
}
9万+

被折叠的 条评论
为什么被折叠?



