package appstu.view;
import java.awt.BorderLayout;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JSplitPane;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.Dimension;
import javax.swing.JInternalFrame;
import appstu.util.RetrieveObject;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.table.DefaultTableModel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JTextField;
import java.util.Locale;
import java.util.Calendar;
import javax.swing.JOptionPane;
import appstu.util.CommonaJdbc;
import javax.swing.DefaultDesktopManager;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import appstu.model.Obj_gradeinfo_sub ;
public class JF_view_gradesub extends JInternalFrame {
BorderLayout borderLayout1 = new BorderLayout();
JSplitPane jSplitPane1 = new JSplitPane();
JScrollPane jScrollPane2 = new JScrollPane();
JPanel jPanel2 = new JPanel();
FlowLayout flowLayout1 = new FlowLayout();
JTable jTable1 = new JTable();
JLabel jLabel1 = new JLabel();
JComboBox jComboBox1 = new JComboBox();
JLabel jLabel2 = new JLabel();
JComboBox jComboBox2 = new JComboBox();
JButton jBadd = new JButton();
JButton jBsave = new JButton();
JButton jBexit = new JButton();
JScrollPane jScrollPane1 = new JScrollPane();
JTable jTable2 = new JTable();
//////////////////
String classid[] = null;
String examkindid[] = null;
String examkindname[] = null;
String subjectcode[] = null;
String subjectname[] = null;
JLabel jLabel3 = new JLabel();
JTextField jTextField1 = new JTextField();
JButton jBdel = new JButton();
public JF_view_gradesub() {
try {
jbInit();
initialize();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(borderLayout1);
jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
jSplitPane1.setDividerSize(10);
jPanel2.setLayout(flowLayout1);
jLabel1.setText("选择班级:");
jLabel2.setText("考试种类:");
jBadd.setText("添加");
jBadd.addActionListener(new JF_view_gradesub_jBadd_actionAdapter(this));
jBsave.setText("存盘");
jBsave.addActionListener(new JF_view_gradesub_jBsave_actionAdapter(this));
jBexit.setText("退出");
jBexit.addActionListener(new JF_view_gradesub_jBexit_actionAdapter(this));
this.setClosable(true);
jComboBox2.addItemListener(new JF_view_gradesub_jComboBox2_itemAdapter(this));
jLabel3.setText("考试日期:");
jTextField1.setPreferredSize(new Dimension(96, 26));
jTextField1.setText("");
flowLayout1.setAlignment(FlowLayout.RIGHT);
jTable1.addMouseListener(new JF_view_gradesub_jTable1_mouseAdapter(this));
jBdel.setText("删除");
jBdel.addActionListener(new JF_view_gradesub_jBdel_actionAdapter(this));
jSplitPane1.add(jScrollPane2, JSplitPane.TOP);
jSplitPane1.add(jScrollPane1, JSplitPane.BOTTOM);
jScrollPane1.getViewport().add(jTable2);
jPanel2.add(jLabel3);
jPanel2.add(jTextField1);
jPanel2.add(jLabel2);
jPanel2.add(jComboBox1);
jPanel2.add(jLabel1);
jPanel2.add(jComboBox2);
jPanel2.add(jBadd);
jPanel2.add(jBdel);
jPanel2.add(jBsave);
jPanel2.add(jBexit);
jScrollPane2.getViewport().add(jTable1);
this.getContentPane().add(jPanel2, java.awt.BorderLayout.NORTH);
this.getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);
setSize(700,500);
setVisible(true);
jSplitPane1.setDividerLocation(159);
}
public void initialize(){
RetrieveObject retrieve = new RetrieveObject();
java.util.Vector vdata = new java.util.Vector();
String sqlStr = null;
java.util.Collection collection = null;
java.util.Iterator iterator = null;
sqlStr = "SELECT * FROM tb_examkinds";
collection = retrieve.getTableCollection(sqlStr);
iterator = collection.iterator();
examkindid = new String[collection.size()];
examkindname = new String[collection.size()];
int i = 0;
while(iterator.hasNext()){
vdata = (java.util.Vector)iterator.next();
examkindid[i] = String.valueOf(vdata.get(0));
examkindname[i] = String.valueOf(vdata.get(1));
jComboBox1.addItem(vdata.get(1));
i ++;
}
sqlStr = "select * from tb_classinfo";
collection = retrieve.getTableCollection(sqlStr);
iterator = collection.iterator();
classid = new String[collection.size()];
i = 0 ;
while(iterator.hasNext()){
vdata = (java.util.Vector)iterator.next();
classid[i] = String.valueOf(vdata.get(0));
jComboBox2.addItem(vdata.get(2));
i ++;
}
sqlStr = "select * from tb_subject";
collection = retrieve.getTableCollection(sqlStr);
iterator = collection.iterator();
subjectcode = new String[collection.size()];
subjectname = new String[collection.size()];
i = 0 ;
while(iterator.hasNext()){
vdata = (java.util.Vector)iterator.next();
subjectcode[i] = String.valueOf(vdata.get(0));
subjectname[i] = String.valueOf(vdata.get(1));
i ++;
}
long nCurrentTime = System.currentTimeMillis();
java.util.Calendar calendar = java.util.Calendar.getInstance(new
Locale("CN"));
calendar.setTimeInMillis(nCurrentTime);
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
String mm, dd;
if (month < 10) {
mm = "0" + String.valueOf(month);
} else {
mm = String.valueOf(month);
}
if (day < 10) {
dd = "0" + String.valueOf(day);
} else {
dd = String.valueOf(day);
}
java.sql.Date date = java.sql.Date.valueOf(year + "-" + mm + "-" + dd);
jTextField1.setText(String.valueOf(date));
}
public void jComboBox2_itemStateChanged(ItemEvent e) {
String cid = classid[jComboBox2.getSelectedIndex()];
DefaultTableModel tablemodel = null;
String[] name = {"学生编号", "班级编号", "学生姓名", "性别", "年龄", "家庭住址", "联系电话"};
String sqlStr = "select * from tb_studentinfo where classID = '" + cid + "'";
appstu.util.RetrieveObject bdt = new appstu.util.RetrieveObject();
tablemodel = bdt.getTableModel(name, sqlStr);
jTable1.setModel(tablemodel);
jTable1.setRowHeight(24);
}
public void jBadd_actionPerformed(ActionEvent e) {
int currow ;
currow = jTable1.getSelectedRow();
System.out.println("当前行:" + currow);
if (currow >= 0){
DefaultTableModel tablemodel = null;
String[] name = {"学生编号","学生姓名", "考试类别", "考试科目", "考试成绩", "考试时间"};
tablemodel = new DefaultTableModel(name,0);
String sqlStr = null;
java.util.Collection collection = null;
Object[] object = null;
java.util.Iterator iterator = null;
sqlStr = "SELECT subject FROM tb_subject";
评论0