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

📄 bumenchakan.java

📁 中小学校园的教师
💻 JAVA
字号:
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.*;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 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();  JPanel jPanel1 = new JPanel();  Border border1;  TitledBorder titledBorder1;  JLabel jLabel2 = new JLabel();  public buMenChaKan() {    try {      jbInit();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  void jbInit() throws Exception {    border1 = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.white,Color.white,new Color(103, 101, 98),new Color(148, 145, 140));    titledBorder1 = new TitledBorder(new EtchedBorder(EtchedBorder.RAISED,Color.white,SystemColor.desktop),"查询条件");    this.getContentPane().setBackground(SystemColor.text);    this.setDefaultCloseOperation(HIDE_ON_CLOSE);     this.setSize(new Dimension(800, 580));                  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("幼圆", 0, 13));    jLabel1.setText("查询条件");    jLabel1.setBounds(new Rectangle(65, 59, 75, 19));    jTextField1.setText("");    jTextField1.setBounds(new Rectangle(382, 57, 153, 22));    jTextField1.addActionListener(new buMenChaKan_jTextField1_actionAdapter(this));    jButton1.setBounds(new Rectangle(608, 56, 61, 29));    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(580);    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));    jPanel1.setBackground(SystemColor.text);    jPanel1.setName("");    jPanel1.setBorder(titledBorder1);    jPanel1.setLayout(null);    jComboBox1.setBounds(new Rectangle(194, 59, 123, 22));    jLabel2.setIcon(new ImageIcon(new java.net.URL("file:///D:/UI6.0/untitled2/pictrue/1234.jpg")));    jLabel2.setText("jLabel2");    jPanel1.add(jComboBox1, null);    jPanel1.add(jLabel1, null);    jPanel1.add(jTextField1, null);    jPanel1.add(jButton1, null);    this.getContentPane().add(jLabel2,         new XYConstraints(418, 313, 378, 241));    this.getContentPane().add(jLabel3, new XYConstraints(89, 197, 71, 23));    this.getContentPane().add(jTextField3, new XYConstraints(218, 199, 115, -1));    this.getContentPane().add(jLabel6, new XYConstraints(403, 200, 67, 23));    this.getContentPane().add(jTextField6,  new XYConstraints(504, 198, 115, -1));    this.getContentPane().add(jButton2, new XYConstraints(684, 193, 65, 28));    this.getContentPane().add(jTextField7,  new XYConstraints(509, 274, 115, -1));    this.getContentPane().add(jButton3, new XYConstraints(684, 269, -1, -1));    this.getContentPane().add(jTextField5,  new XYConstraints(221, 362, 115, -1));    this.getContentPane().add(jTextField4,  new XYConstraints(217, 280, 115, -1));    this.getContentPane().add(jLabel7, new XYConstraints(399, 274, 100, 23));    this.getContentPane().add(jLabel4, new XYConstraints(94, 280, 64, 23));    this.getContentPane().add(jLabel5, new XYConstraints(97, 358, 60, 23));    this.getContentPane().add(jPanel1,        new XYConstraints(28, 24, 752, 130));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);      int n=Integer.parseInt(jTextField1.getText());     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(NumberFormatException ex)   {     JOptionPane.showMessageDialog(null, "输入错误,请重新输入!");   }   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 + -