examhighselectpanelaction.java

来自「培训时做的学生管理系统.基于J2SE平台开发」· Java 代码 · 共 892 行 · 第 1/3 页

JAVA
892
字号
package cn.com.action.chivementaction;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.table.DefaultTableModel;

import cn.com.dao.chivementdao.ExamDao;
import cn.com.dao.chivementdao.ExamHighSelectDao;
import cn.com.dialog.chivementdialog.ExamHighSelectDialog;
import cn.com.panel.chivementpanel.ExamPanel;
import cn.com.vo.chivementvo.ChivementVo;

public class ExamHighSelectPanelAction implements ActionListener {
	private String[] column = { "学号", "组号", "学生姓名", "课程编号", "课程名称", "课程成绩" };

	ExamHighSelectDialog highSelectDialog;

	private ExamPanel chivementPanel;

	public ExamHighSelectPanelAction(ExamHighSelectDialog highSelectDialog,
			ExamPanel chivementPanel) {
		super();
		this.highSelectDialog = highSelectDialog;
		this.chivementPanel = chivementPanel;
	}

	public void actionPerformed(ActionEvent e) {
		String str = e.getActionCommand();
		if (str.equals("提交")) {
			ChivementVo examVo = null;
			ExamDao examdao = null;
			ExamHighSelectDao examhighdao = null;

			boolean selectClass5 = highSelectDialog.getSelectClassBox()
					.isSelected();
			boolean selectStuId4 = highSelectDialog.getSelectStuIdBox()
					.isSelected();
			boolean selectGroupId3 = highSelectDialog.getSelectGroupIdBox()
					.isSelected();
			boolean selectStuName2 = highSelectDialog.getSelectStuNameBox()
					.isSelected();
			boolean selectClassName1 = highSelectDialog.getSelectClassNameBox()
					.isSelected();

			if (selectClass5&&!selectClassName1 && !selectStuName2 && !selectGroupId3
					&& !selectStuId4) {
//				00001
				int classNo = 0;
				try {
					classNo = Integer.parseInt(highSelectDialog
							.getSelectClassText().getText());
					examVo = new ChivementVo();
					examVo.setC_id(classNo);
					examdao = new ExamDao(examVo);
					Object[][] s2 = examdao.selectByCid();
					chivementPanel.creatJTable().setModel(
							new DefaultTableModel(s2, column));
					highSelectDialog.getDialog().dispose();
					if(s2.length==0){
						javax.swing.JOptionPane
						.showMessageDialog(null, "没有搜索到结果!");
					}
				} catch (NumberFormatException ex) {
					javax.swing.JOptionPane.showMessageDialog(null,
							"请输入正确的字符格式!");
				}
			} else if (selectStuId4&&!selectClassName1 && !selectStuName2 && !selectGroupId3
					&& !selectClass5) {
//				00010
				int stuId = 0;
				try {
					stuId = Integer.parseInt(highSelectDialog
							.getSelectStuIdText().getText());
					examVo = new ChivementVo();
					examVo.setS_id(stuId);
					examdao = new ExamDao(examVo);
					Object[][] s2 = examdao.selectBySid();
					chivementPanel.creatJTable().setModel(
							new DefaultTableModel(s2, column));
					highSelectDialog.getDialog().dispose();
					if(s2.length==0){
						javax.swing.JOptionPane
						.showMessageDialog(null, "没有搜索到结果!");
					}
				} catch (NumberFormatException ex) {
					javax.swing.JOptionPane.showMessageDialog(null,
							"请输入正确的字符格式!");
				}
			} else if (selectClass5 && selectStuId4&&!selectClassName1 && !selectStuName2 && !selectGroupId3
					 ) {
//				00011
				int classNo = 0;
				int stuId = 0;
				try {
					classNo = Integer.parseInt(highSelectDialog
							.getSelectClassText().getText());
					stuId = Integer.parseInt(highSelectDialog
							.getSelectStuIdText().getText());
					examVo = new ChivementVo();
					examVo.setC_id(classNo);
					examVo.setS_id(stuId);
					examhighdao = new ExamHighSelectDao(examVo);
					Object[][] s2 = examhighdao.select00011();
					chivementPanel.creatJTable().setModel(
							new DefaultTableModel(s2, column));
					highSelectDialog.getDialog().dispose();
					if(s2==null){
						javax.swing.JOptionPane
						.showMessageDialog(null, "没有搜索到结果!");
					}
				} catch (NumberFormatException ex) {
					javax.swing.JOptionPane.showMessageDialog(null,
							"请输入正确的字符格式!");
				}
			} else if (selectGroupId3&&!selectClassName1 && !selectStuName2 
					&& !selectStuId4 && !selectClass5) {
//				00100
				int groupId = 0;
				try {
					groupId = Integer.parseInt(highSelectDialog
							.getSelectGroupIdText().getText());
					examVo = new ChivementVo();
					examVo.setG_id(groupId);
					examdao = new ExamDao(examVo);
					Object[][] s2 = examdao.selectByGid();
					chivementPanel.creatJTable().setModel(
							new DefaultTableModel(s2, column));
					highSelectDialog.getDialog().dispose();
					if(s2.length==0){
						javax.swing.JOptionPane
						.showMessageDialog(null, "没有搜索到结果!");
					}
				} catch (NumberFormatException ex) {
					javax.swing.JOptionPane.showMessageDialog(null,
							"请输入正确的字符格式!");
				}
			} else if (selectGroupId3 && selectClass5&&!selectClassName1 && !selectStuName2
					&& !selectStuId4) {
//				00101
				int classNo = 0;
				int groupId = 0;
				try {
					classNo = Integer.parseInt(highSelectDialog
							.getSelectClassText().getText());
					groupId = Integer.parseInt(highSelectDialog
							.getSelectGroupIdText().getText());
					examVo = new ChivementVo();
					examVo.setC_id(classNo);
					examVo.setG_id(groupId);
					examhighdao = new ExamHighSelectDao(examVo);
					Object[][] s2 = examhighdao.select00101();
					chivementPanel.creatJTable().setModel(
							new DefaultTableModel(s2, column));
					highSelectDialog.getDialog().dispose();
					if(s2==null){
						javax.swing.JOptionPane
						.showMessageDialog(null, "没有搜索到结果!");
					}
				} catch (NumberFormatException ex) {
					javax.swing.JOptionPane.showMessageDialog(null,
							"请输入正确的字符格式!");
				}
			} else if (selectGroupId3 && selectStuId4&&!selectClassName1 && !selectStuName2
					&& !selectClass5) {
//				00110
				int stuId = 0;
				int groupId = 0;
				try {
					stuId = Integer.parseInt(highSelectDialog
							.getSelectStuIdText().getText());
					groupId = Integer.parseInt(highSelectDialog
							.getSelectGroupIdText().getText());
					examVo = new ChivementVo();
					examVo.setS_id(stuId);
					examVo.setG_id(groupId);
					examhighdao = new ExamHighSelectDao(examVo);
					Object[][] s2 = examhighdao.select00110();
					chivementPanel.creatJTable().setModel(
							new DefaultTableModel(s2, column));
					highSelectDialog.getDialog().dispose();
					if(s2==null){
						javax.swing.JOptionPane
						.showMessageDialog(null, "没有搜索到结果!");
					}
				} catch (NumberFormatException ex) {
					javax.swing.JOptionPane.showMessageDialog(null,
							"请输入正确的字符格式!");
				}
			} else if (selectGroupId3 && selectStuId4 && selectClass5&&!selectClassName1 && !selectStuName2) {
//				00111
				int classNo = 0;
				int stuId = 0;
				int groupId = 0;
				try {
					classNo = Integer.parseInt(highSelectDialog
							.getSelectClassText().getText());
					stuId = Integer.parseInt(highSelectDialog
							.getSelectStuIdText().getText());
					groupId = Integer.parseInt(highSelectDialog
							.getSelectGroupIdText().getText());
					examVo = new ChivementVo();
					examVo.setC_id(classNo);
					examVo.setS_id(stuId);
					examVo.setG_id(groupId);
					examhighdao = new ExamHighSelectDao(examVo);
					Object[][] s2 = examhighdao.select00111();
					chivementPanel.creatJTable().setModel(
							new DefaultTableModel(s2, column));
					highSelectDialog.getDialog().dispose();
					if(s2==null){
						javax.swing.JOptionPane
						.showMessageDialog(null, "没有搜索到结果!");
					}
				} catch (NumberFormatException ex) {
					javax.swing.JOptionPane.showMessageDialog(null,
							"请输入正确的字符格式!");
				}
			} else if (selectStuName2&&!selectClassName1 && !selectGroupId3
					&& !selectStuId4 && !selectClass5) {
//				01000
				String stuName = highSelectDialog.getSelectStuNameText()
						.getText();
				examVo = new ChivementVo();
				examVo.setS_name(stuName);
				examdao = new ExamDao(examVo);
				Object[][] s2 = examdao.selectByName();
				chivementPanel.creatJTable().setModel(
						new DefaultTableModel(s2, column));
				highSelectDialog.getDialog().dispose();
				if(s2.length==0){
					javax.swing.JOptionPane
					.showMessageDialog(null, "没有搜索到结果!");
				}
			} else if (selectStuName2 && selectClass5&&!selectClassName1 && !selectGroupId3
					&& !selectStuId4) {
//				01001
				int classNo = 0;
				try {
					classNo = Integer.parseInt(highSelectDialog
							.getSelectClassText().getText());
					String stuName = highSelectDialog.getSelectStuNameText()
					.getText();
					examVo = new ChivementVo();
					examVo.setC_id(classNo);
					examVo.setS_name(stuName);
					examhighdao = new ExamHighSelectDao(examVo);
					Object[][] s2 = examhighdao.select01001();
					chivementPanel.creatJTable().setModel(
							new DefaultTableModel(s2, column));
					highSelectDialog.getDialog().dispose();
					if(s2==null){
						javax.swing.JOptionPane
						.showMessageDialog(null, "没有搜索到结果!");
					}
				} catch (NumberFormatException ex) {
					javax.swing.JOptionPane.showMessageDialog(null,
							"请输入正确的字符格式!");
				}
			} else if (selectStuName2 && selectStuId4&&!selectClassName1  && !selectGroupId3
					&& !selectClass5) {
//				01010
				int stuId = 0;
				try {
					stuId = Integer.parseInt(highSelectDialog
							.getSelectStuIdText().getText());
					String stuName = highSelectDialog.getSelectStuNameText()
					.getText();
					examVo = new ChivementVo();
					examVo.setS_id(stuId);
					examVo.setS_name(stuName);
					examhighdao = new ExamHighSelectDao(examVo);
					Object[][] s2 = examhighdao.select01010();
					chivementPanel.creatJTable().setModel(
							new DefaultTableModel(s2, column));
					highSelectDialog.getDialog().dispose();
					if(s2==null){
						javax.swing.JOptionPane
						.showMessageDialog(null, "没有搜索到结果!");
					}
				} catch (NumberFormatException ex) {
					javax.swing.JOptionPane.showMessageDialog(null,
							"请输入正确的字符格式!");
				}
			} else if (selectStuName2 && selectStuId4 && selectClass5&&!selectClassName1  && !selectGroupId3
					) {
//				01011
				int classNo = 0;
				int stuId = 0;
				try {
					classNo = Integer.parseInt(highSelectDialog
							.getSelectClassText().getText());
					stuId = Integer.parseInt(highSelectDialog
							.getSelectStuIdText().getText());
					String stuName = highSelectDialog.getSelectStuNameText()
					.getText();
					examVo = new ChivementVo();
					examVo.setC_id(classNo);

⌨️ 快捷键说明

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