📄 modifymerchantaction.java
字号:
/**
*
*/
package cn.bway.myoffice.merchant.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import cn.bway.common.BwayHibernateException;
import cn.bway.common.Util;
import cn.bway.common.WebConstant;
import cn.bway.common.action.BaseAction;
import cn.bway.myoffice.merchant.form.MerchantForm;
import cn.bway.myoffice.merchant.impl.MerchantManagerFactory;
import cn.bway.myoffice.merchant.model.Merchant;
/**
* @author Kson
*
*/
public class ModifyMerchantAction extends BaseAction {
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
MerchantForm pForm = (MerchantForm) form;
ActionErrors errors = new ActionErrors();
String returnStr = WebConstant.FORWARD_SUCCESS;
//����get����
if(request.getMethod().equals("GET")){
try {
Merchant Merchant=(Merchant) MerchantManagerFactory.getMerchantManager().getMerchant(request.getParameter("id"));
pForm.setId(Merchant.getId());
pForm.setStaffid(Merchant.getStaffid());
pForm.setStaffname(Merchant.getStaffname());
pForm.setMername(Merchant.getMername());
pForm.setMercode(Merchant.getMercode());
pForm.setSimplename(Merchant.getSimplename());
pForm.setTel(Merchant.getTel());
pForm.setFax(Merchant.getFax());
pForm.setWeburl(Merchant.getWeburl());
pForm.setEmail(Merchant.getEmail());
pForm.setArea(Merchant.getArea());
pForm.setPostcode(Merchant.getPostcode());
pForm.setAddr(Merchant.getAddr());
pForm.setRemark(Merchant.getRemark());
pForm.setAccount(Merchant.getBankaccount());
pForm.setBankaccount(Merchant.getBankaccount());
pForm.setAdddate(Merchant.getAdddate());
request.setAttribute(WebConstant.PAGE_Object, pForm);
returnStr = WebConstant.FORWARD_INITPAGE;
return mapping.findForward(returnStr);
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BwayHibernateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
saveObject(pForm);
returnStr=WebConstant.FORWARD_SUCCESS;
request.setAttribute(WebConstant.RETURN_Message,"修改成功!");
} catch (BwayHibernateException e) {
returnStr=WebConstant.FORWARD_FAIL;
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("edu.system.excption",e.getMessage()));
this.saveErrors(request,errors);
e.printStackTrace();
}
return mapping.findForward(returnStr);
}
/**
* ����VO,�������
* @throws BwayHibernateException
*/
private void saveObject(MerchantForm form) throws BwayHibernateException{
//�õ������Ͷ���
Merchant pvo=new Merchant();
pvo.setId(form.getId());
pvo.setStaffid(form.getStaffid());
pvo.setStaffname(form.getStaffname());
pvo.setMername(form.getMername());
pvo.setMercode(form.getMercode());
pvo.setSimplename(form.getSimplename());
pvo.setTel(form.getTel());
pvo.setFax(form.getFax());
pvo.setWeburl(form.getWeburl());
pvo.setEmail(form.getEmail());
pvo.setArea(form.getArea());
pvo.setPostcode(form.getPostcode());
pvo.setAddr(form.getAddr());
pvo.setRemark(form.getRemark());
pvo.setAccount(form.getBankaccount());
pvo.setBankaccount(form.getBankaccount());
pvo.setAdddate(form.getAdddate());
MerchantManagerFactory.getMerchantManager().modfilyMerchant(pvo);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -