工资系统代码JAVA版Word格式.docx
《工资系统代码JAVA版Word格式.docx》由会员分享,可在线阅读,更多相关《工资系统代码JAVA版Word格式.docx(45页珍藏版)》请在冰豆网上搜索。
JButtonbutton2=newJButton("
退出系统"
ImageIconim=newImageIcon("
1.jpg"
JLabela1=newJLabel(im);
voidCreate()
{
JPanelpcontentPane=(JPanel)frame.getContentPane();
pcontentPane.add(a1);
pcontentPane.setLayout(newFlowLayout());
pcontentPane.add(button1);
pcontentPane.add(button2);
pcontentPane.setVisible(true);
button1.addActionListener(this);
button2.addActionListener(this);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
publicstaticvoidmain(String[]args)
{
WagesSystemdome=newWagesSystem();
dome.Create();
publicvoidactionPerformed(ActionEvente)
if(button1.equals(e.getSource()))
{
DLdl=newDL();
dl.create();
frame.dispose();
}
if(button2.equals(e.getSource()))
{
System.exit(0);
}
/*登录界面*/
importjava.awt.HeadlessException;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.sql.Statement;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPasswordField;
importjavax.swing.JTextField;
import.*;
importjava.sql.*;
classDLextendsJFrameimplementsActionListener
{
NetConnsql;
Statementsqll;
ResultSetrs;
职工/管理员登陆"
JLabellabel1=newJLabel("
用户名"
JLabellabel2=newJLabel("
密码"
JButtonlogonButton1=newJButton("
系统管理员登录"
JButtonlogonButton2=newJButton("
教职工登录"
JButtonlogonButton3=newJButton("
财务管理员登录"
JButtoncancelButton=newJButton("
退出"
JTextFieldusername=newJTextField(9);
JPasswordFieldpassword=newJPasswordField(9);
staticStringt1;
staticStringt2;
voidcreate()
frame.setLayout(null);
label1.setBounds(60,20,50,20);
frame.add(label1);
username.setBounds(130,20,150,20);
frame.add(username);
label2.setBounds(60,50,50,20);
frame.add(label2);
password.setBounds(130,50,150,20);
frame.add(password);
logonButton1.setBounds(100,90,150,20);
frame.add(logonButton1);
logonButton2.setBounds(100,120,150,20);
frame.add(logonButton2);
logonButton3.setBounds(100,150,150,20);
frame.add(logonButton3);
cancelButton.setBounds(100,180,150,20);
frame.add(cancelButton);
logonButton1.addActionListener(this);
logonButton2.addActionListener(this);
logonButton3.addActionListener(this);
cancelButton.addActionListener(this);
sql=newNetConn();
//建立数据库连接
frame.setSize(350,250);
}
@SuppressWarnings("
deprecation"
t1=username.getText();
t2=password.getText();
//系统管理员登录
if(e.getSource()==logonButton1)
if(username.getText().equals("
admin"
)==true
&
&
(password.getText().equals("
)==true))
{
JOptionPane.showMessageDialog(this,"
登录成功!
"
xtglya=newxtgly();
frame.dispose();
}
else
JOptionPane.showMessageDialog(null,"
输入用户名或密码错误!
}
}
//教职工登陆
if(e.getSource()==logonButton2)
sqll=sql.connect();
try
rs=sqll.executeQuery("
SELECT*FROMuser_teacherwherename="
+"
'
+username.getText()+"
Stringsname,spass;
if(rs.next())
{
sname=rs.getString
(2);
spass=rs.getString(3);
if((password.getText().trim().equals(spass))&
(username.getText().trim().equals(sname)))
{
JOptionPane.showMessageDialog(this,"
Teacher_Pa=newTeacher_P();
a.creat(rs.getString
(1));
frame.dispose();
}
else
JOptionPane.showMessageDialog(null,"
}
}
else
JOptionPane.showMessageDialog(null,"
用户不存在!
catch(SQLExceptione2){
//TODO自动生成的catch块
e2.printStackTrace();
//财务登陆
if(e.getSource()==logonButton3)
SELECT*FROMuser_cwwherename="
CW