⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chaxunteachertinfo.java~3~

📁 中小学校园的教师
💻 JAVA~3~
字号:
package untitled2;import javax.swing.*;import java.awt.*;import com.borland.jbcl.layout.*;import java.awt.event.*;import java.sql.*;import java.io.*;import javax.swing.border.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class chaXunTeachertinfo extends JFrame {  JButton jButton1 = new JButton();  XYLayout xYLayout1 = new XYLayout();  JTextArea jTextArea1 = new JTextArea();  JTextField jTextField1 = new JTextField();  JLabel jLabel1 = new JLabel();  JButton jButton2 = new JButton();  JButton jButton3 = new JButton();  JButton jButton4 = new JButton();  JTextField jTextField2 = new JTextField();  JButton jButton5 = new JButton();  JLabel jLabel2 = new JLabel();  Border border1;  Border border2;  public chaXunTeachertinfo() {    try {      jbInit();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  void jbInit() throws Exception {    border1 = new EtchedBorder(EtchedBorder.RAISED,Color.white,SystemColor.desktop);    border2 = new EtchedBorder(EtchedBorder.RAISED,Color.white,SystemColor.desktop);    this.getContentPane().setBackground(SystemColor.controlLtHighlight);    jButton1.setBackground(new Color(131, 177, 197));    jButton1.setFont(new java.awt.Font("幼圆", 0, 13));    jTextArea1.setEditable(false);    jButton1.setForeground(Color.black);    jButton1.setBorder(border1);    jButton1.setText("查询单个教师信息");    jButton1.addActionListener(new chaXunTeachertinfo_jButton1_actionAdapter(this));    this.setTitle("查询所需教师信息");    this.getContentPane().setLayout(xYLayout1);    jTextArea1.setBorder(border2);    jTextArea1.setVerifyInputWhenFocusTarget(true);    jTextArea1.setText("");    jTextField1.setBackground(Color.white);    jTextField1.setBorder(border1);    jTextField1.setText("");    jLabel1.setFont(new java.awt.Font("幼圆", 0, 13));    jLabel1.setForeground(new Color(13, 98, 144));    jLabel1.setText("请在下面输入教师编号");    jButton2.setBackground(new Color(131, 177, 197));    jButton2.setFont(new java.awt.Font("幼圆", 0, 13));    jButton2.setBorder(border1);    jButton2.setActionCommand("按年级查询教师信息");    jButton2.setText("按部门查询教师信息");    jButton2.addActionListener(new chaXunTeachertinfo_jButton2_actionAdapter(this));    jButton3.setBackground(new Color(131, 177, 197));    jButton3.setFont(new java.awt.Font("幼圆", 0, 13));    jButton3.setBorder(border1);    jButton3.setText("清空");    jButton3.addActionListener(new chaXunTeachertinfo_jButton3_actionAdapter(this));    jButton4.setBackground(new Color(131, 177, 197));    jButton4.setFont(new java.awt.Font("幼圆", 0, 13));    jButton4.setBorder(border1);    jButton4.setText("退出");    jButton4.addActionListener(new chaXunTeachertinfo_jButton4_actionAdapter(this));    xYLayout1.setWidth(800);    xYLayout1.setHeight(600);    jTextField2.setBorder(border1);    jTextField2.setText("");    jButton5.setBackground(new Color(131, 177, 197));    jButton5.setFont(new java.awt.Font("幼圆", 0, 13));    jButton5.setBorder(border1);    jButton5.setActionCommand("查询所有教师信息");    jButton5.setText("查询所有教师信息");    jButton5.addActionListener(new chaXunTeachertinfo_jButton5_actionAdapter(this));    jLabel2.setFont(new java.awt.Font("幼圆", 0, 13));    jLabel2.setForeground(new Color(13, 98, 144));    jLabel2.setToolTipText("");    jLabel2.setVerifyInputWhenFocusTarget(true);    jLabel2.setText("请在下面面输入部门编号");    this.getContentPane().add(jButton3, new XYConstraints(92, 216, 111, 29));    this.getContentPane().add(jTextArea1,         new XYConstraints(33, 288, 732, 284));    this.getContentPane().add(jButton5, new XYConstraints(320, 218, 139, 29));    this.getContentPane().add(jButton4,  new XYConstraints(583, 216, 111, 29));    this.getContentPane().add(jLabel1, new XYConstraints(39, 9, 152, 39));    this.getContentPane().add(jLabel2, new XYConstraints(44, 85, 152, 39));    this.getContentPane().add(jTextField2,    new XYConstraints(145, 129, 164, 31));    this.getContentPane().add(jTextField1, new XYConstraints(144, 47, 164, 31));    this.getContentPane().add(jButton1, new XYConstraints(466, 47, 138, 31));    this.getContentPane().add(jButton2, new XYConstraints(468, 134, 142, 33));  }  void jButton3_actionPerformed(ActionEvent e) {    if(jTextArea1.getText().trim().length()==0)    {     // JOptionPane.showConfirmDialog(this,"确定清空数据吗?","Confirm!",YES_NO_OPTION);    }jTextField1.setText("");    jTextField2.setText("");    jTextArea1.setText("");  }  void jButton4_actionPerformed(ActionEvent e) {this.dispose();  }  void jButton1_actionPerformed(ActionEvent e) {    if(jTextField1.getText().trim().length()==0)    {      JOptionPane.showMessageDialog(null,"请输入查询条件");    }          jTextArea1.setText("");          Connection con = null;          jTextArea1.setText("教师编号\t部门编号\t职务\t姓名\t性别\t电话\t状态\t生日\t学历\n");          try{            String s=jTextField1.getText().trim();            con = DBConnection.getConnection();            String columnName="teacher_id";            String sql = "select * from dbo.teacher  where " + columnName + "='" + s +"'";            PreparedStatement ps = con.prepareStatement(sql);            ResultSet rs = ps.executeQuery();            while(rs.next())            {              int i=1;              // jCBGrade.addItem(rs.getString("grade_name"));              while(i<=10)                jTextArea1.append(rs.getString(i++).toString()+"\t");                jTextArea1.append("\n");            }            if(!rs.next())              JOptionPane.showMessageDialog(null,"对应教师编号为'"+jTextField1.getText().trim()+"'的数据不存在");            DbUtil.close(rs);            DbUtil.close(ps);          }catch(Exception ee){            ee.printStackTrace();          }finally{            DbUtil.close(con);          }  }  void jButton5_actionPerformed(ActionEvent e) {    String sql = "SELECT * FROM teacher ";    jTextArea1.setText("");      Connection con = null;      jTextArea1.setText("教师编号\t\t部门编号\t\t职务\t\t姓名\t\t性别\t\t电话\t\t状态\t\t生日\t\t学历\t\n");      try{        con = DBConnection.getConnection();        PreparedStatement ps = con.prepareStatement(sql);        ResultSet rs = ps.executeQuery();        int counter=0;        boolean more =rs .next();        while(more)        {          counter++;          int i=1;          // jCBGrade.addItem(rs.getString("grade_name"));         while(i<=10)          jTextArea1.append(rs.getString(i++)+"\t");          jTextArea1.append("\n");          more=rs.next();        }        jTextArea1.append("\n\n共找到\t"+Integer.toString(counter)+"\t条记录");        DbUtil.close(rs);        DbUtil.close(ps);      }catch(Exception ee){        ee.printStackTrace();      }finally{        DbUtil.close(con);      }      //for(int i=1;i<=10;i++){       // jCBClass_Num.addItem(String.valueOf(i));      //}  }  void jButton2_actionPerformed(ActionEvent e) {    if(jTextField2.getText().trim().length()==0)       {         JOptionPane.showMessageDialog(null,"请输入查询条件");       }      Connection con = null;             jTextArea1.setText("教师编号\t部门编号\t职务\t姓名\t性别\t电话\t状态\t生日\t学历\n");         String columnName="department_id";         int s=Integer.parseInt(jTextField2.getText().trim());         String sql ="select * from dbo.teacher  where " + columnName + "='" + s +          "'";       try{ con = DBConnection.getConnection();        PreparedStatement ps = con.prepareStatement(sql);        ResultSet rs = ps.executeQuery();          int counter=0;        while(rs.next())        {          counter++;          int i=1;          // jCBGrade.addItem(rs.getString("grade_name"));         while(i<=10)          jTextArea1.append(rs.getString(i++)+"\t");          jTextArea1.append("\n");        }        jTextArea1.append("\n\n共找到\t"+Integer.toString(counter)+"\t条记录");        DbUtil.close(rs);        DbUtil.close(ps);      }catch(Exception ee){        ee.printStackTrace();      }finally{        DbUtil.close(con);      }  }}class chaXunTeachertinfo_jButton3_actionAdapter implements java.awt.event.ActionListener {  chaXunTeachertinfo adaptee;  chaXunTeachertinfo_jButton3_actionAdapter(chaXunTeachertinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton3_actionPerformed(e);  }}class chaXunTeachertinfo_jButton4_actionAdapter implements java.awt.event.ActionListener {  chaXunTeachertinfo adaptee;  chaXunTeachertinfo_jButton4_actionAdapter(chaXunTeachertinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton4_actionPerformed(e);  }}class chaXunTeachertinfo_jButton1_actionAdapter implements java.awt.event.ActionListener {  chaXunTeachertinfo adaptee;  chaXunTeachertinfo_jButton1_actionAdapter(chaXunTeachertinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class chaXunTeachertinfo_jButton5_actionAdapter implements java.awt.event.ActionListener {  chaXunTeachertinfo adaptee;  chaXunTeachertinfo_jButton5_actionAdapter(chaXunTeachertinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton5_actionPerformed(e);  }}class chaXunTeachertinfo_jButton2_actionAdapter implements java.awt.event.ActionListener {  chaXunTeachertinfo adaptee;  chaXunTeachertinfo_jButton2_actionAdapter(chaXunTeachertinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -