Ejemplo n.º 1
0
        private void btnSetupCrew_Click(object sender, RoutedEventArgs e)
        {
            if (currentFlight != null)
            {
                try
                {
                    if (currentFlight.Schedule.Date + currentFlight.Schedule.Time < DateTime.Now)
                    {
                        MessageBox.Show("This flight cannot be changed because it took off!", "Message", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    ChooseCrewWindow setUpCrewWindow = new ChooseCrewWindow();
                    setUpCrewWindow.Flight = currentFlight;
                    setUpCrewWindow.ShowDialog();
                    currentFlight = null;
                }
                catch (Exception)
                {
                }
            }
            else
            {
                MessageBox.Show("Please choose a flight!", "Message", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        private void ResetData()
        {
            changeableTickets.Clear();
            cbTickets.Items.Clear();

            cbCabinType.SelectedIndex  = -1;
            dgFlights.ItemsSource      = null;
            currentFlight              = null;
            btnSearch.IsEnabled        = false;
            btnSaveAndCofirm.IsEnabled = false;
            grSearchFlight.Header      = "Search flight for route: ";

            tblAircraft.Text         = "";
            tblBookingReference.Text = "";
            tblCountry.Text          = "";
            tblDate.Text             = "";
            tblEconomyPrice.Text     = "";
            tblFlightNumber.Text     = "";
            tblFullName.Text         = "";
            tblPassportNumber.Text   = "";
            tblPhone.Text            = "";
            tblRoute.Text            = "";
            tblTime.Text             = "";
            tblTotalPayable.Text     = "";

            tblCostIncurred.Text     = "";
            tblTotalPayable.Text     = "";
            tblTotalAfterChange.Text = "";
            tblTotalPayed.Text       = "";
        }
Ejemplo n.º 3
0
        public void LoadFlights()
        {
            currentFlight         = null;
            dgFlights.ItemsSource = null;

            var date         = dpOutbound.SelectedDate.Value.Date;
            var flightNumber = txtFlightNumber.Text.Trim();
            var schedules    = Db.Context.Schedules.Where(t => t.Date == date).ToList();

            if (txtFlightNumber.Text.Trim() != "")
            {
                schedules = schedules.Where(t => t.FlightNumber == flightNumber).ToList();
            }

            var flights = new List <NewFlight>();

            foreach (var item in schedules)
            {
                flights.Add(new NewFlight()
                {
                    Aircraft     = item.Aircraft.Name + " " + item.Aircraft.MakeModel,
                    Schedule     = item,
                    EconomyPrice = (int)item.EconomyPrice,
                    Crew         = item.CrewId == null ? "None" : item.Crew.CrewName
                });
            }

            dgFlights.ItemsSource = flights;
        }
Ejemplo n.º 4
0
 private void DgFlights_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
 {
     try
     {
         currentFlight = dgFlights.SelectedItem as NewFlight;
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 5
0
 private void DgFlights_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
 {
     try
     {
         currentFlight = dgFlights.SelectedItem as NewFlight;
         CalculateCosts(changeableTickets[cbTickets.SelectedIndex]);
     }
     catch (Exception)
     {
     }
 }
        public async Task <bool> UpdateFlightAsync(Flight flight)
        {
            var newFlight = new NewFlight
            {
                Departure = flight.Departure,
                FromId    = flight.From.Id,
                ToId      = flight.To.Id
            };

            var response = await Client.PutAsync(
                $"{_url}/flights",
                new StringContent(JsonConvert.SerializeObject(newFlight))
                );

            return(response.IsSuccessStatusCode);
        }
Ejemplo n.º 7
0
        public void TestFlightGetStatus()
        {
            NewFlight newFlight = new NewFlight()
            {
                insertFlightCity          = "Kharkiv",
                insertFlightDate          = DateTime.Parse("2016-05-01 12:00:00"),
                insertFlightDirection     = 0,
                insertFlightGate          = 5,
                insertFlightNumber        = 555,
                insertFlightPriceBusiness = 200,
                insertFlightPriceEconomy  = 100,
                insertFlightStatus        = 0,
                insertFlightTerminal      = 'A'
            };
            Flight flightSample = new Flight(newFlight);

            Assert.AreEqual("CheckIn", flightSample.GetFlightStatus());
        }
Ejemplo n.º 8
0
        public void TestFlightToString()
        {
            NewFlight newFlight = new NewFlight()
            {
                insertFlightCity          = "Kharkiv",
                insertFlightDate          = DateTime.Parse("2016-05-01 12:00:00"),
                insertFlightDirection     = 0,
                insertFlightGate          = 0,
                insertFlightNumber        = 555,
                insertFlightPriceBusiness = 200,
                insertFlightPriceEconomy  = 100,
                insertFlightStatus        = 0,
                insertFlightTerminal      = 'A'
            };
            Flight flightSample = new Flight(newFlight);
            string sss          = flightSample.ToString();

            Assert.AreEqual("|Arrival  |01-05-2016 12:00|555   |Kharkiv        |          A/0|CheckIn   |        100|", sss);
        }
Ejemplo n.º 9
0
        private void DgFlights_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            try
            {
                currentFlight = dgFlights.CurrentItem as NewFlight;

                if (currentFlight.Schedule.Confirmed)
                {
                    btnCancelFlight.Content    = "Cancel Flight";
                    btnCancelFlight.Foreground = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    btnCancelFlight.Content    = "Confirm Flight";
                    btnCancelFlight.Foreground = new SolidColorBrush(Colors.Black);
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 10
0
 private void btnDeleteFlight_Click(object sender, RoutedEventArgs e)
 {
     if (currentFlight != null)
     {
         if (currentFlight.Schedule.Tickets.Count == 0)
         {
             if (MessageBox.Show("Do you want to delete this flight?", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK)
             {
                 Db.Context.Schedules.Remove(currentFlight.Schedule);
                 Db.Context.SaveChanges();
                 LoadFlights();
                 currentFlight = null;
             }
         }
         else
         {
             MessageBox.Show("This flight can not be deleted because it is related to tickets", "Message", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     else
     {
         MessageBox.Show("Please choose a flight!", "Message", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 11
0
        public bool AddToList(List <Flight> FlightList)
        {
            NewFlight newFlight = new NewFlight();

            DateTime DateStart = DateTime.Now, DateEnd = DateTime.Now.AddYears(1);



            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("Select direction flight (A)rrival, (D)eparture");
            Console.ForegroundColor = ConsoleColor.DarkGray;
            bool isCorrect = true;

            do
            {
                switch (Console.ReadKey().KeyChar)
                {
                case 'a':
                case 'A':
                    newFlight.insertFlightDirection = 0;
                    isCorrect = false;
                    break;

                case 'd':
                case 'D':
                    newFlight.insertFlightDirection = 1;
                    isCorrect = false;
                    break;

                default:
                    Console.Write("Press 'A' or 'D'");
                    break;
                }
            } while (isCorrect);
            Console.WriteLine();

            isCorrect = true;
            do
            {
                CleanerManager.CheckBorder();
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("Enter date (format YYYY-MM-DD hh:mm): ");
                Console.ForegroundColor = ConsoleColor.DarkGray;
                bool isDate = DateTime.TryParse(Console.ReadLine(), out newFlight.insertFlightDate);
                if (isDate && newFlight.insertFlightDate > DateStart && newFlight.insertFlightDate < DateEnd)
                {
                    isCorrect = false;
                }
                else
                {
                    Console.WriteLine("Incorrect date(less than this or more than one year) or format. Please repeat");
                }
            } while (isCorrect);

            isCorrect = true;
            do
            {
                CleanerManager.CheckBorder();
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("Enter Number flight [100..999]: ");
                Console.ForegroundColor = ConsoleColor.DarkGray;
                bool isDate = int.TryParse(Console.ReadLine(), out newFlight.insertFlightNumber);
                if (isDate && newFlight.insertFlightNumber > 99 && newFlight.insertFlightNumber < 1000)
                {
                    isCorrect = false;
                    foreach (Flight item in FlightList)
                    {
                        if (item != null && item.FlightNumber == newFlight.insertFlightNumber)
                        {
                            Console.WriteLine("A flight number already exists");
                            isCorrect = true;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("-Incorrect flight number. Please repeat");
                }
            } while (isCorrect);

            isCorrect = true;
            do
            {
                CleanerManager.CheckBorder();
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.Write("Enter City: ");
                Console.ForegroundColor    = ConsoleColor.DarkGray;
                newFlight.insertFlightCity = Console.ReadLine();
                if (String.IsNullOrWhiteSpace(newFlight.insertFlightCity))
                {
                    Console.WriteLine("Strange empty city.Please repeat");
                }
                else
                {
                    isCorrect = false;
                }
            } while (isCorrect);

            newFlight.insertFlightTerminal = EnterTerminal();
            Console.WriteLine();
            newFlight.insertFlightGate = EnterGate();

            newFlight.insertFlightStatus = EnterStatus();
            Console.WriteLine();

            newFlight.insertFlightPriceBusiness = EnterPriceTicket("Business");
            Console.WriteLine();

            newFlight.insertFlightPriceEconomy = EnterPriceTicket("Economy");
            Console.WriteLine();

            if (newFlight.insertFlightPriceEconomy > newFlight.insertFlightPriceBusiness)
            {
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("WARNING!!! Price Economy large Price business!!!");
                Console.ForegroundColor = ConsoleColor.Gray;
                Thread.Sleep(300);
            }

            FlightList.Add(new Flight(newFlight));
            LogManager.WriteToLog($"Add new flight number {newFlight.insertFlightNumber}");

            return(true);
        }