/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package admin.login;

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 database.DBConn;
import beans.Users;

/** 
 * MyEclipse Struts
 * Creation date: 05-26-2008
 * 
 * XDoclet definition:
 * @struts.action path="/admin_login" name="adminloginForm" input="/admin_login.jsp" scope="request" validate="true"
 * @struts.action-forward name="admin" path="/admin/admin.jsp"
 */
public class AdminloginAction extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		AdminLoginForm adminloginForm = (AdminLoginForm) form;// TODO Auto-generated method stub
		Users u = new DBConn().loginGuest(adminloginForm.getName(), adminloginForm.getPwd());
		if(u==null||u.getPower()==2)
		{
			return mapping.findForward("2");
		}
		else
		{
			request.getSession().setAttribute("admin", u);
			return mapping.findForward("1");
		}
		
	}
}