Beispiel #1
0
        private void buttonCreate_Click(object sender, RoutedEventArgs e)
        {
            string result = CarCRUDOperations.CreateCar(comboBoxCars, getDictionaryFromCar(carForBinding), ref counter);

            if (result != "Correct")
            {
                MessageBox.Show(result, "Error", MessageBoxButton.OK);
            }
        }
Beispiel #2
0
        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            string result = CarCRUDOperations.DeleteCarById(Singleton.GetInstance().ActualCar.Id, comboBoxCars);

            if (result != "Removed")
            {
                MessageBox.Show(result, "Error", MessageBoxButton.OK);
            }
            else
            {
                MessageBox.Show(result, "Info", MessageBoxButton.OK);
            }
        }
Beispiel #3
0
        private void buttonUpdate_Click(object sender, RoutedEventArgs e)
        {
            string result = CarCRUDOperations.UpdateCar(getDictionaryFromCar(carForBinding));

            if (result != "Update")
            {
                MessageBox.Show(result, "Error", MessageBoxButton.OK);
            }
            else
            {
                MessageBox.Show(result, "Info", MessageBoxButton.OK);
            }
        }
Beispiel #4
0
        private void comboBoxCars_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var    item  = (CmbElement)comboBoxCars.SelectedItem;
            string value = item.Value;

            if (value == "<Create>")
            {
                setButtonsForCreating();
                carForBinding = new Car();
                CmbElement cmbElementDefault = new CmbElement {
                    Id = 0, Value = "<Create>"
                };
                comboBoxReminders.SelectedItem = cmbElementDefault;
                setDataBindingForReminderComboBox();
                disableReminderButtons();
                comboBoxExpenses.SelectedItem = cmbElementDefault;
                setDataBindingForExpenseComboBox();
                disableExpenseButtons();
            }
            else
            {
                try
                {
                    setButtonsForUpdatingAndDeleting();
                    Car car = CarCRUDOperations.ReadCarById(Int32.Parse(value));
                    carForBinding = car;
                    CmbElement cmbElementDefault = new CmbElement {
                        Id = 0, Value = "<Create>"
                    };
                    setDataBindingForReminderComboBox();
                    setDataBindingForExpenseComboBox();
                }
                catch (Exception)
                {
                    ShowErrorInfo("Error in reading proper id.");
                    CmbElement cmbElementDefault = new CmbElement {
                        Id = 0, Value = "<Create>"
                    };
                    comboBoxCars.SelectedItem = cmbElementDefault;
                    return;
                }
            }
            CarTab.DataContext = carForBinding;
        }