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

📄 chaxunstudentinfo.java

📁 中小学校园的教师
💻 JAVA
字号:
package untitled2;import javax.swing.*;import java.awt.*;import com.borland.jbcl.layout.*;import java.awt.event.*;import java.sql.*;import java.io.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class chaXunStudentinfo 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();  public chaXunStudentinfo() {    try {      jbInit();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  void jbInit() throws Exception {    this.setResizable(true);    this.setSize(new Dimension(800, 580));    jButton1.setFont(new java.awt.Font("幼圆", 0, 13));    jTextArea1.setEditable(false);    jButton1.setForeground(Color.black);    jButton1.setText("查询单个学生信息");    jButton1.addActionListener(new chaXunStudentinfo_jButton1_actionAdapter(this));    this.setTitle("查询所需学生信息");    this.getContentPane().setLayout(xYLayout1);    jTextArea1.setVerifyInputWhenFocusTarget(true);    jTextArea1.setText("");    jTextField1.setText("");    jLabel1.setFont(new java.awt.Font("幼圆", 0, 13));    jLabel1.setText("在下面输入学生学籍卡号");    jButton2.setFont(new java.awt.Font("幼圆", 0, 13));    jButton2.setText("按班级查询学生信息");    jButton2.addActionListener(new chaXunStudentinfo_jButton2_actionAdapter(this));    jButton3.setFont(new java.awt.Font("幼圆", 0, 13));    jButton3.setText("清空");    jButton3.addActionListener(new chaXunStudentinfo_jButton3_actionAdapter(this));    jButton4.setFont(new java.awt.Font("幼圆", 0, 13));    jButton4.setText("退出");    jButton4.addActionListener(new chaXunStudentinfo_jButton4_actionAdapter(this));    xYLayout1.setWidth(800);    xYLayout1.setHeight(580);    jTextField2.setText("");    jButton5.setFont(new java.awt.Font("幼圆", 0, 13));    jButton5.setText("查询所有学生信息");    jButton5.addActionListener(new chaXunStudentinfo_jButton5_actionAdapter(this));    jLabel2.setFont(new java.awt.Font("幼圆", 0, 13));    jLabel2.setVerifyInputWhenFocusTarget(true);    jLabel2.setText("在下面面输入班级编号");    this.getContentPane().add(jTextArea1,      new XYConstraints(28, 281, 751, 278));    this.getContentPane().add(jLabel2, new XYConstraints(35, 99, 152, 39));    this.getContentPane().add(jTextField1, new XYConstraints(184, 49, 164, 31));    this.getContentPane().add(jTextField2, new XYConstraints(177, 139, 168, 34));    this.getContentPane().add(jButton1,   new XYConstraints(482, 48, 138, 39));    this.getContentPane().add(jLabel1, new XYConstraints(26, 9, 152, 39));    this.getContentPane().add(jButton3,   new XYConstraints(88, 221, 111, 34));    this.getContentPane().add(jButton2, new XYConstraints(484, 137, 172, 38));    this.getContentPane().add(jButton5,   new XYConstraints(486, 215, 169, 40));    this.getContentPane().add(jButton4,   new XYConstraints(295, 216, 114, 40));  }  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民族\t籍贯\n");          try{            int s=Integer.parseInt(jTextField1.getText().trim());            con = DBConnection.getConnection();            String columnName="card_id";            String sql = "select * from dbo.student  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<=11)                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 student ";    jTextArea1.setText("");      Connection con = null;      jTextArea1.setText("学籍卡号\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;        while(rs.next())        {          counter++;          int i=1;          // jCBGrade.addItem(rs.getString("grade_name"));         while(i<=11)          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);      }      //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民族\t籍贯\n");         String columnName="class_id";         int s=Integer.parseInt(jTextField2.getText().trim());         String sql ="select * from dbo.student  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<=11)          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 chaXunStudentinfo_jButton3_actionAdapter implements java.awt.event.ActionListener {  chaXunStudentinfo adaptee;  chaXunStudentinfo_jButton3_actionAdapter(chaXunStudentinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton3_actionPerformed(e);  }}class chaXunStudentinfo_jButton4_actionAdapter implements java.awt.event.ActionListener {  chaXunStudentinfo adaptee;  chaXunStudentinfo_jButton4_actionAdapter(chaXunStudentinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton4_actionPerformed(e);  }}class chaXunStudentinfo_jButton1_actionAdapter implements java.awt.event.ActionListener {  chaXunStudentinfo adaptee;  chaXunStudentinfo_jButton1_actionAdapter(chaXunStudentinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class chaXunStudentinfo_jButton5_actionAdapter implements java.awt.event.ActionListener {  chaXunStudentinfo adaptee;  chaXunStudentinfo_jButton5_actionAdapter(chaXunStudentinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton5_actionPerformed(e);  }}class chaXunStudentinfo_jButton2_actionAdapter implements java.awt.event.ActionListener {  chaXunStudentinfo adaptee;  chaXunStudentinfo_jButton2_actionAdapter(chaXunStudentinfo adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

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