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

📄 remarkadd.java~7~

📁 java语言做的教务管理系统
💻 JAVA~7~
字号:
package java_教务管理系统;

import java.awt.*;

import javax.swing.*;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class remarkadd extends JPanel {
    public remarkadd() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.setLayout(null);
        jLabel1.setText("学号:");
        jLabel1.setBounds(new Rectangle(43, 7, 36, 15));
        txtresultstuno.setBounds(new Rectangle(93, 5, 114, 20));
        jLabel2.setText("班级编号:");
        jLabel2.setBounds(new Rectangle(227, 10, 60, 15));
        txtresultclassno.setBounds(new Rectangle(300, 8, 95, 20));
        jLabel3.setText("任课老师:");
        jLabel3.setBounds(new Rectangle(227, 38, 60, 15));
        txtlessonteacher.setBounds(new Rectangle(300, 35, 95, 20));
        jLabel4.setText("考试时间:");
        jLabel4.setBounds(new Rectangle(53, 66, 60, 15));
        jLabel5.setText("年");
        jLabel5.setBounds(new Rectangle(194, 66, 12, 15));
        jLabel6.setText("月");
        jLabel6.setBounds(new Rectangle(278, 66, 12, 15));
        jLabel7.setText("日");
        jLabel7.setBounds(new Rectangle(349, 67, 12, 15));
        jLabel8.setText("考试次数:");
        jLabel8.setBounds(new Rectangle(19, 95, 60, 15));
        txtexaminationnumber.setBounds(new Rectangle(93, 94, 115, 20));
        jLabel9.setText("成绩:");
        jLabel9.setBounds(new Rectangle(249, 95, 36, 15));
        txtresult.setBounds(new Rectangle(300, 93, 95, 20));
        jLabel10.setText("备注:");
        jLabel10.setBounds(new Rectangle(41, 125, 36, 15));
        cboexaminationdatedate.setBounds(new Rectangle(295, 62, 48, 23));
        cboexaminationdatemonth.setBounds(new Rectangle(212, 62, 59, 23));
        cboexaminationdateyear.setBounds(new Rectangle(118, 62, 69, 23));
        txaresultremarks.setBounds(new Rectangle(93, 119, 302, 63));
        btnremarkadd.setBounds(new Rectangle(55, 202, 81, 23));
        btnremarkadd.setText("添加成绩");
        btnremarkadd.addActionListener(new remarkadd_btnremarkadd_actionAdapter(this));
        btnexit.setBounds(new Rectangle(220, 202, 81, 23));
        btnexit.setText("退出添加");
        jLabel11.setText("课程编号:");
        jLabel11.setBounds(new Rectangle(20, 40, 61, 15));
        txtremarkcourseno.setBounds(new Rectangle(93, 35, 114, 20));
        this.add(txtresultclassno);
        this.add(jLabel2);
        this.add(jLabel11);
        this.add(txtremarkcourseno);
        this.add(txtresultstuno);
        this.add(jLabel1);
        this.add(jLabel3);
        this.add(txtlessonteacher);
        this.add(cboexaminationdatemonth);
        this.add(jLabel4);
        this.add(cboexaminationdateyear);
        this.add(jLabel5);
        this.add(jLabel6);
        this.add(cboexaminationdatedate);
        this.add(jLabel7);
        this.add(jLabel8);
        this.add(txtexaminationnumber);
        this.add(txtresult);
        this.add(jLabel9);
        this.add(txaresultremarks);
        this.add(btnremarkadd);
        this.add(btnexit);
        this.add(jLabel10);
    }

    String year[] = {"2006", "2007", "2008", "2009"};
//出生时间(月)
    String month[] = {"", "01", "02", "03", "04", "05", "06", "07",
                     "08",
                     "09",
                     "10", "11", "12"};
//出生时间(日)
    String date[] = {"", "01", "02", "03", "04", "05", "06", "07",
                    "08",
                    "09",
                    "10", "11", "12", "13", "14", "15", "16", "17",
                    "18", "19", "20", "21", "22", "23", "24", "25",
                    "26", "27", "28", "29", "30", "31"};
    JLabel jLabel1 = new JLabel();
    JTextField txtresultstuno = new JTextField();
    JLabel jLabel2 = new JLabel();
    JTextField txtresultclassno = new JTextField();
    JLabel jLabel3 = new JLabel();
    JTextField txtlessonteacher = new JTextField();
    JLabel jLabel4 = new JLabel();
    JComboBox cboexaminationdateyear = new JComboBox(year);
    JLabel jLabel5 = new JLabel();
    JComboBox cboexaminationdatemonth = new JComboBox(month);
    JLabel jLabel6 = new JLabel();
    JComboBox cboexaminationdatedate = new JComboBox(date);
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JTextField txtexaminationnumber = new JTextField();
    JLabel jLabel9 = new JLabel();
    JTextField txtresult = new JTextField();
    JLabel jLabel10 = new JLabel();
    JTextArea txaresultremarks = new JTextArea();
    JButton btnremarkadd = new JButton();
    JButton btnexit = new JButton();
    JLabel jLabel11 = new JLabel();
    JTextField txtremarkcourseno = new JTextField();
    public void btnremarkadd_actionPerformed(ActionEvent e) {
        try {
            //考试时间
            String examinationdatename =
                    this.cboexaminationdateyear.getSelectedItem().toString() + "-" +
                    this.cboexaminationdatemonth.getSelectedItem().toString() + "-" +
                    this.cboexaminationdatedate.getSelectedItem().toString() + " ";
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection conn = DriverManager.getConnection("jdbc:odbc:studer");
            PreparedStatement sql = conn.prepareStatement(
                    "insert into result (resultstuno,resultclassno,lessonteacher,examinationdate,examinationnumber,result,resultremarks) values(?,?,?,?,?,?,?)");
            sql.setString(1, this.txtresultstuno.getText());
            sql.setString(2, this.txtresultclassno.getText());
           // sql.setString(3,this.txtremarkcourseno.getText());
            sql.setString(3, this.txtlessonteacher.getText());
            sql.setString(4, examinationdatename);
            sql.setString(5, this.txtexaminationnumber.getText());
            sql.setString(6, this.txtresult.getText());
            sql.setString(7, this.txaresultremarks.getText());
            int row = sql.executeUpdate();
            if (row > 0) {
                JOptionPane.showMessageDialog(this, "添加成功!");
            } else {
                JOptionPane.showMessageDialog(this, "添加失败!");
            }
            sql.close();
            conn.close();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "添加失败!");
        }

    }
}


class remarkadd_btnremarkadd_actionAdapter implements ActionListener {
    private remarkadd adaptee;
    remarkadd_btnremarkadd_actionAdapter(remarkadd adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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