Exemple #1
0
        private void UpdateJourney()
        {
            validJourney = true; //start true
            int      dt;
            DateTime jdate;
            int      day, month, year;
            Boolean  jPaid = (Boolean)PaidRadioBtn.IsChecked;

            try
            {
                dt    = System.Convert.ToInt32(DistanceTravelledTxt.Text);
                day   = System.Convert.ToInt32(JourneyDayTxt.Text);
                month = System.Convert.ToInt32(JourneyMonthTxt.Text);
                year  = System.Convert.ToInt32(JourneyYearTxt.Text);
                jdate = new DateTime(year, month, day);
            }
            catch
            {
                Console.WriteLine("Error reading numeric values!");
                validJourney = false; //Due to likely poor data entry //false
                return;
            }

            J = new Journey(dt, jdate, J.getDatecreated(), DateTime.Now, J.getVehicleID(), jPaid); //New journey with all of the information!
        }
 //Check if date for journey exists already
 public static Boolean JourneyDateExists(List <Journey> allJournies, Journey J)
 {
     foreach (Journey j in allJournies)
     {
         //Check if a date is within 24 hours!
         if (Math.Abs((j.getjourneyAt() - J.getjourneyAt()).TotalHours) < 24 && j.getVehicleID() == J.getVehicleID())
         {
             return(true);
         }
     }
     return(false);
 }