private void ButtonConfirmPayRental_Click(object sender, EventArgs e) { try { Decimal change = _rentalController.CalculateChange(numericUpDownTotalPricePayRental.Value, numericUpDownPayment.Value); // Set the booking date time, rental code & rental key DateTime bookingDateTime = DateTime.Now; string rentalCode = bookingDateTime.ToString("yyyyMMddHHmmssffffff"); string rentalKey = Security.SHA256Hash(rentalCode + _locker.Code + _customer.IcPassport + _rental.Duration.ToString() + _rental.StartDate.ToString("ddMMyyyy") + _employee.IcPassport); // Insert the above data into the rental _rentalController.SetPayRentalData(rentalCode, bookingDateTime, rentalKey); // Save the rental _rentalController.SaveRentalData(); // Display the payment result numericUpDownChange.Value = change; // Generate the QRCode Bitmap qrCodeImage = _rentalController.GenerateQR(rentalKey); pictureBoxQRCodePayRental.Image = qrCodeImage; // Set Rental Inserted as true _isInsertComplete = true; // Hide Confirm & back button buttonConfirmPayRental.Hide(); buttonBackPayRental.Hide(); // Show OK button buttonOKPayRental.Show(); } catch (InvalidUserInputException exception) { exception.ShowErrorMessage(); } }