package com.chenluozhi.frame;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import java.sql.ResultSet;
import java.util.List;
import com.chenluozhi.dao.CCourseDao;
import com.chenluozhi.dao.CourseDao;
import com.chenluozhi.dao.TeacherDao;
import com.chenluozhi.model.CCourseModel;
import com.chenluozhi.model.CourseModel;
import com.chenluozhi.model.TeacherModel;
import com.chenluozhi.util.DBConnection;
import javax.swing.JCheckBox;
public class CCourseManage extends JDialog {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JScrollPane jScrollPane = null;
private JTable jTable = null;
private JButton jButton_ccourse_open = null;
private JButton jButton_ccourse_print = null;
private JLabel jLabel_course_counts = null;
public int total;
private JLabel jLabel = null;
private JLabel jLabel3 = null;
private JComboBox jComboBox_query_condition = null;
private JTextField jTextField_query_word = null;
private JButton jButton_course_query = null;
private JLabel jLabel4 = null;
private JComboBox jComboBox_course_condition = null;
private JButton jButton_course_delete = null;
private JPanel jPanel = null;
private JLabel jLabel1 = null;
private JLabel jLabel5 = null;
private JComboBox jComboBox_course_name = null;
private JButton jButton_course_modify = null;
private JButton jButton_reflash = null;
private JLabel jLabel_student_name = null;
private JLabel jLabel6 = null;
private JComboBox jComboBox_course_counts = null;
private List<CourseModel> course_lists;
private List<TeacherModel> teach_lists;
private List<CCourseModel> ccourse_lists;
DefaultTableModel model = new DefaultTableModel();
private boolean isFirstModify = true;
// private int counts = 0;//记录数
private JCheckBox jCheckBox_teach_filter = null;
private JCheckBox jCheckBox_fuzzy_query = null;
/**
* This is the default constructor
*/
public CCourseManage() {
super();
initialize();
jComboBox_course_condition.addItemListener(new itemListener_course());
jComboBox_course_counts.addItemListener(new itemListener_course());
jButton_course_query.addActionListener(new btnListener());
jButton_ccourse_open.addActionListener(new btnListener());
//jButton_ccourse_print.addActionListener(new btnListener());
jButton_course_query.addActionListener(new btnListener());
jButton_course_delete.addActionListener(new btnListener());
jButton_course_modify.addActionListener(new btnListener());
jButton_reflash.addActionListener(new btnListener());
jCheckBox_teach_filter.addItemListener(new checkListener());
jCheckBox_fuzzy_query.addItemListener(new checkListener());
jTable.getSelectionModel()
.addListSelectionListener(new tableListener());// jTable选中监听!
}
private void initialize() {
this.setSize(655, 568);
this.setContentPane(getJContentPane());
this.setTitle("选课管理");
this.setLocationRelativeTo(null);
// this.setModal(true);
this.setLocationRelativeTo(null);
initTableDataByCombo();
}
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel6 = new JLabel();
jLabel6.setBounds(new Rectangle(306, 24, 95, 24));
jLabel6.setText("学生选课门数:");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(553, 22, 56, 26));
jLabel1.setText("记录数:");
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(19, 25, 105, 24));
jLabel4.setText("按课程名称列举:");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(19, 63, 65, 18));
jLabel3.setText("查询方式:");
jLabel = new JLabel();
jLabel.setText("学生姓名:");
jLabel.setBounds(new Rectangle(13, 21, 68, 25));
jComboBox_query_condition = new JComboBox();
jComboBox_query_condition.addItem("按ID");
jComboBox_query_condition.addItem("按名称");
jComboBox_query_condition.addItem("按成绩");
jComboBox_query_condition.setBounds(new Rectangle(105, 56, 159, 27));
jComboBox_course_name = new JComboBox();
jComboBox_course_name.setBounds(new Rectangle(299, 19, 167, 30));
jComboBox_course_name.setEnabled(false);
jButton_course_modify = new JButton();
jButton_course_modify.setBounds(new Rectangle(162, 58, 144, 27));
jButton_course_modify.setText("修改选课(慎用)");
jButton_reflash = new JButton();
jButton_reflash.setBounds(new Rectangle(509, 20, 99, 26));
jButton_reflash.setText("刷新数据");
jComboBox_course_counts = new JComboBox();
jComboBox_course_counts.setBounds(new Rectangle(413, 24, 122, 23));
jComboBox_course_counts.setEnabled(false);
jComboBox_course_counts.addItem("还没选课学生");
jComboBox_course_counts.addItem("选一门课程");
jComboBox_course_counts.addItem("选两门或以上");
jComboBox_course_condition = new JComboBox();
jComboBox_course_condition.setBounds(new Rectangle(130, 24, 134, 26));
//初始化下拉框数据
CourseDao cd = new CourseDao();
course_lists = cd.getLists(false, -1);
for(int i=0;i<course_lists.size();i++){
jComboBox_course_condition.addItem(course_lists.get(i).getCourse_name());
}
for(int i=0;i<course_lists.size();i++){
jComboBox_course_name.addItem(course_lists.get(i).getCourse_name());
}
// TeacherDao td = new TeacherDao();
// teach_lists = td.getTeacherModelList();
// for(int i =0;i<teach_lists.size();i++){
// jComboBox_course_counts.addItem(teach_lists.get(i).getTeach_name());
// }
jTextField_query_word = new JTextField();
jTextField_query_word.setBounds(new Rectangle(274, 56, 139, 28));
jButton_course_query = new JButton();
jButton_course_query.setBounds(new Rectangle(539, 56, 97, 28));
jButton_course_query.setText("查询(慎用)");
jButton_course_delete = new JButton();
jButton_course_delete.setText("删除选课");
jButton_course_delete.setBounds(new Rectangle(372, 58, 92, 27));
if(Login.login_user_type == 2){
}
jTable = new JTable();
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(jTable);
jScrollPane.setBounds(new Rectangle(20, 90, 620, 300));
String heads[] = {"课程ID","课程名称","学生ID","学生名称","教师ID","教师名称","课程成绩"};
model = new DefaultTableModel(null, heads);
jLabel_student_name = new JLabel();
jLabel_student_name.setBounds(new Rectangle(97, 19, 90, 25));
jLabel_student_name.setText("");
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(209, 20, 74, 26));
jLabel5.setText("所选课程:");
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(17, 403, 619, 105));
jPanel.setBorder(BorderFactory.createTitledBorder("操作面板"));
//jPanel.add(getjButton_ccourse_print(), null);
jPanel.add(jLabel, null);
jPanel.add(getJButton_ccourse_open(), null);
jPanel.add(jButton_course_delete, null);
jPanel.add(jLabel5, null);
jPanel.add(jComboBox_course_name, null);
jPanel.add(jButton_course_modify, null);
jPanel.add(jButton_reflash, null);
jPanel.add(jLabel_student_name, null);
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setBorder(BorderFactory.createTitledBorder("选课信息一览表"));
jCont