Ejemplo n.º 1
0
        /// <summary>
        /// Konstruktor klasy
        /// </summary>
        /// <param name="_mainFrame">Ramka, w której ma zostać zmieniany widok</param>
        /// <param name="_fuelType">Instancja paliwa</param>
        /// <param name="gasolineService">Serwis GasolineService</param>
        public View_FuelType(Frame _mainFrame, FuelType _fuelType, GasolineService gasolineService)
        {
            _gasolineService = gasolineService;
            mainFrame        = _mainFrame;
            fuelType         = _fuelType;

            InitializeComponent();

            List <GasStationFuel> stationWithFuel = _gasolineService.GetGasStationFuelsByFuelId(fuelType.Id);

            stationWithFuel = stationWithFuel.OrderBy(x => x.Price).ToList();

            FuelName.Content = fuelType.FuelName;

            for (int i = 0; i < stationWithFuel.Count; i++)
            {
                var        gf = stationWithFuel[i];
                GasStation gs = _gasolineService.GetGasStationById(gf.GasStationId);

                if (gs != null)
                {
                    // Utworzenie panelu, aby pogrupować stacje
                    StackPanel sp = new StackPanel();

                    // Utworzenie napisu z nazwą stacji i ceną
                    Label lbl = new Label()
                    {
                        Name = "StationName"
                    };
                    lbl.Content = gs.Name + ", " + gf.Price + " zł";
                    sp.Children.Add(lbl);

                    // Utworzenie przycisku
                    Button btn = new Button()
                    {
                        Name = "B" + i, Content = "Zobacz"
                    };
                    btn.Click += ViewStation_ButtonClick;
                    sp.Children.Add(btn);

                    // Przypisanie grupy do widoku
                    Stations.Children.Add(sp);
                }

                gasStations.Add(gs);
            }
        }
Ejemplo n.º 2
0
        public View_AllFuels(Frame _mainFrame, GasolineService gasolineService)
        {
            _gasolineService = gasolineService;
            mainFrame        = _mainFrame;
            InitializeComponent();


            fuelTypes = _gasolineService.GetAllFuelTypes();

            for (int i = 0; i < fuelTypes.Count; i++)
            {
                Button btn = new Button()
                {
                    Name = "B" + i, Content = fuelTypes[i].FuelName
                };
                btn.Click += Btn_Click;

                AllFuels.Children.Add(btn);
            }
        }
        /// <summary>
        /// Konstruktor klasy
        /// </summary>
        /// <param name="mainFrame">Referencja do głównej ramki w aplikacji w celu umożliwienia zmiany widoku/strony</param>
        /// <param name="gasolineService">Przekazanie serwisu GasolineService</param>
        public View_GasStations(Frame mainFrame, GasolineService gasolineService)
        {
            MainFrame        = mainFrame;
            _gasolineService = gasolineService;

            InitializeComponent();

            gasStations = _gasolineService.GetAllGasStations();

            GasStationParent.Children.Clear();


            // Utworzenie nowych przycisków
            for (int i = 0; i < gasStations.Count; i++)
            {
                GasStation gs = gasStations[i];

                // Utworzenie nowego napisu, wraz z nadaniem mu wartości
                System.Windows.Controls.Label newLbl = new Label
                {
                    Content = $"{gs.Name}, {gs.City}, {gs.Street}",
                    Name    = $"Label{i}"
                };

                // Utworzenie nowego przycisku, wraz z nadaniem mu wartości
                System.Windows.Controls.Button newBtn = new Button()
                {
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Margin = new Thickness(newLbl.ActualWidth)
                };
                newBtn.Content = "Wyświetl";
                newBtn.Name    = $"B{i}";

                // Przypisanie handlera do przycisku
                newBtn.Click += ViewStationHandler;

                // Dodanie przycisku, oraz napisu do widoku
                GasStationParent.Children.Add(newLbl);
                GasStationParent.Children.Add(newBtn);
            }
        }
        public View_ViewGasStation(Frame mainFrame, GasStation gasStation, GasolineService gasolineService)
        {
            _gasolineService = gasolineService;
            ge        = new GasolineEntities1();
            MainFrame = mainFrame;
            InitializeComponent();

            ge = new GasolineEntities1();
            gs = gasStation;

            station_name.Content       = gs.Name;
            station_postalcode.Content = gs.PostalCode;
            station_street.Content     = gs.Street;
            station_city.Content       = gs.City;


            fuelTypes       = _gasolineService.GetAllFuelTypes();
            gasStationFuels = ge.GasStationFuels.Where(x => x.GasStationId == gs.Id).ToList();

            UpdateFuels();
        }
Ejemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            _gasolineService = new GasolineService();
        }
 /// <summary>
 /// Konstruktor klasy
 /// </summary>
 /// <param name="mainFrame">Główna ramka</param>
 /// <param name="gasolineService">Serwis GasolineService</param>
 public View_AddGasStation(Frame mainFrame, GasolineService gasolineService)
 {
     _mainFrame       = mainFrame;
     _gasolineService = gasolineService;
     InitializeComponent();
 }