コード例 #1
0
        //private static GruzFrontDB gruzFrontDB;

        //private GruzFrontDB() { }

        //public static GruzFrontDB GetInstance()
        //{
        //    // для исключения возможности создания двух объектов
        //    // при многопоточном приложении
        //    if (gruzFrontDB == null)
        //    {
        //        lock (typeof(GruzFrontDB))
        //        {
        //            if (gruzFrontDB == null)
        //                gruzFrontDB = new GruzFrontDB();
        //        }
        //    }

        //    return gruzFrontDB;
        //}

        /// <summary>
        /// Получить список вагоно-опрокидывателей с вагонами на них
        /// </summary>
        /// <param name="stat"></param>
        /// <returns></returns>
        public List <GruzFront> getGruzFronts(Station stat)
        {
            List <GruzFront> list = new List <GruzFront>();

            //string query = string.Format("select g.id_gruz_front, g.name, count(vo.id_oper) as vag_amount "+
            //"from GRUZ_FRONTS g left join VAGON_OPERATIONS vo "+
            //"on g.id_gruz_front=vo.st_gruz_front and vo.is_hist=0 and vo.is_present=0 "+
            //"where g.id_stat=@id_stat "+
            //"group by id_gruz_front, name "+
            //"order by name");
            //SqlParameter[] sqlParameters = new SqlParameter[1];
            //sqlParameters[0] = new SqlParameter("@id_stat", stat.ID);
            //DataTable table = Conn.executeSelectQuery(query, sqlParameters).Tables[0];
            string query = "[RailCars].[GetGruzFront]";

            SqlParameter[] sqlParameters = new SqlParameter[1];
            sqlParameters[0] = new SqlParameter("@idstation", stat.ID);
            DataTable table = Conn.executeProc(query, sqlParameters).Tables[0];

            foreach (DataRow row in table.Rows)
            {
                GruzFront gf = new GruzFront {
                    ID   = Int32.Parse(row["id_gruz_front"].ToString()), Name = row["name"].ToString().Trim(),
                    Stat = stat, Vag_amount = Int32.Parse(row["vag_amount"].ToString())
                };

                list.Add(gf);
            }

            return(list);
        }
コード例 #2
0
        //TODO: ПЕРЕХОД НА НОВОЕ ОПРЕДЕЛЕНИЕ ИНФОРМАЦИИ ПО ВАГОНАМ
        //private DataTable getVagonsTable(Way way, Side side)
        //{
        //    string str = "";
        //    if (way.Stat.Outer_side == side)
        //        str = "desc";

        //    string query = string.Format("select vo.*, v.num, v.rod, v.st_otpr, o.abr as owner_, c.name as country, vc.name as cond,  " +
        //    "g.name as gruz, g2.name as gruz_amkr, s.name as shop, t.name as tupik, gd.name as gdstait, nc.name as nazn_country, vc2.name as cond2, vc2.id_cond_after, " +
        //    "p.date_mail, p.n_mail, p.[text], p.nm_stan, p.nm_sobstv " +
        //    "from VAGON_OPERATIONS vo " +
        //    "inner join VAGONS v on vo.id_vagon=v.id_vag " +
        //    "left join OWNERS o on v.id_owner=o.id_owner " +
        //    "left join OWNERS_COUNTRIES c on o.id_country=c.id_own_country "+
        //    "left join VAG_CONDITIONS vc on vo.id_cond=vc.id_cond "+
        //    "left join GRUZS g on vo.id_gruz=g.id_gruz "+
        //    "left join GRUZS g2 on vo.id_gruz_amkr=g2.id_gruz "+
        //    "left join SHOPS s on vo.id_shop_gruz_for=s.id_shop "+
        //    "left join TUPIKI t on vo.id_tupik = t.id_tupik "+
        //    "left join GDSTAIT gd on vo.id_gdstait = gd.id_gdstait "+
        //    "left join NAZN_COUNTRIES nc on vo.id_nazn_country = nc.id_country "+
        //    "left join VAG_CONDITIONS2 vc2 on vo.id_cond2=vc2.id_cond "+
        //    "left join v_p_vozvrat_ip p on p.id = (select top 1 id from v_P_VOZVRAT_IP where n_vag=v.num order by DATE_MAIL desc) "+
        //    "where vo.id_way = @id_way and vo.is_present = 1 " +
        //    "order by vo.num_vag_on_way " + str);
        //    SqlParameter[] sqlParameters = new SqlParameter[1];
        //    sqlParameters[0] = new SqlParameter("@id_way", way.ID);

        //    return Conn.executeSelectQuery(query, sqlParameters).Tables[0];

        //                    //if (row["dt_from_way"] != DBNull.Value) vagOnStat.dt_from_way = DateTime.Parse(row["dt_from_way"].ToString());
        //}

        private DataTable getVagonsTable(GruzFront gf)
        {
            string query = "[RailCars].[GetOnStatGruzFrontWagons]";

            SqlParameter[] sqlParameters = new SqlParameter[1];
            sqlParameters[0] = new SqlParameter("@gf", gf.ID);
            return(Conn.executeProc(query, sqlParameters).Tables[0]);
        }
コード例 #3
0
        public List <VagOnStat> getVagons(GruzFront gf)
        {
            List <VagOnStat> list = (base.getVagons(getVagonsTable(gf))).Select(parent => new VagOnStat(parent)).ToList();

            int i = 0;

            foreach (VagOnStat item in list)
            {
                list[i].num_vag_on_way = list.IndexOf(item) + 1;

                i++;
            }

            return(list);
        }
コード例 #4
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);
        }