Exemplo n.º 1
0
        public void loadtripsClient()
        {
            try
            {
                using (StreamReader sr = new StreamReader("client trips.txt"))
                {
                    string line;
                    string source, destination;
                    while ((line = sr.ReadLine()) != null)
                    {
                        int ClientId = int.Parse(line.Split(' ')[0]);
                        int DriverId = int.Parse(line.Split(' ')[1]);
                        source      = line.Split(' ')[2];
                        destination = line.Split(' ')[3];
                        int    price       = int.Parse(line.Split(' ')[4]);
                        string date        = line.Split(' ')[5] + " " + line.Split(' ')[6] + " " + line.Split(' ')[7];
                        Trips  currenttrip = new Trips(DriverId, source, destination, date, price);
                        if (client_Trips.Keys.Contains(ClientId) == false)
                        {
                            client_Trips[ClientId] = new List <Trips>();
                        }
                        client_Trips[ClientId].Add(currenttrip);
                    }
                }
            }

            catch (Exception)
            {
                MessageBox.Show("The file of client trips can not be opened");
            }
        }
Exemplo n.º 2
0
        private void button2_Click_2(object sender, EventArgs e) //stop hena
        {
            ride.Visible = false;
            watch.Stop();
            var  elapseMs = watch.ElapsedMilliseconds;
            long p        = (elapseMs / 1000) * 5;

            if (Form2.isPromo == true)
            {
                p = p / 10;
            }
            if (p < 0)
            {
                p = 0;
            }
            DateTime time    = DateTime.Now;
            String   formate = "d M yyyy";
            string   s       = time.ToString(formate);

            Trips td = new Trips(k.get_id(), k.get_pickup(), k.get_dropoff(), s, p);

            if (Form0.loadData.Driver_Trips.Keys.Contains(Form5.idD) == false)
            {
                Form0.loadData.Driver_Trips[Form5.idD] = new List <Trips>();
            }
            Form0.loadData.Driver_Trips[Form5.idD].Add(td);


            Trips tc = new Trips(Form5.idD, k.get_pickup(), k.get_dropoff(), s, p);

            if (Form0.loadData.client_Trips.Keys.Contains(k.get_id()) == false)
            {
                Form0.loadData.client_Trips[k.get_id()] = new List <Trips>();
            }

            Form0.loadData.client_Trips[k.get_id()].Add(tc);
        }