📄 zhandian_procedure.java
字号:
//后台处理,用于zhandian.jsp的处理
package gongjiaochexitong.gongjiaoche.zhandian_pkg;
import gongjiaochexitong.gongjiaoche.*;
import java.sql.*;
import java.util.Vector;
public class zhandian_procedure { //后台处理(站点列表 + 车次列表)
//将站点名取出显示在列表栏中,以字符串的形式
public static String showZhanDianList(Vector resultList){
String result="\n";
stationinfo station=new stationinfo();
for(int i=0;i<resultList.size();i++){
station = (stationinfo)resultList.get(i);
result=result+station.getStationName()+"\n";
}
return result;
}
//查询数据库有此站点
public static boolean isExistZhangDian(conn_Bus db,String zhandian) throws Exception{
boolean result=false;
ResultSet rs=null;
String sql="select * from stationinfo where stationName='"+zhandian+"'";
rs=db.exeQuery(sql);
if(rs.next()) result=true;
return result;
}
//添加站点
public static int addZhanDian(conn_Bus db,String zhandian,String msg[]) throws Exception{
int result=0;
String sql ="insert into stationinfo(stationName) values('"+zhandian+"')";
if(!isExistZhangDian(db,zhandian)){
result = db.exeUpdate(sql);
}
else{
//插入的站点已经存在
msg[0]="label.zhandian_insertedStationExist"; //字符串数组进行参数传递
}
return result;
}
//删除站点
public static int deleteZhanDian(conn_Bus db,String zhandian,String msg[]) throws Exception{
int result=0;
String sql="delete from stationinfo where stationName='"+zhandian+"'";
if(isExistZhangDian(db,zhandian)){
result = db.exeUpdate(sql);
}
else{
msg[0]="label.zhandian_deleteStationNull";
}
return result;
}
//修改站点
public static int modifyZhanDian(conn_Bus db,String zhandian_old,
String zhandian_new,String msg[]) throws Exception{
int result=0;
String sql="update stationinfo set stationName='"+zhandian_new+"' "
+"where stationName='"+zhandian_old+"'";
if(isExistZhangDian(db,zhandian_old) && !isExistZhangDian(db,zhandian_new)){
result = db.exeUpdate(sql);
}
else if(!isExistZhangDian(db,zhandian_old)){
//要修改的站点不存在,无法进行修改
msg[0]="label.zhandian_modifyBeforeStationNull";
}
else if(isExistZhangDian(db,zhandian_new)){
//修改后的站点出现重复
msg[0]="label.zhandian_modifyAfterStationExist";
}
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -