public class btnListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jButton_Add) {
Course_Add sa = new Course_Add();
sa.setVisible(true);
}
if (e.getSource() == jButton_Delete) {
if (jTable.getSelectedRow() != -1) {
String str = jTable.getValueAt(jTable.getSelectedRow(), 0)
.toString();
String sql = "delete from Course where Cno=" + str
+ "";
DBOperation dbo = new DBOperation();
dbo.TheAll(sql);
LogRecord lo = new LogRecord();
lo.addLog(Login.storeUserName + " 执行了删除选课编号为"+str+"的操作");
try {
model = new DefaultTableModel();
int i = dbo.getTotalRow("select * from Course");// 获取要查询的记录集数目
model.setRowCount(i - 1);// 由于方法一不会自动刷新,删除后要比删除前设置为少一行,免得出现空白行。
model.addColumn("课程编号");
model.addColumn("选课名称");
model.addColumn("授课教师");