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

📄 xqkcpanel.java~4~

📁 简单的学生管理系统。。用JBUILER和SQL2000。
💻 JAVA~4~
字号:
package studentgl;import java.awt.*;import javax.swing.*;import com.borland.dbswing.*;import com.borland.dx.sql.dataset.*;import java.sql.*;import java.awt.event.*;import com.borland.dx.dataset.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class xqkcPanel extends JPanel {  BorderLayout borderLayout1 = new BorderLayout();  JSplitPane jSplitPane1 = new JSplitPane();  JPanel jPanel1 = new JPanel();  JScrollPane jScrollPane1 = new JScrollPane();  JLabel jLabel1 = new JLabel();  JComboBox jComboBox1 = new JComboBox();  JLabel jLabel2 = new JLabel();  JComboBox jComboBox2 = new JComboBox();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  TableScrollPane tableScrollPane1 = new TableScrollPane();  JdbTable jdbTable1 = new JdbTable();  Database database1 = new Database();  QueryDataSet queryDataSet1 = new QueryDataSet();  public xqkcPanel() {    try {      jbInit();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  void jbInit() throws Exception {    this.setLayout(borderLayout1);    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);    jPanel1.setLayout(null);    jLabel1.setFont(new java.awt.Font("Serif", 0, 14));    jLabel1.setForeground(SystemColor.textHighlight);    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);    jLabel1.setText("学期:");    jLabel1.setBounds(new Rectangle(-1, 11, 74, 21));    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");    String url = "jdbc:microsoft:sqlserver://ISSAC:1433;DatabaseName=StudentGL";    String username = "sa";    String password = "123456";    Connection con = DriverManager.getConnection(url,username,password);    Statement stmt1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);    ResultSet strs1 = stmt1.executeQuery("select distinct term from CourseInfo");    ResultSet strs2 = stmt1.executeQuery("select distinct CoName  from CourseInfo");    jComboBox1.setFont(new java.awt.Font("Serif", 0, 12));    jComboBox1.setBounds(new Rectangle(69, 10, 105, 24));    jComboBox1.addItem("");     while(strs1.next()){    jComboBox1.addItem(strs1.getString("term"));   }    jLabel2.setBounds(new Rectangle(195, 12, 74, 21));    jLabel2.setText("课程:");    jLabel2.setHorizontalAlignment(SwingConstants.CENTER);    jLabel2.setForeground(SystemColor.textHighlight);    jLabel2.setFont(new java.awt.Font("Serif", 0, 14));    jComboBox2.setBounds(new Rectangle(266, 9, 105, 24));    jComboBox2.setFont(new java.awt.Font("Serif", 0, 12));    jComboBox2.addItem("");    while(strs2.next()){   jComboBox2.addItem(strs2.getString("CoName"));  }    con.close();    jButton1.setBounds(new Rectangle(83, 44, 73, 25));    jButton1.setFont(new java.awt.Font("Serif", 0, 12));    jButton1.setForeground(Color.red);    jButton1.setText("确定");    jButton1.addActionListener(new xqkcPanel_jButton1_actionAdapter(this));    jButton2.setBounds(new Rectangle(280, 45, 73, 25));    jButton2.setFont(new java.awt.Font("Serif", 0, 12));    jButton2.setForeground(Color.orange);    jButton2.setText("重设");    jButton2.addActionListener(new xqkcPanel_jButton2_actionAdapter(this));    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:microsoft:sqlserver://Issac:1433;DatabaseName=studentgl", "sa", "123456", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));    //queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "", null, true, Load.ALL));   // column1.setCaption("123");    //column1.setColumnName("NewColumn1");    //column1.setDataType(com.borland.dx.dataset.Variant.STRING);    //column1.setServerColumnName("NewColumn1");    //column1.setSqlType(0);    jdbTable1.setFont(new java.awt.Font("Serif", 0, 12));    this.add(jSplitPane1, BorderLayout.CENTER);    jSplitPane1.add(jPanel1, JSplitPane.TOP);    jPanel1.add(jLabel2, null);    jPanel1.add(jLabel1, null);    jPanel1.add(jComboBox1, null);    jPanel1.add(jComboBox2, null);    jPanel1.add(jButton1, null);    jPanel1.add(jButton2, null);    jSplitPane1.add(jScrollPane1, JSplitPane.BOTTOM);    jScrollPane1.getViewport().add(tableScrollPane1, null);    tableScrollPane1.getViewport().add(jdbTable1, null);    jSplitPane1.setDividerLocation(80);  //  queryDataSet1.setColumns(new Column[] {column1});  }  void jButton1_actionPerformed(ActionEvent e) {  if((jComboBox1.getSelectedItem().toString()!=null)&&(jComboBox2.getSelectedItem().toString()!=null)){      queryDataSet1.close();      String Term=jComboBox1.getSelectedItem().toString();      String coname=jComboBox2.getSelectedItem().toString();      queryString="select StID,StName,Score from kcview where term='"+Term+"' and Coname='"+coname+"'";      queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1,queryString,null, true, Load.ALL));      column1.setCaption("学号");    //column1.setFont(new java.awt.Font("Serif", 0, 14));     column1.setColumnName("StID");    column1.setDataType(com.borland.dx.dataset.Variant.STRING);    column1.setTableName("kcview");    column1.setServerColumnName("StID");    column1.setSqlType(0);    column1.setWidth(5);    column2.setCaption("姓名");     //column1.setFont(new java.awt.Font("Serif", 0, 14));     column2.setColumnName("StName");     column2.setDataType(com.borland.dx.dataset.Variant.STRING);     column2.setTableName("kcview");     column2.setServerColumnName("StName");     column2.setSqlType(0);     column2.setWidth(8);     column3.setCaption("成绩");     //column2.setFont(new java.awt.Font("Serif", 0, 12));     column3.setColumnName("Score");     column3.setDataType(com.borland.dx.dataset.Variant.STRING);     column3.setTableName("kcview");     column3.setServerColumnName("Score");     column3.setSqlType(0);     column3.setWidth(8);     queryDataSet1.setColumns(new Column[] {column1,column2,column3});       queryDataSet1.refresh();       jdbTable1.setDataSet(queryDataSet1);       jdbTable1.repaint();     }   }     private String queryString;     Column column1 = new Column();     Column column2 =new Column();     Column column3 =new Column();  void jButton2_actionPerformed(ActionEvent e) {      jComboBox1.setSelectedIndex(0);      jComboBox2.setSelectedIndex(0);  }}class xqkcPanel_jButton1_actionAdapter implements java.awt.event.ActionListener {  xqkcPanel adaptee;  xqkcPanel_jButton1_actionAdapter(xqkcPanel adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class xqkcPanel_jButton2_actionAdapter implements java.awt.event.ActionListener {  xqkcPanel adaptee;  xqkcPanel_jButton2_actionAdapter(xqkcPanel adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

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