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

📄 banjixinxi.java~14~

📁 成绩管理系统可以对学生、课程、选课、成绩的录入、班级、用户的信息进行管理等
💻 JAVA~14~
字号:
package coursedesign;

import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.QueryDataSet;
import com.borland.dx.sql.dataset.QueryResolver;
import com.borland.dx.sql.dataset.ConnectionDescriptor;
import com.borland.dx.sql.dataset.QueryDescriptor;
import com.borland.dx.sql.dataset.Load;
import com.borland.dbswing.JdbTable;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class banjixinxi
    extends JFrame {
  XYLayout xYLayout1 = new XYLayout();
  JComboBox jComboBox1 = new JComboBox();
  Database database1 = new Database();
  QueryDataSet queryDataSet1 = new QueryDataSet();
  QueryResolver queryResolver1 = new QueryResolver();
  JdbTable jdbTable1 = new JdbTable();

  public banjixinxi() {
    try {
      jbInit();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    getContentPane().setLayout(xYLayout1);
    setTitle("学生基本信息划询");
    setSize(new Dimension(400, 400));
    jComboBox1.setToolTipText("");
    jComboBox1.addItem("请选择查询条件");
     jComboBox1.addItem("学生信息");
     jComboBox1.addItem("班级信息");
     jComboBox1.addItem("选课信息");

    jComboBox1.setSelectedItem(this);
    database1.setConnection(new ConnectionDescriptor(
        "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student", "sa",
        "yaya", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver", null));
    queryDataSet1.setQuery(new QueryDescriptor(database1,
                                               "SELECT * FROM chengjibiao", null, true,
                                               Load.ALL));
    jComboBox1.addActionListener(new banjixinxi_jComboBox1_actionAdapter(this));
    this.getContentPane().add(jComboBox1, new XYConstraints(2, 1, 111, -1));
    jdbTable1.setDataSet(queryDataSet1);
    this.getContentPane().add(jdbTable1, new XYConstraints(5, 47, 393, 223));
  }

  public static void main(String[] args) {
    banjixinxi banjixinxi = new banjixinxi();

  }

  public void jComboBox1_actionPerformed(ActionEvent e) {
   // int Select = jComboBox1.getSelectedIndex();
    //String first=e.getActionCommand().trim();
    //String actionCommand = e.getActionCommand().trim();
    int state = jComboBox1.getSelectedIndex();
   String first = jComboBox1.getSelectedItem();
    if(state==1)
    {
      try{
         String sql="select * from base_info";
         queryDataSet1.close();
            //将SQL语句传给queryDataSet1执行。
            queryDataSet1.setQuery(new QueryDescriptor(database1, sql, null, true,Load.ALL));
            //将queryDataSet1打开
            queryDataSet1.open();
            //刷新queryDataSet1
            queryDataSet1.refresh();
       }//end try
       catch(Exception ex)
       {
         JOptionPane.showMessageDialog(null, "Sorry!暂时没有学生信息记录");
       }//end catch

    }//end if
    else{
     if(state==2){
         try {
      String sql1 = "select * from class_info";
      queryDataSet1.close();
      //将SQL语句传给queryDataSet1执行。
      queryDataSet1.setQuery(new QueryDescriptor(database1, sql1, null, true,
                                                 Load.ALL));
      //将queryDataSet1打开
      queryDataSet1.open();
      //刷新queryDataSet1
      queryDataSet1.refresh();
    } //end try
    catch (Exception ex) {
      JOptionPane.showMessageDialog(null, "Sorry!暂时没有班级信息记录");
    } //end catch
   }//end if of else
       else
       {
         try{
         String sql2="select * from xuankebiao";
         queryDataSet1.close();
            //将SQL语句传给queryDataSet1执行。
            queryDataSet1.setQuery(new QueryDescriptor(database1, sql2, null, true,Load.ALL));
            //将queryDataSet1打开
            queryDataSet1.open();
            //刷新queryDataSet1
            queryDataSet1.refresh();
       }//end try
       catch(Exception ex)
       {
         JOptionPane.showMessageDialog(null, "Sorry!暂时没有课程信息记录");
       }//end catch

       }//end else of else

    }//end else
   // jComboBox1.addItem("学生信息");
     //jComboBox1.addItem("班级信息");
    // jComboBox1.addItem("选课信息");




  }
}

class banjixinxi_jComboBox1_actionAdapter
    implements ActionListener {
  private banjixinxi adaptee;
  banjixinxi_jComboBox1_actionAdapter(banjixinxi adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jComboBox1_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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