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

📄 xiugaichengji.java

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

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

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class xiugaichengji
    extends JFrame {
  XYLayout xYLayout1 = new XYLayout();
  JTextField jTextField1 = new JTextField();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JButton jButton1 = new JButton();
  JLabel jLabel3 = new JLabel();
  JTextField jTextField2 = new JTextField();
  JdbTable jdbTable1 = new JdbTable();
  Database database1 = new Database();
  QueryDataSet queryDataSet1 = new QueryDataSet();
  QueryResolver queryResolver1 = new QueryResolver();
  JdbTextField jdbTextField1 = new JdbTextField();
  JdbTextField jdbTextField2 = new JdbTextField();
  JLabel jLabel4 = new JLabel();
  JLabel jLabel5 = new JLabel();
  JButton jButton2 = new JButton();
  JLabel jLabel6 = new JLabel();
  JButton jButton3 = new JButton();
  public xiugaichengji() {
    try {
      jbInit();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    getContentPane().setLayout(xYLayout1);
    this.getContentPane().setBackground(UIManager.getColor(
        "InternalFrame.inactiveTitleForeground"));
    setSize(new Dimension(500, 400));
    setTitle("修改成绩");
    jButton1.setText("搜索");
    jButton1.addActionListener(new xiugaichengji_jButton1_actionAdapter(this));
    jLabel2.setText("学号");
    jLabel3.setText("课程");
    queryResolver1.setDatabase(database1);
    queryResolver1.setUpdateMode(com.borland.dx.dataset.UpdateMode.
                                 CHANGED_COLUMNS);
    queryDataSet1.setResolver(queryResolver1);
    jdbTable1.setDataSet(queryDataSet1);
    jLabel1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 20));
    jLabel4.setText("课程");
    jLabel5.setText("成绩");
    jdbTextField1.setColumnName("course_name");
    jdbTextField1.setDataSet(queryDataSet1);
    jdbTextField2.setColumnName("result");
    jdbTextField2.setDataSet(queryDataSet1);
    jButton2.setText("提交");
    jButton2.addActionListener(new xiugaichengji_jButton2_actionAdapter(this));
    jLabel6.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 20));
    jLabel6.setText("请在下面的框内容输入你要修改的:");
    queryDataSet1.setQuery(new QueryDescriptor(database1,
                                               "SELECT * FROM XUANKEBIAO", null, true,
                                               Load.ALL));
    database1.setConnection(new ConnectionDescriptor(
        "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student", "sa",
        "zjxy2006", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));
    jLabel1.setText("请输入你要修改的学生的学号和课程名");
    jButton3.setText("返回所有记录");
    jButton3.addActionListener(new xiugaichengji_jButton3_actionAdapter(this));
    this.getContentPane().add(jLabel1, new XYConstraints(19, 9, 364, -1));
    this.getContentPane().add(jLabel4, new XYConstraints(11, 301, -1, -1));
    this.getContentPane().add(jdbTextField1, new XYConstraints(77, 298, 92, -1));
    this.getContentPane().add(jLabel5, new XYConstraints(206, 303, -1, -1));
    this.getContentPane().add(jdbTextField2, new XYConstraints(268, 298, 86, 22));
    this.getContentPane().add(jButton2, new XYConstraints(396, 294, -1, -1));
    this.getContentPane().add(jLabel6, new XYConstraints(6, 244, 416, 31));
    this.getContentPane().add(jdbTable1, new XYConstraints(1, 119, 500, 98));
    this.getContentPane().add(jLabel2, new XYConstraints(17, 66, -1, -1));
    this.getContentPane().add(jTextField1, new XYConstraints(49, 64, 69, -1));
    this.getContentPane().add(jLabel3, new XYConstraints(138, 68, -1, -1));
    this.getContentPane().add(jTextField2, new XYConstraints(186, 64, 72, -1));
    this.getContentPane().add(jButton1, new XYConstraints(296, 61, -1, -1));
    this.getContentPane().add(jButton3, new XYConstraints(383, 61, -1, -1));
    //jLabel7.setIcon(b);
  }

  public static void main(String[] args) {
    xiugaichengji xiugaichengji = new xiugaichengji();
  }
//*************************查找要修改成绩的学生信息********************
   public void jButton1_actionPerformed(ActionEvent e) {
     String Field1 = jTextField1.getText().trim();
     String Field2 = jTextField2.getText().trim();
     if (Field1.equals("") && Field2.equals("")) {
       try {
         JOptionPane.showMessageDialog(null, "请输入查询条件!");
       }
       catch (Exception ex) {
         System.out.println(ex.getMessage());
       }
     } //end if
     else {
       try {
         String sql = "select * from xuankebiao where id='" + Field1 +
             "' or course_name='" + Field2 + "'";
         queryDataSet1.close();
//将SQL语句传给queryDataSet1执行。
         queryDataSet1.setQuery(new QueryDescriptor(database1, sql, null, true,
             Load.ALL));
         queryDataSet1.open(); //将queryDataSet1打开
         queryDataSet1.refresh(); //刷新queryDataSet1
       } //end try
       catch (Exception ex) {
         JOptionPane.showMessageDialog(null, "Sorry!没有你要的信息,请检查你输入的信息!");
       } //end catch
     } //end else
   }
//********************************修改成绩****************************
  public void jButton2_actionPerformed(ActionEvent e) {
    String id=jTextField1.getText();
    String Field1 = jdbTextField1.getText().trim();
    String Field2 = jdbTextField2.getText().trim();
    int re=Integer.parseInt(Field2);
    try {
      Jdbcconn conn = new Jdbcconn(); //连接数据库
      conn.OpenConn("student", "sa", "zjxy2006");
      String strSQL =
          "update xuankebiao set course_name='"+Field1+"' ,result='"+re+"' where id='"+id+"'";
      conn.executeUpdate(strSQL);
      JOptionPane.showMessageDialog(null, "修改成功");
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
      JOptionPane.showMessageDialog(null, "数据库没有链接成功,数据没有修改成功!");
    } //end catch

  }
//********************************返回所有记录****************************
  public void jButton3_actionPerformed(ActionEvent e) {
    String sql = "select * from xuankebiao";
    try {
      queryDataSet1.close();
//将SQL语句传给queryDataSet1执行。
      queryDataSet1.setQuery(new QueryDescriptor(database1, sql, null, true,
                                                 Load.ALL));
      queryDataSet1.open();
      queryDataSet1.refresh();
    } //end try
    catch (Exception ex) {
      JOptionPane.showMessageDialog(null, "Sorry!返回出现错误!");
    } //end catch
  }
}

class xiugaichengji_jButton3_actionAdapter
    implements ActionListener {
  private xiugaichengji adaptee;
  xiugaichengji_jButton3_actionAdapter(xiugaichengji adaptee) {
    this.adaptee = adaptee;
  }

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

class xiugaichengji_jButton2_actionAdapter
    implements ActionListener {
  private xiugaichengji adaptee;
  xiugaichengji_jButton2_actionAdapter(xiugaichengji adaptee) {
    this.adaptee = adaptee;
  }

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

class xiugaichengji_jButton1_actionAdapter
    implements ActionListener {
  private xiugaichengji adaptee;
  xiugaichengji_jButton1_actionAdapter(xiugaichengji adaptee) {
    this.adaptee = adaptee;
  }

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

⌨️ 快捷键说明

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