public void Test_RC_Ways(int id_way) { RC_Ways ws = new RC_Ways(); WAYS way = ws.GetWays(id_way); WL(way); }
public void Test_RC_WaysToStations(int id_station, string num) { RC_Ways ws = new RC_Ways(); WAYS w = ws.GetWaysOfStations(id_station, num); int? nw = ws.GetIDWaysToStations(id_station, num); WL(w); Console.WriteLine(" id: {0}", nw); }
public int?GetIDWaysToStations(int id_station, string num) { WAYS ws = GetWaysOfStations(id_station, num); if (ws != null) { return(ws.id_way); } return(null); }
/// <summary> /// Удалить /// </summary> /// <param name="id_way"></param> /// <returns></returns> public WAYS DeleteWAYS(int id_way) { WAYS dbEntry = context_edit.WAYS.Find(id_way); if (dbEntry != null) { context_edit.WAYS.Remove(dbEntry); context_edit.SaveChanges(); } return(dbEntry); }
/// <summary> /// Добавить или править /// </summary> /// <param name="WAYS"></param> /// <returns></returns> public int SaveWAYS(WAYS WAYS) { WAYS dbEntry; if (WAYS.id_way == 0) { dbEntry = new WAYS() { id_way = WAYS.id_way, id_stat = WAYS.id_stat, id_park = WAYS.id_park, num = WAYS.num, name = WAYS.name, vag_capacity = WAYS.vag_capacity, order = WAYS.order, bind_id_cond = WAYS.bind_id_cond, for_rospusk = WAYS.for_rospusk, }; context_edit.WAYS.Add(dbEntry); } else { dbEntry = context_edit.WAYS.Find(WAYS.id_way); if (dbEntry != null) { dbEntry.id_way = WAYS.id_way; dbEntry.id_stat = WAYS.id_stat; dbEntry.id_park = WAYS.id_park; dbEntry.num = WAYS.num; dbEntry.name = WAYS.name; dbEntry.vag_capacity = WAYS.vag_capacity; dbEntry.order = WAYS.order; dbEntry.bind_id_cond = WAYS.bind_id_cond; dbEntry.for_rospusk = WAYS.for_rospusk; } } try { context_edit.SaveChanges(); } catch (Exception e) { return(-1); } return(dbEntry.id_way); }
public void Test_SUD_RC_Ways() { RC_Ways ws = new RC_Ways(); WAYS w1 = new WAYS() { id_way = 0, id_stat = 4, id_park = null, num = "0", name = "Тест", vag_capacity = 7, order = null, bind_id_cond = null, for_rospusk = null, }; int id_new = ws.SaveWays(w1); Test_RC_Ways(id_new); WAYS w2 = new WAYS() { id_way = id_new, id_stat = 4, id_park = null, num = "0", name = "Тест11111", vag_capacity = 9, order = null, bind_id_cond = null, for_rospusk = null, }; int id_ch = ws.SaveWays(w2); Test_RC_Ways(id_ch); WAYS del = ws.DeleteWays(id_ch); WL(del); }
/// <summary> /// Определить ID пути системы Railcars (если ID нет в системе создать путь) /// </summary> /// <param name="id_station_kis"></param> /// <param name="num_way"></param> /// <returns></returns> public int?DefinitionIDWays(int id_station, int?num_way) { if (num_way != null) { int?way = rs_ways.GetIDWaysToStations(id_station, ((int)num_way).ToString()); if (way == null) { int res = rs_ways.SaveWays(new WAYS() { id_way = 0, id_stat = id_station, id_park = null, num = ((int)num_way).ToString(), name = "?", vag_capacity = null, order = null, bind_id_cond = null, for_rospusk = null, }); if (res > 0) { return(res); } } return(way); } else { WAYS ws = rs_ways.GetWaysOfStations(id_station).OrderBy(w => w.num).FirstOrDefault(); if (ws != null) { return(ws.id_way); } } return(null); }
/// <summary> /// Вернуть ID станции /// </summary> /// <param name="id_way"></param> /// <returns></returns> public int?GetIDStationOfWay(int id_way) { WAYS way = GetWays(id_way); return(way != null ? way.id_stat : null); }
/// <summary> /// Добавить или править /// </summary> /// <param name="WAYS"></param> /// <returns></returns> public int SaveWays(WAYS ways) { return(rep_w.SaveWAYS(ways)); }
public void WL(WAYS t) { Console.WriteLine("id_way: {0}, id_stat: {1}, id_park: {2}, num: {3}, name: {4}, vag_capacity: {5}, order: {6}, bind_id_cond: {7}, for_rospusk: {8}", t.id_way, t.id_stat, t.id_park, t.num, t.name, t.vag_capacity, t.order, t.bind_id_cond, t.for_rospusk); }