Beispiel #1
0
 public string Risky(BO.Bus bus, int km) //check if its ok to drive
 {
     if (bus.Fuel < km)                  //chek if there is enough feul for the drive
     {
         if (bus.Fuel <= 5)
         {
             bus.State = Status.NeedRefuel;
         }
         return("There is not enough fuel for the trip ");
     }
     if (bus.KmOfTreatment + km >= 20000)
     {//check if it ok to drive
         bus.State = Status.NeedTreatment;
         return("Time for treatment");
     }
     if (bus.DateOfTreatment <= DateTime.Now.AddYears(-1))//Checks if more than a year has passed since the last treatment
     {
         bus.State = Status.NeedTreatment;
         //throw new Exception("Time for treatment, more then year from the last");
     }
     else
     {
         bus.State = Status.Ready;
     }
     return("OK");
 }
 /// <summary>
 /// open the window of the bus info
 /// </summary>
 private void ShowBusesInfo()
 {
     BO.Bus bus = BusesDataGrid.SelectedItem as BO.Bus;
     if (bus != null)
     {
         BusInfo win = new BusInfo(bus);
         win.ShowDialog();
         ShowBuses();
     }
 }
Beispiel #3
0
        public void UpdateBusDetails(BO.Bus bus)
        {
            try
            {
                dl.UpdateBus(BusBoDoAdapter(bus));
            }

            catch (DO.BadBusLicenseNumberException ex)
            {
                throw new BO.BadLicensNumberException(ex.Message, ex);
            }
        }
Beispiel #4
0
 //copy&convert constractor
 public Bus(BO.Bus b)
 {
     LicensNumber    = b.LicensNumber;
     KmSum           = b.KmSum;
     DateOfBeg       = b.DateOfBeg;
     Charger         = b.Charger;
     ComfortSeat     = b.ComfortSeat;
     Wifi            = b.Wifi;
     Fuel            = b.Fuel;
     upFuel          = b.Fuel;
     DateOfTreatment = b.DateOfTreatment;
     KmOfTreatment   = b.KmOfTreatment;
     Upstatus        = b.State;
 }
Beispiel #5
0
 public void Drive(BO.Bus bus, int kmDrive)//take the bus for drive
 {
     if (Risky(bus, kmDrive) == "OK")
     {
         //Fuel and km update
         bus.KmSum         += kmDrive;
         bus.Fuel          -= kmDrive;
         bus.KmOfTreatment += kmDrive;
     }
     else
     {
         throw new ArgumentException("Can not drive!");
     }
 }
 /// <summary>
 /// window ctor
 /// </summary>
 public NewBusInfo()
 {
     InitializeComponent();
     try
     {
         bl  = BLFactory.GetBL();
         bus = new BO.Bus()
         {
             LastTreatmentDate  = DateTime.Now,
             TripSinceTreatment = 0,
             FuelRemain         = 400,
             BusStatus          = Status.Ready
         };
         date.DataContext = bus;
     }
     catch (BO.MissingData ex) //creating bo failed
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #7
0
 public void Refuel(BO.Bus bus)  //Fuel update
 {
     bus.Fuel = 1200;
 }
Beispiel #8
0
 public void Treatment(BO.Bus bus)//Update the current date, and the trip on which the treatment was performed.
 {
     bus.DateOfTreatment = DateTime.Now;
     bus.KmOfTreatment   = 0;
 }
Beispiel #9
0
 DO.Bus BusBoDoAdapter(BO.Bus busBO)
 {
     DO.Bus busDO = new DO.Bus();
     busBO.CopyPropertiesTo(busDO);
     return(busDO);
 }
Beispiel #10
0
 BO.Bus BusDoBoAdapter(DO.Bus busDO)
 {
     BO.Bus busBO = new BO.Bus();
     busDO.CopyPropertiesTo(busBO);
     return(busBO);
 }