private void LoadGroups() { this._groups.Clear(); using (var sqlCmd = MainPluginClass.App.SqlWork()) { sqlCmd.sql = string.Format(@"SELECT wtg.gid, wtg.name, ARRAY(SELECT route_id FROM autobase.waybills_tasks_ways WHERE group_id = wtg.gid AND route_id is not null) as routes, ARRAY(SELECT zone_id FROM autobase.waybills_tasks_ways WHERE group_id = wtg.gid AND zone_id is not null) as zones FROM autobase.waybills_tasks_ways_groups wtg WHERE wtg.gid in (SELECT * FROM autobase.get_access_ways_groups()) ORDER BY name;", _id_org); sqlCmd.ExecuteReader(); while (sqlCmd.CanRead()) { RouteM route = new RouteM(sqlCmd.GetValue <int>("gid"), sqlCmd.GetValue <string>("name"), _id_org); var odhs = sqlCmd.GetValue <int[]>("routes").ToList(); foreach (var item in odhs) { route.Odhs.Add(Odhs.FirstOrDefault(w => w.Id == item)); } var zones = sqlCmd.GetValue <int[]>("zones").ToList(); foreach (var item in zones) { route.Zones.Add(Zones.FirstOrDefault(w => w.Id == item)); } _groups.Add(route); } } }
public ActionResult Edit(int id) { BusdbEntities db = new BusdbEntities(); RouteM find = new RouteM(); var xx = db.routes.Where(x => x.rid == id).FirstOrDefault(); find.Routeid = xx.rid; find.FromLocation = xx.from_location; find.ToLocation = xx.to_location; return(View(find)); }
private void RenameRouteToDb(RouteM route, string name) { using (var sqlCmd = MainPluginClass.App.SqlWork()) { sqlCmd.sql = "UPDATE autobase.waybills_tasks_ways_groups SET name = :newname WHERE gid = :id;"; sqlCmd.AddParam(new Params(":newname", name, NpgsqlTypes.NpgsqlDbType.Text)); sqlCmd.AddParam(new Params(":id", route.Id, NpgsqlTypes.NpgsqlDbType.Integer)); sqlCmd.ExecuteNonQuery(); } LoadRoutes(); }
public ActionResult Create(RouteM xx) { BusdbEntities db = new BusdbEntities(); route r = new route(); r.rid = xx.Routeid; r.from_location = xx.FromLocation; r.to_location = xx.ToLocation; db.routes.Add(r); db.SaveChanges(); return(RedirectToAction("index")); }
public ActionResult Edit(RouteM xx) { BusdbEntities db = new BusdbEntities(); var find = db.routes.Where(x => x.rid == xx.Routeid).FirstOrDefault(); find.rid = xx.Routeid; find.from_location = xx.FromLocation; find.to_location = xx.ToLocation; db.Entry(find).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("index")); }
// GET: Route public ActionResult Index() { BusdbEntities busdb = new BusdbEntities(); List <route> routeList = busdb.routes.ToList(); RouteM rbs = new RouteM(); List <RouteM> RListNew = routeList.Select(x => new RouteM { Routeid = x.rid, FromLocation = x.from_location, ToLocation = x.to_location, }).ToList(); return(View(RListNew)); }
private void SetSelectedZoneFromRoute(RouteM group) { foreach (var item in Zones) { if (item != null) { item.Selected = false; } } foreach (var item in group.Zones) { if (item != null) { item.Selected = true; } } MoveSelectedToUp(); OnPropertyChanged("CountZones"); }
private void SetSelectedOdhFromRoute(RouteM route) { foreach (var item in Odhs) { item.Selected = false; } foreach (var item in route.Odhs) { item.Selected = true; } foreach (var item in Zones) { item.Selected = false; } foreach (var item in route.Zones) { item.Selected = true; } MoveSelectedToUp(); }