源代码
package lesson2;
import java。sql。*;
public class employee {
public String num; public String name; public String sex; public String age; public String edu; public String sla; public String add; public String tel;
public void init(String x1,String x2,String x3,String x4,String x5,String x6,String x7,String x8) {
num=x1; name=x2; sex=x3; age=x4; edu=x5; sla=x6; add=x7; tel=x8;
}
public void load(String f) {
try
{
Class.forName(”com.microsoft。sqlserver。jdbc。SQLServerDriver”); String url=\"jdbc:sqlserver://localhost:1433;DatabaseName=employee”;
String userName=”sa”; String password=”xhw”; Connection conn=DriverManager。getConnection(url,userName,password); if(conn!=null)
System.out.println(”已成功地与SQL Server 2005数据库建立连接!”);
Statement stmt=conn。createStatement(); stmt.executeUpdate(f); stmt。close(); }
catch(Exception e) {
e。printStackTrace(); } } }
package lesson2;
import java。awt。*;
import java。awt。event。*; import java。sql.*;
public class lesson2_1 {
static Frame f;
CardLayout myCard; Panel p1; Panel p2; Panel p3; Panel p4; Panel p5; Panel p6; Panel p7; Panel p8;
public static void main(String[] args) {
lesson2_1 test=new lesson2_1(); test.go1(); test。go2(); test。go3(); test。go4();
}
test。go5(); test。go6(); test.go7(); test。go8();
public void go1() {
f=new Frame(\"呵 呵 !!!\"); myCard=new CardLayout(); f。setLayout(myCard);
p1=new Panel();
Button b1,b2,b3;
Label L1;
TextField te1;
final TextField te2;
p1.setLayout(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints();
Panel p1_1=new Panel();
p1_1。setLayout(new GridBagLayout());
GridBagConstraints x=new GridBagConstraints();
b1=new Button(\" 请 输 入 用 户 名 ”); b1。setBackground(Color.CYAN);
x。insets=new Insets(50,50,50,50); x。gridx=0; x。gridy=0;
x。gridwidth=1; x。gridheight=1; p1_1。add(b1,x);
b2=new Button(” 请 输 入 密 码 ”); b2。setBackground(Color。CYAN);
x.gridx=0; x.gridy=5;
x。gridwidth=1; x。gridheight=1; p1_1.add(b2,x);
te1=new TextField(15);
c。insets=new Insets(40,0,40,0);
x。gridx=5; x。gridy=0;
x。gridwidth=1; x。gridheight=1; p1_1。add(te1,x);
te2=new TextField(15); x.gridx=5;
x.gridy=5;
x。gridwidth=1; x。gridheight=1; p1_1。add(te2,x);
L1=new Label(” * * * * * * * * * *欢 迎 进 入 职 工 管 理 系 统* * * * * * * * * * * * * *\");
L1.setBackground(Color。CYAN); c。gridx=0; c.gridy=0;
c.gridwidth=0; c.gridheight=1;
p1。add(L1,c);
b3=new Button(” 登 录 b3。setBackground(Color。CYAN); c。gridx=0; c。gridy=10; c。gridwidth=5; c。gridheight=5; p1。add(b3,c);
\");
c。gridx=0; c。gridy=20; c。gridwidth=5; c。gridheight=5; p1.add(p1_1,c);
p1.setBackground(Color。green); f.add(p1,\"First”);
myCard.show(f,\"First”); f。setSize(600,600);
}
f。setVisible(true); f。addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System。exit(0); } } );
b3.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) {
String x=te2。getText(); int y=Integer。parseInt(x); if(y==106) myCard。show(f,”Second\"); } });
public void go2() {
p2=new Panel();
Button b1,b2,b3,b4,b5,b6; Label L1;
p2.setLayout(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints(); c。insets=new Insets(50,0,8,0);
b1 = new Button(”1 职 工 信 息 录 b1。setBackground(Color。CYAN); c.gridx=1;
c。gridy=50; c。gridwidth=5; c。gridheight=50; p2.add(b1,c);
b2=new Button(”2 职 工 信 息 浏 b2。setBackground(Color.CYAN); c。gridx=1; c。gridy=100; c。gridwidth=5; c.gridheight=50; p2.add(b2,c);
b3=new Button(”3 职 工 信 息 查 询b3.setBackground(Color。CYAN); c。gridx=1; c。gridy=150; c。gridwidth=5; c。gridheight=50; p2.add(b3,c);
b4=new Button(”4 职 工 信 息 排 序”); b4。setBackground(Color。CYAN); c。gridx=1; c。gridy=200; c。gridwidth=5; c.gridheight=50;
入”);
览”); \");
\");
入 职
p2。add(b4,c);
b5=new Button(”5 职 工 信 息 修 改”); b5.setBackground(Color。CYAN); c。gridx=1; c.gridy=250; c.gridwidth=5; c.gridheight=50; p2.add(b5,c);
b6=new Button(”6 职 工 信 息 删 除b6.setBackground(Color.CYAN); c.gridx=1; c。gridy=300; c。gridwidth=5; c.gridheight=50;
p2.add(b6,c);
L1=new Label(\" * * * * * * * *欢 迎 进 工 管 理 系 统* * * * * * * * * *\"); L1.setBackground(Color。CYAN); c。gridx=1; c。gridy=0; c.gridwidth=5; c.gridheight=10; p2.add(L1,c);
p2。setBackground(Color。green); f。add(p2,\"Second\"); b1.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
myCard.show(f,\"Third”); } });
b2。addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) {
myCard.show(f,”Fourth”); } });
b3。addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) {
myCard。show(f,”Fifth\"); } });
b4。addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) {
myCard.show(f,”Sixth\"); }
});
b5。addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) {
myCard.show(f,\"Seventh”); } });
b6。addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
myCard。show(f,\"Eighth\"); } });
}
public void go3() {
p3=new Panel();
p3.setLayout(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints();
Button b1,b2,b3,b4,b5,b6,b7,b8,b9,b10;
final TextField te1,te2,te3,te4,te5,te6,te7,te8; Label L1;
c.insets=new Insets(60,50,0,0);
L1=new Label(”* * * * * * * * * * * * * * * 请 输 入 下 面 信 息 * * * * * * * * * * * * * * * *”);
L1。setBackground(Color。CYAN);
c.gridx=0; c.gridy=0;
c。gridwidth=0; c.gridheight=1; p3。add(L1,c);
b1=new Button(\" 工 号 ”); b1.setBackground(Color.CYAN); c。gridx=0; c.gridy=10; c.gridwidth=1; c。gridheight=1; p3.add(b1,c);
b2=new Button(” 姓 名 \"); b2。setBackground(Color.CYAN); c.gridx=35; c。gridy=10; c。gridwidth=1; c.gridheight=1; p3。add(b2,c);
b3=new Button(” 性 别 \"); b3。setBackground(Color。CYAN); c.gridx=0; c.gridy=30; c。gridwidth=1; c。gridheight=1; p3。add(b3,c);
b4=new Button(” 年 龄 ”); b4。setBackground(Color.CYAN); c。gridx=35; c。gridy=30;
c。gridwidth=1; c.gridheight=1; p3。add(b4,c);
b5=new Button(\" 学 历 \"); b5。setBackground(Color。CYAN); c。gridx=0; c。gridy=50; c。gridwidth=1; c。gridheight=1;
p3。add(b5,c);
b6=new Button(” 工 资 \"); b6。setBackground(Color。CYAN); c。gridx=35; c。gridy=50; c。gridwidth=1; c.gridheight=1; p3。add(b6,c);
b7=new Button(” 住 址 ”); b7.setBackground(Color。CYAN); c。gridx=0; c。gridy=70;
c。gridwidth=1; c。gridheight=1; p3。add(b7,c);
b8=new Button(\" 电 话 ”);
b8.setBackground(Color。CYAN); c。gridx=35; c。gridy=70; c。gridwidth=1; c.gridheight=1; p3。add(b8,c);
b9=new Button(\" 提 交 \"b9。setBackground(Color。CYAN); c。gridx=10; c.gridy=100; c。gridwidth=1; c。gridheight=1; p3。add(b9,c);
b10=new Button(” 返 回b10.setBackground(Color.CYAN); c.gridx=35; c.gridy=100;
c.gridwidth=1; c。gridheight=1; p3.add(b10,c); te1=new TextField(10); c.gridx=10;
); );
\"
c。gridy=10; c。gridwidth=1; c。gridheight=1; p3.add(te1,c);
te2=new TextField(10); c。gridx=37; c。gridy=10; c.gridwidth=1; c.gridheight=1; p3。add(te2,c);
te3=new TextField(10); c。gridx=10; c.gridy=30;
c。gridwidth=1; c。gridheight=1; p3。add(te3,c);
te4=new TextField(10); c。gridx=37; c。gridy=30; c.gridwidth=1; c.gridheight=1; p3。add(te4,c);
te5=new TextField(10); c.gridx=10; c。gridy=50; c.gridwidth=1; c.gridheight=1; p3。add(te5,c);
te6=new TextField(10); c。gridx=37; c。gridy=50; c.gridwidth=1; c。gridheight=1; p3.add(te6,c);
te7=new TextField(10); c。gridx=10; c.gridy=70; c。gridwidth=1;
c。gridheight=1; p3。add(te7,c);
te8=new TextField(10); c。gridx=37; c。gridy=70; c.gridwidth=1; c。gridheight=1; p3。add(te8,c);
p3.setBackground(Color.green); f.add(p3,”Third\");
b9.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
employee e1=new employee(); e1.init(te1。getText(),te2.getText(),te3。getText(),te4。getText(),
te5。getText(),te6。getText(),te7.getText(),te8。getText());
String x=”’\"; String y=\"'\";
String z=”,”; String w=\")\";
String sql=”insert into xhw values(\"; sql=sql+x+e1
num+y+z+x+e1.name+y+z+x+e1.sex+y+z+x+e1。age+y+z+x+e1。edu+y+z +x+e1.sla+y+z+x+e1。add+y+z+x+e1.tel+y+w; e1.load(sql);
te1。setText(\"”); te2.setText(\"\"); te3。setText(\"”); te4.setText(””); te5。setText(””); te6.setText(”\"); te7。setText(”\"); te8。setText(”\");
。
}
} });
b10。addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) {
myCard.show(f,\"Second”); } });
public void go4() {
p4=new Panel();
p4.setLayout(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints();
Button b1,b2; Label L1;
final TextArea ta;
c.insets=new Insets(60,0,0,0);
L1=new Label(”* * * * * * * * * * * * * * * 欢 迎 进 入 信 息 浏 览 界 面 * * * * * * * * * * * * * * * *\");
L1。setBackground(Color.CYAN); c。gridx=0; c.gridy=0;
c。gridwidth=0; c。gridheight=1; p4。add(L1,c);
b1=new Button(” 浏 览 ”); b1。setBackground(Color.CYAN); c.gridx=0; c。gridy=10; c。gridwidth=1; c.gridheight=1; p4.add(b1,c);
b2=new Button(\" 返 回 ”); b2。setBackground(Color.CYAN); c.gridx=0; c。gridy=20; c。gridwidth=1; c。gridheight=1; p4。add(b2,c);
ta= new TextArea(15,50); c。gridx=0; c.gridy=11; c。gridwidth=1; c.gridheight=1; p4.add(ta,c);
p4。setBackground(Color。green); f。add(p4,”Fourth”);
b1。addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) { try {
Class.forName(”com。microsoft.sqlserver。jdbc.SQLServerDriver\"); String url=”jdbc:sqlserver://localhost:1433;DatabaseName=employee”; String userName=”sa\"; String password=”xhw”; Connection conn=DriverManager.getConnection(url,userName,password); xhw”);
Statement stmt=conn。createStatement();
ResultSet rs=stmt。executeQuery(\"select * from
employee[] em =new employee[10]; int i=0;
while(rs。next()) {
employee em1=new employee(); em1。num=rs.getString(”工号”); em1。name=rs。getString(”姓名\");
}
em1。sex=rs.getString(”性别\"); em1。age=rs.getString(”年龄\"); em1。edu=rs.getString(\"学历\"); em1。sla=rs。getString(”工资\"); em1.add=rs.getString(”住址”); em1。tel=rs。getString(”电话”); em[i]=em1; i++;
\电话\\n\";
String s = ”工号\姓名\性别\年龄\学历\工资\住址 for(int j=0;js=s+em[j]。num+\"\\"+em[j]。name+\"\”+em[j]。sex+”\”+em[j]。age+”\\"+
em[j]。edu+\"\”+em[j]。sla+”\”+em[j]。add+”\”+em[j]。tel+”\\n\\n”;
}
ta。setText(s); rs.close();
stmt.close();
}
catch(Exception e1)
{ e1。printStackTrace(); }
}
});
b2。addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
ta。setText(”\"); myCard.show(f,”Second”); }
}); }
public void go5() {
p5=new Panel();
p5。setLayout(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints(); c。insets=new Insets(40,0,0,0);
Panel p5_2=new Panel();
p5_2.setLayout(new GridBagLayout());
GridBagConstraints x=new GridBagConstraints(); x。insets=new Insets(30,60,0,80);
Button b1,b2,b3,b4; final TextField t1; final TextField t2; final TextArea ta; Label L1;
b1=new Button(” 查 询 名 称 ”); b1.setBackground(Color。CYAN); x。gridx=0; x。gridy=0;
x。gridwidth=2; x.gridheight=1; p5_2.add(b1,x);
b2=new Button(” 查 询 范 围 ”); b2。setBackground(Color。CYAN); x。gridx=0; x。gridy=5;
x。gridwidth=2; x。gridheight=1; p5_2。add(b2,x);
b3=new Button(\" 查 询 \"); b3。setBackground(Color.CYAN); x。gridx=0; x。gridy=10; x.gridwidth=2; x。gridheight=1; p5_2。add(b3,x);
b4=new Button(\" 返 回 ”);
b4。setBackground(Color。CYAN); x。gridx=20; x。gridy=10; x.gridwidth=1; x。gridheight=1; p5_2.add(b4,x);
t1 = new TextField(10); x.gridx=20; x.gridy=0; x。gridwidth=1; x.gridheight=1; p5_2.add(t1,x);
t2=new TextField(10); x.gridx=20; x。gridy=5; x。gridwidth=1; x。gridheight=1; p5_2。add(t2,x);
L1=new Label(\" * * * * * * 进 入 职 工 信 息 查 * * * * * * * * *\");
L1。setBackground(Color.CYAN); c。gridx=0; c。gridy=0; c。gridwidth=0; c。gridheight=1; p5。add(L1,c); c。gridx=0; c。gridy=5; c。gridwidth=1; c。gridheight=1; p5.add(p5_2,c);
ta= new TextArea(10,65); c.gridx=0; c.gridy=10; c。gridwidth=1; c.gridheight=1; p5。add(ta,c);
* *询 * 欢界 迎面 * * * *
p5。setBackground(Color.green); f。add(p5,”Fifth”);
b4。addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) {
t1。setText(””); t2.setText(\"”); ta。setText(””);
myCard。show(f,”Second”);
} });
b3.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) { try {
Class。forName(\"com。microsoft。sqlserver。jdbc。SQLServerDriver\");
String url=”jdbc:sqlserver://localhost:1433;DatabaseName=employee”;
String userName=\"sa\"; String password=”xhw”; Connection conn=DriverManager。getConnection(url,userName,password);
Statement stmt=conn。createStatement(); String sql=”select * from xhw where \"; String sql1=t1。getText(); String sql2=t2.getText();
sql=sql+sql1+\"'\"+sql2+\"'”;
ResultSet rs=stmt。executeQuery(sql); employee[] em =new employee[10]; int i=0;
while(rs.next()) {
employee em1=new employee(); em1.num=rs.getString(”工号”); em1。name=rs。getString(”姓名\"); em1。sex=rs。getString(\"性别”); em1。age=rs.getString(”年龄”);
em1。edu=rs.getString(”学历\"); em1。sla=rs.getString(”工资”); em1.add=rs。getString(\"住址\"); em1。tel=rs。getString(”电话”); em[i]=em1; i++;
}
String s = \" 工号\姓名\性别\年龄\学历\工资\住址\电话\\n”;
for(int j=0;js=s+\" \"+em[j].num+”\”+em[j]。name+\"\\"+em[j]。sex+\"\”+em[j].age+\"\”+ em[j]。edu+\"\”+em[j]。sla+\"\”+em[j]。add+\"\”+em[j].tel+\"\\n\\n”; }
ta.setText(s);
}
public void go6() {
p6=new Panel();
p6。setLayout(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints(); c。insets=new Insets(60,0,30,0);
Panel p6_1=new Panel();
p6_1.setLayout(new GridBagLayout());
GridBagConstraints x=new GridBagConstraints();
rs。close(); stmt.close(); }
catch(Exception e1)
{ e1。printStackTrace(); } } });
x。insets=new Insets(0,40,0,40);
Label L1;
Button b1,b2,b3; final TextArea ta;
b1=new Button(”按年龄排序\"); x。gridx=0; x.gridy=0;
x.gridwidth=1; x.gridheight=1; p6_1.add(b1,x);
b2=new Button(”按工资排序\"); x.gridx=10; x。gridy=0; x.gridwidth=1; x。gridheight=1; p6_1.add(b2,x);
b3=new Button(\" 返 回 \"); x.gridx=15; x.gridy=0;
x.gridwidth=1; x。gridheight=1; p6_1。add(b3,x);
L1=new Label(” * * * * * * * * * * * 欢入 职 工 信 息 查 询 界 * * * * * * *”);
L1.setBackground(Color。CYAN); c。gridx=0; c.gridy=0; c.gridwidth=1; c。gridheight=1; p6.add(L1,c);
c。gridx=0; c。gridy=5; c.gridwidth=1; c.gridheight=1; p6。add(p6_1,c);
迎 面 * *进 * *
ta=new TextArea(10,65); c.gridx=0; c.gridy=10; c.gridwidth=1; c。gridheight=1; p6。add(ta,c);
p6。setBackground(Color。green); f。add(p6,”Sixth\");
b1.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) { try {
Class。forName(”com.microsoft。sqlserver。jdbc。SQLServerDriver”);
String url=”jdbc:sqlserver://localhost:1433;DatabaseName=employee”;
String userName=\"sa”; String password=\"xhw\";
Connection conn=DriverManagergetConnection(url,userName,password); xhw”);
。
Statement stmt=conn。createStatement();
ResultSet rs=stmt.executeQuery(”select * from
employee[] em =new employee[10]; int i=0;
while(rs。next()) {
employee em1=new employee(); em1.num=rs。getString(”工号”); em1。name=rs.getString(”姓名”); em1.sex=rs。getString(\"性别\"); em1。age=rs。getString(\"年龄”); em1.edu=rs。getString(”学历\"); em1。sla=rs。getString(”工资\"); em1。add=rs。getString(”住址”); em1。tel=rs。getString(”电话”); em[i]=em1; i++;
}
employee zz ; int x,y;
for(int f=1;f〈i-1;f++) for(int k=f+1;k〈i;k++) {
x=Integer。parseInt(em[f].age);
y=Integer.parseInt(em[k].age);
if(x〉y) {
zz=em[f]; em[f]=em[k]; em[k]=zz; } }
String s = ” \"+\"工号\姓名\性别\年龄\学历\工资\住址\电话\\n\";
for(int j=0;j〈i;j++) {
s=s+” ”+em[j]。num+\"\”+em[j].name+”\”+em[j].sex+”\”+em[j].age+”\\"+
em[j]。edu+”\\"+em[j]。sla+\"\”+em[j]。add+\"\”+em[j].tel+”\\n\\n”; }
ta。setText(s); rs.close();
stmt.close(); }
catch(Exception e1)
{ e1。printStackTrace(); }
}
});
b2.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) { try {
Class。forName(”com.microsoft.sqlserver。jdbc。SQLServerDriver\");
String url=\"jdbc:sqlserver://localhost:1433;DatabaseName=employee\";
String userName=\"sa”; String password=”xhw”; Connection conn=DriverManager.getConnection(url,userName,password);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(\"select * from
employee[] em =new employee[10]; int i=0;
while(rs。next()) {
employee em1=new employee(); em1.num=rs.getString(”工号”); em1.name=rs.getString(”姓名”); em1。sex=rs。getString(\"性别”); em1。age=rs.getString(\"年龄”); em1。edu=rs。getString(\"学历”); em1.sla=rs。getString(”工资”); em1.add=rs。getString(”住址\"); em1。tel=rs.getString(”电话”); em[i]=em1; i++;
xhw\");
}
employee zz ; int x,y;
for(int f=1;f〈i—1;f++)
for(int k=f+1;kx=Integer.parseInt(em[f]。sla);
y=Integer。parseInt(em[k].sla);
if(x>y) {
zz=em[f];
em[f]=em[k]; em[k]=zz; } }
String s = ” ”+”工号\姓名\性别\年龄\学历\工资\住址\电话\\n”;
for(int j=0;j〈i;j++) {
s=s+” ”+em[j].num+”\\"+em[j]。name+”\\"+em[j].sex+\"\”+em[j]。age+”\”+ em[j].edu+\"\”+em[j].sla+\"\”+em[j]。add+”\”+em[j]。tel+\"\\n\\n”; }
ta.setText(s); rs。close();
stmt。close();
}
catch(Exception e1)
{ e1.printStackTrace(); }
} });
b3。addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e)
{ ta。setText(\"\");
myCard。show(f,\"Second”);
} });
}
public void go7() {
p7=new Panel();
p7。setLayout(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints(); c.insets=new Insets(40,0,50,0); Panel p7_1=new Panel();
p7_1.setLayout(new GridBagLayout());
GridBagConstraints x=new GridBagConstraints(); x.insets=new Insets(30,60,0,80);
Label L1;
Button b1,b2,b3,b4,b5,b6,b7; final TextField t1; final TextField t2; final TextField t3;
b1=new Button(” 信 息 编 号 b1。setBackground(Color。CYAN); x。gridx=0; x。gridy=0; x。gridwidth=1; x.gridheight=1; p7_1。add(b1,x);
b2=new Button(” 修 改 名 称 b2。setBackground(Color.CYAN); x。gridx=0; x。gridy=5;
x。gridwidth=1; x.gridheight=1;
p7_1.add(b2,x);
); \")
;
”
b3=new Button(” 修 改 值 ”);
b3。setBackground(Color.CYAN); x.gridx=0; x。gridy=10; x。gridwidth=1; x.gridheight=1; p7_1。add(b3,x);
b4=new Button(\" 修 \");
b4。setBackground(Color。CYAN); x.gridx=0; x。gridy=15; x.gridwidth=1; x。gridheight=1; p7_1。add(b4,x);
b5=new Button(” 返 ”);
b5。setBackground(Color.CYAN); x.gridx=10; x.gridy=15; x。gridwidth=1; x。gridheight=1; p7_1。add(b5,x);
b6=new Button(” 查 ”);
b6。setBackground(Color。CYAN); x。gridx=0; x。gridy=20; x。gridwidth=1; x。gridheight=1; p7_1。add(b6,x);
b7=new Button(\" 继 ”);
b7.setBackground(Color.CYAN); x。gridx=10; x.gridy=20;
x。gridwidth=1;
x。gridheight=1;
改 回 询 续 p7_1。add(b7,x);
t1=new TextField(16); x.gridx=10; x.gridy=0;
x。gridwidth=1; x。gridheight=1; p7_1。add(t1,x);
t2=new TextField(16); x.gridx=10; x.gridy=5;
x。gridwidth=1; x。gridheight=1; p7_1。add(t2,x);
t3=new TextField(16); x.gridx=10; x.gridy=10;
x。gridwidth=1; x。gridheight=1; p7_1。add(t3,x);
L1=new Label(\" * * * * * * * * * * *进 入 职 工 信 息 修 改 界 * * * * * * * * *”);
L1。setBackground(Color.CYAN); c。gridx=0; c。gridy=0;
c。gridwidth=1; c。gridheight=1; p7。add(L1,c); c。gridx=0; c。gridy=10; c.gridwidth=1; c。gridheight=1; p7。add(p7_1,c);
p7。setBackground(Color.green); f.add(p7,”Seventh\");
b4。addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e)
欢 面迎 * * {
employee e1=new employee(); String sql;
sql=”update xhw set ”+t2。getText()+\"=”+”'\"+t3.getText()+”'”+”where 工号='” +t1.getText()+”’\"; System。out。println(sql); e1.load(sql); t1.setText(\"”); t2。setText(””); t3.setText(\"”); }
});
b5。addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) {
myCard。show(f,\"Second”); }
});
b6。addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) {
myCard。show(f,”Fifth\");
}
});
b7。addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
t1.setText(”\"); t2。setText(””); t3。setText(””);
}
});
}
public void go8() {
p8=new Panel();
p8。setLayout(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints(); c。insets=new Insets(10,0,70,0);
Panel p8_1=new Panel();
p8_1.setLayout(new GridBagLayout());
GridBagConstraints x=new GridBagConstraints(); x.insets=new Insets(80,60,0,80);
Button b1,b2,b3; Label L1;
final TextField t1;
b1=new Button(” 工 号 \"); b1.setBackground(Color.CYAN); x.gridx=0; x。gridy=0;
x。gridwidth=1; x。gridheight=1; p8_1.add(b1,x);
b2=new Button(” 删 除 ”); b2。setBackground(Color.CYAN); x。gridx=0; x。gridy=10; x。gridwidth=1; x.gridheight=1; p8_1。add(b2,x);
b3=new Button(\" 返 回 ”); b3。setBackground(Color.CYAN); x。gridx=10; x。gridy=10; x。gridwidth=1; x。gridheight=1; p8_1。add(b3,x);
t1=new TextField(11);
t1。setBackground(Color。CYAN); x。gridx=10; x.gridy=0;
x。gridwidth=1; x。gridheight=1; p8_1。add(t1,x);
L1=new Label(\" * * * * * * * * * * * 欢 迎 进 入 职 工 信 息 删 除 界 * * * * * * * * * * *\");
L1.setBackground(Color。CYAN); c。gridx=0; c。gridy=0;
c。gridwidth=1; c.gridheight=1; p8。add(L1,c); c.gridx=0; c.gridy=5; c。gridwidth=1; c.gridheight=1; p8.add(p8_1,c);
p8。setBackground(Color。green); f.add(p8,”Eighth\");
b2。addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) { employee e1=new employee(); String sql;
sql=”delete from xhw where 工号=” +t1。getText(); System。out.println(sql); e1。load(sql);
} });
b3。addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
面
} }
myCard.show(f,”Second\");
}
});
因篇幅问题不能全部显示,请点此查看更多更全内容