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

📄 editaccountaction.java

📁 icome
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.icome.struts.action;



import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

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

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.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.icome.bo.AccountBO;
import com.icome.entity.Account;
import com.icome.struts.form.EditAccountForm;

/** 
 * MyEclipse Struts
 * Creation date: 12-17-2006
 * 
 * XDoclet definition:
 * @struts.action path="/editAccount" name="editAccountForm" input="/form/editAccount.jsp" scope="request" validate="true"
 */
public class EditAccountAction extends Action {
	/*
	 * Generated Methods
	 */

	
	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws ParseException 
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)  {
		EditAccountForm editAccountForm = (EditAccountForm) form;// TODO Auto-generated method stub
		
		HttpSession session=request.getSession();
		ActionMessages errors=new ActionMessages();
		String uid=(String)session.getAttribute("uid");
		AccountBO aBO=new AccountBO();
	    Account a=aBO.findById(uid);
	    
	    String f=null;
	    
	    String s="你要编辑的用户不存在";
	    if(a==null)
	    {
	    	f="failure";
	    	errors.add("userNotExist",new ActionMessage(s));
	    	return mapping.findForward(f);
	    }
	    
	    a.setAbout(editAccountForm.getAbout());
	    a.setAddress(editAccountForm.getAddress());
	 
	  
	   String birthyear=(String)editAccountForm.getBirthyear() ;
	   String birthmonth=(String)editAccountForm.getBirthmonth();
	   String birthday=(String)editAccountForm.getBirthday();
	   
	    String g=birthyear+"/"+birthmonth+"/"+birthday;
	    SimpleDateFormat   df=new   SimpleDateFormat("yyyy/MM/dd");   
       
	   
	    Date d=null;
	    
	    try
	    {
	    	//d=fm.parse(g);
	    	 d=df.parse(g);
	    }
	    catch(ParseException pe)
	    {
	    	String peError="你的生日输入有错误 "+pe.toString();
	    	errors.add("birthdayError",new ActionMessage(peError));
	    }
	  
	  
	a.setBirthday(d);
	a.setCellphone(editAccountForm.getCellphone());
    a.setDepartment(editAccountForm.getDepartment());
    a.setEmail(editAccountForm.getEmail());
    a.setMsn(editAccountForm.getMsn());
    a.setQq(editAccountForm.getQq());
    a.setRealname(editAccountForm.getRealname());
    a.setTelephone(editAccountForm.getTelephone());
    a.setUniversity(editAccountForm.getUniversity());
    a.setZipcode(editAccountForm.getZipcode());
    
    String sex=editAccountForm.getSex();
    Integer i=null;
     if(sex.equals("male"))
    	 i=new Integer(0);
     else
    	 i=new Integer(1);
     
     a.setSex(i);
     
    boolean b=aBO.save(a);
    if(b)
    {
    	f="success";
    	
    }
    else
    {
    	f="failure";
    	String m="编辑用户信息失败!";
    	errors.add("editAccountFailure",new ActionMessage(m));
    }
    if(!errors.isEmpty())
    {
    saveErrors(request, errors);
    }
		return mapping.findForward(f);
	}
}

⌨️ 快捷键说明

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