📄 admininfoaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.chinahr.web.struts.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
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 org.apache.struts.actions.DispatchAction;
import com.chinahr.web.struts.form.AdminInfoForm;
import com.chinahr.pojo.*;
/**
* MyEclipse Struts Creation date: 10-24-2008
*
* XDoclet definition:
*
* @struts.action path="/adminInfo" name="adminInfoForm"
* input="/form/adminInfo.jsp" parameter="method" scope="request"
* validate="true"
*/
public class AdminInfoAction extends DispatchAction {
/*
* Generated Methods
*/
private com.chinahr.biz.AdminInfoBiz adminInfoBiz;
public void setAdminInfoBiz(com.chinahr.biz.AdminInfoBiz adminInfoBiz) {
this.adminInfoBiz = adminInfoBiz;
}
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward deleAdmin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int au = Integer.parseInt(request.getParameter("id"));
try {
PrintWriter wr = response.getWriter();
if (adminInfoBiz.deleteAdminInfo(au)) {
List<SysAdminInfo> list = adminInfoBiz.getAllAdminInfo();
request.setAttribute("adminlist", list);
return mapping.findForward("ajax");
} else {
response.getWriter().write("deno");
response.getWriter().close();
return null;
}
} catch (Exception e) {
return null;
}
}
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String error="";
SysAdminInfo admin=new SysAdminInfo();
try{
String userid=request.getParameter("userid");
String pwd=request.getParameter("pwd");
int i=adminInfoBiz.islogin(userid, pwd,admin);
if(i==0){
error="没有这个用户";
}
if(i==1){
error="密码错误!";
}
}catch(Exception e){
error="用户名或密码错误!";
}
if(error.length()<2){
request.getSession().setAttribute("adminInfo", admin);
try {
response.sendRedirect("/ChinaHR/adminInfo.do?method=mangUser");
return null;
} catch (IOException e) {
error="系统错误!";
}
}else{
request.setAttribute("error", error);
}
return mapping.findForward("adminlogin");
}
public ActionForward loadAdmin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SysAdminInfo admin=(SysAdminInfo)request.getSession().getAttribute("adminInfo");
int au;
try{
au = Integer.parseInt(request.getParameter("id"));
admin = adminInfoBiz.getAdminInfoByAdminId(au);
}catch(Exception e){
admin=(SysAdminInfo)request.getSession().getAttribute("adminInfo");
}
request.setAttribute("adm", admin);
return mapping.findForward("load");
}
public ActionForward updathis(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AdminInfoForm adminInfoForm = (AdminInfoForm) form;
try{
SysAdminInfo adm=adminInfoForm.getAdmin();
SysAdminInfo ad=adminInfoBiz.getAdminInfoByAdminId(adm.getAdminId());
adm.setAdminPass(ad.getAdminPass());
if (adminInfoBiz.updateAdminInfo(adm)) {
request.setAttribute("adm", adm);
return mapping.findForward("myinfo");
} else {
response.getWriter().write("addno");
response.getWriter().close();
return null;
}
}catch(Exception e){
return null;
}
}
public ActionForward upPass(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String pw1=request.getParameter("pw1");
String pw2=request.getParameter("pw2");
SysAdminInfo ad=(SysAdminInfo)request.getSession().getAttribute("adminInfo");
PrintWriter pr=null;
try {
pr= response.getWriter();
if(!pw1.equals(ad.getAdminPass())){
pr.write("输入的原始密码不正确!");
}else{
ad.setAdminPass(pw2);
pr.write("密码修改成功!");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
pr.write("异常信息");
}
pr.close();
return null;
}
public ActionForward addAdmin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AdminInfoForm adminInfoForm = (AdminInfoForm) form;// TODO
// Auto-generated
// method stub
ActionErrors errors = new ActionErrors();
try {
if (request.getParameter("admin.adminId").length() > 0) {
SysAdminInfo adm=adminInfoForm.getAdmin();
SysAdminInfo ad=adminInfoBiz.getAdminInfoByAdminId(adm.getAdminId());
adm.setAdminPass(ad.getAdminPass());
if (adminInfoBiz.updateAdminInfo(adm)) {
List<SysAdminInfo> list = adminInfoBiz.getAllAdminInfo();
request.setAttribute("adminlist", list);
return mapping.findForward("ajax");
} else {
response.getWriter().write("addno");
response.getWriter().close();
return null;
}
} else {
if (adminInfoBiz.addAdminInfo(adminInfoForm.getAdmin())) {
List<SysAdminInfo> list = adminInfoBiz.getAllAdminInfo();
request.setAttribute("adminlist", list);
return mapping.findForward("ajax");
} else {
response.getWriter().write("addno");
response.getWriter().close();
return null;
}
}
} catch (Exception e) {
return null;
}
}
public ActionForward viwList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List<SysAdminInfo> list = adminInfoBiz.getAllAdminInfo();
request.setAttribute("adminlist", list);
return mapping.findForward("addAdmin");
}
public ActionForward mangUser(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SysAdminInfo ad=(SysAdminInfo)request.getSession().getAttribute("adminInfo");
ad=adminInfoBiz.getAdminInfoByAdminId(ad.getAdminId());
request.getSession().setAttribute("adminInfo", ad);
request.setAttribute("adm", ad);
return mapping.findForward("user");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -