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

📄 manageraction.java

📁 医药管理
💻 JAVA
字号:
package com.xttc.action;


import java.io.UnsupportedEncodingException;

import com.xttc.pojo.Druginfo;
import com.xttc.pojo.Managerinfo;
import com.xttc.dao.ManagerinfoDAO;
import com.xttc.datainterface.IManagerService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.xttc.actionform.ManagerInfoActionForm;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.xttc.util.Encodingfilter;




public class ManagerAction extends DispatchAction {
	private IManagerService IManagerService;
	public IManagerService getIManagerService() {
		return IManagerService;
	}
	public void setIManagerService(IManagerService managerService) {
		IManagerService = managerService;
	}
	public ActionForward managerLogin(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ManagerInfoActionForm actionForm = (ManagerInfoActionForm)form;
		Managerinfo managerinfo = new Managerinfo();
		managerinfo.setUserName((String)request.getSession().getAttribute("user_name"));
		managerinfo.setPassword((String)request.getSession().getAttribute("pass_word"));
		if(IManagerService.managerLogin(managerinfo).size()!=0){
			request.getSession().setAttribute("managerinfo",IManagerService.managerLogin(managerinfo).get(0));
			return mapping.findForward("loginSuccess");
		}
		return mapping.findForward("loginFail");
	}
	
	public ActionForward changePassword(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ManagerInfoActionForm actionForm = (ManagerInfoActionForm)form;
		Managerinfo managerinfo = new Managerinfo();
		managerinfo.setPassword(actionForm.getNewpassword());
		managerinfo.setId(actionForm.getId());
		managerinfo.setRemark(actionForm.getRemark());
		request.setAttribute("changepwd", IManagerService.updManager(managerinfo));
		return mapping.findForward("changepassword");
	}
	
	public ActionForward updManager(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ManagerInfoActionForm actionForm = (ManagerInfoActionForm)form;
		Managerinfo managerinfo = new Managerinfo();
		managerinfo.setUserName(actionForm.getUsername());
		managerinfo.setPassword(actionForm.getPassword());
		managerinfo.setRemark(actionForm.getRemark());
		managerinfo.setId(actionForm.getId());
		request.setAttribute("updManager", IManagerService.updManager(managerinfo));
		return mapping.findForward("updManager");
	}


	public ActionForward addManager(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ManagerInfoActionForm actionForm = (ManagerInfoActionForm)form;
		Managerinfo managerinfo = new Managerinfo();
	    managerinfo.setUserName(actionForm.getUsername());
		managerinfo.setPassword(actionForm.getPassword());
		managerinfo.setRemark(actionForm.getRemark());
		request.setAttribute("addManager", IManagerService.addManager(managerinfo));
		return mapping.findForward("add");
	}
	
	public ActionForward delManager(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ManagerInfoActionForm actionForm = (ManagerInfoActionForm)form;
		Managerinfo managerinfo = new Managerinfo();
		managerinfo.setId(Integer.parseInt(request.getParameter("userid")));
		if(IManagerService.findByExamplef(managerinfo).size()==1){
		request.setAttribute("delManager", IManagerService.delManager(managerinfo));
		return mapping.findForward("updManager");
		}
		return mapping.findForward("updManagerFail");
	}
	public ActionForward findAll(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		request.setAttribute("allManager", IManagerService.findAll());
		return mapping.findForward("findallManager");
		
	}
	
    public ActionForward findById(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		Managerinfo managerinfo = new Managerinfo();
		managerinfo.setId(Integer.parseInt(request.getParameter("userid")));
		if((IManagerService.findByExamplef(managerinfo).size()==1)){
		request.setAttribute("iniuserupd", IManagerService.findByExamplef(managerinfo));
		//request.setAttribute("allUser", IManagerService.findAll());
		return mapping.findForward("iniuserupd");
		}
		return mapping.findForward("iniuserupdFail");
	}

}

⌨️ 快捷键说明

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