clientaction.java

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

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

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.ClientForm;
import com.crm.pojo.Client;
import com.crm.pojo.ClientState;
import com.crm.service.IClientBiz;
import com.crm.service.IClientStateBiz;
import com.crm.service.IDictBiz;
import com.crm.service.IEmployeeBiz;

/** 
 * MyEclipse Struts
 * Creation date: 10-18-2008
 * 
 * XDoclet definition:
 * @struts.action path="/client" name="clientForm" parameter="operate" scope="request"
 * 薛霞
 * 客户信息的相关操作
 */
public class ClientAction extends DispatchAction {
	private IClientBiz clientBiz;
	private IDictBiz dictBiz;
	private IClientStateBiz csBiz;
	private Client clientQB=new Client();
	private IEmployeeBiz employeeBiz;
	public void setEmployeeBiz(IEmployeeBiz employeeBiz) {
		this.employeeBiz = employeeBiz;
	}
	public void setClientBiz(IClientBiz clientBiz) {
		this.clientBiz = clientBiz;
	}
	public void setDictBiz(IDictBiz dictBiz) {
		this.dictBiz = dictBiz;
	}
	public ActionForward toList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		clientQB=new Client();
		this.page(clientQB, request);
		List areaList=dictBiz.findByType("地区");
		List gradeList=dictBiz.findByType("企业客户等级");
		request.getSession().setAttribute("areas", areaList);
		request.getSession().setAttribute("grades", gradeList);
		List sfList=dictBiz.findByType("满意度");
		List creditList=dictBiz.findByType("信任度");
		request.getSession().setAttribute("sfList", sfList);
		request.getSession().setAttribute("creditList", creditList);
		return mapping.findForward("list");
	}
	//查询
	public ActionForward doFind(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ClientForm cf=(ClientForm) form;
		Client client=cf.getClient();
		clientQB=client;
		this.page(client, request);
		return mapping.findForward("list");	
	}
	
	public ActionForward doPage(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		this.page(clientQB, request);
		return mapping.findForward("list");	
	}
	public ActionForward toEdit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		int id=Integer.parseInt(request.getParameter("id"));
		Client c=clientBiz.findById(id);
		request.setAttribute("client", c);
		List empList=employeeBiz.findAll();
		request.setAttribute("empList", empList);
		return mapping.findForward("edit");	
	}
	public ActionForward doDel(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		int id=Integer.parseInt(request.getParameter("id"));
		Client c=clientBiz.findById(id);
		clientBiz.del(c);
		return this.toList(mapping, form, request, response);
	}
	public ActionForward doEdit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ClientForm cf=(ClientForm) form;
		Client client=cf.getClient();
		int csId=Integer.parseInt(request.getParameter("id"));
		ClientState cs=csBiz.findById(csId);
		client.setClientState(cs);
		System.out.println(client.getClientState().getClientStateName());
		System.out.println(client.getClientState().getClientStateId());
		clientBiz.update(client);
		return this.toList(mapping, form, request, response);
	}
	public void page(Client client,HttpServletRequest request){
		int pageSize=10;//一页查几行
		int count=clientBiz.findAll(client).size();//一共多少行	
		System.out.println(count);
		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=clientBiz.find(client,pageNo,pageSize);
		request.setAttribute("page", page);
		request.setAttribute("pageSize", pageSize);
		request.setAttribute("pageNo", pageNo);
		request.setAttribute("count", count);
		request.setAttribute("clientList",dictList);
	}
	public void setCsBiz(IClientStateBiz csBiz) {
		this.csBiz = csBiz;
	}
}

⌨️ 快捷键说明

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