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); } }
// GET: Inspections public ActionResult Index() { sqlconn.Open(); List <Inspection> inspections = InspectionLogic.FindAll(sqlconn); sqlconn.Close(); return(View(inspections)); }
private void cbVehicle_SelectionChanged(object sender, SelectionChangedEventArgs e) { Inspection newInsp = InspectionLogic.PrepareNewInspection(_sqlConn, Convert.ToInt32(cbVehicle.SelectedValue)); if (newInsp == null) { return; } inspectionDatePicker.SelectedDate = newInsp.InspectionDate; validToPicker.SelectedDate = newInsp.ValidTo; cbStation.SelectedValue = newInsp.InspectionStation.Id; tbPrice.Text = newInsp.Price.ToString(); }
// GET: Stats public ActionResult Index() { sqlconn.Open(); long vehiclesCount = VehicleLogic.CountVehiclesByAdminId(sqlconn, 1); long driversCount = VehicleLogic.CountDriversByAdminId(sqlconn, 1); long inspectionsCount = InspectionLogic.EndingInspectionsCount(sqlconn, 1, 30); sqlconn.Close(); ViewData["Vehicles"] = vehiclesCount; ViewData["Drivers"] = driversCount; ViewData["Inspections"] = inspectionsCount; return(View()); }
private void Refresh() { tbTitle.Text = _vehicle.Title; tbType.Text = _vehicle.VehicleType.TypeName; tbVin.Text = _vehicle.Vin; tbLicensePlate.Text = _vehicle.LicensePlate; tbBrand.Text = _vehicle.VehicleBrand.BrandName; tbVintage.Text = _vehicle.Vintage.ToString(); var lastInsp = InspectionLogic.GetLastInspection(_sqlConn, _vehicle.Id); if (lastInsp == null) { return; } tbValidDays.Text = (lastInsp.ValidTo - DateTime.Today).TotalDays + " dní"; tbValidTo.Text = lastInsp.ValidTo.ToShortDateString(); tbStation.Text = lastInsp.InspectionStation.Company; }
public ActionResult Delete(int id, Vehicle vehicle) { try { sqlconn.Open(); List <Inspection> inspections = InspectionLogic.FindAllByVehicleId(sqlconn, id); sqlconn.Close(); if (inspections.Count > 0) { return(View("<script>alert('Nemůžete smazat vozidlo, které obsahuje prohlídky.');</script>")); } sqlconn.Open(); VehicleLogic.Delete(sqlconn, 1, vehicle.Id); sqlconn.Close(); return(RedirectToAction(nameof(Index))); } catch { return(View(vehicle)); } }