package dp.admin.svlt; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import dp.utils.DbConn; import net.sf.json.JSONObject; public class Del extends HttpServlet { /** * Constructor of the object. */ public Del() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //设置传输数据编码方式 request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html"); HttpSession session=request.getSession(); //获取当前登录用户信息 Object utype=session.getAttribute("utype"); Object userid=session.getAttribute("userid"); //创建json对象 JSONObject json=new JSONObject(); if(utype==null||userid==null){ json.put("msg", "请重新登陆。"); return; } //获取前台数据tname String tname=request.getParameter("tname"); //创建数据库操作对象 DbConn db=new DbConn(); //管理员信息删除 if("admin".equals(tname)){ String ids=request.getParameter("idi"); int bls=db.deleteOrUpdate("delete from userinfo where id="+ids); if(bls>0){ json.put("msg", 1); }else{ json.put("msg", "删除失败"); } } //顾客信息删除 if("cusinfo".equals(tname)){ String ids=request.getParameter("idi"); Object cidcard=db.getOnlyOne("select cidcard from cusinfo where id="+ids); int bls=db.deleteOrUpdate("delete from cusinfo where id="+ids); if(bls>0){ json.put("msg", 1); //顾客信息删除,同时情况,其购票信息 db.deleteOrUpdate("delete from dpiao where cidcard="+cidcard); }else{ json.put("msg", "删除失败"); } } //火车信息删除 if("traininfo".equals(tname)){ String ids=request.getParameter("idi"); if(db.checkTrue("select id from piao where tid="+ids)){ json.put("msg", "该列车有票务信息存在不能删除."); }else if(db.checkTrue("select id from xianlu where tid="+ids)){ json.put("msg", "该火车有线路信息存在不能删除."); }else{ int bls=db.deleteOrUpdate("delete from traininfo where id="+ids); if(bls>0){ json.put("msg", 1); }else{ json.put("msg", "删除失败"); } } } //站点信息删除 if("zhandian".equals(tname)){ String ids=request.getParameter("idi"); if(db.checkTrue("select id from xianlu where zdid="+ids)){ json.put("msg", "该站点有线路信息存在不能删除."); }else{ int bls=db.deleteOrUpdate("delete from zhandian where id="+ids); if(bls>0){ json.put("msg", 1); }else{ json.put("msg", "删除失败"); } } } //线路信息删除 if("xianlu".equals(tname)){ String zdid=request.getParameter("zdid"); String tid=request.getParameter("tid"); int bls=db.deleteOrUpdate("delete from xianlu where zdid="+zdid+" and tid="+tid); if(bls>0){ json.put("msg", 1); }else{ json.put("msg", "删除失败"); } } //车票信息删除 if("piao".equals(tname)){ String id=request.getParameter("idi"); int bls=db.deleteOrUpdate("delete from piao where id="+id); if(bls>0){ json.put("msg", 1); }else{ json.put("msg", "删除失败"); } } PrintWriter out=response.getWriter(); out.print(json.toString()); out.flush(); out.close(); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } }

2072376767 LV2
2024年12月26日
ma406805131 LV19
2024年12月26日
李朝磊 LV18
2024年12月16日
sword_1 LV1
2024年11月16日
微信网友_6444139264921600 LV8
2024年7月1日
zdysql LV2
2024年6月26日
zeng1206 LV7
2024年6月15日
pangzhihui LV14
2024年2月22日
2244193927 LV1
2023年12月26日
天下第一无双 LV1
2023年12月10日

yeligui123456
3月12日
暂无贡献等级
ma406805131 LV19
2024年12月26日
2072376767 LV2
2024年12月25日
zjjxy2312040436
2024年12月23日
暂无贡献等级
李朝磊 LV18
2024年12月16日
xxx-123456
2024年12月13日
暂无贡献等级
gjthxlcc
2024年11月28日
暂无贡献等级
sword_1 LV1
2024年11月16日
fisher_x
2024年9月10日
暂无贡献等级
微信网友_6444139264921600 LV8
2024年7月1日