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

📄 gdzcaction.java

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

import java.text.SimpleDateFormat;
import java.util.Date;
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.qtyy.condition.GdzcCondition;
import com.wygl.qtyy.domain.Gdzc;
import com.wygl.qtyy.service.GdzcService;
/*固定资产管理*/
public class GdzcAction extends AbstractAction implements ModelDriven {
	
	private GdzcService      gdzcService;                            //固定资产服务
	private DmListService    dmListService;                          //代码表查询服务
	private GdzcCondition    condition;                              //固定资产查询条件
	private Gdzc             gdzc;                                   //固定资产对象
	private String           gdzcId;                                 //固定资产主键
	private List             gdzcList;                               //固定资产列表
	private List             gdzcIds = new XWorkList(String.class);  //固定资产对象主键列表
	private List             gzdzlbList;                             //固定资产类别下拉列表

	protected void initModel() throws Exception {
		String lb = condition.getLb();
		String zcName = condition.getZcName();
		if(zcName==null||zcName.equals("")){
			zcName = "%";
		}
		condition = new GdzcCondition();
		condition.setLb(lb);
		condition.setZcName(zcName);
	}
	public Object getModel(){
		try{
		    condition = (GdzcCondition) get("condition");
		}catch (Exception e){
		    condition = new GdzcCondition();
		}
		if(condition == null){
			condition = new GdzcCondition();
		}
		return condition;
	}
	/**初始化服务*/
	public void initService() {
		if(gdzcService == null){
			gdzcService = (GdzcService) this.getServiceBean("gdzcService");	
		}
		if(dmListService == null){
			dmListService = (DmListService) this.getServiceBean("dmListService");	
		}
	}
	/**查询列表信息*/
	/**
	 * @return
	 * @throws Exception
	 */
	public String query() throws Exception {
		try{
			initService();
			setCopy();//条件复制
			String deptId = this.getSessionInfo().getDeptId();
			condition.setDeptId(deptId);
			gdzcService.setCondition(condition);//传入condition条件
			gdzcService.creatHquery();//构建hql
			condition = (GdzcCondition) gdzcService.getCondition();//获得设置完的condition
			gdzcList  = gdzcService.queryList();//查询结果集
			set("condition",condition);
			return "query";
		}catch (HibernateException e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	/**查询列表信息*/
	/**
	 * @return
	 * @throws Exception
	 */
	public String view() throws Exception {
		try{
			initService();
			setCopy();//条件复制
			String deptId = this.getSessionInfo().getDeptId();
			condition.setDeptId(deptId);
			gdzcService.setCondition(condition);//传入condition条件
			gdzcService.creatHquery();//构建hql
			condition = (GdzcCondition) gdzcService.getCondition();//获得设置完的condition
			gdzcList  = gdzcService.queryList();//查询结果集
			set("condition",condition);
			return "view";
		}catch (HibernateException e) {
			e.printStackTrace();
			return ERROR;
		}
	}
		
	//条件复制
	public void setCopy()throws Exception{
		//进行条件复制,用来判断同一功能,不同菜单的切换/
		if (condition.getLbcopy().equals("%")){
			condition.setLbcopy(condition.getLb());
		}else if (!condition.getLb().equals(condition.getLbcopy())){
			initModel();			
			condition.setLbcopy(condition.getLb());
		}	
	}
	/**查询具体对象信息*/
	public String queryById() throws Exception{
		try{
			initService();
			String deptId   = this.getSessionInfo().getDeptId();

			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");	
			String djksrq= sdf.format(new Date());
			
			if (condition.getGdzcId()!= null && !condition.getGdzcId().equals("")){
				gdzc = (Gdzc)gdzcService.queryById(Gdzc.class,condition.getGdzcId());
			}else{
				gdzc = new Gdzc();
				gdzc.setDeptId(deptId);
				gdzc.setDeptName(this.getSessionInfo().getDeptName());
				gdzc.setCzsj(djksrq);
			}
			gzdzlbList = dmListService.getxllb("GdzcType");
			return "queryById";	
		}catch (HibernateException e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	/**保存对象*/
	public String save() throws Exception{
		try{
			initService();
			String rtn = gdzcService.save(gdzc);
			if (rtn.equals("false")){
				this.addActionError("输入的信息已存在,请重新输入!");
				return ERROR;
			}else if (rtn.equals("error")){
				this.addActionError("保存失败!");
				return ERROR;
			}	
			gzdzlbList = dmListService.getxllb("GdzcType");
			return "queryById";
		}catch (HibernateException e) {
			e.printStackTrace();
			return ERROR;
		}
	}
	/**删除对象*/
	public String delete() throws Exception {
		try{
			initService();
			String rtn =gdzcService.delete(gdzcIds);
			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 GdzcCondition getCondition() {
		return condition;
	}
	public void setCondition(GdzcCondition condition) {
		this.condition = condition;
	}
	public DmListService getDmListService() {
		return dmListService;
	}
	public void setDmListService(DmListService dmListService) {
		this.dmListService = dmListService;
	}
	public Gdzc getGdzc() {
		return gdzc;
	}
	public void setGdzc(Gdzc gdzc) {
		this.gdzc = gdzc;
	}
	public String getGdzcId() {
		return gdzcId;
	}
	public void setGdzcId(String gdzcId) {
		this.gdzcId = gdzcId;
	}
	public List getGdzcIds() {
		return gdzcIds;
	}
	public void setGdzcIds(List gdzcIds) {
		this.gdzcIds = gdzcIds;
	}
	public List getGdzcList() {
		return gdzcList;
	}
	public void setGdzcList(List gdzcList) {
		this.gdzcList = gdzcList;
	}
	public GdzcService getGdzcService() {
		return gdzcService;
	}
	public void setGdzcService(GdzcService gdzcService) {
		this.gdzcService = gdzcService;
	}
	public List getGzdzlbList() {
		return gzdzlbList;
	}
	public void setGzdzlbList(List gzdzlbList) {
		this.gzdzlbList = gzdzlbList;
	}
	
	
	

}

⌨️ 快捷键说明

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