package gongzi;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class UI_2_IM_xiugai extends JFrame{
public UI_2_IM_xiugai() {
super();
this.setTitle("修改员工信息");
getContentPane().setLayout(null);
setSize(450, 600);
setLocationRelativeTo(null);
setResizable(false);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageIcon img = new ImageIcon("E:\\2.jpg");
JLabel jl_bg = new JLabel(img); //背景
jl_bg.setBounds(0,0,450,600); //设置位置和大小,先setLayout(null)一下。
getLayeredPane().add(jl_bg, new Integer(Integer.MIN_VALUE));
((JPanel)this.getContentPane()).setOpaque(false); //设置透明
final JLabel label_1 = new JLabel();
label_1.setText("员工编号:");
label_1.setBounds(45, 20, 70, 30);
getContentPane().add(label_1);
final JLabel label_2 = new JLabel();
label_2.setText("姓名:");
label_2.setBounds(60, 70, 70, 30);
getContentPane().add(label_2);
final JLabel label_3 = new JLabel();
label_3.setText("性别:");
label_3.setBounds(60, 120, 70, 30);
getContentPane().add(label_3);
final JLabel label_4 = new JLabel();
label_4.setText("身份证号:");
label_4.setBounds(45, 170, 70, 30);
getContentPane().add(label_4);
final JLabel label_5 = new JLabel();
label_5.setText("入职日期:");
label_5.setBounds(45, 220, 70, 30);
getContentPane().add(label_5);
final JLabel label_6 = new JLabel();
label_6.setText("所在部门:");
label_6.setBounds(45, 270, 70, 30);
getContentPane().add(label_6);
final JLabel label_7 = new JLabel();
label_7.setText("工作岗位:");
label_7.setBounds(45, 320, 70, 30);
getContentPane().add(label_7);
final JLabel label_8 = new JLabel();
label_8.setText("民族:");
label_8.setBounds(60, 370, 70, 30);
getContentPane().add(label_8);
final JLabel label_9 = new JLabel();
label_9.setText("籍贯:");
label_9.setBounds(60, 420, 70, 30);
getContentPane().add(label_9);
final JLabel label_10 = new JLabel();
label_10.setText("现住址:");
label_10.setBounds(45, 470, 70, 30);
getContentPane().add(label_10);
final JLabel label_11 = new JLabel();
label_11.setText("权限:");
label_11.setBounds(60, 520, 70, 30);
getContentPane().add(label_11);
final JTextField b1= new JTextField(10);
b1.setBounds(120, 20, 180, 27);
getContentPane().add(b1);
final JTextField b2= new JTextField(15);
b2.setBounds(120, 70, 180, 27);
getContentPane().add(b2);
final JTextField b3= new JTextField(15);
b3.setBounds(120, 120, 180, 27);
getContentPane().add(b3);
final JTextField b4= new JTextField(15);
b4.setBounds(120, 170, 180, 27);
getContentPane().add(b4);
final JTextField b5= new JTextField(15);
b5.setBounds(120, 220, 180, 27);
getContentPane().add(b5);
final JTextField b6= new JTextField(15);
b6.setBounds(120, 270, 180, 27);
getContentPane().add(b6);
final JTextField b7= new JTextField(15);
b7.setBounds(120, 320, 180, 27);
getContentPane().add(b7);
final JTextField b8= new JTextField(15);
b8.setBounds(120, 370, 180, 27);
getContentPane().add(b8);
final JTextField b9= new JTextField(15);
b9.setBounds(120, 420, 180, 27);
getContentPane().add(b9);
final JTextField b10= new JTextField(15);
b10.setBounds(120, 470, 180, 27);
getContentPane().add(b10);
final JTextField b11= new JTextField(15);
b11.setBounds(120, 520, 180, 27);
getContentPane().add(b11);
final JButton button1 = new JButton();
button1.setText("查询");
button1.setBounds(310, 20, 100, 30);
getContentPane().add(button1);
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String b_1 = b1.getText();
// dispose();
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("加载驱动成功!");
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=db_gz","sa","123456");
System.out.println("连接数据库成功!");
Statement stmt_1=con.createStatement();
String sql_1 = "select * FROM ygdata WHERE 员工编号='"+ b_1 +"'";
ResultSet rs_1=stmt_1.executeQuery(sql_1);
if (rs_1.next()) {
b2.setText(rs_1.getString(2));
b3.setText(rs_1.getString(3));
b4.setText(rs_1.getString(4));
b5.setText(rs_1.getString(5));
b6.setText(rs_1.getString(6));
b7.setText(rs_1.getString(7));
b8.setText(rs_1.getString(8));
b9.setText(rs_1.getString(9));
b10.setText(rs_1.getString(10));
b11.setText(rs_1.getString(11));
}
else {
JOptionPane.showMessageDialog(new JPanel(), "数据库中没有该员工信息!", "提示",JOptionPane.WARNING_MESSAGE);
dispose();
UI_2_IM u=new UI_2_IM();
}
rs_1.close();
stmt_1.close();
con.close();
}
catch(Exception ee){
ee.printStackTrace();
System.out.println("连接数据库失败!");
}
}
});
final JButton button2 = new JButton();
button2.setText("重置");
button2.setBounds(310, 60, 100, 30);
getContentPane().add(button2);
button2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
b1.setText("");
b2.setText("");
b3.setText("");
b4.setText("");
b5.setText("");
b6.setText("");
b7.setText("");
b8.setText("");
b9.setText("");
b10.setText("");
b11.setText("");
}
});
final JButton button3 = new JButton();
button3.setText("修改");
button3.setBounds(310, 100, 100, 30);
getContentPane().add(button3);
button3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String b_1 = b1.getText();
String b_2 = b2.getText();
String b_3 = b3.getText();
String b_4 = b4.getText();
String b_5 = b5.getText();
String b_6 = b6.getText();
String b_7 = b7.getText();
String b_8 = b8.getText();
String b_9 = b9.getText();
String b_10 = b10.getText();
String b_11 = b11.getText();
// dispose();
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("加载驱动成功!");
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=db_gz","sa","123456");
System.out.println("连接数据库成功!");
Statement stmt_1=con.createStatement();
Statement stmt_2=con.createStatement();
String sql_1 = "DELETE FROM ygdata WHERE 员工编号='"+ b_1 +"'";
String sql_2 = "insert into ygdata values('"+b_1+"','"+b_2+"','"+b_3+"','"+b_4+"','"+b_5+"','"+b_6+"','"+b_7+"','"
+b_8+"','"+b_9+"','"+b_10+"','"+b_11+"')";
int T=stmt_1.executeUpdate(sql_1);
if (T>0) {
int t = stmt_2.executeUpdate(sql_2);
if(t>0) {
JOptionPane.showMessageDialog(new JPanel(), "成功修改员工信息", "提示",JOptionPane.INFORMATION_MESSAGE);
dispose();
UI_2_IM u=new UI_2_IM();
}
else {
JOptionPane.showMessageDialog(new JPanel(), "员工"+b_2+"的信息被删除", "警告",JOptionPane.INFORMATION_MESSAGE);
dispose();
UI_2_IM u=new UI_2_IM();
}
}
else {
JOptionPane.showMessageDialog(new JPanel(), "员工"+b_2+"的信息被删除", "警告",JOptionPane.IN
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
gz.rar (86个子文件)
gz
src
gongzi
UI_2_IM.java 5KB
UI_2_FX.java 4KB
UI_2_GZ_shanchu.java 4KB
UI_2_IM_tianjia.java 7KB
UI_1.java 2KB
JTextFieldHintListener.java 1KB
UI_2_IM_shanchu.java 3KB
UI_2_IM_xiugai.java 9KB
UI_2.java 2KB
DbUtil.java 2KB
UI_2_GZ_tianjia.java 7KB
UI_1_xinxi.java 6KB
Test.java 150B
UI_2_GZ.java 5KB
UI_2_GZ_xiugai.java 8KB
DL.java 5KB
UI_2_IM_chaxun.java 6KB
UI_2_GZ_chaxun.java 5KB
bin
gongzi
UI_2_IM_shanchu$2.class 3KB
UI_1.class 2KB
UI_2$3.class 694B
UI_2_GZ_shanchu$2.class 3KB
UI_2_FX$1.class 706B
DL.class 5KB
UI_2_GZ$2.class 728B
UI_2_GZ$3.class 726B
UI_2_IM_tianjia.class 4KB
UI_2_IM$4.class 726B
UI_2_GZ_tianjia.class 3KB
UI_2_IM$5.class 706B
UI_2_GZ_shanchu.class 2KB
UI_1_xinxi$1.class 859B
UI_2_GZ_chaxun$1.class 3KB
UI_2_IM_xiugai$1.class 3KB
UI_1$3.class 752B
UI_2_IM$3.class 726B
UI_2_IM_tianjia$2.class 760B
UI_2_IM_xiugai$2.class 1KB
UI_2_GZ_chaxun$3.class 754B
UI_2_GZ.class 5KB
UI_2_GZ_xiugai$2.class 1KB
UI_2$1.class 696B
UI_2_GZ_tianjia$1.class 4KB
UI_2_GZ_xiugai$1.class 3KB
UI_2_GZ$4.class 726B
UI_2_IM_shanchu.class 2KB
UI_1_xinxi.class 6KB
UI_2_GZ_xiugai.class 3KB
UI_2_IM_chaxun$3.class 754B
DL$1.class 795B
UI_2_IM_shanchu$1.class 760B
UI_2.class 2KB
UI_2_GZ_xiugai$3.class 4KB
UI_2_IM$1.class 729B
UI_1$1.class 836B
UI_2_GZ_tianjia$2.class 3KB
UI_2$4.class 624B
UI_1_xinxi$2.class 859B
UI_2_IM_chaxun.class 4KB
UI_2_IM_xiugai$4.class 754B
UI_2$2.class 696B
UI_2_GZ_tianjia$3.class 760B
DLTest.class 842B
UI_2_IM.class 5KB
UI_2_IM_chaxun$1.class 3KB
JTextFieldHintListener.class 1KB
DL$2.class 666B
UI_2_GZ_xiugai$4.class 754B
UI_2_IM_xiugai$3.class 4KB
UI_1$2.class 836B
UI_2_IM_tianjia$1.class 4KB
UI_2_GZ$1.class 729B
UI_2_GZ_chaxun$2.class 1KB
DbUtil.class 2KB
UI_2_GZ$5.class 706B
Test.class 434B
UI_2_IM_chaxun$2.class 1KB
UI_2_FX.class 4KB
UI_2_IM_xiugai.class 4KB
UI_2_GZ_chaxun.class 3KB
UI_2_IM$2.class 728B
UI_2_GZ_shanchu$1.class 760B
.classpath 504B
.settings
org.eclipse.jdt.core.prefs 670B
.project 378B
test
gongzi
DLTest.java 363B
共 86 条
- 1
资源评论
大胖东
- 粉丝: 1451
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功