Esempio 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);
            }
        }
Esempio n. 2
0
        // GET: Vehicles/Details/5
        public ActionResult Details(int id)
        {
            sqlconn.Open();
            Vehicle vehicle = VehicleLogic.FindById(sqlconn, id);

            sqlconn.Close();
            return(View(vehicle));
        }