Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            SqlKernel.InitializeDatabase();
            Utilities.InitializeUtilities(this);

            VehiclesList.ItemsSource        = Utilities.VehicleList;
            TransportationsList.ItemsSource = Utilities.TransportationList;

            RefreshPlot(null, null);
        }
Пример #2
0
        private void AddTransportation_Click(object sender, MouseButtonEventArgs e)
        {
            AddTransportationWindow addTransportationWindow = new AddTransportationWindow();

            addTransportationWindow.ShowDialog();
            if (addTransportationWindow.DialogResult == false)
            {
                return;
            }

            // Add the vehicle to the list and the database
            SqlKernel.AddTransportation(addTransportationWindow.Transportation);
            Utilities.TransportationList.Add(addTransportationWindow.Transportation);
        }
Пример #3
0
        private void AddTransportation_Click(object sender, MouseButtonEventArgs e)
        {
            Transportation = new Transportation()
            {
                TransportationID      = SqlKernel.GetAvailableTransportationID(),
                TransportationName    = NameTextBox.Text,
                CityPercentage        = 100 - (int)RoadTypeSlider.Value,
                HighwayPercentage     = (int)RoadTypeSlider.Value,
                TotalDistanceOriginal = float.Parse(DistanceTextBox.Text),
                DistanceUnitOriginal  = (DistanceUnit)DistanceTypeComboBox.SelectedIndex,
                RepeatFrequency       = RepeatFrequency.WEEK,
                RepeatAmount          = 5
            };

            DialogResult = true;
        }
Пример #4
0
        private void AddVehicle_Click(object sender, MouseButtonEventArgs e)
        {
            Vehicle = new Vehicle()
            {
                VehicleID                  = SqlKernel.GetAvailableVehicleID(),
                NameShort                  = NameTextBox.Text,
                PriceOriginal              = float.Parse(PriceTextBox.Text, CultureInfo.InvariantCulture.NumberFormat),
                ConsumptionCityOriginal    = float.Parse(ConsumptionCityTextBox.Text, CultureInfo.InvariantCulture.NumberFormat),
                ConsumptionHighwayOriginal = float.Parse(ConsumptionHighwayTextBox.Text, CultureInfo.InvariantCulture.NumberFormat),
                ConsumptionUnitOriginal    = Utilities.ConsumptionUnit,
                CurrencyUnitOriginal       = Utilities.CurrencyUnit,
                VehicleType                = (VehicleType)VehicleTypeCombobox.SelectedIndex
            };

            DialogResult = true;
        }
Пример #5
0
        /// <summary>
        /// Loads any precursor data needed for the application. These data are the application settings and any
        /// saved data the user created.
        /// </summary>
        /// <param name="mainWindow"></param>
        public static void InitializeUtilities(MainWindow mainWindow)
        {
            // Retreive the settings DataTable from the database
            DataTable settingsDataTable = SqlKernel.ExecuteQuery("SELECT * FROM SETTINGS;");
            DataRow   settingsDataRow   = settingsDataTable.Rows[0];

            // Initialize the window properties
            mainWindow.Width       = Convert.ToInt32(settingsDataRow["WINDOW_WIDTH"]);
            mainWindow.Height      = Convert.ToInt32(settingsDataRow["WINDOW_HEIGHT"]);
            mainWindow.WindowState = Convert.ToInt32(settingsDataRow["FULLSCREEN"]) == 1 ? WindowState.Maximized : WindowState.Normal;

            // Initialize the default units
            ConsumptionUnit = (ConsumptionUnit)Convert.ToInt32(settingsDataRow["SELECTED_CONSUMPTION_UNIT_INDEX"]);
            CurrencyUnit    = (CurrencyUnit)Convert.ToInt32(settingsDataRow["SELECTED_CURRENCY_UNIT_INDEX"]);
            DistanceUnit    = (DistanceUnit)Convert.ToInt32(settingsDataRow["SELECTED_DISTANCE_UNIT_INDEX"]);

            // Initialize the lists
            VehicleList        = new ObservableCollection <Vehicle>(SqlKernel.GetVehicles());
            TransportationList = new ObservableCollection <Transportation>(SqlKernel.GetTransportations());
        }