vcaction.java

来自「一套自己原先在学校作的CRM,大家指点下」· Java 代码 · 共 136 行

JAVA
136
字号
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.crm.action.sale;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.crm.form.VenditionChangForm;
import com.crm.pojo.VenditionChance;
import com.crm.service.IEmployeeBiz;
import com.crm.service.IVenditionChangBiz;

/** 
 * MyEclipse Struts
 * Creation date: 01-16-2009
 * 
 * XDoclet definition:
 * @struts.action path="/vc" name="venditionChangForm" parameter="operate" scope="request"
 */
public class VcAction extends DispatchAction {
	private IVenditionChangBiz vcBiz;
	private IEmployeeBiz employeeBiz;
	public void setEmployeeBiz(IEmployeeBiz employeeBiz) {
		this.employeeBiz = employeeBiz;
	}
	public void setVcBiz(IVenditionChangBiz vcBiz) {
		this.vcBiz = vcBiz;
	}
	private VenditionChance vcQB=new VenditionChance();
	//查询所有的
	public ActionForward toList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		List empList=employeeBiz.findAll();
		request.getSession().setAttribute("empList", empList);
		vcQB=new VenditionChance();
		this.page(new VenditionChance(), request);
		return mapping.findForward("list");
	}
	//修改
	public ActionForward toEdit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		int id=Integer.parseInt(request.getParameter("id"));
		List list=vcBiz.findByProperty("chanceId", id);
		request.setAttribute("vcU", (VenditionChance)list.get(0));
		return mapping.findForward("edit");
	}
	public ActionForward doEdit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		VenditionChangForm vcForm = (VenditionChangForm) form;// TODO Auto-generated method stub
		VenditionChance vc=vcForm.getVc();
		vcBiz.update(vc);
		return this.toList(mapping, form, request, response);
	}
	//添加
	public ActionForward toAdd(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		return mapping.findForward("add");
	}
	public ActionForward doAdd(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		VenditionChangForm venditionChangForm = (VenditionChangForm) form;// TODO Auto-generated method stub
		VenditionChance vc=venditionChangForm.getVc();
		vcBiz.save(vc);
		return toList(mapping, form, request, response);
	}
	//删除
	public ActionForward doDel(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		int id=Integer.parseInt(request.getParameter("id"));
		List list=vcBiz.findByProperty("chanceId", id);
		vcBiz.del((VenditionChance)list.get(0));
		return toList(mapping, form, request, response);
	}
	//分配
	public ActionForward toDispatch(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		int id=Integer.parseInt(request.getParameter("id"));
		List list=vcBiz.findByProperty("chanceId", id);
		request.setAttribute("vcU", (VenditionChance)list.get(0));
		return mapping.findForward("dispatch");
	}
	public ActionForward doDispatch(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		VenditionChangForm vcForm = (VenditionChangForm) form;// TODO Auto-generated method stub
		VenditionChance vc=vcForm.getVc();
		VenditionChance v=(VenditionChance) vcBiz.findByProperty("chanceId", vc.getChanceId()).get(0);
		v.setChanceAssignTime(vc.getChanceAssignTime());
		v.setChanceEmployee(vc.getChanceEmployee());
		v.setChanceState("开发中");
		vcBiz.update(v);
		return this.toList(mapping, form, request, response);
	}
	//查询
	public ActionForward doFind(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		VenditionChangForm venditionChangForm = (VenditionChangForm) form;
		VenditionChance vc=venditionChangForm.getVc();
		vcQB=vc;
		this.page(vc, request);
		return mapping.findForward("list");	
	}
	//分页
	public ActionForward doPage(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		this.page(vcQB, request);
		return mapping.findForward("list");	
	}
	public void page(VenditionChance vc,HttpServletRequest request){
		int pageSize=10;//一页查几行
		int count=vcBiz.findAll(vc).size();//一共多少行	
		int page=count%pageSize==0?count/pageSize:count/pageSize+1;//一共多少页
		int pageNo=1;//第几页查
		//没有转到第几页
			if(request.getParameter("pageNo")==null || request.getParameter("pageNo").equals("")){
				pageNo=1;
			}else{
				pageNo=Integer.parseInt(request.getParameter("pageNo"));
			}	
		
		List dictList=vcBiz.find(vc,pageNo,pageSize);
		request.setAttribute("page", page);
		request.setAttribute("pageSize", pageSize);
		request.setAttribute("pageNo", pageNo);
		request.setAttribute("count", count);
		request.setAttribute("vcList",dictList);
	}
}

⌨️ 快捷键说明

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