public void rewrite_cars() { StreamWriter sw = new StreamWriter("car.txt", false, Encoding.ASCII); string line = ""; for (int x = 0; x < List_Driver.Count(); x++) { if (Cars_Data.ContainsKey(List_Driver[x].getDriverId()) == true) { line += List_Driver[x].getDriverId(); line += " "; Cars c = Cars_Data[List_Driver[x].getDriverId()]; line += c.getModel(); line += " "; line += c.getColor(); line += " "; line += c.getYear(); line += " "; line += c.getPlateNo(); sw.WriteLine(line); line = ""; } } //close the file sw.Close(); }
private void button1_Click(object sender, EventArgs e) { hist.Visible = true; dataGridView1.Rows.Clear(); List <Trips> T = new List <Trips>(); if (Form0.loadData.client_Trips.ContainsKey(Form5.idC) == true) { T = Form0.loadData.client_Trips[Form5.idC]; for (int i = 0; i < T.Count; i++) { string Dname = ""; for (int j = 0; j < Form0.loadData.List_Driver.Count; j++) { if (T[i].getid() == Form0.loadData.List_Driver[j].getDriverId()) { Dname = Form0.loadData.List_Driver[j].getDriverName(); break; } } Cars carr = new Cars(); carr = Form0.loadData.Cars_Data[T[i].getid()]; dataGridView1.Rows.Add(Dname, T[i].getSource(), T[i].getDestination(), T[i].getPrice(), T[i].getDate(), carr.getPlateNo(), carr.getModel(), carr.getColor(), carr.getYear()); } } else { MessageBox.Show("You have made no rides till now"); } }
private void button3_Click(object sender, EventArgs e) { reporttrips.Visible = true; dataGridView1.Rows.Clear(); string cname = ""; string dname = ""; for (int i = 0; i < Form0.loadData.List_Client.Count; i++) //viewing all history by admin { if (Form0.loadData.client_Trips.ContainsKey(Form0.loadData.List_Client[i].get_id()) == true) { cname = Form0.loadData.List_Client[i].get_name(); List <Trips> T = new List <Trips>(); T = Form0.loadData.client_Trips[Form0.loadData.List_Client[i].get_id()]; for (int j = 0; j < T.Count; j++) { for (int k = 0; k < Form0.loadData.List_Driver.Count; k++) //three loops as we need the driver's name and client's name { if (T[j].getid() == Form0.loadData.List_Driver[k].getDriverId()) { dname = Form0.loadData.List_Driver[k].getDriverName(); break; } } Cars carr = new Cars(); carr = Form0.loadData.Cars_Data[T[j].getid()]; dataGridView1.Rows.Add(cname, dname, T[j].getSource(), T[j].getDestination(), T[j].getPrice(), T[j].getDate(), carr.getPlateNo(), carr.getModel(), carr.getColor(), carr.getYear()); } } } }