社团活动学分管理系统

原创 2017年07月09日 10:28:52

摘要

之前忙于期末考试,所以没有时间把期末之前的课设写成博客。这次的课设虽然给定了可选题目,但是老师说做什么都可以。看见可选题目里有关于学分管理系统,考虑到时间紧迫,同时兼顾期末考试,故选择了这个社团学分管理系统。这里我也很感谢自己在校团委管理全校活动学分的同学为我这次课设提供了真实的学分数据。资源已经上传,如要下载请移步:http://download.csdn.net/detail/qq_30091945/9892876


遇到的困难

对于上学期的聊天室课设放不下,图形化界面当时花了很久才写完,这次百了下,图形画界面居然不是自己写,是用拖拽。我这次用的是Eclipse的插件——WindowBuilder。如没有安装的请移步WindowBuilder安装教程博客,网址为:http://blog.csdn.net/jason0539/article/details/21219043
之后由于想到所做的系统需要导入导出Excel文件,但是Java本身不支持Excel解析,故百度了个解析Excel的jar包——jxl,具体操作请移步:http://blog.csdn.net/yhawaii/article/details/6927927


不足之处

不足之处就是主窗口最大化之后,所有的标签,输入文本框,下拉列表的布局完全不安乱,或者说组件不能随着窗口的大小而相应变化,故改为把窗口不能改成固定大小且不能最大化。同时对于Excel导入导出功能,由于解析Excel文件的jar包–jxl不支持2010以上版本的Excel,故必须把Eccel文件转换为xls格式的文件才能导入。同时jxl一次导入3000条数据。而且现在只能解决单独导入学生信息,活动信息,学生-活动信息的excel文件,对于i一次性导入所有信息仍未解决。


社团活动学分管理数据库代码与E-R图

create database Community_Activity_Credit_Management

create table Student
(
    Student_ID nvarchar(20)primary key,
    Student_Name nvarchar(20),
    Class nvarchar(20),
    College nvarchar(20)
)

create table Activity
(
    Activity_name nvarchar(20)primary key,
    Organizer nvarchar(20),
    Term nvarchar(20)
)

create table Student_Activity
(
    Stu_ID nvarchar(20),
    Activity_Name nvarchar(20),
    Credit float,
    Certification_Time varchar(20),
    Prize nvarchar(20),
    primary key(Stu_ID,Activity_Name),
    foreign key(Stu_ID) references Student(Student_ID),
    foreign key(Activity_Name) references activity(Activity_Name)
)

这里写图片描述


主界面代码

package 社团活动学分管理系统;

import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JMenu;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SpringLayout;
import javax.swing.filechooser.FileSystemView;
import javax.swing.table.DefaultTableModel;

import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

import java.io.BufferedReader;
import java.io.File;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.awt.event.ActionEvent;
import javax.swing.JTable;
import java.awt.GridLayout;
import java.awt.Toolkit;

/*
 * 这是社团 学分管理系统的图形化主界面
 */

public class Community_Activity_Credit_Management {

    private JFrame frame;                           //程序主界面
    private JTextField textField_2;                 //“姓名”标签对应的输入文本框
    private JTextField textField_3;                 //“学号”标签对应的输入文本框
    private JTextField textField_4;                 //“活动名称”标签对应的输入文本框
    private JTextField textField_5;                 //“大于等于”标签对应输入文本框
    private JTextField textField_6;                 //“小于等于”标签对应输入文本框
    private JComboBox<String> comboBox;             //起始认证日期的"年"下拉列表
    private JComboBox<String> comboBox_1;           //起始认证日期的"月"下拉列表
    private JComboBox<String> comboBox_2;           //“学院”标签对应下拉列表
    private JComboBox<String> comboBox_3;           //“年级”标签对应下拉列表
    private JComboBox<String> comboBox_4;           //“班级”标签对应的下拉列表
    private JComboBox<String> comboBox_5;           //“活动主办方”标签对应的下拉列表
    private JComboBox<String> comboBox_6;           //起始认证日期的"日"下拉列表
    private JComboBox<String> comboBox_7;           //终止认证日期的"年"下拉列表
    private JComboBox<String> comboBox_8;           //终止认证日期的"月"下拉列表
    private JComboBox<String> comboBox_9;           //终止认证日期的"日"下拉列表
    private JTable table;                           //查询结果结果表格
    static SQL sql;                                 //社团活动学分管理系统的数据库功能实体类
    static HashMap<String, Integer> Grade;          //年级哈希表             
    static String[] names;                          //Jtable的属性
    /**
     * Launch the application.程序主运行程序
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    //实例化一个主程序窗口类
                    Community_Activity_Credit_Management window = new Community_Activity_Credit_Management();
                    window.frame.setVisible(true);

                    //JDBC驱动连接
                    String JDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";// SQL数据库引擎
                    String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=Community_Activity_Credit_Management";// 数据源
                    String userName = "sa";
                    String passWord = "123456";
                    sql = new SQL(JDriver, url, userName, passWord);

                    //年级哈希表初始化
                    Grade = new HashMap<>();
                    Grade.put("大一", 1);
                    Grade.put("大二", 2);
                    Grade.put("大三", 3);
                    Grade.put("大四", 4);
                    Grade.put("大五", 5);
                    Grade.put("大六", 6);

                    //JTable属性初始化
                    names = new String[10];
                    File file = new File("bin/社团活动学分管理系统/属性.txt");
                    BufferedReader in = new BufferedReader(new FileReader(file));
                    String str;
                    int i = 0;
                    while((str = in.readLine()) != null){
                        names[i++] = str;
                    }
                    in.close();
                } catch (Exception e) {;
                    e.printStackTrace();
                }
            }
        });
    }

    //获得起始时间或者终止时间的日字符串方法
    public String Get_Time_Day(String year,String month){
        String str = "";
        switch(Integer.valueOf(month)){
            case 1 :str += "31";break;
            case 2 :break;
            case 3 :str += "31";break;
            case 4 :str += "30";break;
            case 5 :str += "31";break;
            case 6 :str += "30";break;
            case 7 :str += "31";break;
            case 8 :str += "31";break;
            case 9 :str += "30";break;
            case 10:str += "31";break;
            case 11:str += "30";break;
            case 12:str += "31";break;
        }
        if(IsLeap_Year(Integer.valueOf(year)) && Integer.valueOf(month) == 2){
            str += "29";
        }
        if(!IsLeap_Year(Integer.valueOf(year)) && Integer.valueOf(month) == 2){
            str += "28";
        }
        return str;
    }

    //获取标准格式的认证日期方法
    public String Get_Certification_Time(String year,String month,String day){
        String str = "";
        str += year;
        str += "-";
        str += (Integer.valueOf(month) >= 10)?month:"0"+month;
        str += "-";
        str += (Integer.valueOf(day) >= 10)?day:"0"+day;
        return str;
    }

    //获取SQL Date的字符串方法
    public String Get_SQL_Time(String date){
        SimpleDateFormat format = (SimpleDateFormat)DateFormat.getInstance();
        format.applyPattern("yyyy-MM-dd");
        java.util.Date long_date;
        java.sql.Date sqlDate;
        String longdate = "";
        try {
            long_date = format.parse(date);
            sqlDate = new java.sql.Date(long_date.getTime());
            longdate = sqlDate.toString();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return longdate;
    }

    //根据各个下拉菜单,输入文本框获取SQL查询语句方法
    public String GetQuerySQL(){
            //SQL查询语句
            String query_sql = "SELECT  S.*,A.*,SA.Prize,SA.Certification_Time,SA.Credit "
                                        +"FROM Student S,Activity A,Student_Activity SA "
                                        + "WHERE S.Student_ID = SA.Student_ID AND A.Activity_Name = SA.Activity_Name";

            //如果学号输入文本框不为空
            if(!"".equals(textField_3.getText())){
                query_sql += " AND S.Student_ID = " + "'"+textField_3.getText().trim().toString()+"'";
            }

            //如果活动名称输入文本框不为空
            if(!"".equals(textField_4.getText())){
                query_sql += " AND A.Activity_Name = "+"'"+textField_4.getText().trim().toString()+"'";
            }

            //如果姓名输入文本框不为空
            if(!"".equals(textField_2.getText())){
                query_sql += " AND S.Student_Name = "+"'"+textField_2.getText().trim().toString()+"'";
            }

            //“学分大于等于输入文本框”不为空
            if(!"".equals(textField_5.getText())){
                query_sql += " AND SA.Credit >= "+textField_5.getText().trim().toString();
            }

            //“学分小于等于输入文本框”不为空
            if(!"".equals(textField_6.getText())){
                query_sql += " AND SA.Credit <= "+textField_6.getText().trim().toString();
            }

            //活动主办方下拉列表是“--请选择--”略过,若不是,则加入相应的查询语句
            if(!"--请选择--".equals(comboBox_5.getSelectedItem().toString())){
                query_sql += " AND A.Organizer = "+"'"+comboBox_5.getSelectedItem().toString()+"'";
            }

            //班级下拉菜单是“--请选择--”略过,若不是,则加入相应的查询语句
            if(!"--请选择--".equals(comboBox_4.getSelectedItem().toString())){
                query_sql += " AND S.Class = "+"'"+comboBox_4.getSelectedItem().toString()+"'";
            }

            //年级下拉菜单是“--请选择--”略过,若不是,则加入相应的查询语句
            String grade = comboBox_3.getSelectedItem().toString();
            if(!"--请选择--".equals(grade)){
                int values = Grade.get(grade);
                int nowyear = Calendar.getInstance().get(Calendar.YEAR);
                int month = Calendar.getInstance().get(Calendar.MONTH)+1;
                int entryyear = 0;
                if(month >= 1 && month <= 6){
                    entryyear = nowyear-values;
                }else{
                    entryyear = nowyear-values+1;
                }
                String tmp = String.valueOf(entryyear);
                String patch = tmp.substring(tmp.length()-2,tmp.length());
                //System.out.println(patch);
                query_sql += " AND S.Student_ID like"+"'"+patch+"%'";
            }

            //学院下拉菜单是“--请选择--”略过,若不是,则加入相应的查询语句
            if(!"--请选择--".equals(comboBox_2.getSelectedItem().toString())){
                query_sql += " AND S.College = "+"'"+comboBox_2.getSelectedItem().toString()+"'";
            }

            //起始认证时间与终止认证时间是否被选
            String Start_Time_Year = comboBox.getSelectedItem().toString();
            String Stop_Time_Year = comboBox_7.getSelectedItem().toString();
            String Start_Time_Month = comboBox_1.getSelectedItem().toString();
            String Stop_Time_Month = comboBox_8.getSelectedItem().toString();
            String Start_Time_Day = comboBox_6.getSelectedItem().toString();
            String Stop_Time_Day = comboBox_9.getSelectedItem().toString();
            //System.out.println(Start_Time_Year+"-"+Start_Time_Month+"-"+Start_Time_Day);
            //System.out.println(Stop_Time_Year+"-"+Stop_Time_Month+"-"+Stop_Time_Day);
            //System.out.println();

            //起始日期的年月日与终止日期的年月日下拉列表的状态 ,不为“--请选择--”为真,反之为假
            boolean start_time_year_flag = !"--请选择--".equals(Start_Time_Year);
            boolean start_time_month_flag = !"--请选择--".equals(Start_Time_Month);
            boolean start_time_day_flag = !"--请选择--".equals(Start_Time_Day);
            boolean stop_time_year_flag = !"--请选择--".equals(Stop_Time_Year);
            boolean stop_time_month_flag = !"--请选择--".equals(Stop_Time_Month);
            boolean stop_time_day_flag = !"--请选择--".equals(Stop_Time_Day);
            //System.out.println(start_time_year_flag);
            //System.out.println(start_time_month_flag);
            //System.out.println(start_time_day_flag);
            //System.out.println(stop_time_year_flag);
            //System.out.println(stop_time_month_flag);
            //System.out.println(stop_time_day_flag);
            boolean start_time_all_flag = start_time_year_flag && start_time_month_flag 
                                            && start_time_day_flag;
            boolean stop_time_all_flag = stop_time_year_flag && stop_time_month_flag
                                            && stop_time_day_flag;
            boolean start_time_notall_flag = start_time_year_flag || start_time_month_flag 
                                            || start_time_day_flag;
            boolean stop_time_notall_flag = stop_time_year_flag || stop_time_month_flag
                                            || stop_time_day_flag;
            //System.out.println(start_time_all_flag);
            //System.out.println(stop_time_all_flag);
            String start_time_str = "";
            String stop_time_str = "";
            //起始认证日期与终止日期的年同时被全选时,且不为“--请选择--”
            if(start_time_all_flag && stop_time_all_flag){
                //被选起始日期
                start_time_str += Get_Certification_Time(Start_Time_Year, Start_Time_Month, Start_Time_Day);

                //被选终止日期
                stop_time_str += Get_Certification_Time(Stop_Time_Year, Stop_Time_Month, Stop_Time_Day);

                //获取SQL长日期字符串
                String start = Get_SQL_Time(start_time_str);
                String stop = Get_SQL_Time(stop_time_str);
              //System.out.println(start);
              //System.out.println(stop);
              //System.out.println();
                query_sql += " AND SA.Certification_Time BETWEEN " +"'"+start+"'"+" AND '"+stop+"'";
            }else if(start_time_notall_flag && !stop_time_notall_flag){
                if(!start_time_year_flag){
                    Start_Time_Year = "";
                    Start_Time_Year += "1970";
                    //System.out.println(Start_Time_Year);
                }
                if(!start_time_month_flag){
                    Start_Time_Month = "";
                    Start_Time_Month += "1";
                    //System.out.println(Start_Time_Month);
                }
                if(!start_time_day_flag){
                    Start_Time_Day = "";
                    Start_Time_Day += "1";
                    //System.out.println(Start_Time_Day);
                }
                start_time_str += Get_Certification_Time(Start_Time_Year, Start_Time_Month, Start_Time_Day);
                String start = Get_SQL_Time(start_time_str);
                //System.out.println(start);
                //System.out.println();
                query_sql += " AND SA.Certification_Time >= "+"'"+start+"'";
            }else if(!start_time_all_flag && stop_time_all_flag){
                if(!stop_time_year_flag){
                    Stop_Time_Year = "";
                    Stop_Time_Year += "2100";
                    //System.out.println(Stop_Time_Year);
                }
                if(!stop_time_month_flag){
                    Stop_Time_Month = "";
                    Stop_Time_Month += "12";
                    //System.out.println(Stop_Time_Month);
                }
                if(!stop_time_day_flag){
                    Stop_Time_Day = "";
                    Stop_Time_Day += Get_Time_Day(Stop_Time_Year, Stop_Time_Month);
                    //System.out.println(Stop_Time_Day);
                }
                stop_time_str += Get_Certification_Time(Stop_Time_Year, Stop_Time_Month, Stop_Time_Day);
                String stop = Get_SQL_Time(stop_time_str);
                //System.out.println(stop);
                //System.out.println();
                query_sql += " AND SA.Certification_Time <= "+"'"+stop+"'";
            }
            //System.out.println(query_sql);
            return query_sql;
    }

    //社团活动学分管理系统的构造方法
    public Community_Activity_Credit_Management() {
        initialize();
    }

    //把路径path下的txt文件的内容导入下拉列表的方法
    public void ComboBox_AddItem(JComboBox<String> comboBox,String path){
        File file = new File(path);
        BufferedReader in = null;
        try {
            in = new BufferedReader(new FileReader(file));
            String str;
            while((str = in.readLine())!= null){
                comboBox.addItem(str.trim());
            }
            in.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    //判断闰年方法
    public static boolean IsLeap_Year(int year){
        boolean flag;
        if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)){
            flag = true;
        }else{
            flag = false;
        }
        return flag;
    }


    //数据导入JTable表格方法,总分查询除外
    public void Import_Data(ResultSet result,JTable table){
        try {
            result.last();
            int cnt = result.getRow();
            result.beforeFirst();
            String[][] data = new String[cnt][10];
            int i = 0;
            while(result.next()){
                data[i][0] = result.getString("Student_Name");
                data[i][1] = result.getString("Student_ID");
                data[i][2] = result.getString("College");
                data[i][3] = result.getString("Class");
                data[i][4] = result.getString("Activity_name");
                data[i][5] = result.getString("Organizer");
                data[i][6] = result.getString("Term");
                data[i][7] = result.getString("Prize");
                data[i][8] = result.getString("Certification_Time");
                data[i][9] = result.getString("Credit");
                i++;
            }
            for(int j = 0 ; j < i ; j++){
                for(int k = 0 ; k < 10 ; k++){
                    System.out.print(data[j][k]+"    ");
                }
                System.out.println();
            }
            //结果展示
            DefaultTableModel model = new DefaultTableModel(data,names);
            table.setModel(model);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    //导数总分数据到JTable组件并显示
    public void Import_Sum(ResultSet result , ResultSet sum ,JTable table){
        try {
            result.last();
            int cnt = result.getRow();
            result.beforeFirst();
            String[][] data = new String[cnt*2][10];
            int i = 0;
            while(result.next()){
                if(i == 0){
                    data[i][0] = result.getString("Student_Name");
                    data[i][1] = result.getString("Student_ID");
                    data[i][2] = result.getString("College");
                    data[i][3] = result.getString("Class");
                    data[i][4] = result.getString("Activity_name");
                    data[i][5] = result.getString("Organizer");
                    data[i][6] = result.getString("Term");
                    data[i][7] = result.getString("Prize");
                    data[i][8] = result.getString("Certification_Time");
                    data[i][9] = result.getString("Credit");
                    i++;
                }else{
                    if(result.getString("Student_ID").equals(data[i-1][1])){
                        data[i][0] = result.getString("Student_Name");
                        data[i][1] = result.getString("Student_ID");
                        data[i][2] = result.getString("College");
                        data[i][3] = result.getString("Class");
                        data[i][4] = result.getString("Activity_name");
                        data[i][5] = result.getString("Organizer");
                        data[i][6] = result.getString("Term");
                        data[i][7] = result.getString("Prize");
                        data[i][8] = result.getString("Certification_Time");
                        data[i][9] = result.getString("Credit");
                        i++;
                    }else{
                        sum.next();
                        data[i][8] = "合计:";
                        data[i][9] = sum.getString("_sum");
                        i++;
                        data[i][0] = result.getString("Student_Name");
                        data[i][1] = result.getString("Student_ID");
                        data[i][2] = result.getString("College");
                        data[i][3] = result.getString("Class");
                        data[i][4] = result.getString("Activity_name");
                        data[i][5] = result.getString("Organizer");
                        data[i][6] = result.getString("Term");
                        data[i][7] = result.getString("Prize");
                        data[i][8] = result.getString("Certification_Time");
                        data[i][9] = result.getString("Credit");
                        i++;
                    }
                }
            }

            /*for(int j = 0 ; j < 2*i ; j++){
                for(int k = 0 ; k < 10 ; k++){
                    System.out.print(data[j][k]+"    ");
                }
                System.out.println();
            }*/
            String[] names = {"姓名","学号","学院","班级","活动名称","活动主办方","学年学期","奖项","认证时间","学分"};
            DefaultTableModel model = new DefaultTableModel(data,names);
            table.setModel(model);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /**
     * Initialize the contents of the frame.界面初始化
     */
    private void initialize() {
        frame = new JFrame();
        frame.setTitle("\u793E\u56E2\u6D3B\u52A8\u5B66\u5206\u7BA1\u7406\u7CFB\u7EDF");
        frame.setBounds(100, 100, 1280, 589);
        frame.setResizable(false);
        frame.setMinimumSize(new Dimension(400,400));
        frame.setMaximumSize(new Dimension(400,400));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //菜单工具栏设计
        JMenuBar menuBar = new JMenuBar();
        frame.setJMenuBar(menuBar);

        //“菜单栏”下拉菜单设计
        JMenu menu = new JMenu("\u83DC\u5355");
        menuBar.add(menu);

        //“导入学生信息”菜单项设计
        JMenuItem mntmi = new JMenuItem("\u5BFC\u5165\u6587\u4EF6\uFF08I\uFF09");
        menu.add(mntmi);
        mntmi.setMnemonic('I');
        mntmi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub
                JFileChooser chooser = new JFileChooser();
                chooser.setVisible(true);
                chooser.setMultiSelectionEnabled(true);
                chooser.showOpenDialog(mntmi);
                String absolutePath = chooser.getSelectedFile().getAbsolutePath();
                sql.Insert_ExcelFile(absolutePath);
            }
        });

        //“退出”菜单设计
        JMenuItem mntme_1 = new JMenuItem("\u9000\u51FA\uFF08E\uFF09");
        menu.add(mntme_1);
        mntme_1.setMnemonic('E');
        mntme_1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                JOptionPane pane = new JOptionPane();
                String message = "确定要退出吗?";
                int showConfirmDialog = JOptionPane.showConfirmDialog(mntme_1, message,"退出",JOptionPane.YES_NO_CANCEL_OPTION);
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();   //获取当前屏幕大小
                Dimension frameSize = pane.getPreferredSize();//获取当前窗口大小
                pane.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);//保持窗口弹出位置居中
                if(showConfirmDialog == JOptionPane.YES_OPTION){
                    System.exit(0);
                }
            }
        });

        SpringLayout springLayout = new SpringLayout();
        frame.getContentPane().setLayout(springLayout);

        //面板
        JPanel panel = new JPanel();
        springLayout.putConstraint(SpringLayout.NORTH, panel, 10, SpringLayout.NORTH, frame.getContentPane());
        springLayout.putConstraint(SpringLayout.WEST, panel, 10, SpringLayout.WEST, frame.getContentPane());
        springLayout.putConstraint(SpringLayout.SOUTH, panel, -356, SpringLayout.SOUTH, frame.getContentPane());
        springLayout.putConstraint(SpringLayout.EAST, panel, 0, SpringLayout.EAST, frame.getContentPane());
        frame.getContentPane().add(panel);

        //“信息填入窗口”设计
        SpringLayout sl_panel = new SpringLayout();
        panel.setLayout(sl_panel);

        //“起始认证日期”标签
        JLabel label_2 = new JLabel("\u8D77\u59CB\u8BA4\u8BC1\u65E5\u671F");
        sl_panel.putConstraint(SpringLayout.NORTH, label_2, 10, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, label_2, 10, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_2, -116, SpringLayout.SOUTH, panel);
        sl_panel.putConstraint(SpringLayout.EAST, label_2, -1173, SpringLayout.EAST, panel);
        panel.add(label_2);

        //"终止认证日期标签"设计
        JLabel lblNewLabel1 = new JLabel("\u7EC8\u6B62\u8BA4\u8BC1\u65E5\u671F");
        sl_panel.putConstraint(SpringLayout.NORTH, lblNewLabel1, 70, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, lblNewLabel1, 10, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.EAST, lblNewLabel1, -1163, SpringLayout.EAST, panel);
        panel.add(lblNewLabel1);

        //“学院”标签设计
        JLabel lblNewLabel_1 = new JLabel("\u5B66\u9662");
        sl_panel.putConstraint(SpringLayout.NORTH, lblNewLabel_1, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.SOUTH, lblNewLabel_1, 0, SpringLayout.SOUTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.EAST, lblNewLabel_1, -742, SpringLayout.EAST, panel);
        panel.add(lblNewLabel_1);

        //“学院”标签对应下拉列表设计
        comboBox_2 = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox_2, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.WEST, comboBox_2, 3, SpringLayout.EAST, lblNewLabel_1);
        String college_path = "bin/社团活动学分管理系统/学院.txt";
        comboBox_2.addItem("--请选择--");
        ComboBox_AddItem(comboBox_2, college_path);
        panel.add(comboBox_2);

        //“年级”标签设计
        JLabel label_3 = new JLabel("\u5E74\u7EA7");
        sl_panel.putConstraint(SpringLayout.EAST, comboBox_2, -24, SpringLayout.WEST, label_3);
        sl_panel.putConstraint(SpringLayout.EAST, label_3, -597, SpringLayout.EAST, panel);
        sl_panel.putConstraint(SpringLayout.WEST, label_3, 636, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.NORTH, label_3, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_3, 0, SpringLayout.SOUTH, lblNewLabel1);
        panel.add(label_3);

        //“年级”标签对应下拉列表设计
        comboBox_3 = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox_3, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.WEST, comboBox_3, 6, SpringLayout.EAST, label_3);
        sl_panel.putConstraint(SpringLayout.SOUTH, comboBox_3, 0, SpringLayout.SOUTH, lblNewLabel1);
        int nowyear = Calendar.getInstance().get(Calendar.YEAR);
        comboBox_3.addItem("--请选择--");
        comboBox_3.addItem("大一");
        comboBox_3.addItem("大二");
        comboBox_3.addItem("大三");
        comboBox_3.addItem("大四");
        comboBox_3.addItem("大五");
        comboBox_3.addItem("大六");
        panel.add(comboBox_3);

        //“班级”标签设计
        JLabel label_4 = new JLabel("\u73ED\u7EA7");
        sl_panel.putConstraint(SpringLayout.EAST, comboBox_3, -6, SpringLayout.WEST, label_4);
        sl_panel.putConstraint(SpringLayout.WEST, label_4, 764, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.NORTH, label_4, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_4, 0, SpringLayout.SOUTH, lblNewLabel1);
        panel.add(label_4);

        //“班级”标签对应的下拉列表设计
        comboBox_4 = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.WEST, comboBox_4, 6, SpringLayout.EAST, label_4);
        sl_panel.putConstraint(SpringLayout.SOUTH, comboBox_4, 0, SpringLayout.SOUTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox_4, 0, SpringLayout.NORTH, lblNewLabel1);
        comboBox_4.addItem("--请选择--");
        String class_path = "bin/社团活动学分管理系统/班级.txt";
        ComboBox_AddItem(comboBox_4, class_path);
        //System.out.println(comboBox_4.getSelectedItem().toString());
        panel.add(comboBox_4);

        //“姓名”标签设计
        JLabel label_5 = new JLabel("\u59D3\u540D");
        sl_panel.putConstraint(SpringLayout.SOUTH, label_5, -10, SpringLayout.SOUTH, panel);
        panel.add(label_5);

        //“姓名”标签对应的输入文本框设计
        textField_2 = new JTextField();
        sl_panel.putConstraint(SpringLayout.WEST, textField_2, 409, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.EAST, label_5, -6, SpringLayout.WEST, textField_2);
        sl_panel.putConstraint(SpringLayout.NORTH, textField_2, 0, SpringLayout.NORTH, label_5);
        sl_panel.putConstraint(SpringLayout.SOUTH, textField_2, 0, SpringLayout.SOUTH, label_5);
        panel.add(textField_2);
        textField_2.setColumns(10);

        //“学号”标签设计
        JLabel label_6 = new JLabel("\u5B66\u53F7");
        sl_panel.putConstraint(SpringLayout.NORTH, label_6, 18, SpringLayout.SOUTH, comboBox_2);
        sl_panel.putConstraint(SpringLayout.WEST, label_6, 543, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_6, -18, SpringLayout.SOUTH, panel);
        sl_panel.putConstraint(SpringLayout.EAST, textField_2, -14, SpringLayout.WEST, label_6);
        panel.add(label_6);

        //“学号”标签对应的输入文本框设计
        textField_3 = new JTextField();
        sl_panel.putConstraint(SpringLayout.NORTH, textField_3, 19, SpringLayout.SOUTH, comboBox_2);
        sl_panel.putConstraint(SpringLayout.WEST, textField_3, 6, SpringLayout.EAST, label_6);
        sl_panel.putConstraint(SpringLayout.SOUTH, textField_3, -10, SpringLayout.SOUTH, panel);
        panel.add(textField_3);
        //System.out.println("".equals(textField_3.getText()));
        textField_3.setColumns(10);

        //“活动名称”标签设计
        JLabel label_7 = new JLabel("\u6D3B\u52A8\u540D\u79F0");
        sl_panel.putConstraint(SpringLayout.NORTH, label_7, 9, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_7, -116, SpringLayout.SOUTH, panel);
        panel.add(label_7);

        //“活动名称”标签对应的输入文本框设计
        textField_4 = new JTextField();
        sl_panel.putConstraint(SpringLayout.NORTH, textField_4, 10, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, textField_4, -13, SpringLayout.NORTH, label_4);
        sl_panel.putConstraint(SpringLayout.EAST, comboBox_4, 0, SpringLayout.EAST, textField_4);
        sl_panel.putConstraint(SpringLayout.EAST, label_7, -19, SpringLayout.WEST, textField_4);
        sl_panel.putConstraint(SpringLayout.WEST, textField_4, 789, SpringLayout.WEST, panel);
        panel.add(textField_4);
        textField_4.setColumns(10);

        //"活动主办方”标签设计
        JLabel lblNewLabel_2 = new JLabel("\u6D3B\u52A8\u4E3B\u529E\u65B9");
        sl_panel.putConstraint(SpringLayout.NORTH, lblNewLabel_2, 10, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, lblNewLabel_2, 528, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, lblNewLabel_2, -13, SpringLayout.NORTH, comboBox_2);
        panel.add(lblNewLabel_2);

        //“活动主办方”标签对应的下拉列表设计
        comboBox_5 = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox_5, 8, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, comboBox_5, -12, SpringLayout.NORTH, comboBox_2);
        sl_panel.putConstraint(SpringLayout.EAST, lblNewLabel_2, -6, SpringLayout.WEST, comboBox_5);
        sl_panel.putConstraint(SpringLayout.WEST, comboBox_5, 600, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.EAST, comboBox_5, -6, SpringLayout.WEST, label_7);
        //comboBox_5.addItem("");
        String path = "bin/社团活动学分管理系统/活动主办方.txt";
        comboBox_5.addItem("--请选择--");
        ComboBox_AddItem(comboBox_5,path);
        panel.add(comboBox_5);

        //“明细查询”按钮设计
        JButton btnNewButton = new JButton("\u660E\u7EC6\u67E5\u8BE2");
        sl_panel.putConstraint(SpringLayout.NORTH, btnNewButton, 10, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.EAST, textField_4, -7, SpringLayout.WEST, btnNewButton);
        sl_panel.putConstraint(SpringLayout.WEST, btnNewButton, 917, SpringLayout.WEST, panel);
        btnNewButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                try {
                    Statement statement = sql.GetConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    String query_sql_detail = "SELECT  S.*,A.*,SA.Prize,SA.Certification_Time,SA.Credit "
                                    +"FROM Student S,Activity A,Student_Activity SA "
                                        + "WHERE S.Student_ID = SA.Student_ID AND A.Activity_Name = SA.Activity_Name";
                    query_sql_detail += " ORDER BY SA.Student_ID,S.College ,S.Class,A.Term,SA.Certification_Time,A.Organizer,A.Activity_Name,SA.Credit";
                    ResultSet result = statement.executeQuery(query_sql_detail);
                    Import_Data(result, table);
                } catch (SQLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
        });
        panel.add(btnNewButton);

        //“总分查询”按钮设计
        JButton btnNewButton_1 = new JButton("\u603B\u5206\u67E5\u8BE2");
        sl_panel.putConstraint(SpringLayout.WEST, btnNewButton_1, 1022, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.EAST, btnNewButton, -6, SpringLayout.WEST, btnNewButton_1);
        sl_panel.putConstraint(SpringLayout.NORTH, btnNewButton_1, 10, SpringLayout.NORTH, panel);
        btnNewButton_1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                //明细查询SQL查询语句
                String query_sql_all = "SELECT  S.*,A.*,SA.Prize,SA.Certification_Time,SA.Credit "
                                            +"FROM Student S,Activity A,Student_Activity SA "
                                            + "WHERE S.Student_ID = SA.Student_ID AND A.Activity_Name = SA.Activity_Name";

                //总分查询SQL查询语句
                String query_sql_sum = "SELECT SA.Student_ID,Sum(SA.Credit) as _sum "
                                        +"FROM Student_Activity SA Group BY SA.Student_ID";

                //如果学号输入文本框不为空
                if(!"".equals(textField_3.getText())){
                    query_sql_all += " AND S.Student_ID = " + "'"+textField_3.getText()+"'";
                }

                //如果姓名输入文本框不为空
                if(!"".equals(textField_2.getText())){
                    query_sql_all += " AND S.Student_Name = "+"'"+textField_2.getText()+"'";
                }
                query_sql_all += " ORDER BY SA.Student_ID,S.College ,S.Class,A.Term,SA.Certification_Time,A.Organizer,A.Activity_Name,SA.Credit";
                //System.out.println(query_sql_all);
                //System.out.println(query_sql_sum);
                try {
                    Statement statement1 = sql.GetConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    Statement statement2 = sql.GetConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    ResultSet sum = statement1.executeQuery(query_sql_sum);
                    ResultSet result = statement2.executeQuery(query_sql_all);
                    Import_Sum(result, sum, table);
                } catch (SQLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
        });
        panel.add(btnNewButton_1);

        //“Excel输出”按钮设计
        JButton btnExcel = new JButton("Excel\u8F93\u51FA");
        sl_panel.putConstraint(SpringLayout.EAST, btnNewButton_1, -6, SpringLayout.WEST, btnExcel);
        sl_panel.putConstraint(SpringLayout.WEST, btnExcel, 1127, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.EAST, btnExcel, -10, SpringLayout.EAST, panel);
        sl_panel.putConstraint(SpringLayout.NORTH, btnExcel, 10, SpringLayout.NORTH, panel);
        btnExcel.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub
                try {
                    String[] excel_header = {"姓名","学号","学院","班级","活动名称",
                                            "活动主办方","学年学期","奖项","认证时间","学分"};
                    //得到主机的桌面的绝对路径,并生成输出Excel文件的绝对路径(用系统时间命名)
                    String output_excel_path = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath();
                    Date date = new Date();
                    SimpleDateFormat fomat = new SimpleDateFormat("yyyy年MM月dd日HH点mm分ss秒");
                    String str = fomat.format(date);
                    output_excel_path += "\\"+str+".xls";
                    File output_excel = new File(output_excel_path);
                    //创建一个Excel工作簿
                    WritableWorkbook workbook = Workbook.createWorkbook(output_excel);
                    //生成名为“Sheet0”的工作表,参数0表示这是第一页
                    WritableSheet sheet = workbook.createSheet("Sheet0", 0);
                    //把属性名写在第i列第0行
                    for(int i = 0 ; i < excel_header.length ; i++){
                        Label label = new Label(i,0, excel_header[i]);
                        sheet.addCell(label);
                    }
                    DefaultTableModel model = (DefaultTableModel)table.getModel();
                    int rows = model.getRowCount();
                    int columns = model.getColumnCount();
                    //把数据一次写在第j列第i+1行
                    for(int i = 0 ; i < rows ; i++){
                        for(int j = 0 ; j < columns ; j++){
                            Label label = new Label(j,i+1,(String) model.getValueAt(i, j));
                            sheet.addCell(label);
                        }
                    }
                    workbook.write();
                    workbook.close();
                    JOptionPane pane = new JOptionPane();
                    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();   //获取当前屏幕大小
                    Dimension frameSize = pane.getPreferredSize();//获取当前窗口大小
                    pane.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);//保持窗口弹出位置居中
                    String message = "Excel文件已经放在桌面上了!\n"
                                    +"文件名为:"+str;
                    @SuppressWarnings("unused")
                    int showConfirmDialog = JOptionPane.showConfirmDialog(btnExcel, message,"确定",JOptionPane.DEFAULT_OPTION);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (RowsExceededException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (WriteException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        });
        panel.add(btnExcel);

        //“记录查询”按钮设计
        JButton button = new JButton("\u8BB0\u5F55\u67E5\u8BE2");
        sl_panel.putConstraint(SpringLayout.SOUTH, btnNewButton_1, -13, SpringLayout.NORTH, button);
        sl_panel.putConstraint(SpringLayout.SOUTH, button, 0, SpringLayout.SOUTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.NORTH, button, 0, SpringLayout.NORTH, lblNewLabel1);
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                try {
                    String query_sql = GetQuerySQL();
                    query_sql += " ORDER BY SA.Student_ID,S.College ,S.Class,A.Term,SA.Certification_Time,A.Organizer,A.Activity_Name,SA.Credit";
                    //System.out.println(query_sql);
                    Statement statement = sql.GetConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    ResultSet result;
                    result = statement.executeQuery(query_sql);
                    Import_Data(result, table);
                } catch (SQLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
        });
        panel.add(button);

        //“记录删除”按钮设计
        JButton button_1 = new JButton("\u8BB0\u5F55\u5220\u9664");
        sl_panel.putConstraint(SpringLayout.EAST, button, -6, SpringLayout.WEST, button_1);
        sl_panel.putConstraint(SpringLayout.WEST, button_1, 1127, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, btnExcel, -13, SpringLayout.NORTH, button_1);
        sl_panel.putConstraint(SpringLayout.SOUTH, button_1, 0, SpringLayout.SOUTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.NORTH, button_1, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.EAST, button_1, 0, SpringLayout.EAST, btnExcel);
        button_1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                try {
                    String join = "DELETE FROM Student_Activity WHERE";
                    DefaultTableModel model = (DefaultTableModel)table.getModel();
                    int rows = model.getRowCount();
                    Statement statement = sql.GetConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    int cnt = 0;
                    for(int i = 0 ; i < rows ; i++){
                        String delete_sql = " Student_ID = '"+model.getValueAt(i, 1)+"'";
                        delete_sql += " AND Activity_Name = '"+model.getValueAt(i, 4)+"'";      
                        delete_sql = join + delete_sql;
                        System.out.println(delete_sql);
                        if(statement.executeUpdate(delete_sql) == -1){
                            System.out.println("删除失败");
                        }else{
                            cnt++;
                        }
                    }
                    JOptionPane pane = new JOptionPane();
                    String message = "共有"+rows+"条数据,已经删除了"+cnt+"条数据";
                    int showConfirmDialog = JOptionPane.showConfirmDialog(button_1, message,"删除结果",JOptionPane.PLAIN_MESSAGE);
                    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();   //获取当前屏幕大小
                    Dimension frameSize = pane.getPreferredSize();//获取当前窗口大小
                    pane.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);//保持窗口弹出位置居中
                    if(showConfirmDialog == JOptionPane.PLAIN_MESSAGE){
                        for(int i = 0 ; i < rows ; i++){
                            model.removeRow(i);
                        }
                    }
                } catch (SQLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
        });
        panel.add(button_1);

        //“退出”按钮设计
        JButton button_2 = new JButton("\u9000     \u51FA");
        sl_panel.putConstraint(SpringLayout.EAST, label_6, -553, SpringLayout.WEST, button_2);
        sl_panel.putConstraint(SpringLayout.EAST, textField_3, -399, SpringLayout.WEST, button_2);
        sl_panel.putConstraint(SpringLayout.NORTH, button_2, 9, SpringLayout.SOUTH, button_1);
        sl_panel.putConstraint(SpringLayout.SOUTH, button_2, -15, SpringLayout.SOUTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, button_2, 0, SpringLayout.WEST, btnExcel);
        sl_panel.putConstraint(SpringLayout.EAST, button_2, -10, SpringLayout.EAST, panel);
        button_2.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                JOptionPane pane = new JOptionPane();
                String message = "确定要退出吗?";
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();   //获取当前屏幕大小
                Dimension frameSize = pane.getPreferredSize();//获取当前窗口大小
                pane.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);//保持窗口弹出位置居中
                int showConfirmDialog = JOptionPane.showConfirmDialog(button_2, message,"退出",JOptionPane.YES_NO_CANCEL_OPTION);
                if(showConfirmDialog == JOptionPane.YES_OPTION){
                    System.exit(0);
                }
            }
        });
        panel.add(button_2);

        //“学分范围”标签设计
        JLabel label_8 = new JLabel("\u5B66\u5206\u8303\u56F4");
        sl_panel.putConstraint(SpringLayout.SOUTH, lblNewLabel1, -6, SpringLayout.NORTH, label_8);
        sl_panel.putConstraint(SpringLayout.NORTH, label_8, 103, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_8, -10, SpringLayout.SOUTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, label_8, 10, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.EAST, label_8, -1188, SpringLayout.EAST, panel);
        panel.add(label_8);

        //“大于等于”标签设计
        JLabel label_9 = new JLabel("\u5927\u4E8E\u7B49\u4E8E");
        sl_panel.putConstraint(SpringLayout.NORTH, label_9, 9, SpringLayout.SOUTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.WEST, label_9, 6, SpringLayout.EAST, label_8);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_9, -15, SpringLayout.SOUTH, panel);
        sl_panel.putConstraint(SpringLayout.EAST, label_9, -1124, SpringLayout.EAST, panel);
        panel.add(label_9);

        //“大于等于”标签对应的输入文本框设计
        textField_5 = new JTextField();
        sl_panel.putConstraint(SpringLayout.NORTH, textField_5, 0, SpringLayout.NORTH, label_5);
        sl_panel.putConstraint(SpringLayout.WEST, textField_5, 6, SpringLayout.EAST, label_9);
        sl_panel.putConstraint(SpringLayout.SOUTH, textField_5, -10, SpringLayout.SOUTH, panel);
        sl_panel.putConstraint(SpringLayout.EAST, textField_5, 72, SpringLayout.EAST, label_9);
        panel.add(textField_5);
        textField_5.setColumns(10);

        //“小于等于”标签设计
        JLabel label_10 = new JLabel("\u5C0F\u4E8E\u7B49\u4E8E");
        sl_panel.putConstraint(SpringLayout.WEST, label_10, 217, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_10, -10, SpringLayout.SOUTH, panel);
        sl_panel.putConstraint(SpringLayout.EAST, label_10, -981, SpringLayout.EAST, panel);
        panel.add(label_10);

        //“小于等于”标签对应输入文本框设计
        textField_6 = new JTextField();
        sl_panel.putConstraint(SpringLayout.WEST, label_5, 22, SpringLayout.EAST, textField_6);
        sl_panel.putConstraint(SpringLayout.WEST, textField_6, 279, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, textField_6, -10, SpringLayout.SOUTH, panel);
        sl_panel.putConstraint(SpringLayout.EAST, textField_6, -914, SpringLayout.EAST, panel);
        panel.add(textField_6);
        textField_6.setColumns(10);

        //起始认证日期的"年"下拉列表
        comboBox = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox, 9, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, comboBox, 103, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.EAST, comboBox, -1080, SpringLayout.EAST, panel);
        comboBox.addItem("--请选择--");
        for(int i = 2011 ; i <= nowyear ; i++){
            comboBox.addItem(String.valueOf(i));
        }
        panel.add(comboBox);

        //起始认证日期的"年"标签
        JLabel label = new JLabel("\u5E74");
        sl_panel.putConstraint(SpringLayout.NORTH, label, 10, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, label, 25, SpringLayout.EAST, comboBox);
        panel.add(label);

        //起始认证日期的"月"下拉列表
        comboBox_1 = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox_1, 10, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, comboBox_1, 6, SpringLayout.EAST, label);
        sl_panel.putConstraint(SpringLayout.EAST, comboBox_1, 0, SpringLayout.EAST, textField_6);
        comboBox_1.addItem("--请选择--");
        for(int i = 1 ; i <= 12 ; i++){
            comboBox_1.addItem(String.valueOf(i));
        }
        panel.add(comboBox_1);

        //起始认证日期的"月"标签
        JLabel label_1 = new JLabel("\u6708");
        sl_panel.putConstraint(SpringLayout.NORTH, label_1, 10, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, label_1, 9, SpringLayout.EAST, comboBox_1);
        sl_panel.putConstraint(SpringLayout.EAST, label_1, -877, SpringLayout.EAST, panel);
        panel.add(label_1);

        //起始认证日期的"日"下拉列表
        comboBox_6 = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox_6, -1, SpringLayout.NORTH, label_2);
        sl_panel.putConstraint(SpringLayout.WEST, comboBox_6, 6, SpringLayout.EAST, label_1);
        comboBox_6.addItem("--请选择--");
        for( int i = 1 ; i <= 31 ; i++){
            comboBox_6.addItem(String.valueOf(i));
        }
        panel.add(comboBox_6);

        //起始认证日期的"日"标签
        JLabel label_11 = new JLabel("\u65E5");
        sl_panel.putConstraint(SpringLayout.EAST, comboBox_6, -6, SpringLayout.WEST, label_11);
        sl_panel.putConstraint(SpringLayout.NORTH, label_11, 10, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.WEST, label_11, 488, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_11, -13, SpringLayout.NORTH, lblNewLabel_1);
        sl_panel.putConstraint(SpringLayout.EAST, label_11, -18, SpringLayout.WEST, lblNewLabel_2);
        panel.add(label_11);

        //终止认证日期的"年"下拉列表
        comboBox_7 = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.SOUTH, comboBox, -3, SpringLayout.NORTH, comboBox_7);
        sl_panel.putConstraint(SpringLayout.WEST, comboBox_7, 6, SpringLayout.EAST, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox_7, 60, SpringLayout.NORTH, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, comboBox_7, -66, SpringLayout.SOUTH, panel);
        comboBox_7.addItem("--请选择--");
        for(int i = 2011 ; i <= nowyear ; i++){
            comboBox_7.addItem(String.valueOf(i));
        }
        panel.add(comboBox_7);

        //终止认证日期的"年"标签
        JLabel label_12 = new JLabel("\u5E74 ");
        sl_panel.putConstraint(SpringLayout.SOUTH, label, -13, SpringLayout.NORTH, label_12);
        sl_panel.putConstraint(SpringLayout.EAST, label, 12, SpringLayout.EAST, label_12);
        sl_panel.putConstraint(SpringLayout.NORTH, label_10, 0, SpringLayout.SOUTH, label_12);
        sl_panel.putConstraint(SpringLayout.EAST, comboBox_7, -6, SpringLayout.WEST, label_12);
        sl_panel.putConstraint(SpringLayout.NORTH, label_12, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.WEST, label_12, 202, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_12, -57, SpringLayout.SOUTH, panel);
        panel.add(label_12);

        //终止认证日期的"月"下拉列表
        comboBox_8 = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.SOUTH, comboBox_1, -13, SpringLayout.NORTH, comboBox_8);
        sl_panel.putConstraint(SpringLayout.EAST, label_12, -7, SpringLayout.WEST, comboBox_8);
        sl_panel.putConstraint(SpringLayout.SOUTH, comboBox_8, 0, SpringLayout.SOUTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox_8, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.WEST, comboBox_8, 232, SpringLayout.WEST, panel);
        comboBox_8.addItem("--请选择--");
        for(int i = 1 ; i <= 12 ; i++){
            comboBox_8.addItem(String.valueOf(i));
        }
        panel.add(comboBox_8);

        //终止认证日期的"月"标签
        JLabel label_13 = new JLabel("\u6708");
        sl_panel.putConstraint(SpringLayout.SOUTH, label_1, -13, SpringLayout.NORTH, label_13);
        sl_panel.putConstraint(SpringLayout.WEST, label_13, 337, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.NORTH, textField_6, 19, SpringLayout.SOUTH, label_13);
        sl_panel.putConstraint(SpringLayout.EAST, comboBox_8, -6, SpringLayout.WEST, label_13);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_13, 0, SpringLayout.SOUTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.NORTH, label_13, 0, SpringLayout.NORTH, lblNewLabel1);
        panel.add(label_13);

        //终止认证日期的"日"下拉列表
        comboBox_9 = new JComboBox<String>();
        sl_panel.putConstraint(SpringLayout.SOUTH, comboBox_6, -13, SpringLayout.NORTH, comboBox_9);
        sl_panel.putConstraint(SpringLayout.NORTH, label_5, 19, SpringLayout.SOUTH, comboBox_9);
        sl_panel.putConstraint(SpringLayout.NORTH, comboBox_9, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.WEST, comboBox_9, 380, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.SOUTH, comboBox_9, 0, SpringLayout.SOUTH, lblNewLabel1);
        comboBox_9.addItem("--请选择--");
        for( int i = 1 ; i <= 31 ; i++){
            comboBox_9.addItem(String.valueOf(i));
        }
        panel.add(comboBox_9);

        //终止认证日期的"日"标签
        JLabel label_14 = new JLabel("\u65E5");
        sl_panel.putConstraint(SpringLayout.EAST, label_14, -779, SpringLayout.EAST, panel);
        sl_panel.putConstraint(SpringLayout.WEST, lblNewLabel_1, 6, SpringLayout.EAST, label_14);
        sl_panel.putConstraint(SpringLayout.EAST, label_13, -102, SpringLayout.WEST, label_14);
        sl_panel.putConstraint(SpringLayout.EAST, comboBox_9, -6, SpringLayout.WEST, label_14);
        sl_panel.putConstraint(SpringLayout.SOUTH, label_14, 0, SpringLayout.SOUTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.NORTH, label_14, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.WEST, label_14, 467, SpringLayout.WEST, panel);
        panel.add(label_14);

        //显示结果窗口网格面面板
        JPanel panel_1 = new JPanel();
        springLayout.putConstraint(SpringLayout.NORTH, panel_1, 8, SpringLayout.SOUTH, panel);
        springLayout.putConstraint(SpringLayout.WEST, panel_1, 10, SpringLayout.WEST, frame.getContentPane());
        springLayout.putConstraint(SpringLayout.SOUTH, panel_1, 347, SpringLayout.SOUTH, panel);
        springLayout.putConstraint(SpringLayout.EAST, panel_1, 0, SpringLayout.EAST, panel);
        frame.getContentPane().add(panel_1);
        panel_1.setLayout(new GridLayout(1, 0, 0, 0));

        //查询结果结果表格
        table = new JTable();
        table.setFillsViewportHeight(true);
        table.setEnabled(false);
        panel_1.add(new JScrollPane(table));

        //"获奖查询"按钮设计
        JButton button_3 = new JButton("\u83B7\u5956\u67E5\u8BE2");
        sl_panel.putConstraint(SpringLayout.EAST, label_4, -122, SpringLayout.WEST, button_3);
        sl_panel.putConstraint(SpringLayout.SOUTH, btnNewButton, -13, SpringLayout.NORTH, button_3);
        sl_panel.putConstraint(SpringLayout.WEST, button, 6, SpringLayout.EAST, button_3);
        sl_panel.putConstraint(SpringLayout.SOUTH, button_3, 0, SpringLayout.SOUTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.NORTH, button_3, 0, SpringLayout.NORTH, lblNewLabel1);
        sl_panel.putConstraint(SpringLayout.WEST, button_3, 917, SpringLayout.WEST, panel);
        sl_panel.putConstraint(SpringLayout.EAST, button_3, 0, SpringLayout.EAST, btnNewButton);
        button_3.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub
                try {
                    String query_sql_getPrize = GetQuerySQL(); 
                    query_sql_getPrize += " AND SA.Prize != 'NULL'";
                    query_sql_getPrize += " ORDER BY SA.Student_ID,S.College ,S.Class,A.Term,SA.Certification_Time,A.Organizer,A.Activity_Name,SA.Credit";
                    System.out.println(query_sql_getPrize);
                    Statement statement = sql.GetConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    ResultSet result = statement.executeQuery(query_sql_getPrize);
                    Import_Data(result, table);
                } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
            }
        });
        panel.add(button_3);
    }
}

数据库查询模块代码

package 社团活动学分管理系统;

import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

/*
 * 这是社团学分管理系统与数据库查询相关的功能模块
 */

public class SQL {
    private String JDriver;                 //JDBC SQL Sever数据库驱动名称
    private String Url;                     //需要连接的数据库的url
    private String UserName;                //用户账号名称
    private String PassWord;                //用户账号密码
    private Connection connection;          //数据库连接实例 

    public Connection GetConnection() {
        return connection;
    }

    //构造方法
    public SQL(String jDriver, String url, String userName, String passWord) {
        super();
        JDriver = jDriver;
        Url = url;
        UserName = userName;
        PassWord = passWord;

        //加载SQL Sever数据库引擎
        try {
            Class.forName(JDriver);// 加载数据库引擎,返回给定字符串名的类
        } catch (ClassNotFoundException e) {
            // e.printStackTrace();
            System.out.println("加载数据库引擎失败");
            System.exit(0);
        }
        System.out.println("数据库驱动成功");

        //与数据库建立连接
        try {
            connection = DriverManager.getConnection(this.Url,this.UserName,this.PassWord);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    //插入一条活动信息方法
    public void Insert_Acticity(Activity activity){
        try {
            String insert_sql = "INSERT INTO Activity "+activity.Insert_SQL();
            String query_sql = "SELECT * FROM Activity "+activity.Select_SQL();
            //System.out.println(insert_sql);
            //System.out.println(query_sql);
            Statement statement = this.connection.createStatement();
            ResultSet executeQuery = statement.executeQuery(query_sql);
            boolean flag = false;           //判断表中数据是否存在标志
            while(executeQuery.next()){
                String activity_name = executeQuery.getString("Activity_Name");
                String term = executeQuery.getString("Term");
                String organizer = executeQuery.getString("Organizer");
                if(activity.equals(new Activity(activity_name,organizer,term))){
                    flag = true;
                    break;
                }else {
                    continue;
                }
            }
            if(flag){
                System.out.println("数据已经在学生信息表存在,不需要进行插入");
            }else{
                int row = statement.executeUpdate(insert_sql);
                if(row == 1){
                    System.out.println("插入数据成功");
                }else{
                    System.out.println("插入数据失败");
                }
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    //插入一条学生记录方法
    public void Insert_Student(Student student){
        try {
            String insert_sql = "INSERT INTO Student "+student.Insert_SQL();
            String query_sql = "SELECT * FROM Student "+student.Select_SQL();
            //System.out.println(insert_sql);
            //System.out.println(query_sql);
            Statement statement = this.connection.createStatement();
            ResultSet executeQuery = statement.executeQuery(query_sql);
            boolean flag = false;           //判断表中数据是否存在标志
            while(executeQuery.next()){
                String stu_id = executeQuery.getString("Student_ID");
                String stu_name = executeQuery.getString("Student_Name");
                String _class = executeQuery.getString("Class");
                String college = executeQuery.getString("College");
                if(student.equals(new Student(stu_name,stu_id,_class,college))){
                    flag = true;
                    break;
                }else {
                    continue;
                }
            }
            if(flag){
                System.out.println("数据已经在学生信息表存在,不需要进行插入");
            }else{
                int row = statement.executeUpdate(insert_sql);
                if(row == 1){
                    System.out.println("插入数据成功");
                }else{
                    System.out.println("插入数据失败");
                }
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void Insert_Student_Activity(Student_Activity student_activity){
        try {
            String insert_sql = "INSERT INTO Student_Activity "+student_activity.Insert_SQL();
            String query_sql = "Select * from Student_Activity "+student_activity.Select_SQL();
            System.out.println(insert_sql);
            System.out.println(query_sql);
            Statement statement = this.connection.createStatement();
            ResultSet executeQuery = statement.executeQuery(query_sql);
            boolean flag = false;           //判断表中数据是否存在标志
            while(executeQuery.next()){
                String stu_id = executeQuery.getString("Student_ID");
                String activity_name = executeQuery.getString("Activity_Name");
                float credit = (float)executeQuery.getInt("Credit");
                String certification_time = executeQuery.getString("Certification_Time");
                String prize = executeQuery.getString("Prize");
                if(student_activity.equals(new Student_Activity(stu_id, activity_name, prize, certification_time,credit))){
                    flag = true;
                    break;
                }else {
                    continue;
                }
            }
            if(flag){
                System.out.println("数据已经在学生活动信息表存在,不需要进行插入");
            }else{
                int row = statement.executeUpdate(insert_sql);
                if(row == 1){
                    System.out.println("插入数据成功");
                }else{
                    System.out.println("插入数据失败");
                }
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    //整体导入Excel文件
    public void Insert_ExcelFile(String path){
        try {
            File file = new File(path);
            System.out.println(path);
            Workbook workbook = Workbook.getWorkbook(file);
            Sheet[] sheets = workbook.getSheets();
            for(Sheet sheet:sheets){
                int rows = sheet.getRows();
                if( rows > 0){
                    if(rows > 1){
                        Cell[] cell = sheet.getRow(0);
                        String str = null;
                        for(Cell c:cell){
                            str += c.getContents().trim();
                        }

                        //Excel文件如果是学生信息的文件
                        if(str.contains("姓名") && str.contains("学号")
                                &&str.contains("学院")&&str.contains("班级")){
                            for(int i = 1 ; i < rows ; i++){
                                Cell[] cells = sheet.getRow(i);
                                String[] s = new String[4];
                                for(int j = 0 ; j < cells.length ; j++){
                                    s[j] = cells[j].getContents().trim();
                                }
                                Student student = new Student(s[0], s[1], s[2], s[3]);
                                Insert_Student(student);
                            }
                        }

                        //Excel文件如果是活动信息的文件
                        if(str.contains("活动名称") && str.contains("活动主办方")
                                &&str.contains("学年学期")){
                            for(int i = 1 ; i < rows ; i++){
                                Cell[] cells = sheet.getRow(i);
                                String[] s = new String[3];
                                for(int j = 0 ; j < cells.length ; j++){
                                    s[j] = cells[j].getContents().trim();
                                }
                                Activity activity = new Activity(s[0], s[1], s[2]);
                                Insert_Acticity(activity);
                            }
                        }

                        //Excel文件如果是学生活动信息的文件
                        if(str.contains("学号") && str.contains("活动名称") &&str.contains("认证日期") &&
                                str.contains("奖项") &&str.contains("学分")){
                            for(int i = 1 ; i < rows ; i++){
                                Cell[] cells = sheet.getRow(i);
                                String[] s = new String[5];
                                for(int j = 0 ; j < cells.length ; j++){
                                    s[j] = cells[j].getContents().trim();
                                    System.out.println(s[2]);
                                }
                                s[3] = "20"+s[3];
                                try {  
                                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                                    java.util.Date date = format.parse(s[3]);  
                                    java.sql.Date sqlDate = new java.sql.Date(date.getTime()); 
                                    String string = sqlDate.toString();
                                    Student_Activity student_activity = new Student_Activity(s[0], s[1], s[2],string,Float.valueOf(s[4]));
                                    Insert_Student_Activity(student_activity);
                                }catch (Exception ex) {  
                                    System.out.println(ex.getMessage());  
                                }
                            }
                        }
                    }
                }
            }
        }catch (BiffException | IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    //记录查询
    public boolean Query(String query_sql){
        try {
            Statement statement = this.connection.createStatement();
            ResultSet executeQuery = statement.executeQuery(query_sql);
            return executeQuery.next();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return false;
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String JDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";// SQL数据库引擎
        String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=Community_Activity_Credit_Management";// 数据源
        String userName = "sa";
        String passWord = "123456";
        SQL sql = new SQL(JDriver, url, userName, passWord);
        //String path1 = "D:\\大学计算机\\嵌入式操作系统\\专题实训2\\社团活动学分管理系统\\bin\\社团活动学分管理系统\\活动信息.xls";
        //String path2 = "D:\\大学计算机\\嵌入式操作系统\\专题实训2\\社团活动学分管理系统\\bin\\社团活动学分管理系统\\学生信息.xls";
        String path3 = "C:\\Users\\77183\\Desktop\\学生活动信息.xls";
        //sql.Insert_ExcelFile(path2);
        //sql.Insert_ExcelFile(path1);
        sql.Insert_ExcelFile(path3);
    }
}

学生信息类代码

package 社团活动学分管理系统;

/*
 * 这是社团学分管理系统的学生实体类
 */

public class Student {
    private String Student_Name;                //学生姓名
    private String Student_ID;                  //学生学号
    private String Class;                       //学生班级
    private String College;                     //学生学院

    //学生实体类构造方法
    public Student(String student_Name, String student_ID, String class1, String college) {
        super();
        Student_Name = student_Name;
        Student_ID = student_ID;
        Class = class1;
        College = college;
    }

    //数据库插入语句生成方法
    public String Insert_SQL() {
        return "VALUES('"+Student_Name+"','"+Student_ID+"','"+Class+"','"+College+"')";
    }

    //数据库查询语句生成方法
    public String Select_SQL() {
        return "WHERE Student_Name = '"+ Student_Name + "' and Student_ID = '" 
                + Student_ID + "' and Class = '" + Class + "' and College = '" + College+"'";
    }

    public String getStudent_Name() {
        return Student_Name;
    }

    public String getStudent_ID() {
        return Student_ID;
    }

    public String getclass() {
        return Class;
    }

    public String getCollege() {
        return College;
    }   

    public boolean equal(Student student){
        boolean student_id = this.Student_ID.equals(student.getStudent_ID());
        boolean student_name = this.Student_Name.equals(student.getStudent_Name());
        boolean _class = this.Class.equals(student.getclass());
        boolean college = this.College.equals(student.getCollege());
        boolean flag = student_id && student_name && _class && college;
        return flag;
    }
}

活动信息类代码

package 社团活动学分管理系统;

/*
 * 这是社团学分管理数据库中的活动数据库的活动实体类
 */

public class Activity {
    private String Activity_Name = null;                    //活动名称
    private String Organizer = null;                        //主办方
    private String Term = null;                             //学年学期

    //构造方法
    public Activity(String activity_Name, String organizer, String term) {
        super();
        Organizer = organizer;
        Activity_Name = activity_Name;
        Term = term;
    }

    //数据库的插入语句生成方法
    public String Insert_SQL(){
        String str = "VALUES('" +  Activity_Name + "','" + Organizer + "','" + Term + "')";
        return str;
    }

    //数据库的查询语句生成方法
    public String Select_SQL(){
        return "WHERE Organizer = '"+ Organizer + "' and Activity_Name = '" 
                        + Activity_Name + "' and Term = '" + Term+"'";
    }   

    public String getOrganizer() {
        return Organizer;
    }

    public String getActivity_Name() {
        return Activity_Name;
    }

    public String getTerm() {
        return Term;
    }

    public boolean equal(Activity activity){
        boolean activity_name = this.Activity_Name.equals(activity.getActivity_Name());   
        boolean term = this.Term.equals(activity.getTerm());
        boolean organizer = this.Organizer.equals(activity.getOrganizer());
        boolean flag = activity_name && term && organizer;
        return flag;
    }
}

学生-活动信息类代码

package 社团活动学分管理系统;


/*
 * 这是社团活动学分管理系统中学生-活动实体类
 */

public class Student_Activity {
    private String Student_ID = null;                   //学生学号
    private String Activity_Name = null;                //活动名称
    private String Prize = null;                        //奖项
    private String Certification_Time = null;           //认证日期
    private float Credit = 0;                           //活动学分

    //学生-活动实体类构造方法
    public Student_Activity(String student_ID,String activity_Name, String prize,String certification_Time,float credit) {
        Activity_Name = activity_Name;
        Student_ID = student_ID;
        Certification_Time = certification_Time;
        Credit = credit;
        Prize = prize;
    }

    //数据库插入语句生成方法
    public String Insert_SQL() {
        String str = "VALUES('"+Student_ID+"','"+Activity_Name+"',";
        if(this.Prize == null){
            str += "null";
        }else{
            str += "'"+Prize+"'";
        }
        str += ",'"+Certification_Time +"',"+String.valueOf(Credit)+")";
        System.out.println(str);
        return str;
    }

    //数据库查询语句生成方法
    public String Select_SQL() {
        String str = "WHERE Activity_Name = '"+ Activity_Name + "' and Student_ID = '" 
                + Student_ID + "' and Certification_Time = '" + Certification_Time 
                + "' and Credit = " + String.valueOf(Credit)+" AND Prize = "+"'"+this.Prize+"'";
        return str;
    }

    public String getActivity_Name() {
        return Activity_Name;
    }

    public String getStudent_ID() {
        return Student_ID;
    }

    public String getCertification_Time() {
        return Certification_Time;
    }

    public float getCredit() {
        return Credit;
    }

    public String getPrize() {
        return Prize;
    }

    public boolean equals(Student_Activity obj) {
        // TODO Auto-generated method stub
        boolean activity_name = this.Activity_Name.equals(obj.getActivity_Name());
        boolean student_id = this.Student_ID.equals(obj.getStudent_ID());
        boolean certification_time = this.Certification_Time.equals(obj.getCertification_Time());
        boolean credit = (this.Credit == obj.getCredit());
        boolean prize = this.Prize.equals(obj.getPrize());
        boolean flag = activity_name && student_id && certification_time && credit && prize;
        return flag;
    }
}

功能描述

1) Excel文件导入:可以将学生信息,活动信息,活动信息的Excel文件的数据导入到数据库中,但是一定要注意必须把Excel文件的格式转化为xls文件即2003版的Excel文件格式。因为所用到用来解析Excel文件的jar包即jxl现在不支持2010版本以上的Excel文件。对于学生信息数据需要按照姓名,学号,学院,班级格式进行填写。对于活动信息数据文件需要按照活动名称,主办方,学年学期的格式进行填写。对于学生活动信息数据文件需要按照学号,活动名称,认证日期,奖项,学分的格式进行填写。下面是该功能的截图。
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
2) 按照起始认证时间查询学生活动信息:此功能是可以查询认证时间在起始认证时间之后(包含起始认证时间)的所有学生活动数据信息。下面是该功能的截图。
这里写图片描述
3) 按照终止认证时间查询学生活动信息:此功能是可以查询认证时间在终止认证时间之前(包含终止认证时间)的所有学生活动数据信息。下面是该功能的截图。
这里写图片描述
4) 按照起始认证时间与终止认证时间查询学生活动信息:此功能是可以查询在认证时间在起始认证时间与终止认证时间之间(包含起始认证时间与终止认证时间)的所有学生活动数据信息。下面是该功能的截图。
这里写图片描述
5) 按照活动主办方查询学生活动信息:可以查询活动由已选的活动主办方的主办的所有学生活动数据。下面是该功能的截图。
这里写图片描述
6) 按照姓名查询学生活动信息:可以查询活动学生名为XXX的所有学生活动信息数据(不推荐这么查询,最好用学号来查询,毕竟可能出现重名情况)。下面是该功能的截图。
这里写图片描述
7) 按照学号查询学生活动信息:可以查询活动学生学号为XXXXXXXX的所有学生活动信息数据。下面是该功能的截图。
这里写图片描述
8) 按照学分范围进行查询学生活动信息:可以查询活动学分大于等于x,或者小于等于y,或者大于等于x且小于等于y的说有学生活动信息数据。下面是该功能的截图。
这里写图片描述
9) 总分查询:可以以学生为类别,查询该学生的说有活动信息以及计算总社团活动学分。下面是该功能的截图。
这里写图片描述
10) 记录删除:可以把已经查询并在界面中显示的所有学生活动信息数据进行删除。下面是该功能的截图。
这里写图片描述
11) 获奖查询:可以查询某学会已经获奖活动的详细信息
这里写图片描述
12) Excel文件输出:可以把已经查询显示的学生活动记录以Excel文件形式进行输出到电脑桌面。下面是该功能的截图。
这里写图片描述

版权声明:本文为博主原创文章,未经博主允许不得转载。若需转载,请注明http://blog.csdn.net/qq_30091945 举报

相关文章推荐

社团活动学分管理系统

摘要之前忙于期末考试,所以没有时间把期末之前的课设写成博客。这次的课设虽然给定了可选题目,但是老师说做什么都可以。看见可选题目里有关于学分管理系统,考虑到时间紧迫,同时兼顾期末考试,故选择了这个社团学...

旅行社管理系统

指导老师:倪静 旅行社管理信息系统课程设计报告     课    题:      旅行社管理信息系统 姓    名:  &#...

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

社区网格化GIS管理系统

基础数据平台 主要是通过网格员对辖区范围内的人、地、事、物、组织五大要素进行全面的信息采集管理,收集地理位置、小区楼栋、房屋、单位门店、人口信息、民政救济、党建纪检、工会工作、计划生育、劳动保障...

文章标题

大学生为什么需要参加社团学号16340034 【数据科学与计算机学院】(http://sdcs.sysu.edu.cn/)内容目录大学生为什么需要参加社团 内容目录 社团的种类 社团的作用 发展兴趣...

08月05日 星期三

学生管理系统 08月05日 星期三定义方法的作用:1、分而治之 2、实现代码的重用形参:形参的本质是变量,目的是为了接受实参的值。 - 实参的作用是给形参变量赋什么样的值。实参可以是变量或常量,...

学生成绩管理分析系统

自己写的  不算太好 慢慢改进吧。。。。。。 #include #include #include #include #include #define HEADER1 "------------...

学生成绩分析管理系统

/*学生成绩分析管理系统 进入密码为:1234 学生成绩保存在E盘文件名为a.txt 以下有截图说明*/ #include #include #include #include #define LEN...

包管理系统分析

包管理脚本 /system/bin/pm 解析: pm的使用方法可以参考  Pm.java (frameworks\base\cmds\pm\src\com\android\commands\pm...

给文件夹添加用户权限后,用户还是不能打开或修改子文件夹?

服务器环境:Windows Server 20003 R2 文件夹:a/b/c/d.txt ;a/b/e;a/b/f; 问题描述:公司新员工需要查看服务器上的文件d.txt,并需要修改上面的文...

全球分布式团队工作管理系统软件

一 分布式软件开发环境 对于很多跨国的软件公司,经常会出现同一软件的开发设计或者测试团队分布在世界各地,我们称这种环境为分布式的软件开发环境。如下图 实施异地开发的最初目的是为了降...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)