📄 classintercalateaddaction.java
字号:
package cn.com.action.classmanageraction.classaddaction;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import cn.com.dao.classmanagerdao.Impl;
import cn.com.dialog.classmanagerdialog.classintercalate.ClassIntercalate;
import cn.com.dialog.classmanagerdialog.classintercalate.ClassIntercalateAdd;
import cn.com.dialog.classmanagerdialog.classintercalate.ClassUpdate;
import cn.com.vo.classmanagervo.ClassVO;
public class ClassIntercalateAddAction implements ActionListener {
ClassIntercalateAdd add;
ClassIntercalate table;
public ClassIntercalateAddAction(ClassIntercalateAdd add) {
this.add = add;
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stu
String str = e.getActionCommand();
Impl impl = null;
if (str.equals("添加")) {
ClassVO vo, showvo;
if (!add.classID.getText().equals("")
&& !add.classname.getText().equals("")
&& !add.credithour.getText().equals("")
&& !add.totaltime.getText().equals("")) {
impl = new Impl();
if(!impl.checkClassEx(Integer.parseInt(add.classID.getText()))){
if (ClassIntercalateAdd.c4.getSelectedItem().toString().equals(
" ")) {
JOptionPane.showMessageDialog(null, "没有该老师,请另外选择!");
} else {
}
int a1 = Integer.parseInt(add.c1.getSelectedItem().toString());// 获得开课的周次
int a2 = Integer.parseInt(add.c2.getSelectedItem().toString());// 获得结束课程的周次
if (a1 <= a2) {
String s = ClassIntercalateAdd.classID.getText();
// System.out.println(s);
// if(s == ""){
// JOptionPane.showMessageDialog(null, "请输入课程编号",
// "课程添加",
// JOptionPane.YES_NO_OPTION);
// }
int a = Integer.parseInt(s);
DefaultTableModel model = (DefaultTableModel) ClassIntercalate
.buildJTable().getModel();
// 获得输入的课程编号
vo = add.getInputInfo();
System.out.println(vo);
if (impl.appendClass(vo)) {
JOptionPane.showMessageDialog(null, "课程添加成功!");
try {
showvo = ClassIntercalate.getInputInfo(impl
.classinfo(a));
Object[] data = { new Integer(showvo.getClassID()),
showvo.getClassname(),
showvo.getTotaltime(),
showvo.getClasstime(),
showvo.getCredithour(),
showvo.getClassestate(),
showvo.getTeacherID(),
showvo.getTeachername(),
showvo.getTeacherduty(),
showvo.getClassremark() };
model.addRow(data);
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
add.dialog.dispose();
}
} else {
JOptionPane.showMessageDialog(null, "开课时间不能比结束时间迟!");
}
}else{
JOptionPane.showMessageDialog(null, "该课程编号已经存在!");
}
} else {
JOptionPane.showMessageDialog(null, "课程编号、课程名、课时、学分、老师编号不能为空!");
}
} else if (str.equals("退出")) {
add.dialog.dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -