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

📄 showexam.java

📁 accp s1毕业项目 考试管理系统
💻 JAVA
字号:
package com.exam.ui.student;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import com.exam.db.bean.BanJi;
import com.exam.db.bean.Course;
import com.exam.db.bean.Student;
import com.exam.db.dao.BanJiDao;
import com.exam.db.dao.CourseDao;
import com.exam.db.dao.StudentDao;
import com.exam.ui.SuperFrame;

public class ShowExam extends SuperFrame {
	private static final long serialVersionUID = 1L;
	private String stuID;
	private int couID;
	private String couName="";

	public ShowExam(String stuID) {
		try {
			this.stuID = stuID;
			init();
			this.setVisible(true);
			this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
			this.setResizable(false);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void init() {
		this.setTitle("学生信息");
		this.setSize(400, 300);
		this.setCenter();

		JPanel pnlTotal = new JPanel();
		this.getContentPane().add(pnlTotal);
		pnlTotal.setLayout(null);

		JPanel pnlInfo = new JPanel();
		pnlInfo.setBounds(30, 40, 150, 180);
		pnlInfo.setBorder(BorderFactory.createTitledBorder("基本信息"));
		pnlTotal.add(pnlInfo);
		pnlInfo.setLayout(null);

		JButton btnStudent = new JButton("基本信息");
		btnStudent.setBounds(20, 60, 110, 25);
		pnlInfo.add(btnStudent);

		JButton btnScore = new JButton("成绩查询");
		btnScore.setBounds(20, 110, 110, 25);
		pnlInfo.add(btnScore);

		JPanel pnlExam = new JPanel();
		pnlExam.setBounds(200, 40, 150, 180);
		pnlExam.setBorder(BorderFactory.createTitledBorder("考试信息"));
		pnlTotal.add(pnlExam);
		pnlExam.setLayout(null);

		JLabel lblCourse = new JLabel("请选择科目");
		lblCourse.setForeground(Color.red);
		lblCourse.setBounds(20, 30, 110, 25);
		pnlExam.add(lblCourse);

		final JComboBox cboCourse = new JComboBox();
		cboCourse.addItem("");
		cboCourse.setBounds(20, 60, 110, 25);
		pnlExam.add(cboCourse);

		StudentDao studentDao = new StudentDao();
		Student student = new Student();
		student = studentDao.selectStudentByStuID(stuID);

		BanJiDao banJiDao = new BanJiDao();
		BanJi banJi = new BanJi();
		banJi = banJiDao.selectBanJiByID(student.getBanJiID());

		CourseDao courseDao = new CourseDao();
		List<Course> list = new ArrayList<Course>();
		list = courseDao.selectCourseNameByGrade(banJi.getGrade());
		for (int i = 0; i < list.size(); i++) {
			cboCourse.addItem(list.get(i).getGrade() + "-"
					+ list.get(i).getCouName());
		}

		JButton btnExam = new JButton("开始考试");
		btnExam.setBounds(20, 110, 110, 25);
		pnlExam.add(btnExam);

		cboCourse.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent arg0) {
				String str = cboCourse.getSelectedItem().toString();
				if (str=="") {
					couName = "";
				} else {
					couName = str.substring(3);
				}
				if(couName==""){
				}else{
					CourseDao courseDao = new CourseDao();
					Course course = courseDao.selectCourseByNameAndGrade(couName,str.substring(0,2).toString().trim());
					couID = course.getCouID();
				}
			}
		});
		
		btnScore.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				new ShowStudentScore(stuID);
			}			
		});
		btnStudent.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				new StudentInfo(stuID);
			}
		});
		btnExam.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if (couName.equals("")) {
					JOptionPane.showMessageDialog(null, "请选择考试科目!");
				} else {
					new Exam(stuID, couID, couName);
				}
			}
		});
	}
}

⌨️ 快捷键说明

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