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

📄 scorepanel.java

📁 这是一个员工管理系统
💻 JAVA
字号:
package com.orilore.ssms.view;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.orilore.ssms.bo.*;
import java.util.List;
import com.orilore.ssms.entity.*;
import javax.swing.JOptionPane;

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

    private void jbInit() throws Exception {
        this.setLayout(null);
        jLabel1.setText("学号:");
        jLabel1.setBounds(new Rectangle(56, 45, 80, 23));
        jLabel2.setText("课程:");
        jLabel2.setBounds(new Rectangle(55, 90, 70, 26));
        jLabel3.setText("成绩:");
        jLabel3.setBounds(new Rectangle(55, 137, 52, 24));
        cmbSid.setBounds(new Rectangle(121, 44, 125, 25));
        cmbCource.setBounds(new Rectangle(121, 95, 124, 24));
        txtScore.setBounds(new Rectangle(120, 141, 125, 23));
        jButton1.setBounds(new Rectangle(108, 189, 107, 23));
        jButton1.setText("录入成绩");
        jButton1.addActionListener(new ScorePanel_jButton1_actionAdapter(this));
        this.add(jLabel1);
        this.add(jLabel2);
        this.add(jLabel3);
        this.add(cmbSid);
        this.add(cmbCource);
        this.add(txtScore);
        this.add(jButton1);
    }
    public void init(){
        StudentBo sb = new StudentBo();
        CourceBo cb  = new CourceBo();
        List<Student> list = sb.queryAllStudent();
        for(Student s:list){
            cmbSid.addItem(s.getId());
        }
        List<Cource> cList = cb.queryAllCource();
        for(Cource c:cList){
            cmbCource.addItem(c.getCname());
        }

    }
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JComboBox cmbSid = new JComboBox();
    JComboBox cmbCource = new JComboBox();
    JTextField txtScore = new JTextField();
    JButton jButton1 = new JButton();
    public void jButton1_actionPerformed(ActionEvent e) {
        ScoreBo scb = new ScoreBo();

        int sid = (Integer)cmbSid.getSelectedItem();
        String cname = (String)cmbCource.getSelectedItem();
        int score = Integer.parseInt(txtScore.getText());

        Student s = new Student();
        s.setId(sid);
        Cource c = new Cource();
        c.setCname(cname);

        Score sc = new Score();
        sc.setCource(c);
        sc.setStudent(s);
        sc.setScore(score);
        if(scb.addScore(sc)){
            JOptionPane.showMessageDialog(this,"录入成功");
        }

    }
}


class ScorePanel_jButton1_actionAdapter implements ActionListener {
    private ScorePanel adaptee;
    ScorePanel_jButton1_actionAdapter(ScorePanel adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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