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

📄 305340dc4630001d1e52e118c965c1c9

📁 客户关系管理系统主要管理新老客户的一些信息并可以发现潜在客户
💻
字号:
/**
 * 
 */
package com.qrsx.qrsxcrm.action;

import java.util.List;

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

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.qrsx.qrsxcrm.dao.OutStoreDAO;
import com.qrsx.qrsxcrm.form.OutStoreForm;
import com.qrsx.qrsxcrm.model.Order;
import com.qrsx.qrsxcrm.model.OutStore;
import com.qrsx.qrsxcrm.web.Pager;

/**
 * @author Administrator
 *
 */
public class OutStoreAction extends BaseDispatchAction
{
	@SuppressWarnings("unchecked")
	public ActionForward save(ActionMapping mapping,ActionForm form ,HttpServletRequest request,HttpServletResponse response)throws Exception{
//		ActionErrors errors=form.validate(mapping,request);
//		if(!errors.isEmpty()){
//			saveErrors(request,errors);
//			return edit(mapping,form,request,response);
//		}
		OutStoreDAO OutStoreDAO=new OutStoreDAO(OutStore.class);
		OutStoreForm OutStoreForm = (OutStoreForm)form;
		String OrderId = OutStoreForm.getOrderId();
		Order Order = (Order) OutStoreDAO.findById(Order.class, OrderId);
		
		OutStore OutStore=new OutStore();
		BeanUtils.copyProperties(OutStore,form);
		OutStore.setOrder(Order);
		
		if( OutStore.getId()==null||OutStore.getId().trim().length()==0 ){
			OutStoreDAO.create(OutStore);
			saveMessage(request,"create" ,OutStore.getOutStoreId());
		}
		else{
			OutStoreDAO.updates(OutStore);
			saveMessage(request,"update",OutStore.getOutStoreId());
		}
		return mapping.findForward("success");
	}
		
	@SuppressWarnings("unchecked")
	public ActionForward list(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
			OutStoreDAO OutStoreDAO=new OutStoreDAO(OutStore.class);
			OutStore OutStore=new OutStore();
			BeanUtils.copyProperties(OutStore,form);
			List<Order> orders = OutStoreDAO.findAll("from Order");
			request.setAttribute("orders", orders);
			
			try {
				Pager pager = null;
				
				List results = OutStoreDAO.findAll("from OutStore");//得到总数据
				
				pager = new Pager(); // 构造分页对象
				int totalRows = results.size(); // 得到总数据量
				pager.init(totalRows);

				if (request.getParameter("action") != null) {
					pager.doAction(request.getParameter("action").toString());
				}
				// 使用分页标签的方法
				List list = OutStoreDAO.findAllByPage(OutStore, (pager.getCurrentPage() - 1)* pager.getPageSize(),pager.getPageSize());
				request.getSession().setAttribute("pagerstruts", pager);
				request.setAttribute("outStores", list);
			} catch (Exception e) {
				e.printStackTrace();
			}
			
			
			
			return mapping.findForward("list");
		}
	
	@SuppressWarnings("unchecked")
	public ActionForward edit(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
		OutStoreDAO OutStoreDAO=new OutStoreDAO(OutStore.class);
		List<Order> orders = OutStoreDAO.findAll("from Order");
		request.setAttribute("orders", orders);
		String id=request.getParameter("id");
		if(id!=null&&id.trim().length()>0){
			OutStore outStore =(OutStore) OutStoreDAO.findById( OutStore.class, id);
			if( outStore.getOrder() != null )
			{
				outStore.setOrderId(outStore.getOrder().getId());
			}
			
			if (outStore!=null){
				BeanUtils.copyProperties(form,outStore);
			}
		}
		return mapping.findForward("edit");
	}
	
	
	@SuppressWarnings("unchecked")
	public ActionForward delete(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
		String id=request.getParameter("id");
		OutStoreDAO OutStoreDAO=new OutStoreDAO(OutStore.class);
		OutStore OutStore =(OutStore) OutStoreDAO.findById( OutStore.class, id);
		OutStoreDAO.delete(OutStore);
		
		return mapping.findForward("success");
	}

	
	public ActionForward info(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
		String id=request.getParameter("id");
		if(id!=null&&id.trim().length()>0){
			OutStoreDAO OutStoreDAO=new OutStoreDAO(OutStore.class);
			OutStore OutStore =(OutStore) OutStoreDAO.findById( OutStore.class, id);
			request.setAttribute("outStore",OutStore);
		}
		return mapping.findForward("info");
	}
}

⌨️ 快捷键说明

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