public void btnCheckOut_Click(object sender, EventArgs e) { try { string regNr = HelperClass.StringWash(txtLicensePlate.Text.ToUpper()); if (regNr != null) { if (radFreeOfCharge.Checked) { if (HelperClass.BackEndIO.BackEndCheckOutNoCost(regNr)) { Vehicle checkedOutVehicle = new Vehicle(regNr); checkedOutVehicle = HelperClass.BackEndIO.CheckOutInfo(regNr); DateTime UpdatedTime = checkedOutVehicle.ArrivalTime ?? DateTime.Now; TimeSpan span = DateTime.Now - UpdatedTime; MessageBox.Show($"Vehicle {regNr} is now checked out from the parking.\n" + $"Arrived at {checkedOutVehicle.ArrivalTime}\n" + $"Checked out at {checkedOutVehicle.DepartureTime} \n" + $"Parked for {span.Days} days ,{span.Hours} hours and {span.Minutes} minutes \n" + $"Total cost {checkedOutVehicle.PricePaid} CZK" + $"\n\nPress enter for main menu"); } else { MessageBox.Show("Could not find vehicle in the parking lot."); } } else { if (HelperClass.BackEndIO.BackEndCheckOut(regNr)) { Vehicle checkedOutVehicle = new Vehicle(regNr); checkedOutVehicle = HelperClass.BackEndIO.CheckOutInfo(regNr); DateTime UpdatedTime = checkedOutVehicle.ArrivalTime ?? DateTime.Now; TimeSpan span = DateTime.Now - UpdatedTime; MessageBox.Show($"Vehicle {regNr} is now checked out from the parking.\n" + $"Arrived at {checkedOutVehicle.ArrivalTime}\n" + $"Checked out at {checkedOutVehicle.DepartureTime} \n" + $"Parked for {span.Days} days ,{span.Hours} hours and {span.Minutes} minutes \n" + $"Total cost {checkedOutVehicle.PricePaid} CZK" + $"\n\nPress enter for main menu"); } else { MessageBox.Show("Could not find vehicle in the parking lot."); } } } else { MessageBox.Show("Invalid input."); } } catch (Exception ex) { MessageBox.Show(ex.Message); //throw; } txtLicensePlate.Text = string.Empty; radFreeOfCharge.Checked = false; }