//JOURNEYS ADD EDIT DELETE
        private void AddJourniesBtn_Click(object sender, RoutedEventArgs e)
        {
            beforeEffects();
            AddJourneyWindow addJourneyWin = new AddJourneyWindow(vehicleID, true);

            addJourneyWin.ShowDialog();
            if (addJourneyWin.getSaveState() && addJourneyWin.getValidity())
            {
                Journey J = addJourneyWin.getJourney(); // Get the new journey
                journies.Add(J);                        //  Add to the list
                allJournies.Add(J);                     //Add to the list of all journeys
                Console.WriteLine(" Journey Added");
            }
            afterEffects();
        }
Пример #2
0
        //Add new journey
        private void NewJourneyBtn_Click(object sender, RoutedEventArgs e)
        {
            AddJourneyWindow addJourneyWin = new AddJourneyWindow(R.getVehicle().getVehicleID(), false);

            addJourneyWin.ShowDialog();
            if (addJourneyWin.getSaveState() && addJourneyWin.getValidity())
            {
                Journey   J        = addJourneyWin.getJourney(); // Get the new journey
                Boolean[] rentable = R.isJourneyRentable(J);     //use rental of vehicle to check if vehicle can be rented for this journey

                //Add to the list of unpaid journies
                if (rentable[0] && rentable[1] && rentable[2] && rentable[3]) //Rentable as met all conditions
                {
                    R.addTemporaryRental(J);                                  //set rental awaiting payment
                    performRefresh();                                         //Refresh display
                    //Disable button, one sucessful rent for window
                    NewJourneyBtn.IsHitTestVisible = false;
                    NewJourneyBtn.Opacity          = 0.5;
                }
                else
                { //not rentable
                    String errorMsg = "Not Rentable:";
                    if (!rentable[0])
                    {
                        errorMsg = errorMsg + " Date Taken!";
                    }                                                           //Check if journey of same date exists in database!
                    if (!rentable[1])
                    {
                        errorMsg = errorMsg + " Service Required!";
                    }                                                                 //Needs service
                    if (!rentable[2])
                    {
                        errorMsg = errorMsg + " Journey date older than car!";
                    }                                                                            //Car doesn't exist yet!
                    if (!rentable[3])
                    {
                        errorMsg = errorMsg + " Journey too long!";
                    }                          //Journey too long!
                    MessageBox.Show(errorMsg); //WHy not rentable
                }
            }
            else if (!addJourneyWin.getValidity())
            {
                MessageBox.Show("Invalid Data Inputs");
            }
        }