工资系统代码JAVA版.docx
- 文档编号:2442380
- 上传时间:2022-10-29
- 格式:DOCX
- 页数:45
- 大小:24.57KB
工资系统代码JAVA版.docx
《工资系统代码JAVA版.docx》由会员分享,可在线阅读,更多相关《工资系统代码JAVA版.docx(45页珍藏版)》请在冰豆网上搜索。
工资系统代码JAVA版
工资系统代码
/*系统欢迎界面*/
importjava.awt.FlowLayout;
importjava.awt.event.*;
importjavax.swing.*;
@SuppressWarnings("serial")
classWagesSystemextendsJFrameimplementsActionListener
{
JFrameframe=newJFrame("欢迎进入工资管理系统");
JButtonbutton1=newJButton("进入系统");
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.*;
@SuppressWarnings("serial")
classDLextendsJFrameimplementsActionListener
{
NetConnsql;
Statementsqll;
ResultSetrs;
JFrameframe=newJFrame("职工/管理员登陆");
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);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@SuppressWarnings("deprecation")
publicvoidactionPerformed(ActionEvente)
{
t1=username.getText();
t2=password.getText();
//系统管理员登录
if(e.getSource()==logonButton1)
{
if(username.getText().equals("admin")==true
&&(password.getText().equals("admin")==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)
{
sqll=sql.connect();
try
{
rs=sqll.executeQuery("SELECT*FROMuser_cwwherename="+"'"+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,"登录成功!
");
CW
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 工资 系统 代码 JAVA
![提示](https://static.bdocx.com/images/bang_tan.gif)