You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.0 KiB
142 lines
4.0 KiB
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();
|
|
}
|
|
|
|
}
|