📄 trainbussiness1.cs
字号:
using System;
using DataAccess;
using System.Data;
using BusinessRule.Table;
using BusinessRule.Tables;
namespace BusinessRule.TablesBusines
{
/// <summary>
/// TrainBussiness1 的摘要说明。
/// </summary>
public class TrainBussiness1
{
DataAccessInfo access = new DataAccessInfo();
/// <summary>
/// 根据始发站和终点站获得车次的详细信息
/// </summary>
/// <param name="schedule"></param>
/// <returns></returns>
public DataSet GetScheInfoByCity(T_schedule schedule)
{
DataSet ds = new DataSet();
//编写查询车次的SQL语句
string sql = string.Format("select schedulecode as '车次',fromcity as '始发站',tocity as '终点站',distance as '里程',leavetime as '开车时间',speed as '类型',票价=case "+
"when speed='普快' then distance/100*10 "+
"when speed='特快' then distance/100*10*2 "+
"when speed='快速' then distance/100*10*1.2 "+
"end "+
"from t_schedule where fromcity='{0}' and tocity='{1}'", schedule.Fromcity, schedule.Tocity);
//调用数据访问层的方法
ds = access.GetDataSet(sql);
return ds;
}
/// <summary>
/// 查询中转站
/// </summary>
/// <returns></returns>
public DataSet GetZhongZhuanzhan(string from,string to)
{
DataSet ds=new DataSet();
//编写SQL语句
string sql=string.Format("select a.schedulecode as '车次',b.cityname as '中转站'"+
" from t_schedule_detail a,t_schedule_detail b "+
"where a.schedulecode=b.schedulecode and a.cityname='{0}' and b.cityname in ("+
"select cityname from t_schedule_detail "+
"where cityname <> '{0}' and schedulecode in ("+
"select schedulecode from t_schedule_detail where cityname='{1}'))",from,to);
//调用数据访问层的方法
ds=access.GetDataSet(sql);
return ds;
}
public DataSet GetCityName(string fromcity,string zhongzhuan,string tocity)
{
DataSet ds=new DataSet();
string sql = string.Format( "select a.schedulecode as '车次' ,a.cityname as '起始站',b.cityname as '到达站',b.numofschedule-a.numofschedule as '经过站数',票价=case "+
" when T_schedule.speed='普快' then T_schedule.distance/100*10" +
" when T_schedule.speed='特快' then T_schedule.distance/100*10*2" +
" when T_schedule.speed='快速' then T_schedule.distance/100*10*1.2 end " +
"from T_schedule,t_schedule_detail a,t_schedule_detail b " +
" where a.schedulecode=b.schedulecode and a.cityname='{0}' and b.cityname='{1}' " +
"select a.schedulecode as '车次', a.cityname as '起始站',b.cityname as '到达站' ,b.numofschedule-a.numofschedule as '经过站数' ,票价=case "+
" when T_schedule.speed='普快' then T_schedule.distance/100*10 " +
" when T_schedule.speed='特快' then T_schedule.distance/100*10*2 " +
" when T_schedule.speed='快速' then T_schedule.distance/100*10*1.2 end " +
" from T_schedule,t_schedule_detail a,t_schedule_detail b " +
" where a.schedulecode=b.schedulecode and a.cityname='{1}' and b.cityname='{2}' ", fromcity, zhongzhuan, tocity);
//调用数据访问层的方法
ds=access.GetDataSet(sql);
return ds;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -