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

📄 浏览模块.java~1~

📁 学生信息管理系统(JBuilder x 开发,采用RSA 512位公钥加密,私钥用于找回密码,2006-4-5)
💻 JAVA~1~
字号:
package 学生信息管理系统;import java.awt.*;import javax.swing.*;import com.borland.dx.sql.dataset.*;import com.borland.dbswing.*;import java.awt.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2001</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class 浏览模块 extends JDialog {  JPanel jPanel1 = new JPanel();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  JLabel jLabel3 = new JLabel();  FlowLayout flowLayout1 = new FlowLayout();  JTextField jTextField1 = new JTextField();  JTextField jTextField2 = new JTextField();  JTextField jTextField3 = new JTextField();  JPanel jPanel2 = new JPanel();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  JButton jButton3 = new JButton();  Database database1 = new Database();  QueryDataSet queryDataSet1 = new QueryDataSet();  JPanel jPanel3 = new JPanel();  TableScrollPane tableScrollPane1 = new TableScrollPane();  JdbTable jdbTable1 = new JdbTable();  FlowLayout flowLayout2 = new FlowLayout();  JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();  private int counter=0;  public 浏览模块(Frame frame, String title, boolean modal) {    super(frame, title, modal);    try {      jbInit();      pack();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  public 浏览模块() {    this(null, "", false);  }  private void jbInit() throws Exception {    this.getContentPane().setLayout(null);    jPanel1.setFont(new java.awt.Font("Dialog", 0, 15));    jPanel1.setBounds(new Rectangle(23, 7, 261, 158));    jPanel1.setLayout(flowLayout1);    jLabel1.setFont(new java.awt.Font("Dialog", 0, 15));    jLabel1.setPreferredSize(new Dimension(80, 30));    jLabel1.setText("模  块  号:");    jLabel2.setFont(new java.awt.Font("Dialog", 0, 15));    jLabel2.setPreferredSize(new Dimension(80, 30));    jLabel2.setText("模  块  名:");    jLabel3.setFont(new java.awt.Font("Dialog", 0, 15));    jLabel3.setPreferredSize(new Dimension(80, 30));    jLabel3.setText("提交日期:");    jTextField1.setFont(new java.awt.Font("Dialog", 0, 15));    jTextField1.setPreferredSize(new Dimension(120, 30));    jTextField1.setText("");    jTextField2.setFont(new java.awt.Font("Dialog", 0, 15));    jTextField2.setPreferredSize(new Dimension(120, 30));    jTextField2.setText("");    jTextField3.setFont(new java.awt.Font("Dialog", 0, 15));    jTextField3.setPreferredSize(new Dimension(120, 30));    jTextField3.setText("");    jButton1.setFont(new java.awt.Font("Dialog", 0, 15));    jButton1.setPreferredSize(new Dimension(120, 30));    jButton1.setText("查找");    jButton1.addActionListener(new 浏览模块_jButton1_actionAdapter(this));    jButton2.setFont(new java.awt.Font("Dialog", 0, 15));    jButton2.setPreferredSize(new Dimension(120, 30));    jButton2.setText("增加");    jButton2.addActionListener(new 浏览模块_jButton2_actionAdapter(this));    jButton3.setFont(new java.awt.Font("Dialog", 0, 15));    jButton3.setPreferredSize(new Dimension(120, 30));    jButton3.setText("返回");    jButton3.addActionListener(new 浏览模块_jButton3_actionAdapter(this));    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:学生信息管理", "sample", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));    jPanel3.setLayout(flowLayout2);    jdbTable1.setFont(new java.awt.Font("Dialog", 0, 15));    tableScrollPane1.setFont(new java.awt.Font("Dialog", 0, 15));    tableScrollPane1.setPreferredSize(new Dimension(450, 200));    jPanel3.setBounds(new Rectangle(39, 191, 460, 205));    jPanel2.setBounds(new Rectangle(303, 7, 197, 100));    jdbNavToolBar1.setBounds(new Rectangle(71, 164, 452, 28));    jPanel1.add(jLabel1, null);    jPanel1.add(jTextField1, null);    jPanel1.add(jLabel2, null);    jPanel1.add(jTextField2, null);    jPanel1.add(jLabel3, null);    jPanel1.add(jTextField3, null);    jPanel1.add(jButton1, null);    this.getContentPane().add(jPanel2, null);    this.getContentPane().add(jPanel3, null);    jPanel3.add(tableScrollPane1, null);    this.getContentPane().add(jPanel1, null);    this.getContentPane().add(jdbNavToolBar1, null);    jPanel2.add(jButton2, null);    jPanel2.add(jButton3, null);  }  void jButton1_actionPerformed(ActionEvent e) {    String sql = "";      sql= "select * from 模块";String str1=jTextField1.getText(),str2=jTextField2.getText(),str3=jTextField3.getText();     //判断查询条件     if(str1.length()!=0||str2.length()!=0||str3.length()!=0)                {sql+=" where ";}     if(str1.length()!=0)         {sql+="模块号="+str1;          if(str2.length()!=0||str3.length()!=0)            sql+=" AND ";        }    if(str2.length()!=0){sql+="模块名=" +"'"+str2+"'";                              if(str3.length()!=0)sql+=" AND ";    }    if(str3.length()!=0){sql+="提交日期="+"'"+str3+"'";}if(counter==0){    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, sql, null, true, Load.ALL));    counter++;}  else       {queryDataSet1.close();        queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, sql, null, true, Load.ALL));    }    jdbTable1.setDataSet(queryDataSet1);    tableScrollPane1.getViewport().add(jdbTable1, null);  }  void jButton2_actionPerformed(ActionEvent e) {    String sql = "";        sql= "INSERT INTO 模块(模块号,模块名,提交日期) VALUES ";  String str1=jTextField1.getText(),str2=jTextField2.getText(),str3=jTextField3.getText();       //判断查询条件       sql+="("+str1+",";       sql+="'"+str2+"'"+",";       sql+="'"+str3+"'";       sql+=")";       if(str1.length()==0)JOptionPane.showMessageDialog(this,"模块号不能为空!","警告",JOptionPane.INFORMATION_MESSAGE);      else{       if(counter==0){queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, sql, null, true, Load.ALL));         counter++;}            else {queryDataSet1.close();               queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, sql, null, true, Load.ALL));            }      try{queryDataSet1.executeQuery();}catch(Exception ex){ JOptionPane.showMessageDialog(this,"已增加数据记录!","增加记录",JOptionPane.INFORMATION_MESSAGE);      }      }        jTextField1.setText("");        jTextField2.setText("");        jTextField3.setText("");  }  void cancel() {              dispose();         }  void jButton3_actionPerformed(ActionEvent e) {           if (e.getSource() == jButton3) {             cancel();           }  }}class 浏览模块_jButton1_actionAdapter implements java.awt.event.ActionListener {  浏览模块 adaptee;  浏览模块_jButton1_actionAdapter(浏览模块 adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class 浏览模块_jButton2_actionAdapter implements java.awt.event.ActionListener {  浏览模块 adaptee;  浏览模块_jButton2_actionAdapter(浏览模块 adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}class 浏览模块_jButton3_actionAdapter implements java.awt.event.ActionListener {  浏览模块 adaptee;  浏览模块_jButton3_actionAdapter(浏览模块 adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton3_actionPerformed(e);  }}

⌨️ 快捷键说明

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