import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import java.awt.geom.*;
public class denglu extends Frame
{
public Label name=new Label("用户名");
public Label pass=new Label("密码");
public TextField txtname=new TextField();
public TextField txtpass=new TextField();
public Button btok=new Button("登陆");
public Button btexit=new Button("取消");
public dbcon conu=new dbcon();
private String sql=null;
private ResultSet rs=null;
//private Image img;
ImageIcon img;
public denglu()
{
//img=getToolkit().getImage(getClass().getResource("/ww.jpg"));
img=new ImageIcon("dl.jpg");
//Dimension scr=Toolkit.getDefaultToolkit().getScreenSize();
// Dimension frm=this.getSize();
//setLocation((scr.width-frm.width)/2,(scr.height-frm.height)/2-18);
txtpass.setEchoChar('*');
txtname.setBounds(120,260,120,27);
txtpass.setBounds(120,300,120,27);
btok.setBounds(340,260,100,28);
btexit.setBounds(340,300,100,28);
add(name);
add(txtname);
add(pass);
add(txtpass);
add(btok);
add(btexit);
setTitle("欢迎使用工资管理系统");
setLayout(null);
setResizable(false);
setSize(500,350);
setLocationRelativeTo(null);
setVisible(true);
btexit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
dispose();
System.exit(0);
} });
btok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
sql="select * from 用户信息 where 职工号='"+txtname.getText()+"' and 密码='"+txtpass.getText()+"'";
try {
rs=conu.getrs(conu.con,sql);
if(rs.next())
{ mainBorder mb=new mainBorder(txtname.getText());
setVisible(false);
}
else { JOptionPane jop=new JOptionPane();
jop.showMessageDialog(null,"用户名或密码错误","信息提示!",-1);}
}catch(Exception ee){}
}
} );
addWindowListener( new WindowAdapter()
{public void windowClosing(WindowEvent e)
{ dispose();
System.exit(0);
}
} );
}
public void paint(Graphics g)
{
g.drawImage(img.getImage(),0,0,this.getWidth(),this.getHeight(),this);
}
public static void main(String args[])
{ denglu dl=new denglu();
}
}