Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Inspection im = new Inspection()
                {
                    Id                = -1,
                    Vehicle           = VehicleLogic.FindById(_sqlConn, Convert.ToInt32(cbVehicle.SelectedValue)),
                    InspectionDate    = inspectionDatePicker.SelectedDate.Value,
                    ValidTo           = validToPicker.SelectedDate.Value,
                    InspectionStation = InspectionStationLogic.FindById(_sqlConn, Convert.ToInt32(cbStation.SelectedValue)),
                    ProtocolNumber    = tbProtocolNr.Text,
                    Tachometer        = Convert.ToInt32(tbTachometer.Text),
                    Price             = Convert.ToInt32(tbPrice.Text),
                    Defects           = tbDefects.Text
                };

                bool result = InspectionLogic.Insert(_sqlConn, im, out var error);
                if (!result)
                {
                    MessageBox.Show(error, "Stop", MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                else
                {
                    MessageBox.Show($"Prohlídka byla uložena.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Vyplněné údaje jsou chybné:\n{ex.Message}",
                                "Stop", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Ejemplo n.º 2
0
        public void Refresh()
        {
            List <Vehicle> vehicles = VehicleLogic.FindAll(_sqlConn);

            cbVehicle.ItemsSource       = vehicles;
            cbVehicle.DisplayMemberPath = "Title";
            cbVehicle.SelectedValuePath = "Id";

            List <InspectionStation> stations = InspectionStationLogic.FindAll(_sqlConn);

            cbStation.ItemsSource       = stations;
            cbStation.DisplayMemberPath = "Company";
            cbStation.SelectedValuePath = "Id";
        }