public static void AddRoute(RoutView rout) { var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var db = server.GetDatabase("TransportSystem"); var collectionRoute = db.GetCollection <Route>("Route"); Route r = new Route() { Duration = rout.Duration, DynamicFields = rout.DynamicFields, Line = rout.Line, Price = rout.Price }; foreach (var stat in rout.Stations) { r.Stations.Add(new MongoDBRef("Station", stat.Id)); } r.Transport = new MongoDBRef("Transport", rout.Transport.Id); collectionRoute.Insert(r); }
private void btnDodajStanicu_Click(object sender, EventArgs e) { int poz; if (int.TryParse(txtDodajStanicu.Text, out poz)) { if (poz < 0 || poz > route.Stations.Count) { return; } } else { return; } ChoseStation ss = new ChoseStation(route); ss.ShowDialog(); if (ss.station != null) { route = RouteModel.Rout(route.Id, ss.station.Id, poz); listBox1.Items.Clear(); listBox1.Items.AddRange(route.Stations.ToArray()); } }
private void btnAdd_Click(object sender, EventArgs e) { newRout = new RoutView(); int br; if (!int.TryParse(txtBroj.Text, out br)) { return; } newRout.Line = br; TransportView test = comboBox1.SelectedItem as TransportView; if (test == null) { return; } newRout.Transport = new Transport { Id = test.Id }; newRout.Stations = listBox1.Items.Cast <Station>().ToList(); RouteModel.AddRoute(newRout); this.Close(); }
private void btnObrisiStanicu_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex == -1) { return; } route = RouteModel.RemoveStation(route.Id, ((Station)listBox1.SelectedItem).Id); listBox1.Items.Clear(); listBox1.Items.AddRange(route.Stations.ToArray()); }
private void deleteLine_Click(object sender, EventArgs e) { if (dataGridView1.DataSource == null) { return; } RoutView st = dataGridView1.SelectedRows[0].DataBoundItem as RoutView; RouteModel.DeleteRout(st.Id); setRouts(); }
public AddNewRide(Transport trs, RoutView rts, RideView rt = null) { InitializeComponent(); route = rts; ts = trs; ride = rt; if (rt != null) { initData(); } else { initNewData(); } }
public void drawmapLines(RoutView rt, Color lineColor) { for (int i = 0; i < rt.Stations.Count; i++) { //render.FillEllipse(Brushes.Black,(float) rt.Stations[i].Lat - wight / 2,(float) rt.Stations[i].Lon - height / 2, wight, height); if (i > 0) { render.DrawLine(new Pen(lineColor, 10), (float)rt.Stations[i - 1].Lat, (float)rt.Stations[i - 1].Lon, (float)rt.Stations[i].Lat, (float)rt.Stations[i].Lon); } string lines = ""; for (int j = 0; j < rt.Stations[i].Lines.Count; j++) { lines += rt.Stations[i].Lines[j].ToString(); if (j < rt.Stations[i].Lines.Count - 1) { lines += ","; } } SizeF sz = render.MeasureString(lines, new Font(FontFamily.GenericMonospace, 10)); render.DrawString(lines, new Font(FontFamily.GenericMonospace, 10), Brushes.Black, new PointF((float)rt.Stations[i].Lat - sz.Width / 2, (float)rt.Stations[i].Lon + height / 2 + 2)); } //render.Flush(); }
private void btnClose_Click(object sender, EventArgs e) { newRout = null; this.Close(); }
public NovaLinija() { InitializeComponent(); newRout = null; }
public ChoseStation(RoutView st = null) { InitializeComponent(); route = st; }
public Ride(RoutView rt) { InitializeComponent(); rout = rt; listBox1.Items.AddRange(RideModel.GetAllRides(rout.Id).ToArray()); }
public Linija(RoutView route) { InitializeComponent(); this.route = route; listBox1.Items.AddRange(route.Stations.ToArray()); }