⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trainaccess.cs

📁 用C#编写的实现火车查询功能的程序功能比较完整
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using TrainSystem.Common;
using System.Data;

namespace TrainSystem.Access
{
    public class TrainAccess
    {
        private DataBaseOperate DBOperate = null;
        DataSet ds = new DataSet();
        public TrainAccess()
        {
            DBOperate = new DataBaseOperate();
            
        }

        public DataSet SelectNonstop(string StarCity,string EndCity)
        {
            string sql;
            sql = "select * from trainlist where traincode in("+
                    "select traincode from  trainDetails ta "+
                    "where cityname='" + EndCity + "' and traincode in(" +
                    "select traincode from  trainDetails tb where cityname='" + StarCity + "' and ta.trainid>tb.trainid))";

            
            try
            {
                ds = DBOperate.Search(sql, "trainlist");
            }
            catch (Exception ex)
            {
                throw ex ; 
            }
            return ds;
        }

        public DataSet SelectChangeTrains(string StarCity,string EndCity)
        {
            string sql;
            sql = "select distinct cityname from  TrainDetails where TrainCode in(" +
            "select TrainCode from  TrainDetails where cityname='" + EndCity + "') and " +
            "cityname<>'" + EndCity + "' and cityname in(select distinct cityname from  TrainDetails " +
            "where TrainCode in(select TrainCode from  TrainDetails " +
            "where cityname='" + StarCity + "') and cityname<>'" + StarCity + "')";
            
            try
            {
                ds = DBOperate.Search(sql, "TrainDetails");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ds;

        }


        public DataSet SelectTrainInfo(string traincode)
        {
            string sql;
            sql = "select * from traindetails where traincode='"+traincode+"'";
           
            try
            {
                ds = DBOperate.Search(sql, "traindetails");
            }
            catch ( Exception ex)
            {
                
                throw ex;
            }
            return ds;
        }
        public DataSet SelectTrainCode(string traincode)
        {
            string sql;
            sql = "select * from trainlist where traincode='" + traincode + "'";
           
            try
            {
                ds = DBOperate.Search(sql, "traindetails");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ds;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -