📄 servetrain.java
字号:
/*
*
*/
import java.io.*;
import java.text.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
*
* @author Chen Xin Wu
*/
public class ServeTrain extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
HtmlOut htmlOut = new HtmlOut (response);
// 得到名字和口令
String name,pass;
Person person = new Person();
person.setName (CommonMethods.GetUserName(request));
pass = CommonMethods.GetUserPass (request);
if( person.getName ()==null || (!person.checkPassword(pass)) )
{
htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
"请先登录!","Login?action=reLog");
htmlOut.outHtml();
return;
}
TrainChannel cn = (TrainChannel)CommonMethods.FindChannel("train");
if( cn == null ){
htmlOut.setErrorID (htmlOut.CHANNEL_NOT_FIND ,"",
"Train Channel not found","EditChannel?channel=train");
htmlOut.outHtml();
return;
}
String shijian_delete,trainid,station,ccrq,tqtx,methodName,trainid_delete;
String station_delete,station_start,jdrm;
//用户触发的动作名
methodName = request.getParameter("action");
//车次
trainid = request.getParameter("trainid");
//下车站
station=CommonMethods.getParameterValue (request,"station");
//乘车站
station_start=CommonMethods.getParameterValue (request,"station_start");
//乘车日期
ccrq=request.getParameter ("ccrq");
//提前时间
tqtx=request.getParameter ("tqtx");
//用户根据车次删除
trainid_delete= request.getParameter("trainid_delete");
//用户根据下车站删除
station_delete=CommonMethods.getParameterValue (request,"station_delete");
//接待人名
jdrm=CommonMethods.getParameterValue (request,"jdrm");
//用户根据时间删除
shijian_delete=CommonMethods.getParameterValue (request,"shijian_delete");
boolean b;
b = true;
//添加
if(methodName.compareTo("add")==0)
{
b = cn.addTrain(jdrm,trainid,station,station_start,ccrq,tqtx,person,htmlOut);
if( b==false ){
htmlOut.outHtml ();
return;
}
htmlOut.setRedirect ("EditChannel?channel=train");
}
//删除
if(methodName.compareTo("delete")==0)
{
b = cn.deleteTrain(shijian_delete,trainid_delete,station_delete,person,htmlOut);
if( b==false ){
htmlOut.outHtml ();
return;
}
htmlOut.setRedirect ("EditChannel?channel=train");
}
//
if(methodName.compareTo("tx")==0)
{
b = cn.makeTX(person,htmlOut,request);
if( b==false ){
htmlOut.outHtml();
return;
}
//htmlOut.setRedirect ("EditChannel?channel=stock");
}
htmlOut.outHtml ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -