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

📄 f0c71551562e001d141adb233f2e4e02

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

/**
 * @author Administrator
 *
 */
public class OutStoreAction extends BaseDispatchAction
{
	/**
	 * 
	 */
	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.DeptDAO;
	import com.qrsx.qrsxcrm.dao.InStoreDAO;
	import com.qrsx.qrsxcrm.form.InStoreForm;
	import com.qrsx.qrsxcrm.model.Dept;
	import com.qrsx.qrsxcrm.model.InStore;
	import com.qrsx.qrsxcrm.model.Stock;
	import com.qrsx.qrsxcrm.web.Pager;

	/**
	 * @author Administrator
	 *
	 */
	public class InStoreAction 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);
//			}
			InStoreDAO inStoreDAO=new InStoreDAO(InStore.class);
			InStoreForm inStoreForm = (InStoreForm)form;
			String stockId = inStoreForm.getStockId();
			Stock stock = (Stock) inStoreDAO.findById(Stock.class, stockId);
			
			InStore inStore=new InStore();
			BeanUtils.copyProperties(inStore,form);
			inStore.setStock(stock);
			
			if( inStore.getId()==null||inStore.getId().trim().length()==0 ){
				inStoreDAO.create(inStore);
				saveMessage(request,"create" ,inStore.getInStoreId());
			}
			else{
				inStoreDAO.updates(inStore);
				saveMessage(request,"update",inStore.getInStoreId());
			}
			return mapping.findForward("success");
		}
			
		@SuppressWarnings("unchecked")
		public ActionForward list(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
				InStoreDAO inStoreDAO=new InStoreDAO(InStore.class);
				InStore inStore=new InStore();
				BeanUtils.copyProperties(inStore,form);
				List<Stock> stocks = inStoreDAO.findAll("from Stock");
				request.setAttribute("stocks", stocks);
				
				try {
					Pager pager = null;
					
					List results = inStoreDAO.findAll("from InStore");//得到总数据
					
					pager = new Pager(); // 构造分页对象
					int totalRows = results.size(); // 得到总数据量
					pager.init(totalRows);

					if (request.getParameter("action") != null) {
						pager.doAction(request.getParameter("action").toString());
					}
					// 使用分页标签的方法
					List list = inStoreDAO.findAllByPage(inStore, (pager.getCurrentPage() - 1)* pager.getPageSize(),pager.getPageSize());
					request.getSession().setAttribute("pagerstruts", pager);
					request.setAttribute("inStores", 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{
			InStoreDAO inStoreDAO=new InStoreDAO(InStore.class);
			List<Stock> stocks = inStoreDAO.findAll("from Stock");
			request.setAttribute("stocks", stocks);
			String id=request.getParameter("id");
			if(id!=null&&id.trim().length()>0){
				InStore inStore =(InStore) inStoreDAO.findById( InStore.class, id);
				if( inStore.getStock() != null )
				{
					inStore.setStockId(inStore.getStock().getStockId());
				}
				
				if (inStore!=null){
					BeanUtils.copyProperties(form,inStore);
				}
			}
			return mapping.findForward("edit");
		}
		
		
		@SuppressWarnings("unchecked")
		public ActionForward delete(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
			String id=request.getParameter("id");
			InStoreDAO inStoreDAO=new InStoreDAO(InStore.class);
			InStore inStore =(InStore) inStoreDAO.findById( InStore.class, id);
			inStoreDAO.delete(inStore);
			
			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){
				InStoreDAO inStoreDAO=new InStoreDAO(InStore.class);
				InStore inStore =(InStore) inStoreDAO.findById( InStore.class, id);
				request.setAttribute("inStore",inStore);
			}
			return mapping.findForward("info");
		}
	}

}

⌨️ 快捷键说明

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