parent
c384633a04
commit
e675da40ad
@ -0,0 +1,86 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.electric_addBean;
|
||||
import com.dao.electriDao;
|
||||
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 electricAdd extends ActionSupport {
|
||||
private int Electric_ID;
|
||||
private String Electric_Dormitory_Number;
|
||||
private String Electric_Residual;
|
||||
private String Edate;
|
||||
public int getElectric_ID() {
|
||||
return Electric_ID;
|
||||
}
|
||||
|
||||
public void setElectric_ID(int Electric_ID) {
|
||||
this.Electric_ID = Electric_ID;
|
||||
}
|
||||
|
||||
public String getElectric_Dormitory_Number() {
|
||||
return Electric_Dormitory_Number;
|
||||
}
|
||||
|
||||
public void setElectric_Dormitory_Number(String Dormitory_Number) {
|
||||
this.Electric_Dormitory_Number = Electric_Dormitory_Number;
|
||||
}
|
||||
|
||||
public String getElectric_Residual() {
|
||||
return Electric_Residual;
|
||||
}
|
||||
|
||||
public void setElectric_Residual(String Electric_Residual) {
|
||||
this.Electric_Residual = Electric_Residual;
|
||||
}
|
||||
|
||||
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='electricAdd.jsp';</script>");
|
||||
out.flush();
|
||||
out.close();
|
||||
return null;
|
||||
}
|
||||
long l = System.currentTimeMillis();
|
||||
Date date = new Date(l);
|
||||
//转换提日期输出格式
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Edate=dateFormat.format(date);
|
||||
Electric_ID=1;
|
||||
Electric_Dormitory_Number="01-1-101";
|
||||
Electric_Residual="46";
|
||||
electric_addBean cnbean=new electric_addBean();
|
||||
cnbean.setElectric_ID(Electric_ID);
|
||||
cnbean.setElectric_Dormitory_Number(Electric_Dormitory_Number);
|
||||
cnbean.setElectric_Residual(Electric_Residual);
|
||||
new electriDao().Add(cnbean);
|
||||
|
||||
//跳转
|
||||
out.print("<script language='javascript'>alert('添加成功!');window.location='StudentManager.action.action';</script>");
|
||||
out.flush();out.close();return null;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.electric_addBean;
|
||||
import com.dao.electriDao;
|
||||
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 electricManager extends ActionSupport {
|
||||
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private List<electric_addBean> list;
|
||||
|
||||
|
||||
public List<electric_addBean> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<electric_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;
|
||||
}
|
||||
|
||||
//处理用户请求的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='入住'";
|
||||
// }
|
||||
//查询所有
|
||||
if(session.getAttribute("type").toString().equals("3")){ 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 electriDao().GetList(strWhere, "Electric_Dormitory_Number");
|
||||
|
||||
return ERROR;}
|
||||
else{
|
||||
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 electriDao().GetList(strWhere, "Electric_Dormitory_Number");
|
||||
|
||||
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,79 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.electric_addBean;
|
||||
import com.dao.electriDao;
|
||||
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 electricUpdatesave extends ActionSupport {
|
||||
private int Electric_ID;
|
||||
private String Electric_Dormitory_Number;
|
||||
private String Electric_Residual;
|
||||
public int getElectric_ID() {
|
||||
return Electric_ID;
|
||||
}
|
||||
|
||||
public void setElectric_ID(int studentID) {
|
||||
this.Electric_ID = studentID;
|
||||
}
|
||||
|
||||
public String getElectric_Dormitory_Number() {
|
||||
return Electric_Dormitory_Number;
|
||||
}
|
||||
|
||||
public void setElectric_Dormitory_Number(String studentDormitory_Number) {
|
||||
this. Electric_Dormitory_Number = studentDormitory_Number;
|
||||
}
|
||||
|
||||
|
||||
public String getElectric_Residual() {
|
||||
return Electric_Residual;
|
||||
}
|
||||
public void setElectric_Residual(String studentResidual) { this.Electric_Residual = studentResidual;
|
||||
}
|
||||
|
||||
//处理用户请求的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;
|
||||
}
|
||||
electric_addBean cnbean=new electric_addBean();
|
||||
cnbean= new electriDao().GetBean(Electric_ID);
|
||||
cnbean.setElectric_ID(Electric_ID);
|
||||
cnbean.setElectric_Dormitory_Number(Electric_Dormitory_Number);
|
||||
cnbean.setElectric_Residual(Electric_Residual);
|
||||
|
||||
|
||||
/*if(!(isInvalid(Student_Password)))
|
||||
{
|
||||
cnbean.setStudent_Password(Student_Password);
|
||||
}*/
|
||||
new electriDao().Update(cnbean);
|
||||
|
||||
//跳转
|
||||
out.print("<script language='javascript'>alert('修改成功!');window.location='electricManager.action';</script>");
|
||||
out.flush();out.close();return null;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
private boolean isInvalid(String value) {
|
||||
return (value == null || value.length() == 0);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.action;
|
||||
|
||||
import com.bean.electric_addBean;
|
||||
import com.dao.electriDao;
|
||||
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 electricupdate extends ActionSupport{
|
||||
|
||||
//下面是Action内用于封装用户请求参数的属性
|
||||
private int Electric_ID;
|
||||
|
||||
private electric_addBean cnbean;
|
||||
public int getElectric_ID() {
|
||||
return Electric_ID;
|
||||
}
|
||||
|
||||
public void setElectric_ID(int Electric_ID) {
|
||||
this.Electric_ID= Electric_ID;
|
||||
}
|
||||
|
||||
public electric_addBean getCnbean() {
|
||||
return cnbean;
|
||||
}
|
||||
|
||||
public void setCnbean(electric_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;
|
||||
}
|
||||
|
||||
//查询
|
||||
cnbean=new electriDao().GetBean(Electric_ID);
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//判断是否空值
|
||||
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