예제 #1
0
        /// <summary>
        /// Получить список поездов (!! временное условие "не показывать поезда отправленные на Прокатную-1 с пом. ПО, а только из КИС)
        /// </summary>
        /// <param name="stat">Станция прибытия</param>
        /// <param name="sp">Класс данных отправки (станция, вагоноопрокид, цех)</param>
        /// <returns></returns>
        private DataTable getTrainsTable(Station stat, SendingPoint sp)
        {
            int type = -1;

            if (sp.GetType().IsAssignableFrom(typeof(Station)))
            {
                type = 0;   // станция
            }
            else if (sp.GetType().IsAssignableFrom(typeof(GruzFront)))
            {
                type = 1;   // Вагоноопрокид
            }
            else
            {
                type = 2;   // Цех
            }
            string query = "[RailCars].[GetAdmissTrains]";

            SqlParameter[] sqlParameters = new SqlParameter[2];
            sqlParameters[0] = new SqlParameter("@idstation", stat.ID);
            sqlParameters[1] = new SqlParameter("@type", type);
            return(Conn.executeProc(query, sqlParameters).Tables[0]);
        }
예제 #2
0
        /// <summary>
        /// сформировать и вернуть список поездов (List<Train>) в прибытии
        /// </summary>
        /// <param name="stat"></param>
        /// <param name="sp"></param>
        /// <returns></returns>
        public List <Train> getTrains(Station stat, SendingPoint sp)
        {
            DataTable table = getTrainsTable(stat, sp); // Получить список поездов для снятия

            List <Train> list = new List <Train>();

            foreach (DataRow row in table.Rows)
            {
                Train train = new Train();
                train.Num = Int32.Parse(row["st_lock_train"].ToString());
                //train.StationFrom = new Station(Int32.Parse(row["id_stat"].ToString()), "ст. "+row["stat"].ToString().Trim());
                //train.StationFrom.PointName = StationUtils.GetInstance().ClassName;
                if (row["st_gruz_front"] != DBNull.Value && Int32.Parse(row["st_gruz_front"].ToString()) != -1)
                {
                    GruzFront gf = new GruzFront();
                    gf.PointName = GruzFrontUtils.GetInstance().ClassName;
                    gf.ID        = Int32.Parse(row["st_gruz_front"].ToString());
                    gf.Name      = row["gruz_front_name"].ToString();
                    //gf.Stat = train.StationFrom;
                    train.SendingPoint = gf;
                }
                else
                if (row["st_shop"] != DBNull.Value && Int32.Parse(row["st_shop"].ToString()) != -1)
                {
                    Shop shop = new Shop();
                    shop.PointName = ShopUtils.GetInstance().ClassName;
                    shop.ID        = Int32.Parse(row["st_shop"].ToString());
                    shop.Name      = row["shop_name"].ToString();
                    //train.Shop.Stat = train.StationFrom;
                    train.SendingPoint = shop;
                }
                else
                {
                    Station stationFrom = new Station();
                    stationFrom.PointName = StationUtils.GetInstance().ClassName;
                    stationFrom.ID        = Int32.Parse(row["id_stat"].ToString());
                    stationFrom.Name      = "ст. " + row["stat"].ToString().Trim();
                    train.SendingPoint    = stationFrom;
                }
                train.StationTo = stat;
                if (!sp.GetType().IsAssignableFrom(typeof(Station)))
                {
                    train.DateFromStat = DateTime.Parse(row["dt_from_way"].ToString());
                }
                else
                {
                    train.DateFromStat = DateTime.Parse(row["dt_from_stat"].ToString());
                }
                train.Vag_amount = Int32.Parse(row["vag_amount"].ToString());
                if (row["st_lock_locom1"] != DBNull.Value)
                {
                    train.St_lock_locom1 = Int32.Parse(row["st_lock_locom1"].ToString());
                }
                if (row["st_lock_locom2"] != DBNull.Value)
                {
                    train.St_lock_locom2 = Int32.Parse(row["st_lock_locom2"].ToString());
                }
                //if (row["id_ora_23_temp"] != DBNull.Value)
                //{
                //    train.id_ora_23_temp = Int32.Parse(row["id_ora_23_temp"].ToString());//TODO:
                //}
                //if (row["id_oracle"] != DBNull.Value)
                //{
                //    train.id_oracle = Int32.Parse(row["id_oracle"].ToString());             //TODO:
                //}
                list.Add(train);
            }

            return(list);
        }