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

📄 bumenchakan.java~6~

📁 中小学校园的教师
💻 JAVA~6~
字号:
package untitled2;import javax.swing.*;import java.awt.*;import java.awt.event.*;import com.borland.jbcl.layout.*;import java.awt.event.*;import com.borland.jbcl.layout.*;import java.sql.*;import java.sql.Statement;import java.sql.SQLException;import java.sql.Statement;import java.sql.Connection;import java.sql.ResultSet;import com.borland.dx.sql.dataset.*;import com.borland.dbswing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class buMenChaKan extends JFrame {  XYLayout xYLayout1 = new XYLayout();  JTextField jTextField1 = new JTextField();  JLabel jLabel1 = new JLabel();  JButton jButton1 = new JButton();  JButton jButton3 = new JButton();  Statement stmt=null;  Connection con=null;  JTextField jTextField3 = new JTextField();  JTextField jTextField4 = new JTextField();  JTextField jTextField5 = new JTextField();  JTextField jTextField6 = new JTextField();  JTextField jTextField7 = new JTextField();  JLabel jLabel3 = new JLabel();  JLabel jLabel4 = new JLabel();  JLabel jLabel5 = new JLabel();  JLabel jLabel6 = new JLabel();  JLabel jLabel7 = new JLabel();  Database database1 = new Database();  QueryDataSet queryDataSet1 = new QueryDataSet();  JButton jButton2 = new JButton();  JComboBox jComboBox1 = new JComboBox();  public buMenChaKan() {    try {      jbInit();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  void jbInit() throws Exception {    this.setDefaultCloseOperation(HIDE_ON_CLOSE);     this.setSize(new Dimension(800,600));                  this.setEnabled(true);    this.setFont(new java.awt.Font("楷体_GB2312", 0, 12));    this.setLocale(java.util.Locale.getDefault());    this.setTitle("欢迎您进入部门查看界面");    this.getContentPane().setLayout(xYLayout1);    jLabel1.setFont(new java.awt.Font("Dialog", 0, 13));    jLabel1.setText("查询条件");    jTextField1.setText("");    jTextField1.addActionListener(new buMenChaKan_jTextField1_actionAdapter(this));    jButton1.setFont(new java.awt.Font("Dialog", 0, 13));    jButton1.setSize(new Dimension(73, 25));    jButton1.setText("查询");    jButton1.addActionListener(new buMenChaKan_jButton1_actionAdapter(this));    jButton3.setEnabled(true);    jButton3.setFont(new java.awt.Font("Dialog", 0, 13));    jButton3.setText("退出 ");    jButton3.addActionListener(newbuMenChaKan_jButton3_actionAdapter(this));    jTextField6.setText("");    jTextField4.setText("");    jTextField7.setText("");    jTextField5.setText("");    jTextField3.setText("");    jTextField3.addActionListener(new buMenChaKan_jTextField3_actionAdapter(this));    jLabel3.setFont(new java.awt.Font("Dialog", 0, 13));    jLabel3.setHorizontalAlignment(SwingConstants.CENTER);    jLabel3.setText("部门编号");    jLabel4.setFont(new java.awt.Font("Dialog", 0, 13));    jLabel4.setHorizontalAlignment(SwingConstants.CENTER);    jLabel4.setText("部门名称");    jLabel5.setFont(new java.awt.Font("Dialog", 0, 13));    jLabel5.setHorizontalAlignment(SwingConstants.CENTER);    jLabel5.setText("部门组长");    jLabel6.setFont(new java.awt.Font("Dialog", 0, 13));    jLabel6.setText("部门电话");    jLabel7.setFont(new java.awt.Font("Dialog", 0, 13));    jLabel7.setText("部门办公室");    xYLayout1.setWidth(800);    xYLayout1.setHeight(600);    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:Digital_campus", "dbw", "123456", false, "sun.jdbc.odbc.JdbcOdbcDriver"));    database1.setDatabaseName("");    queryDataSet1.setTableName("department");    queryDataSet1.setStoreName("");    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT  * FROM department ", null, true, Load.ALL));    jButton2.setFont(new java.awt.Font("Dialog", 0, 13));    jButton2.setText("清空");    jButton2.addActionListener(new buMenChaKan_jButton2_actionAdapter(this));    jComboBox1.addActionListener(new buMenChaKan_jComboBox1_actionAdapter(this));    this.getContentPane().add(jTextField6,   new XYConstraints(333, 173, 119, -1));    this.getContentPane().add(jTextField3,  new XYConstraints(126, 173, 115, -1));    this.getContentPane().add(jTextField4,  new XYConstraints(125, 206, 118, -1));    this.getContentPane().add(jTextField5,  new XYConstraints(126, 241, 119, -1));    this.getContentPane().add(jLabel6,  new XYConstraints(261, 171, 67, 23));    this.getContentPane().add(jLabel7,    new XYConstraints(260, 206, 100, 23));    this.getContentPane().add(jTextField7,  new XYConstraints(334, 205, 122, -1));    this.getContentPane().add(jLabel5, new XYConstraints(32, 242, 60, 23));    this.getContentPane().add(jLabel4, new XYConstraints(33, 210, 64, 23));    this.getContentPane().add(jLabel3,  new XYConstraints(29, 175, 71, 23));    this.getContentPane().add(jButton2, new XYConstraints(519, 146, 65, 28));    this.getContentPane().add(jButton3, new XYConstraints(519, 200, -1, -1));    this.getContentPane().add(jButton1, new XYConstraints(518, 86, -1, -1));    this.getContentPane().add(jTextField1, new XYConstraints(299, 94, 153, -1));    this.getContentPane().add(jLabel1,   new XYConstraints(37, 95, 75, -1));    this.getContentPane().add(jComboBox1,    new XYConstraints(127, 92, 114, -1));jComboBox1.addItem("部门编号");jComboBox1.addItem("部门名称");  }  void jButton3_actionPerformed(ActionEvent e) {this.dispose();  }  void jButton1_actionPerformed(ActionEvent e) throws SQLException {     String sql1=new String();String sql2=new String();    sql1= "select * from department where department_id=? "; sql2= "select * from department where department_name=?";    Connection con = null;   try{     con =DBConnection.getConnection();     PreparedStatement ps;     String str=jComboBox1.getSelectedItem().toString();     if(str=="部门编号")    ps = con.prepareStatement(sql1);     else       ps = con.prepareStatement(sql2);     ps.setString(1, jTextField1.getText());     ResultSet rs = ps.executeQuery();     boolean more= rs.next();    if(!more)       JOptionPane.showMessageDialog(null, "该部门不存在!");else     while(more)       {         jTextField3.setText(String.valueOf(rs.getInt(1)));    jTextField4.setText(rs.getString(2).trim());      jTextField5.setText(rs.getString(3).trim());   jTextField6.setText(rs.getString(4).trim());     jTextField7.setText(rs.getString(5).trim());      JOptionPane.showMessageDialog(null, "查询成功!");     more=rs.next();     jTextField3.setEditable(false);     jTextField3.setEditable(false);     jTextField4.setEditable(false);     jTextField5.setEditable(false);     jTextField6.setEditable(false);     jTextField7.setEditable(false);       }     DbUtil.close(rs);     DbUtil.close(ps);   }catch(Exception ex){     ex.printStackTrace();   }finally{     DbUtil.close(con);   }  }  void jTextField1_actionPerformed(ActionEvent e) {  }  void jTextField3_actionPerformed(ActionEvent e) {  }  void jButton2_actionPerformed(ActionEvent e) {    jTextField1.setEditable(true);    jTextField3.setEditable(true);     jTextField4.setEditable(true);     jTextField5.setEditable(true);     jTextField6.setEditable(true);     jTextField7.setEditable(true);    jTextField1.setText("");        jTextField3.setText("");       jTextField4.setText("");        jTextField5.setText("");        jTextField6.setText("");        jTextField7.setText("");  }  void jComboBox1_actionPerformed(ActionEvent e) {  }}class buMenChaKan_jButton3_actionAdapter implementsjava.awt.event.ActionListener {  buMenChaKan adaptee;  buMenChaKan_jButton3_actionAdapter(buMenChaKan adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton3_actionPerformed(e);  }}class buMenChaKan_jButton1_actionAdapter implementsjava.awt.event.ActionListener {  buMenChaKan adaptee;  buMenChaKan_jButton1_actionAdapter(buMenChaKan adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    try {      adaptee.jButton1_actionPerformed(e);    }    catch (SQLException ex) {    }  }}class buMenChaKan_jTextField1_actionAdapter implements java.awt.event.ActionListener {  buMenChaKan adaptee;  buMenChaKan_jTextField1_actionAdapter(buMenChaKan adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jTextField1_actionPerformed(e);  }}class buMenChaKan_jTextField3_actionAdapter implements java.awt.event.ActionListener {  buMenChaKan adaptee;  buMenChaKan_jTextField3_actionAdapter(buMenChaKan adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jTextField3_actionPerformed(e);  }}class buMenChaKan_jButton2_actionAdapter implements java.awt.event.ActionListener {  buMenChaKan adaptee;  buMenChaKan_jButton2_actionAdapter(buMenChaKan adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}class buMenChaKan_jComboBox1_actionAdapter implements java.awt.event.ActionListener {  buMenChaKan adaptee;  buMenChaKan_jComboBox1_actionAdapter(buMenChaKan adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jComboBox1_actionPerformed(e);  }}

⌨️ 快捷键说明

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