📄 studentlogic.java
字号:
package com.student.logic;
import com.student.dao.HbmDAO;
import com.student.actionform.StudentActionForm;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import com.student.vo.BaseInfo;
import com.student.assistvo.AssistVo;
import com.student.vo.User;
import com.student.dao.DAOException;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class StudentLogic {
private HbmDAO dao;
private StudentActionForm form;
public StudentLogic(StudentActionForm form) {
dao = new HbmDAO();
dao.setAutoClose(false);
this.form = form;
}
public void getStudents()
{
String str = "from BaseInfo";
List students = dao.list(str);
form.setStudents(students);
}
public void addStudent()
{
BaseInfo student = new BaseInfo();
student.setStudentUID(null);
student.setStudentAge(new Integer(20));
student.setStudentClass("350761");
student.setStudentCode("35076108");
student.setStudentGender("male");
student.setStudentName("Mike");
form.getStudents().add(student);
}
public void saveStudent()
{
List students = form.getStudents();
for (Iterator iter = students.iterator(); iter.hasNext(); ) {
BaseInfo item = (BaseInfo)iter.next();
if(item.getStudentUID().equals(new Long(0)))
{
item.setStudentUID(null);
}
try {
dao.store(item);
}
catch (DAOException ex) {
ex.printStackTrace();
}
}
}
public void deleteStudent()
{
Long uid = form.getDeleteUID();
String str = "select user from User user where studentUID=" + uid.toString();
try {
List users = dao.list(str);
for(int i=0;i< users.size();i++)
{
if(!((User)users.get(i)).getUserName().equals("admin"))
{
dao.remove( (User) users.get(i));
}
else
{
User user = ((User)users.get(i));
user.setStudentUID(null);
dao.store(user);
}
}
dao.remove(BaseInfo.class, uid);
}
catch (DAOException ex) {
ex.printStackTrace();
}
}
public void closeDAO()
{
dao.closeSession();
dao = null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -