数据库应用-java+sqlserver(十二)TeaInfo

TeaInfo:

import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;

public class TeaInfo extends JPanel implements ActionListener
{
    static JLabel jid,jname,jsex,jbirth,jpost,jdepart;
    JButton b;
    //ModifyPassword modify;
    TeaInfo(MyFrame f)
    {
        setLayout(new BorderLayout());
        //modify=new ModifyPassword(f,"修改密码",true);
        
        jid=new JLabel();
        jname=new JLabel();
        jsex=new JLabel();
        jbirth=new JLabel();
        jpost=new JLabel();
        jdepart=new JLabel();
        
        JPanel p=new JPanel();
        b=new JButton("修改密码");
        b.addActionListener(this);
        p.add(b);
        add(p,BorderLayout.SOUTH);
        initInstance(this);
    }
    private void initInstance(Object obj)
    {
        Box base=Box.createHorizontalBox();
        Box left=Box.createVerticalBox();
        Box right=Box.createVerticalBox();
        JPanel p11=new JPanel(),
               p12=new JPanel(),
               p13=new JPanel(),
               p14=new JPanel(),
               p15=new JPanel();
               
        JPanel p21=new JPanel(),
               p22=new JPanel(),
               p23=new JPanel(),
               p24=new JPanel(),
               p25=new JPanel();
        
        p11.add(new JLabel("教师编号:"));
        p21.add(jid);
        p12.add(new JLabel("教师姓名:"));
        p22.add(jname);
        p13.add(new JLabel("教师性别:"));
        p23.add(jsex);
        p14.add(new JLabel("教师生日:"));
        p24.add(jbirth);
        p15.add(new JLabel("教师职称:"));
        p25.add(jpost);
        
        
        left.add(Box.createVerticalStrut(30));
        left.add(p11);
        left.add(Box.createVerticalStrut(10));
        left.add(p12);
        left.add(Box.createVerticalStrut(10));
        left.add(p13);
        left.add(Box.createVerticalStrut(10));
        left.add(p14);
        left.add(Box.createVerticalStrut(10));
        left.add(p15);
        left.add(Box.createVerticalStrut(10));
        
        right.add(Box.createVerticalStrut(30));
        right.add(p21);
        right.add(Box.createVerticalStrut(10));
        right.add(p22);
        right.add(Box.createVerticalStrut(10));
        right.add(p23);
        right.add(Box.createVerticalStrut(10));
        right.add(p24);
        right.add(Box.createVerticalStrut(10));
        right.add(p25);
        right.add(Box.createVerticalStrut(10));
        
        base.add(new JPanel());
        base.add(new JPanel());
        base.add(new JPanel());
        base.add(new JPanel());
        base.add(new JPanel());
        base.add(left);
        base.add(right);
        base.add(new JPanel());
        base.add(new JPanel());
        base.add(new JPanel());
        base.add(new JPanel());
        base.add(new JPanel());
        this.add(base,BorderLayout.CENTER);
    }
    public void actionPerformed(ActionEvent e)
    {
        //modify.setVisible(true);
    }
    public static void saveTea(String id)
    {
        SqlManager DBm=SqlManager.createInstance();
        DBm.connectDB();
        String sql="exec ProcTeacher'"+id+"'";
        ResultSet rs=DBm.executeQuery(sql);
        System.out.println(sql);
        try{
            rs.next();
            System.out.println(rs.getString(1)+"是是是 是");
            jid.setText(rs.getString(1));
            jname.setText(rs.getString(2));
            jsex.setText(rs.getString(3));
            jbirth.setText(rs.getString(4));
            jpost.setText(rs.getString(5));
            jdepart.setText(rs.getString(6));
            
        }catch(SQLException e){
            e.printStackTrace();
        }
    }
}

转载于:https://www.cnblogs.com/1997Ff/p/7365208.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值