⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 personaction.java

📁 本源码为教学管理信息系统
💻 JAVA
字号:
package com.wygl.xtgl.action;

import java.util.ArrayList;
import java.util.List;

import net.sf.hibernate.HibernateException;

import com.hibernate.action.AbstractAction;
import com.opensymphony.xwork.ModelDriven;
import com.opensymphony.xwork.util.XWorkList;
import com.wygl.dmwh.service.DmListService;
import com.wygl.taglib.SelectOptions;
import com.wygl.xtgl.condition.PersonCondition;
import com.wygl.xtgl.domain.Employee;
import com.wygl.xtgl.service.SysDao;

/**
 * @author Administrator
 *
 * 
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class PersonAction extends AbstractAction implements ModelDriven {
	private SysDao      sysDao;
	private DmListService dmListService;
	private PersonCondition condition;
	private List 		supdws;
	private List 		subdws;
	private List 		persons;
	private String	    employeeId;
	private String      xmlString="";
	private Employee    employee;
	private List    selectedRoles=new XWorkList(String.class);
	private String      backlb="";
	private List      xbList;//性别
	private List      zwList;//职位
	private List      jbList;//级别
	private List      zqList;//职权
	private List      ztList;//状态
	private List      xlList;//学历
	private List      mzList;//民族
	private List      sjList;//私教
	
	protected void initModel() throws Exception {
		String name = condition.getName();
		String dwdm = condition.getDwdm();
		condition = new PersonCondition();
		condition.setName(name);
		condition.setDwdm(dwdm);
	}
	public Object getModel(){
		try{
		    condition = (PersonCondition) get("condition");
		}catch (Exception e){
		    condition = new PersonCondition();
		}
		if(condition == null){
			condition = new PersonCondition();
		}
		return condition;
	}
	
	public String list() throws Exception {		
		sysDao=(SysDao)getServiceBean("sysDao");	
		subdws=sysDao.searchDw("1");
		sysDao.setCondition(condition);//传入condition条件
		sysDao.creatHquery();//构建hql
		condition = (PersonCondition) sysDao.getCondition();//获得设置完的condition
		persons = sysDao.queryList();//查询结果集
		set("condition",condition);
		return "list";
	}
	/**查询具体对象信息*/
	public String edit() throws Exception{
		try{			
			sysDao=(SysDao)getServiceBean("sysDao");
			employee=(Employee)sysDao.queryById(condition.getEmployeeId());	//从数据库中查出此修改对象
			getDmList();
			return "edit";	
		}catch (HibernateException e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	public String creat() throws Exception{
		try{			
			sysDao=(SysDao)getServiceBean("sysDao");
			employee=(Employee)sysDao.queryById(condition.getEmployeeId());	//从数据库中查出此修改对象
			getDmList();
			return "creat";	
		}catch (HibernateException e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	public String add() throws Exception {	
		try{			
			sysDao=(SysDao)getServiceBean("sysDao");
			String dwdm =this.getSessionInfo().getDeptId();
			if(dwdm==null || dwdm.equals("")){
				this.addActionError("登录人的单位代码不能为空!");
				return ERROR;
			}
			String rtn = sysDao.save(employee);
			if (rtn.equals("error")){
				this.addActionError("保存失败!");
				return ERROR;
			}	
			getDmList();
			return "edit";
		}catch (HibernateException e) {
			e.printStackTrace();
			return ERROR;
		}
	}	
	public void getDmList() throws Exception {		
		dmListService=(DmListService)getServiceBean("dmListService");		
		xbList = dmListService.getXbList();
		zwList = dmListService.getZwList();
		jbList = dmListService.getJbList();
		zqList = dmListService.getZqList();
		ztList = dmListService.getZtList();
		xlList = dmListService.getXlList();
		mzList = dmListService.getMzList();
		subdws=sysDao.searchDw("1");
	}
	/**保存对象*/
	public String save() throws Exception{
		try{		
			sysDao=(SysDao)getServiceBean("sysDao");	
			String dwdm =this.getSessionInfo().getDeptId();
			if(dwdm==null || dwdm.equals("")){
				this.addActionError("登录人的单位代码不能为空!");
				return ERROR;
			}
			String rtn = sysDao.save(employee);
			getDmList();
			if (rtn.equals("false")){
				this.addActionError("输入的人员已存在,请重新输入!");
				return ERROR;
			}else if (rtn.equals("error")){
				this.addActionError("保存失败!");
				return ERROR;
			}			
			return "save";
		}catch (HibernateException e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	public String delete() throws Exception {
		try{		
			sysDao=(SysDao)getServiceBean("sysDao");	
			String rtn =sysDao.delete(selectedRoles);
			if(rtn.equals("false")){
				this.addActionError("没有可以删除的信息!");
				return ERROR;
			}else if (rtn.equals("error")){
				this.addActionError("删除失败!");
				return ERROR;
			}
			return "delete";
		}catch (HibernateException e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	public String person2user() throws Exception {			
		sysDao=(SysDao)getServiceBean("sysDao");
		employee=(Employee)sysDao.queryById(condition.getEmployeeId());	//从数据库中查出此修改对象
		return "person2user";
	}
	
	public String uploadFile() throws Exception{//上传照片功能
		try {
			sysDao=(SysDao)getServiceBean("sysDao");
			if (sysDao.uploadFj(condition.getEmployeeId()).equals("false")){
				this.addActionError("上传照片名称重复,请重新输入!");
				return ERROR;
			}
			return "uploadFile";
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	public String Delzp() throws Exception{//删除照片功能
		try {
			sysDao=(SysDao)getServiceBean("sysDao");
			sysDao.delZp(condition.getEmployeeId());
			return "delzp";
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	public Employee getEmployee() {
		if(employee==null){
			employee=new Employee();
		}
		return employee;
	}
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public List getSelectedRoles() {
		return selectedRoles;
	}
	public void setSelectedRoles(List selectedRoles) {
		this.selectedRoles = selectedRoles;
	}
	public List getPersons() {
		return persons;
	}
	public void setPersons(List persons) {
		this.persons = persons;
	}	
	public String getEmployeeId() {
		return employeeId;
	}
	public void setEmployeeId(String employeeId) {
		this.employeeId = employeeId;
	}
	public List getSubdws() {		
		return subdws;
	}
	public void setSubdws(List subdws) {		
		this.subdws = subdws;
	}
	public List getSupdws() {
		
		return supdws;
	}
	public void setSupdws(List supdws) {
		this.supdws = supdws;
	}
	public SysDao getSysDao() {
		return sysDao;
	}
	public void setSysDao(SysDao sysDao) {
		this.sysDao = sysDao;
	}
	public String getXmlString() {
		return xmlString;
	}
	public void setXmlString(String xmlString) {
		this.xmlString = xmlString;
	}
	public String getBacklb() {
		return backlb;
	}
	public void setBacklb(String backlb) {
		this.backlb = backlb;
	}
	public DmListService getDmListService() {
		return dmListService;
	}
	public void setDmListService(DmListService dmListService) {
		this.dmListService = dmListService;
	}
	public List getJbList() {
		return jbList;
	}
	public void setJbList(List jbList) {
		this.jbList = jbList;
	}
	public List getMzList() {
		return mzList;
	}
	public void setMzList(List mzList) {
		this.mzList = mzList;
	}
	public List getXbList() {
		return xbList;
	}
	public void setXbList(List xbList) {
		this.xbList = xbList;
	}
	public List getXlList() {
		return xlList;
	}
	public void setXlList(List xlList) {
		this.xlList = xlList;
	}
	public List getZqList() {
		return zqList;
	}
	public void setZqList(List zqList) {
		this.zqList = zqList;
	}
	public List getZtList() {
		return ztList;
	}
	public void setZtList(List ztList) {
		this.ztList = ztList;
	}
	public List getZwList() {
		return zwList;
	}
	public void setZwList(List zwList) {
		this.zwList = zwList;
	}
	public List getSjList() {
		List list = new ArrayList();
		list.add(new SelectOptions("是","是"));
		list.add(new SelectOptions("否","否"));
		return list;
	}
	public void setSjList(List sjList) {
		this.sjList = sjList;
	}
	public PersonCondition getCondition() {
		return condition;
	}
	public void setCondition(PersonCondition condition) {
		this.condition = condition;
	}	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -