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

📄 coursereporttablemodel.java

📁 一个可以存储和打印成绩单的系统
💻 JAVA
字号:
package org.minjey.cjsjk.report;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.Date;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Properties;import java.util.Vector;import javax.swing.table.AbstractTableModel;import org.minjey.cjsjk.model.Course;import org.minjey.cjsjk.model.Major;import org.minjey.cjsjk.model.Student;import org.minjey.cjsjk.model.StudentCourse;import org.minjey.cjsjk.util.PropertyDict;import org.minjey.cjsjk.util.PropertyLoader;public class CourseReportTableModel extends AbstractTableModel {		private Major major;	private Vector<CourseUlities> courses;	//private List students;	private Properties properties;		private static final Class[] COLUMN_TYPES = {		Course.class	};		private static final String[] COLUMN_NAMES ={		"course", "title", 		"text.station", "station", "text.majortype", "major.majortype", "text.majorrecord", "major.majorrecord", "course.session",		"text.course", "course", "text.major", "major", "text.point", "course.point", "text.teacher", "course.teacher",		"text.stuno", "text.stuname", "text.stuscore", "text.stupoint", "text.stuno", "text.stuname", "text.stuscore", "text.stupoint",		"text.cheng", "text.ji", "text.zong", "text.jie", "text.ycjrs", "text.sjcjrs", "text.hgrs", "text.bhgrs", 		"course.ycjrs", "course.sjcjrs", "course.hgrs", "course.bhgrs", "text.bkmd", "course.bkmd", "text.pjf", "course.pjf", 		"text.bei", "text.zhu", "course.bz", "text.dysj", "course.dysj"	};	public CourseReportTableModel(Major major, Vector<Course> courses) {		this.major = major;		this.courses = initCourseUlities(courses);		//students = initOrder(major);		properties = PropertyLoader.loadSystemProperty();	}		public Object getValueAt(int rowIndex, int columnIndex) {		CourseUlities cu = courses.get(rowIndex);		Course course = cu.getCourse();		HashMap<Integer, Object> grades =course.getStudentcourses();		if(columnIndex < COLUMN_NAMES.length) {			switch(columnIndex) {			case 0:	return course;			case 1: 				if(course.getExamtype().getId() == 1) {					return properties.getProperty(PropertyDict.REPORT.COURSE.TTITLE1);				} else {					return properties.getProperty(PropertyDict.REPORT.COURSE.TTITLE2);				}			case 2: return properties.getProperty(PropertyDict.REPORT.COURSE.TSTATION);			case 3: return major.getStation().getName();			case 4: return properties.getProperty(PropertyDict.REPORT.COURSE.TMAJORTYPE);			case 5: return major.getMajortype().getName();			case 6: return properties.getProperty(PropertyDict.REPORT.COURSE.TMAJORRECORD);			case 7: return major.getMajorrecord().getName();			case 8: return DateFactory.getDateSessionStr(course.getSemester(), major.getIntime());			case 9: return properties.getProperty(PropertyDict.REPORT.COURSE.TCOURSE);			case 10: return course.getName();			case 11: return properties.getProperty(PropertyDict.REPORT.COURSE.TMAJOR);			case 12: return major.getName();			case 13: return properties.getProperty(PropertyDict.REPORT.COURSE.TPOINT);			case 14: return course.getPoint()<=0?" ": course.getPoint();			case 15: return properties.getProperty(PropertyDict.REPORT.COURSE.TTEACHER);			case 16: return course.getTeacher();			case 17: case 21: return properties.getProperty(PropertyDict.REPORT.COURSE.TSTUNO);			case 18: case 22: return properties.getProperty(PropertyDict.REPORT.COURSE.TSTUNAME);			case 19: case 23: return properties.getProperty(PropertyDict.REPORT.COURSE.TSTUSCORE);			case 20: case 24: return properties.getProperty(PropertyDict.REPORT.COURSE.TSTUPOINT);			case 25: return properties.getProperty(PropertyDict.REPORT.COURSE.TCHENG);			case 26: return properties.getProperty(PropertyDict.REPORT.COURSE.TJI);			case 27: return properties.getProperty(PropertyDict.REPORT.COURSE.TZONG);			case 28: return properties.getProperty(PropertyDict.REPORT.COURSE.TJIE);			case 29: return properties.getProperty(PropertyDict.REPORT.COURSE.TYCJRS);			case 30: return properties.getProperty(PropertyDict.REPORT.COURSE.TSJCJRS);			case 31: return properties.getProperty(PropertyDict.REPORT.COURSE.THGRS);			case 32: return properties.getProperty(PropertyDict.REPORT.COURSE.TBHGRS);			case 33: return cu.getStulength();			case 34: return cu.getGradeLength();			case 35: return cu.getPathCount();			case 36: return cu.getUnpathCount();			case 37: return properties.getProperty(PropertyDict.REPORT.COURSE.TBKMD);			case 38: return cu.getBkmd();			case 39: return properties.getProperty(PropertyDict.REPORT.COURSE.TPJF);			case 40: return cu.getAverageScore();			case 41: return properties.getProperty(PropertyDict.REPORT.COURSE.TBEI);			case 42: return properties.getProperty(PropertyDict.REPORT.COURSE.TZHU);			case 43: return course.getBz();			case 44: return properties.getProperty(PropertyDict.REPORT.COURSE.TDYSJ);			case 45: 				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");				return sdf.format(new Date());			default: return " ";			}		} else {			columnIndex = columnIndex - COLUMN_NAMES.length;			int no = columnIndex % 4;			int te = (columnIndex - no) / 4;			if(te >= cu.getStulength()) {				return " ";			} else {				Student student = cu.getStudent(te);				//System.out.println(student);				if(student == null) {					return " ";				}				StudentCourse sc = (StudentCourse)grades.get(student.getId());				if(sc == null) {					return " ";				}				switch(no) {				case 0: return student.getStuno();				case 1: return student.getName();				case 2: return sc.getGrade();				case 3: return cu.getStudentPoint(student.getId());				default: return " ";				}			}		}	}		public String getColumnName(int columnIndex) {		if(columnIndex < COLUMN_NAMES.length) {			return COLUMN_NAMES[columnIndex];		} else {			columnIndex = columnIndex - COLUMN_NAMES.length;			int no = columnIndex % 4;			int te = (columnIndex - no) / 4;			String cname = "student" + String.valueOf(te+1);			switch(no) {			case 0:				cname = cname + ".no";				break;			case 1:				cname = cname + ".name";				break;			case 2:				cname = cname + ".score";				break;			case 3:				cname = cname + ".point";				break;			}			System.out.println(cname);			return cname;		}	}		public Class getColumnType(int columnIndex) {		if(columnIndex < COLUMN_NAMES.length) {			return COLUMN_TYPES[columnIndex];		} else {			return String.class;		}	}		public int getColumnCount() {		return COLUMN_NAMES.length + 8 * 20;	}	public int getRowCount() {		return courses.size();	}	private Vector<CourseUlities> initCourseUlities(Vector<Course> courses) {		Vector<CourseUlities> cus = new Vector<CourseUlities>();		Iterator it = courses.iterator();		while(it.hasNext()) {			cus.add(new CourseUlities(major, (Course)it.next()));		}		return cus;	}}

⌨️ 快捷键说明

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