• 数据库应用-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();
    		}
    	}
    }
    
  • 相关阅读:
    Mysql 常用函数(15)- upper 函数
    Mysql 常用函数(14)- lower 函数
    Mysql 常用函数(13)- right 函数
    Mysql 常用函数(12)- left 函数
    Mysql 常用函数(11)- trim 函数
    Mysql 常用函数(10)- strcmp 函数
    Mysql 常用函数(9)- reverse 函数
    Mysql 常用函数(8)- concat 函数
    Mysql 常用函数(7)- length 函数
    影评1|发个以前写的影评《情书》
  • 原文地址:https://www.cnblogs.com/1997Ff/p/7365208.html
Copyright © 2020-2023  润新知