parent
b2e1252a90
commit
763ccea4c5
@ -0,0 +1,100 @@
|
||||
package com.action;
|
||||
|
||||
import com.dao.AdminDao;
|
||||
import com.dao.StudentDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
public class GoLogin extends ActionSupport {
|
||||
|
||||
//??????Action????????????????????????
|
||||
private String Type;
|
||||
private String Username;
|
||||
private String Password;
|
||||
private String Msg;
|
||||
private String check;
|
||||
|
||||
public String getCheck() {
|
||||
return check;
|
||||
}
|
||||
|
||||
public void setCheck(String check) {
|
||||
this.check = check;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return Type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
Type = type;
|
||||
}
|
||||
public String getUsername() {
|
||||
return Username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
Username = username;
|
||||
}
|
||||
public String getPassword() {
|
||||
return Password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
Password = password;
|
||||
}
|
||||
public String getMsg() {
|
||||
return Msg;
|
||||
}
|
||||
public void setMsg(String msg) {
|
||||
Msg = msg;
|
||||
}
|
||||
/**
|
||||
* 以上就是获取输入登入信息的 * */
|
||||
public String execute() throws Exception {
|
||||
|
||||
|
||||
|
||||
|
||||
if(Type.equals("系统管理员"))
|
||||
{
|
||||
if (null == new AdminDao().CheckLogin(Username, Password)) {
|
||||
Msg = "系统检查为空啊哈哈";
|
||||
return INPUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
//???ID
|
||||
String Admin_ID=new AdminDao().CheckLogin(Username, Password);
|
||||
//????session
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
session.setAttribute("id", Admin_ID);
|
||||
session.setAttribute("type", "1");
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
else if(Type.equals("学生"))
|
||||
{
|
||||
if (null == new StudentDao().CheckLogin(Username, Password)) {
|
||||
Msg = "学生用户名或密码输入错误";
|
||||
return INPUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
//???ID
|
||||
String Student_ID=new StudentDao().CheckLogin(Username, Password);
|
||||
//????session
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
session.setAttribute("id", Student_ID);
|
||||
session.setAttribute("type", "3");
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg = "用户名或密码输入错误";
|
||||
return INPUT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.StudentBean;
|
||||
import com.dao.StudentDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
public class LogAdd extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
|
||||
private String Student_ID;
|
||||
public String getStudent_ID() {
|
||||
return Student_ID;
|
||||
}
|
||||
public void setStudent_ID(String studentID) {
|
||||
Student_ID = studentID;
|
||||
}
|
||||
private StudentBean cnbean;
|
||||
public StudentBean getCnbean() {
|
||||
return cnbean;
|
||||
}
|
||||
public void setCnbean(StudentBean cnbean) {
|
||||
this.cnbean = cnbean;
|
||||
}
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询
|
||||
cnbean=new StudentDao().GetBean(Integer.parseInt(Student_ID));
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.LogBean;
|
||||
import com.dao.LogDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
public class LogAddSave extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private String Log_Date ;
|
||||
private String Log_Remark ;
|
||||
|
||||
public String getLog_Date() {
|
||||
return Log_Date;
|
||||
}
|
||||
|
||||
public void setLog_Date(String logDate) {
|
||||
Log_Date = logDate;
|
||||
}
|
||||
|
||||
public String getLog_Remark() {
|
||||
return Log_Remark;
|
||||
}
|
||||
|
||||
public void setLog_Remark(String logRemark) {
|
||||
Log_Remark = logRemark;
|
||||
}
|
||||
|
||||
private String Log_StudentID;
|
||||
public String getLog_StudentID() {
|
||||
return Log_StudentID;
|
||||
}
|
||||
|
||||
public void setLog_StudentID(String logStudentID) {
|
||||
Log_StudentID = logStudentID;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//添加
|
||||
LogBean cnbean=new LogBean();
|
||||
cnbean.setLog_StudentID(Integer.parseInt(Log_StudentID));
|
||||
cnbean.setLog_TeacherID(Integer.parseInt(session.getAttribute("id").toString()));
|
||||
cnbean.setLog_Date(Log_Date);
|
||||
cnbean.setLog_Remark(Log_Remark);
|
||||
|
||||
new LogDao().Add(cnbean);
|
||||
|
||||
//跳转
|
||||
out.print("<script language='javascript'>alert('缺寝登记成功!');window.location='Index.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.TBBean;
|
||||
import com.dao.TBDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MyLog extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private List<TBBean> list;
|
||||
public List<TBBean> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<TBBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
|
||||
//查询所有
|
||||
list=new TBDao().GetList("TB_TeacherID="+session.getAttribute("id"),"Building_Name");
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.DomitoryBean;
|
||||
import com.bean.LogBean;
|
||||
import com.dao.DomitoryDao;
|
||||
import com.dao.LogDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MyLogList extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private List<LogBean> list;
|
||||
public List<LogBean> getList() {
|
||||
return list;
|
||||
}
|
||||
public void setList(List<LogBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
|
||||
private String Building_ID;
|
||||
public String getBuilding_ID() {
|
||||
return Building_ID;
|
||||
}
|
||||
public void setBuilding_ID(String buildingID) {
|
||||
Building_ID = buildingID;
|
||||
}
|
||||
private List<DomitoryBean> domitorylist;
|
||||
public List<DomitoryBean> getDomitorylist() {
|
||||
return domitorylist;
|
||||
}
|
||||
public void setDomitorylist(List<DomitoryBean> domitorylist) {
|
||||
this.domitorylist = domitorylist;
|
||||
}
|
||||
|
||||
private String SearchRow;
|
||||
private String SearchKey;
|
||||
public String getSearchRow() {
|
||||
return SearchRow;
|
||||
}
|
||||
public void setSearchRow(String searchRow) {
|
||||
SearchRow = searchRow;
|
||||
}
|
||||
public String getSearchKey() {
|
||||
return SearchKey;
|
||||
}
|
||||
public void setSearchKey(String searchKey) {
|
||||
SearchKey = searchKey;
|
||||
}
|
||||
private String Domitory_ID;
|
||||
|
||||
public String getDomitory_ID() {
|
||||
return Domitory_ID;
|
||||
}
|
||||
public void setDomitory_ID(String domitoryID) {
|
||||
Domitory_ID = domitoryID;
|
||||
}
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询条件
|
||||
String strWhere="Student_State='入住' and Building_ID="+Building_ID;
|
||||
if(!(isInvalid(SearchKey)))
|
||||
{
|
||||
strWhere+=" and "+SearchRow+"='"+SearchKey+"'";
|
||||
}
|
||||
if(!(isInvalid(Domitory_ID)))
|
||||
{
|
||||
strWhere+=" and Domitory_ID='"+Domitory_ID+"'";
|
||||
}
|
||||
//查询所有
|
||||
list=new LogDao().GetList(strWhere,"Log_Date desc");
|
||||
|
||||
//查询所有寝室
|
||||
domitorylist=new DomitoryDao().GetList("Domitory_BuildingID="+Building_ID,"Domitory_Name");
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.TBBean;
|
||||
import com.dao.TBDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MyStudent extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private List<TBBean> list;
|
||||
public List<TBBean> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<TBBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
|
||||
//查询所有
|
||||
list=new TBDao().GetList("TB_TeacherID="+session.getAttribute("id"),"Building_Name");
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.DomitoryBean;
|
||||
import com.bean.StudentBean;
|
||||
import com.dao.DomitoryDao;
|
||||
import com.dao.StudentDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MyStudentList extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private List<StudentBean> list;
|
||||
public List<StudentBean> getList() {
|
||||
return list;
|
||||
}
|
||||
public void setList(List<StudentBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
private String Building_ID;
|
||||
public String getBuilding_ID() {
|
||||
return Building_ID;
|
||||
}
|
||||
public void setBuilding_ID(String buildingID) {
|
||||
Building_ID = buildingID;
|
||||
}
|
||||
private List<DomitoryBean> domitorylist;
|
||||
public List<DomitoryBean> getDomitorylist() {
|
||||
return domitorylist;
|
||||
}
|
||||
public void setDomitorylist(List<DomitoryBean> domitorylist) {
|
||||
this.domitorylist = domitorylist;
|
||||
}
|
||||
|
||||
private String SearchRow;
|
||||
private String SearchKey;
|
||||
public String getSearchRow() {
|
||||
return SearchRow;
|
||||
}
|
||||
public void setSearchRow(String searchRow) {
|
||||
SearchRow = searchRow;
|
||||
}
|
||||
public String getSearchKey() {
|
||||
return SearchKey;
|
||||
}
|
||||
public void setSearchKey(String searchKey) {
|
||||
SearchKey = searchKey;
|
||||
}
|
||||
private String Domitory_ID;
|
||||
|
||||
public String getDomitory_ID() {
|
||||
return Domitory_ID;
|
||||
}
|
||||
public void setDomitory_ID(String domitoryID) {
|
||||
Domitory_ID = domitoryID;
|
||||
}
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询条件
|
||||
String strWhere="Student_State='入住' and Building_ID="+Building_ID;
|
||||
if(!(isInvalid(SearchKey)))
|
||||
{
|
||||
strWhere+=" and "+SearchRow+"='"+SearchKey+"'";
|
||||
}
|
||||
if(!(isInvalid(Domitory_ID)))
|
||||
{
|
||||
strWhere+=" and Domitory_ID='"+Domitory_ID+"'";
|
||||
}
|
||||
//查询所有
|
||||
list=new StudentDao().GetList(strWhere,"Domitory_Name");
|
||||
|
||||
//查询所有寝室
|
||||
domitorylist=new DomitoryDao().GetList("Domitory_BuildingID="+Building_ID,"Domitory_Name");
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.NoticeBean;
|
||||
import com.dao.NoticeDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
public class Notice extends ActionSupport {
|
||||
private String Msg1;
|
||||
private String Msg2;
|
||||
|
||||
public String getMsg2() {
|
||||
return Msg2;
|
||||
}
|
||||
|
||||
public void setMsg2(String msg2) {
|
||||
Msg2 = msg2;
|
||||
}
|
||||
|
||||
public String getMsg1() {
|
||||
return Msg1;
|
||||
}
|
||||
public void setMsg1(String msg1) {
|
||||
Msg1 = msg1;
|
||||
}
|
||||
private List<NoticeBean> list;
|
||||
public List<NoticeBean> getList() {
|
||||
return list;
|
||||
}
|
||||
public void setList(List<NoticeBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
private List<NoticeBean> repairlist;
|
||||
public List<NoticeBean> getRepairlist() {
|
||||
return list;
|
||||
}
|
||||
public void setRepairlist(List<NoticeBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response= ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
//查询
|
||||
list= new NoticeDao().GetBean();
|
||||
Msg1= String.valueOf(list.get(0));
|
||||
Msg2= String.valueOf(list.get(1));
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.OutBean;
|
||||
import com.dao.OutDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class OutList extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private List<OutBean> list;
|
||||
public List<OutBean> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<OutBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
//查询所有
|
||||
list=new OutDao().GetList("","o.Out_Date desc");
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.AdminBean;
|
||||
import com.bean.StudentBean;
|
||||
import com.bean.TeacherBean;
|
||||
import com.dao.AdminDao;
|
||||
import com.dao.StudentDao;
|
||||
import com.dao.TeacherDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
public class PasswordUpdateSave extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private String Password;
|
||||
private String Password2;
|
||||
private String Msg;
|
||||
public String getPassword() {
|
||||
return Password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
Password = password;
|
||||
}
|
||||
|
||||
public String getPassword2() {
|
||||
return Password2;
|
||||
}
|
||||
|
||||
public void setPassword2(String password2) {
|
||||
Password2 = password2;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return Msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
Msg = msg;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
String type=session.getAttribute("type").toString();
|
||||
if(type.equals("1"))//校园管理员身份
|
||||
{
|
||||
//查询原密码是否正确
|
||||
if (new AdminDao().CheckPassword(session.getAttribute("id").toString(), Password)) {
|
||||
//修改密码
|
||||
AdminBean cnbean=new AdminBean();
|
||||
cnbean=new AdminDao().GetBean(Integer.parseInt(session.getAttribute("id").toString()));
|
||||
cnbean.setAdmin_Password(Password2);
|
||||
new AdminDao().Update(cnbean);
|
||||
out.print("<script language='javascript'>alert('修改成功!');window.location='PasswordUpdate.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg = "用户名或者密码错误";
|
||||
return INPUT;
|
||||
}
|
||||
}
|
||||
else if(type.equals("2"))//楼宇管理员身份
|
||||
{
|
||||
//查询原密码是否正确
|
||||
if (new TeacherDao().CheckPassword(session.getAttribute("id").toString(), Password)) {
|
||||
//修改密码
|
||||
TeacherBean cnbean=new TeacherBean();
|
||||
cnbean=new TeacherDao().GetBean(Integer.parseInt(session.getAttribute("id").toString()));
|
||||
cnbean.setTeacher_Password(Password2);
|
||||
new TeacherDao().Update(cnbean);
|
||||
out.print("<script language='javascript'>alert('修改成功!');window.location='PasswordUpdate.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg = "用户名或者密码错误";
|
||||
return INPUT;
|
||||
}
|
||||
}
|
||||
else if(type.equals("3"))//学生身份
|
||||
{
|
||||
//查询原密码是否正确
|
||||
if (new StudentDao().CheckPassword(session.getAttribute("id").toString(), Password)) {
|
||||
//修改密码
|
||||
StudentBean cnbean=new StudentBean();
|
||||
cnbean=new StudentDao().GetBean(Integer.parseInt(session.getAttribute("id").toString()));
|
||||
cnbean.setStudent_Password(Password2);
|
||||
new StudentDao().Update(cnbean);
|
||||
out.print("<script language='javascript'>alert('修改成功!');window.location='PasswordUpdate.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg = "用户名或者密码错误";
|
||||
return INPUT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.action;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
||||
public class Quit extends ActionSupport {
|
||||
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//清除session
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
session.removeAttribute("id");
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.Repair_addBean;
|
||||
import com.dao.RepairDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
public class RepairAdd extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private int repair_id ;
|
||||
private String repair_address ;
|
||||
private String repair_info ;
|
||||
private String repair_cost;
|
||||
private String repair_time;
|
||||
private String repair_status ;
|
||||
private String repair_tel ;
|
||||
|
||||
public int getRepair_id() {
|
||||
return repair_id;
|
||||
}
|
||||
|
||||
public void setRepair_id(int repair_id) {
|
||||
this.repair_id = repair_id;
|
||||
}
|
||||
public String getRepair_address() {
|
||||
return repair_address;
|
||||
}
|
||||
|
||||
public void setRepair_address(String repair_address) {
|
||||
this.repair_address = repair_address;
|
||||
}
|
||||
|
||||
public String getRepair_info() {
|
||||
return repair_info;
|
||||
}
|
||||
|
||||
public void setRepair_info(String repair_info) {
|
||||
this.repair_info = repair_info;
|
||||
}
|
||||
|
||||
public String getRepair_cost() {
|
||||
return repair_cost;
|
||||
}
|
||||
|
||||
public void setRepair_cost(String repair_cost) {
|
||||
this.repair_cost = repair_cost;
|
||||
}
|
||||
|
||||
public String getRepair_time() {
|
||||
return repair_time;
|
||||
}
|
||||
|
||||
public void setRepair_time(String repair_time) {
|
||||
this.repair_time = repair_time;
|
||||
}
|
||||
|
||||
public String getRepair_status() {
|
||||
return repair_status;
|
||||
}
|
||||
|
||||
public void setRepair_status(String repair_status) {
|
||||
this.repair_status = repair_status;
|
||||
}
|
||||
|
||||
public String getRepair_tel() {
|
||||
return repair_tel;
|
||||
}
|
||||
|
||||
public void setRepair_tel(String repair_tel) {
|
||||
this.repair_tel = repair_tel;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询用户名是否存在
|
||||
// List<StudentBean> list=new StudentDao().GetList("Student_Username='"+Student_Username+"'", "");
|
||||
// if(list.size()>0)
|
||||
// {
|
||||
// out.print("<script language='javascript'>alert('用户名已经存在!');history.back(-1);</script>");
|
||||
// out.flush();out.close();return null;
|
||||
// }
|
||||
//添加
|
||||
|
||||
Repair_addBean cnbean=new Repair_addBean();
|
||||
//new日期对
|
||||
long l = System.currentTimeMillis();
|
||||
Date date = new Date(l);
|
||||
//转换提日期输出格式
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
repair_time=dateFormat.format(date);
|
||||
repair_cost="25";
|
||||
repair_status="待维修";
|
||||
// Repair_addBean cnbean=new Repair_addBean();
|
||||
cnbean.setRepair_id(repair_id);
|
||||
cnbean.setRepair_address(repair_address);
|
||||
cnbean.setRepair_info(repair_info);
|
||||
cnbean.setRepair_tel(repair_tel);
|
||||
// cnbean.setRepair_time(repair_time);
|
||||
//cnbean.setRepair_cost(repair_cost);
|
||||
cnbean.setRepair_status(repair_status);
|
||||
new RepairDao().Add(cnbean);
|
||||
|
||||
//跳转
|
||||
out.print("<script language='javascript'>alert('添加成功!');window.location='Index.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.Repair_addBean;
|
||||
import com.dao.RepairDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
public class RepairList extends ActionSupport {
|
||||
|
||||
private int repair_id;
|
||||
|
||||
|
||||
public int getRepair_id() {
|
||||
return repair_id;
|
||||
}
|
||||
|
||||
public void setRepair_id(int studentid) {
|
||||
repair_id = repair_id;
|
||||
}
|
||||
|
||||
private List<Repair_addBean> list;
|
||||
public List<Repair_addBean> getList() { return list;
|
||||
}
|
||||
public void setList(List<Repair_addBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response= ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
//查询
|
||||
// list=new RepairDao(List<Repair_addBean>)().GetBean(repair_id);
|
||||
|
||||
list=new RepairDao().GetList("strwhere","repair_id");
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.Repair_addBean;
|
||||
import com.dao.RepairDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class RepairManager extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private List<Repair_addBean> list;
|
||||
public List<Repair_addBean> getList() {
|
||||
return list;
|
||||
}
|
||||
public void setList(List<Repair_addBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
private String SearchRow;
|
||||
private String SearchKey;
|
||||
public String getSearchRow() {
|
||||
return SearchRow;
|
||||
}
|
||||
public void setSearchRow(String searchRow) {
|
||||
SearchRow = searchRow;
|
||||
}
|
||||
public String getSearchKey() {
|
||||
return SearchKey;
|
||||
}
|
||||
public void setSearchKey(String searchKey) {
|
||||
SearchKey = searchKey;
|
||||
}
|
||||
// private List<Repair_addBean> buildinglist;
|
||||
// public List<Repair_addBean> getBuildinglist() {
|
||||
// return buildinglist;
|
||||
//}
|
||||
// public void setBuildinglist(List<Repair_addBean> buildinglist) {
|
||||
// this.buildinglist = buildinglist;
|
||||
// }
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
//查询条件
|
||||
String strWhere="1=1";
|
||||
if(!(isInvalid(SearchKey)))
|
||||
{
|
||||
strWhere+=" and "+SearchRow+"='"+SearchKey+"'";
|
||||
}
|
||||
// if(!(isInvalid(Integer.toString(repair_id))))
|
||||
// {
|
||||
// strWhere+=" and repair_id='"+repair_id+"'";
|
||||
// }
|
||||
|
||||
//查询所有楼宇
|
||||
//list=new RepairDao().GetList("","repair_id");
|
||||
|
||||
//查询所有
|
||||
list=new RepairDao().GetList(strWhere,"repair_tel");
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.Repair_addBean;
|
||||
import com.dao.RepairDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
public class RepairUpdate extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private int repair_id;
|
||||
private Repair_addBean cnbean;
|
||||
public int getRepair_id() {
|
||||
System.out.println(repair_id);
|
||||
return repair_id;
|
||||
}
|
||||
|
||||
public void setRepair_id(int studentid) {
|
||||
repair_id = studentid;
|
||||
}
|
||||
|
||||
public Repair_addBean getCnbean() { return cnbean;
|
||||
}
|
||||
|
||||
public void setCnbean(Repair_addBean cnbean) {
|
||||
this.cnbean = cnbean;
|
||||
}
|
||||
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询所有楼宇
|
||||
//list=new RepairDao().GetList("","repair_id");
|
||||
//查询
|
||||
cnbean=new RepairDao().GetBean(repair_id);
|
||||
System.out.println(repair_id);
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.Repair_addBean;
|
||||
import com.dao.RepairDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
public class RepairUpdateSave extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private int repair_id;
|
||||
private String repair_address;
|
||||
private String repair_info;
|
||||
private String repair_cost;
|
||||
private String repair_tel;
|
||||
private String repair_status;
|
||||
private String repair_time;
|
||||
public int getRepair_id() {
|
||||
|
||||
return repair_id;
|
||||
}
|
||||
|
||||
public void setRepair_id(int cookID) {
|
||||
this.repair_id = cookID;
|
||||
}
|
||||
|
||||
|
||||
public String getRepair_time() {
|
||||
return repair_time;
|
||||
}
|
||||
|
||||
public void setRepair_time(String repair_time) {
|
||||
this.repair_time = repair_time;
|
||||
}
|
||||
|
||||
public String getRepair_address() {
|
||||
return repair_address;
|
||||
}
|
||||
|
||||
public void setRepair_address(String repair_address) {
|
||||
this.repair_address = repair_address;
|
||||
}
|
||||
|
||||
public String getRepair_info() {
|
||||
return repair_info;
|
||||
}
|
||||
|
||||
public void setRepair_info(String repair_info) {
|
||||
this.repair_info = repair_info;
|
||||
}
|
||||
|
||||
public String getRepair_cost() {
|
||||
return repair_cost;
|
||||
}
|
||||
|
||||
public void setRepair_cost(String repair_cost) {
|
||||
this.repair_cost = repair_cost;
|
||||
}
|
||||
|
||||
public String getRepair_tel() {
|
||||
return repair_tel;
|
||||
}
|
||||
|
||||
public void setRepair_tel(String repair_tel) {
|
||||
this.repair_tel = repair_tel;
|
||||
}
|
||||
|
||||
public String getRepair_status() {
|
||||
return repair_status;
|
||||
}
|
||||
|
||||
public void setRepair_status(String cookStatus) {
|
||||
this.repair_status = cookStatus;
|
||||
}
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
System.out.println(repair_id);
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询用户名是否存在
|
||||
//List<Repair_addBean> list=new RepairDao().GetList("Teacher_Username='"+Teacher_Username+"' and Teacher_ID!="+Teacher_ID, "");
|
||||
// if(list.size()>0)
|
||||
// {
|
||||
// out.print("<script language='javascript'>alert('用户名已经存在!');history.back(-1);</script>");
|
||||
// out.flush();out.close();return null;
|
||||
// }
|
||||
//修改
|
||||
|
||||
Repair_addBean cnbean=new Repair_addBean();
|
||||
|
||||
cnbean=new RepairDao().GetBean(repair_id);
|
||||
|
||||
cnbean.setRepair_id(repair_id);
|
||||
|
||||
//cnbean.setRepair_address(repair_address);
|
||||
//cnbean.setRepair_info(repair_info);
|
||||
// cnbean.setRepair_cost(rs.getString("repair_cost"));
|
||||
//cnbean.setRepair_tel(repair_tel);
|
||||
// cnbean=new RepairDao().GetBean(repair_id);
|
||||
cnbean.setRepair_status(repair_status);
|
||||
// if(!(isInvalid(repair_status)))
|
||||
//{
|
||||
// cnbean.setRepair_status(repair_status);
|
||||
// }
|
||||
new RepairDao().Update(cnbean);
|
||||
|
||||
//跳转
|
||||
out.print("<script language='javascript'>alert('修改成功!');window.location='RepairManager.action';</script>");
|
||||
out.flush();out.close();return null;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.StudentBean;
|
||||
import com.dao.StudentDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class StudentAddSave extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private String Student_Username ;
|
||||
private String Student_Password ;
|
||||
private String Student_Name ;
|
||||
private String Student_Sex ;
|
||||
private String Student_Class ;
|
||||
public String getStudent_Username() {
|
||||
return Student_Username;
|
||||
}
|
||||
|
||||
public void setStudent_Username(String studentUsername) {
|
||||
Student_Username = studentUsername;
|
||||
}
|
||||
|
||||
public String getStudent_Password() {
|
||||
return Student_Password;
|
||||
}
|
||||
|
||||
public void setStudent_Password(String studentPassword) {
|
||||
Student_Password = studentPassword;
|
||||
}
|
||||
|
||||
public String getStudent_Name() {
|
||||
return Student_Name;
|
||||
}
|
||||
|
||||
public void setStudent_Name(String studentName) {
|
||||
Student_Name = studentName;
|
||||
}
|
||||
|
||||
public String getStudent_Sex() {
|
||||
return Student_Sex;
|
||||
}
|
||||
|
||||
public void setStudent_Sex(String studentSex) {
|
||||
Student_Sex = studentSex;
|
||||
}
|
||||
|
||||
public String getStudent_Class() {
|
||||
return Student_Class;
|
||||
}
|
||||
|
||||
public void setStudent_Class(String studentClass) {
|
||||
Student_Class = studentClass;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询用户名是否存在
|
||||
List<StudentBean> list=new StudentDao().GetList("Student_Username='"+Student_Username+"'", "");
|
||||
if(list.size()>0)
|
||||
{
|
||||
out.print("<script language='javascript'>alert('用户名已经存在!');history.back(-1);</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
//添加
|
||||
StudentBean cnbean=new StudentBean();
|
||||
cnbean.setStudent_Username(Student_Username);
|
||||
cnbean.setStudent_Password(Student_Password);
|
||||
cnbean.setStudent_Name(Student_Name);
|
||||
cnbean.setStudent_Sex(Student_Sex);
|
||||
cnbean.setStudent_Class(Student_Class);
|
||||
cnbean.setStudent_State("未入住");
|
||||
cnbean.setStudent_DomitoryID(1);
|
||||
new StudentDao().Add(cnbean);
|
||||
|
||||
//跳转
|
||||
out.print("<script language='javascript'>alert('添加成功!');window.location='StudentManager.action';</script>");
|
||||
out.flush();out.close();return null;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.action;
|
||||
|
||||
import com.dao.StudentDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
public class StudentDel extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private int Student_ID ;
|
||||
public int getStudent_ID() {
|
||||
return Student_ID;
|
||||
}
|
||||
|
||||
public void setStudent_ID(int userID) {
|
||||
Student_ID = userID;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
|
||||
//删除
|
||||
new StudentDao().Delete(Student_ID);
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.StudentBean;
|
||||
import com.dao.StudentDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class StudentManager extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private List<StudentBean> list;
|
||||
private int a;
|
||||
|
||||
public int getA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public void setA(int a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public List<StudentBean> getList() {
|
||||
return list;
|
||||
}
|
||||
public void setList(List<StudentBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
private String SearchRow;
|
||||
private String SearchKey;
|
||||
private String State;
|
||||
public String getState() {
|
||||
return State;
|
||||
}
|
||||
public void setState(String state) {
|
||||
State = state;
|
||||
}
|
||||
public String getSearchRow() {
|
||||
return SearchRow;
|
||||
}
|
||||
public void setSearchRow(String searchRow) {
|
||||
SearchRow = searchRow;
|
||||
}
|
||||
public String getSearchKey() {
|
||||
return SearchKey;
|
||||
}
|
||||
public void setSearchKey(String searchKey) {
|
||||
SearchKey = searchKey;
|
||||
}
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
//查询条件
|
||||
String strWhere="1=1";
|
||||
if(!(isInvalid(SearchKey)))
|
||||
{
|
||||
strWhere+=" and "+SearchRow+"='"+SearchKey+"'";
|
||||
}
|
||||
if(!(isInvalid(State)))
|
||||
{
|
||||
strWhere+=" and Student_State='"+State+"'";
|
||||
}
|
||||
else
|
||||
{strWhere+="and Student_State='入住'";}
|
||||
//查询所有楼宇
|
||||
//List<StudentBean> list;
|
||||
if(session.getAttribute("number111")==null){
|
||||
|
||||
a=1;
|
||||
list=new StudentDao().GetAllList1(a);}
|
||||
else
|
||||
|
||||
//查询所有
|
||||
list=new StudentDao().GetList("","Student_Name");
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.StudentBean;
|
||||
import com.dao.StudentDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
public class StudentUpdate extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private String Student_ID;
|
||||
private StudentBean cnbean;
|
||||
public String getStudent_ID() {
|
||||
return Student_ID;
|
||||
}
|
||||
|
||||
public void setStudent_ID(String studentID) {
|
||||
Student_ID = studentID;
|
||||
}
|
||||
|
||||
public StudentBean getCnbean() {
|
||||
return cnbean;
|
||||
}
|
||||
|
||||
public void setCnbean(StudentBean cnbean) {
|
||||
this.cnbean = cnbean;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询
|
||||
cnbean=new StudentDao().GetBean(Integer.parseInt(Student_ID));
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.StudentBean;
|
||||
import com.dao.StudentDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class StudentUpdateSave extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private String Student_ID ;
|
||||
private String Student_Username ;
|
||||
private String Student_Password ;
|
||||
private String Student_Name ;
|
||||
private String Student_Sex ;
|
||||
private String Student_Class ;
|
||||
public String getStudent_ID() {
|
||||
return Student_ID;
|
||||
}
|
||||
|
||||
public void setStudent_ID(String studentID) {
|
||||
Student_ID = studentID;
|
||||
}
|
||||
|
||||
public String getStudent_Username() {
|
||||
return Student_Username;
|
||||
}
|
||||
|
||||
public void setStudent_Username(String studentUsername) {
|
||||
Student_Username = studentUsername;
|
||||
}
|
||||
|
||||
public String getStudent_Password() {
|
||||
return Student_Password;
|
||||
}
|
||||
|
||||
public void setStudent_Password(String studentPassword) {
|
||||
Student_Password = studentPassword;
|
||||
}
|
||||
|
||||
public String getStudent_Name() {
|
||||
return Student_Name;
|
||||
}
|
||||
|
||||
public void setStudent_Name(String studentName) {
|
||||
Student_Name = studentName;
|
||||
}
|
||||
|
||||
public String getStudent_Sex() {
|
||||
return Student_Sex;
|
||||
}
|
||||
|
||||
public void setStudent_Sex(String studentSex) {
|
||||
Student_Sex = studentSex;
|
||||
}
|
||||
|
||||
public String getStudent_Class() {
|
||||
return Student_Class;
|
||||
}
|
||||
|
||||
public void setStudent_Class(String studentClass) {
|
||||
Student_Class = studentClass;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询用户名是否存在
|
||||
List<StudentBean> list=new StudentDao().GetList("Student_Username='"+Student_Username+"' and Student_ID!="+Student_ID, "");
|
||||
if(list.size()>0)
|
||||
{
|
||||
out.print("<script language='javascript'>alert('用户名已经存在!');history.back(-1);</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
//修改
|
||||
|
||||
StudentBean cnbean=new StudentBean();
|
||||
cnbean=new StudentDao().GetAllBean(Integer.parseInt(Student_ID));
|
||||
cnbean.setStudent_Username(Student_Username);
|
||||
cnbean.setStudent_Name(Student_Name);
|
||||
cnbean.setStudent_Sex(Student_Sex);
|
||||
cnbean.setStudent_Class(Student_Class);
|
||||
if(!(isInvalid(Student_Password)))
|
||||
{
|
||||
cnbean.setStudent_Password(Student_Password);
|
||||
}
|
||||
new StudentDao().Update(cnbean);
|
||||
|
||||
//跳转
|
||||
out.print("<script language='javascript'>alert('修改成功!');window.location='StudentManager.action';</script>");
|
||||
out.flush();out.close();return null;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.TeacherBean;
|
||||
import com.dao.TeacherDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class TeacherAddSave extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private String Teacher_Username ;
|
||||
private String Teacher_Password ;
|
||||
private String Teacher_Name ;
|
||||
private String Teacher_Sex ;
|
||||
private String Teacher_Tel ;
|
||||
|
||||
public String getTeacher_Username() {
|
||||
return Teacher_Username;
|
||||
}
|
||||
|
||||
public void setTeacher_Username(String cookUsername) {
|
||||
Teacher_Username = cookUsername;
|
||||
}
|
||||
|
||||
public String getTeacher_Password() {
|
||||
return Teacher_Password;
|
||||
}
|
||||
|
||||
public void setTeacher_Password(String cookPassword) {
|
||||
Teacher_Password = cookPassword;
|
||||
}
|
||||
|
||||
public String getTeacher_Name() {
|
||||
return Teacher_Name;
|
||||
}
|
||||
|
||||
public void setTeacher_Name(String cookName) {
|
||||
Teacher_Name = cookName;
|
||||
}
|
||||
|
||||
public String getTeacher_Sex() {
|
||||
return Teacher_Sex;
|
||||
}
|
||||
|
||||
public void setTeacher_Sex(String cookSex) {
|
||||
Teacher_Sex = cookSex;
|
||||
}
|
||||
|
||||
public String getTeacher_Tel() {
|
||||
return Teacher_Tel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询用户名是否存在
|
||||
List<TeacherBean> list=new TeacherDao().GetList("Teacher_Username='"+Teacher_Username+"'", "");
|
||||
if(list.size()>0)
|
||||
{
|
||||
out.print("<script language='javascript'>alert('用户名已经存在!');history.back(-1);</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
//添加
|
||||
TeacherBean cnbean=new TeacherBean();
|
||||
cnbean.setTeacher_Username(Teacher_Username);
|
||||
cnbean.setTeacher_Password(Teacher_Password);
|
||||
cnbean.setTeacher_Name(Teacher_Name);
|
||||
cnbean.setTeacher_Sex(Teacher_Sex);
|
||||
cnbean.setTeacher_Tel(Teacher_Tel);
|
||||
|
||||
new TeacherDao().Add(cnbean);
|
||||
//跳转
|
||||
out.print("<script language='javascript'>alert('添加成功!');window.location='TeacherManager.action';</script>");
|
||||
out.flush();out.close();return null;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.action;
|
||||
|
||||
import com.dao.TeacherDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
public class TeacherDel extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
|
||||
private int Teacher_ID;
|
||||
|
||||
|
||||
public int getTeacher_ID() { return Teacher_ID; }
|
||||
|
||||
public void setTeacher_ID(int userID) {
|
||||
Teacher_ID= userID;
|
||||
}
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
|
||||
//删除
|
||||
new TeacherDao().Delete(Teacher_ID);
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.TeacherBean;
|
||||
import com.dao.TeacherDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class TeacherManager extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private List<TeacherBean> list;
|
||||
public List<TeacherBean> getList() {
|
||||
return list;
|
||||
}
|
||||
public void setList(List<TeacherBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
private String SearchRow;
|
||||
private String SearchKey;
|
||||
public String getSearchRow() {
|
||||
return SearchRow;
|
||||
}
|
||||
public void setSearchRow(String searchRow) {
|
||||
SearchRow = searchRow;
|
||||
}
|
||||
public String getSearchKey() {
|
||||
return SearchKey;
|
||||
}
|
||||
public void setSearchKey(String searchKey) {
|
||||
SearchKey = searchKey;
|
||||
}
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
//查询条件
|
||||
String strWhere="1=1";
|
||||
if(!(isInvalid(SearchKey)))
|
||||
{
|
||||
strWhere+=" and "+SearchRow+"='"+SearchKey+"'";
|
||||
}
|
||||
//查询所有
|
||||
list=new TeacherDao().GetList(strWhere,"Teacher_Name");
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.TeacherBean;
|
||||
import com.dao.TeacherDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
public class TeacherUpdate extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private String Teacher_ID;
|
||||
private TeacherBean cnbean;
|
||||
public String getTeacher_ID() {
|
||||
return Teacher_ID;
|
||||
}
|
||||
|
||||
public void setTeacher_ID(String studentID) {
|
||||
Teacher_ID = studentID;
|
||||
}
|
||||
|
||||
public TeacherBean getCnbean() {
|
||||
return cnbean;
|
||||
}
|
||||
|
||||
public void setCnbean(TeacherBean cnbean) {
|
||||
this.cnbean = cnbean;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询
|
||||
cnbean=new TeacherDao().GetBean(Integer.parseInt(Teacher_ID));
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.TeacherBean;
|
||||
import com.dao.TeacherDao;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class TeacherUpdateSave extends ActionSupport {
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private String Teacher_ID ;
|
||||
private String Teacher_Username ;
|
||||
private String Teacher_Password ;
|
||||
private String Teacher_Name ;
|
||||
private String Teacher_Sex ;
|
||||
private String Teacher_Tel ;
|
||||
public String getTeacher_ID() {
|
||||
return Teacher_ID;
|
||||
}
|
||||
|
||||
public void setTeacher_ID(String cookID) {
|
||||
Teacher_ID = cookID;
|
||||
}
|
||||
|
||||
public String getTeacher_Username() {
|
||||
return Teacher_Username;
|
||||
}
|
||||
|
||||
public void setTeacher_Username(String cookUsername) {
|
||||
Teacher_Username = cookUsername;
|
||||
}
|
||||
|
||||
public String getTeacher_Password() {
|
||||
return Teacher_Password;
|
||||
}
|
||||
|
||||
public void setTeacher_Password(String cookPassword) {
|
||||
Teacher_Password = cookPassword;
|
||||
}
|
||||
|
||||
public String getTeacher_Name() {
|
||||
return Teacher_Name;
|
||||
}
|
||||
|
||||
public void setTeacher_Name(String cookName) {
|
||||
Teacher_Name = cookName;
|
||||
}
|
||||
|
||||
public String getTeacher_Sex() {
|
||||
return Teacher_Sex;
|
||||
}
|
||||
|
||||
public void setTeacher_Sex(String cookSex) {
|
||||
Teacher_Sex = cookSex;
|
||||
}
|
||||
|
||||
public String getTeacher_Tel() {
|
||||
return Teacher_Tel;
|
||||
}
|
||||
|
||||
public void setTeacher_Tel(String cookTel) {
|
||||
Teacher_Tel = cookTel;
|
||||
}
|
||||
|
||||
//处理用户请求的execute方法
|
||||
public String execute() throws Exception {
|
||||
|
||||
//解决乱码,用于页面输出
|
||||
HttpServletResponse response=null;
|
||||
response=ServletActionContext.getResponse();
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
//创建session对象
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
//验证是否正常登录
|
||||
if(session.getAttribute("id")==null){
|
||||
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
|
||||
//查询用户名是否存在
|
||||
List<TeacherBean> list=new TeacherDao().GetList("Teacher_Username='"+Teacher_Username+"' and Teacher_ID!="+Teacher_ID, "");
|
||||
if(list.size()>0)
|
||||
{
|
||||
out.print("<script language='javascript'>alert('用户名已经存在!');history.back(-1);</script>");
|
||||
out.flush();out.close();return null;
|
||||
}
|
||||
//修改
|
||||
|
||||
TeacherBean cnbean=new TeacherBean();
|
||||
cnbean=new TeacherDao().GetBean(Integer.parseInt(Teacher_ID));
|
||||
cnbean.setTeacher_Username(Teacher_Username);
|
||||
cnbean.setTeacher_Name(Teacher_Name);
|
||||
cnbean.setTeacher_Sex(Teacher_Sex);
|
||||
cnbean.setTeacher_Tel(Teacher_Tel);
|
||||
if(!(isInvalid(Teacher_Password)))
|
||||
{
|
||||
cnbean.setTeacher_Password(Teacher_Password);
|
||||
}
|
||||
new TeacherDao().Update(cnbean);
|
||||
|
||||
//跳转
|
||||
out.print("<script language='javascript'>alert('修改成功!');window.location='RepairManager.action';</script>");
|
||||
out.flush();out.close();return null;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
//测试
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue