多源数据教学管理系统之个人课设博客

1.团队课程设计博客链接

https://www.cnblogs.com/hq9-/p/10278470.html

2.个人任务

1)权重功能实现

public static void accuAccordPercent(String tablename, String cname, Map<String, Double> per) {
        Connection conn = null;
        PreparedStatement ps = null;
        PreparedStatement ps2 = null;
        PreparedStatement ps3 = null;
        ResultSet rs = null;
        StringBuilder sb = new StringBuilder();
        String altersql = "alter table " + tablename + " add " + cname + " varchar(20)";
        sb.append("update " + tablename + " set " + cname + "=");

        try {

            conn = JDBCUtil.getConnection();
            ps = conn.prepareStatement(altersql);
            ps.executeUpdate();

            for (Map.Entry<String, Double> entry : per.entrySet()) {
                String clearsql = " UPDATE " + tablename + " set  " + entry.getKey() + " =0 where " + entry.getKey()
                        + "='缺考'or " + entry.getKey() + " is NULL; ";
                ps3 = conn.prepareStatement(clearsql);
                ps3.executeUpdate();
            }
            int flag = 0;
            for (Map.Entry<String, Double> entry : per.entrySet()) {
                if (flag == 0) {
                    sb.append(entry.getKey() + "*" + entry.getValue() + " ");
                    flag = 1;
                } else {
                    sb.append("+ " + entry.getKey() + "*" + entry.getValue() + " ");
                }

            }
            String updatesql = sb + " ;";
            System.out.println(updatesql);
            ps2 = conn.prepareStatement(updatesql);
            ps2.executeUpdate();
            System.out.println("成功设置权重写入总分");

        } catch (SQLException e) {
            System.out.println("SQLException!");
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            JDBCUtil.realeaseAll(rs, ps, conn);
        }

    }

2)系统初始界面

package gui;

public class StartFrame extends javax.swing.JFrame {

    /**
     * Creates new form Login
     */
    public StartFrame() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jCheckBox1 = new javax.swing.JCheckBox();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        jCheckBox1.setText("jCheckBox1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new javax.swing.OverlayLayout(getContentPane()));

        jLabel1.setFont(new java.awt.Font("宋体", 0, 36)); // NOI18N
        jLabel1.setText("欢迎使用多源教学数据管理系统");

        jButton1.setText("进入系统");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(360, Short.MAX_VALUE)
                        .addComponent(jLabel1).addContainerGap(361, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jButton1)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(146, Short.MAX_VALUE)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 176,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                        .addComponent(jButton1).addContainerGap(236, Short.MAX_VALUE)));

        getContentPane().add(jPanel1);

        pack();

        setLocationRelativeTo(null);
    }// </editor-fold>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        new Login().frame.setVisible(true);
        this.setVisible(false);

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(StartFrame.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(StartFrame.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(StartFrame.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(StartFrame.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        }
        // </editor-fold>
        // </editor-fold>
        // </editor-fold>
        // </editor-fold>
        // </editor-fold>
        // </editor-fold>
        // </editor-fold>
        // </editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new StartFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration
}

3)登录界面(非最终版本)

package gui;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class Login {
    public Login() {
        init();
    }

    JFrame frame;// 创建容器

    public void init() {
        // 各个组件
        frame = new JFrame("登录窗口");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new BorderLayout());
        JButton b1 = new JButton("登录");
        JLabel l1 = new JLabel("账号:");
        JLabel l2 = new JLabel("密码:");
        JTextField t1 = new JTextField(12);
        JPasswordField t2 = new JPasswordField(12);
        t2.setEchoChar('*');
        // p1采用FlowLayout布局
        JPanel p1 = new JPanel(new GridLayout(2, 2));
        // 组件添加进p1
        p1.add(l1);
        p1.add(t1);
        p1.add(l2);
        p1.add(t2);
        frame.add(p1, BorderLayout.CENTER);
        frame.add(b1, BorderLayout.SOUTH);
        // b1注册事件监听器
        b1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                String name = t1.getText();
                String password = t2.getText();
                if (!(name.equals("123") && password.equals("456"))) {
                    JOptionPane.showMessageDialog(null, "用户名密码错误!", "【出错啦】", JOptionPane.ERROR_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(null, "用户名密码正确!", "【登录成功】", JOptionPane.PLAIN_MESSAGE);
                    new Menu().setVisible(true);
                    frame.setVisible(false);
                }
            }

        });
        frame.pack();
        frame.setVisible(true);
        double lx = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
        double ly = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
        frame.setLocation(new Point((int) (lx / 2) - 150, (int) (ly / 2) - 150));// 设定窗口出现位置

    }

}

4)界面上的OK按钮

5)参与其他界面的初始代码编写

6)团队博客的编写

3.git提交记录

 

4.课设感想

经过这次课设,发现自己的学习能力太弱,还有待提高。在这次课设中,幸运的和大佬一起做,才能完成此次课设。在今后的学习中,不能仅局限于课本知识,还要多看看外面的世界,学学课本以外的知识,正可谓书到用时方恨少。

posted @ 2019-01-18 13:15  咿呀!  阅读(183)  评论(0编辑  收藏  举报