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

📄 addcustomeraction.java

📁 开发的一个java web的任务管理系统。
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package unicom.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import unicom.bean.Customer;
import unicom.factory.ServiceFactory;
import unicom.service.ICustomerService;

/**
 * @author 陈才旭
 * 日期:Apr 18, 2008
 * 功能:低端控制器,增加实体客户-实体的人
 * 优点:
 * 缺点:
 * 建议:注意权限控制问题,感觉权限控制代码有点多
 */
public class AddCustomerAction extends IdentityFilter {

	public boolean addCustomer(ActionForm form)
	{ 
		DynaActionForm dynaForm = (DynaActionForm)form;
	    Customer c = new Customer();
	    c.setType((String)dynaForm.get("customerType"));
	    c.setNumber((String)dynaForm.get("customerNumber"));
	    c.setName((String)dynaForm.get("customerName"));
	    c.setBirthday((java.sql.Date)dynaForm.get("customerBirthday"));
	    c.setSex((String)dynaForm.get("customerSex"));
	    c.setAddress((String)dynaForm.get("customerAddress"));
	    //调用业务逻辑bean,增加客户
	    ICustomerService customerService = ServiceFactory.createCustomerService();
	    boolean success = customerService.addCustomer(c);
	    return success;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		if(super.isAdminLogin(request))
		{
		    
		    if(addCustomer(form))
		    {
		    	request.setAttribute("msg", "恭喜!增加客户成功");
		    	return mapping.findForward("msgpage");
		    }else{
		    	request.setAttribute("msg", "系统正忙!稍后在试");
		    	return mapping.findForward("msgpage");
		          }
		}else{
			if(super.isOperLogin(request))
			{
				if(addCustomer(form))
				{
					request.setAttribute("msg", "恭喜!增加客户成功");
					return mapping.findForward("msgOperpage");
				}else{
					request.setAttribute("msg", "系统正忙!稍后在试");
			    	return mapping.findForward("msgOperpage");
				}
			}else{
			request.setAttribute("msg", "你还未登录");
			return mapping.findForward("index");
			}
		}
	}
}

⌨️ 快捷键说明

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