Ejemplo n.º 1
0
        /// <summary>
        /// 查询列车运行线路信息,为DateGridView绑定数据源
        /// </summary>
        /// <returns></returns>
        public List <DateView> SelectGridViewStation()
        {
            SqlDataReader   reader = null;
            DateView        view   = null;
            List <DateView> list   = new List <DateView>();
            SqlConnection   con    = SqlConnect.getConn();

            try
            {
                String     selectGVStr = "select StationName,StationEnName,StationStopTime,StationLng,StationLat,StationDistance from WorkingLine order by SubjectStation asc";
                SqlCommand command     = con.CreateCommand();// 绑定SqlConnection对象
                command.CommandText = selectGVStr;
                con.Open();
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    view = new DateView()
                    {
                        StationName   = reader.GetString(0),
                        StationEnName = reader.GetString(1),
                        stopTime      = reader.GetInt32(2),
                        lng           = reader.GetDouble(3),
                        lat           = reader.GetDouble(4),
                        distance      = reader.GetDouble(5)
                    };
                    list.Add(view);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("查询线路信息失败");
            }
            finally
            {
                reader.Close();
                con.Close();
            }
            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查询某一站后面所有站点的隶属站次
        /// </summary>
        /// <param name="substation"></param>某一站的隶属站次
        /// <returns></returns>
        public List <Common> SelectSubStation(int substation)
        {
            SqlDataReader reader = null;
            Common        comm   = null;
            List <Common> list   = new List <Common>();
            SqlConnection con    = SqlConnect.getConn();

            try
            {
                String     selectAllSubStr = "select StationName,SubjectStation from WorkingLine where SubjectStation > @SUBSTATION";
                SqlCommand command         = con.CreateCommand();// 绑定SqlConnection对象
                command.CommandText = selectAllSubStr;
                con.Open();
                command.Parameters.AddWithValue("@SUBSTATION", substation);
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    comm = new Common()
                    {
                        StationName    = reader.GetString(0),
                        SubjectStation = reader.GetInt32(1)
                    };

                    list.Add(comm);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("查询隶属站次数组失败");
            }
            finally
            {
                reader.Close();
                con.Close();
            }
            return(list);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除站点
        /// </summary>
        /// <param name="name"></param>站点名称
        public void deleteSta(String name)
        {
            SqlConnection con = SqlConnect.getConn();

            try
            {
                String     deleteStr = "delete from WorkingLine where StationName=@STATIONNAME";
                SqlCommand command   = con.CreateCommand();// 绑定SqlConnection对象
                command.CommandText = deleteStr;
                con.Open();
                command.Parameters.AddWithValue("@STATIONNAME", name);
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("删除站点失败");
            }
            finally
            {
                con.Close();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据选怎的语音类型查询对应的语音内容
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public List <SpeechModel> SelectSp(string type)
        {
            SqlDataReader      reader = null;
            SpeechModel        SM     = null;
            List <SpeechModel> list   = new List <SpeechModel>();
            SqlConnection      con    = SqlConnect.getConn();

            try
            {
                String     selectSpStr = "select SpeechContent,SpeechEnContent from Speech  where SpeechType =@TYPE";
                SqlCommand command     = con.CreateCommand();// 绑定SqlConnection对象
                command.CommandText = selectSpStr;
                con.Open();
                command.Parameters.AddWithValue("@TYPE", type);
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    SM = new SpeechModel()
                    {
                        speechContent   = reader.GetString(0),
                        speechEnContent = reader.GetString(1)
                    };
                    list.Add(SM);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("查询失败");
            }
            finally
            {
                reader.Close();
                con.Close();
            }
            return(list);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 查询列车运行线路站名称信息,为ComboBox绑定数据源
        /// </summary>
        /// <returns></returns>
        public List <Common> SelectComboBoxStation()
        {
            SqlDataReader reader = null;
            Common        Comm   = null;
            List <Common> list   = new List <Common>();
            SqlConnection con    = SqlConnect.getConn();

            try
            {
                String     selectGVStr = "select StationName,StationEnName from WorkingLine order by SubjectStation asc";
                SqlCommand command     = con.CreateCommand();// 绑定SqlConnection对象
                command.CommandText = selectGVStr;
                con.Open();
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Comm = new Common
                    {
                        StationName   = reader.GetString(0),
                        StationEnName = reader.GetString(1)
                    };

                    list.Add(Comm);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("查询站名称信息失败");
            }
            finally
            {
                reader.Close();
                con.Close();
            }
            return(list);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 修改某一站的上一站的名称
        /// </summary>
        /// <param name="laststationname"></param>上一站的名称
        /// <param name="stationname"></param>站名
        public void UpdateLastStation(String laststationname, String stationname)
        {
            SqlConnection con = SqlConnect.getConn();

            try
            {
                String     updateLastStaNameStr = "update WorkingLine set LastStationName =@LASTSTATIONNAME where StationName =@STATIONNAME";
                SqlCommand commmand             = con.CreateCommand();// 绑定SqlConnection对象
                commmand.CommandText = updateLastStaNameStr;
                commmand.Parameters.AddWithValue("@LASTSTATIONNAME", laststationname);
                commmand.Parameters.AddWithValue("@STATIONNAME", stationname);
                con.Open();
                commmand.ExecuteNonQuery();//执行命令
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("修改上一站名称失败");
            }
            finally
            {
                con.Close();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 修改某一站的隶属站次
        /// </summary>
        /// <param name="stationname"></param>站名
        /// <param name="subject"></param>隶属站次
        public void UpdateSubject(String stationname, int subject)
        {
            SqlConnection con = SqlConnect.getConn();

            try
            {
                String     updateSubStr = "update WorkingLine set SubjectStation =@SUBSTATION where StationName =@STATIONNAME";
                SqlCommand commmand     = con.CreateCommand();// 绑定SqlConnection对象
                commmand.CommandText = updateSubStr;
                commmand.Parameters.AddWithValue("@SUBSTATION", subject);
                commmand.Parameters.AddWithValue("@STATIONNAME", stationname);
                con.Open();
                commmand.ExecuteNonQuery();//执行命令
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("修改隶属站次失败");
            }
            finally
            {
                con.Close();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 修改某一站距上一站的距离
        /// </summary>
        /// <param name="stationname"></param>站名
        /// <param name="distance"></param>距离
        public void UpdateDistance(String stationname, double distance)
        {
            SqlConnection con = SqlConnect.getConn();

            try
            {
                String     updateDisStr = "update WorkingLine set StationDistance =@DISTANCE where StationName =@STATIONNAME";
                SqlCommand commmand     = con.CreateCommand();// 绑定SqlConnection对象
                commmand.CommandText = updateDisStr;
                commmand.Parameters.AddWithValue("@DISTANCE", distance);
                commmand.Parameters.AddWithValue("@STATIONNAME", stationname);
                con.Open();
                commmand.ExecuteNonQuery();//执行命令
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("修改距离失败");
            }
            finally
            {
                con.Close();
            }
        }