private void buttonSetPaid_Click(object sender, EventArgs e) { Boolean paiddate = false; Boolean roomreservation = false; Boolean hallreservation = false; if (dataGridViewFolio.SelectedRows.Count > 0 && dataGridViewFolio.CurrentRow != null) { int folioid = Convert.ToInt32(dataGridViewFolio.CurrentRow.Cells[0].Value); string firstname = Convert.ToString(dataGridViewFolio.CurrentRow.Cells[1].Value); string lastname = Convert.ToString(dataGridViewFolio.CurrentRow.Cells[2].Value); Decimal foliototal = Convert.ToDecimal(dataGridViewFolio.CurrentRow.Cells[3].Value); // Confirm setting due date DialogResult confirmPaiddate = MessageBox.Show("Setting paid date today on folio that belongs to " + firstname + " " + lastname + " with a total cost of kr " + foliototal + "\nAre you sure you want to continue?", "Warning!", MessageBoxButtons.YesNo); if (confirmPaiddate == DialogResult.Yes) { // Checks -> Folio already has paid date, Folio has room reservation active, Folio has hall reservation active MySqlDataReader getFolioPaidStatus = DBGetData.GetFolioPaidDate(folioid); if (getFolioPaidStatus.Read()) { paiddate = true; } getFolioPaidStatus.Dispose(); if (paiddate) { new StatusMessage("Folio has already been paid."); } if (DBGetData.GetFolioRoomreservation(folioid) > 0) { roomreservation = true; } if (roomreservation) { new StatusMessage("Folio owner has an active room reservation, cannot mark with paid date until after checkout."); } if (DBGetData.GetFolioHallreservation(folioid) > 0) { hallreservation = true; } if (hallreservation) { new StatusMessage("Folio owner has an active hall reservation, cannot mark with paid date until after checkout."); } if (!paiddate && !roomreservation && !hallreservation) { // Save entry to database DBSetData.FolioPaidDate(folioid); LoadDataFolio(); dataGridViewFolio.Refresh(); new StatusMessage("Folio marked as paid today."); } } } }