public Patient(Rehab.PatientsRow patientsRow) { patientId = patientsRow.patientid; surname = patientsRow.surname; firstname = patientsRow.firstname; personnumber = patientsRow.personnumber; street = patientsRow.street; zipcode = patientsRow.zipcode; city = patientsRow.city; homePhone = patientsRow.homephone; mobilePhone = patientsRow.mobilephone; workPhone = patientsRow.workphone; freecardDate = patientsRow.freecarddate; info = patientsRow.info; }
public Booking(Rehab.BookingsRow booking) { patientid = booking.patientid; bookingid = booking.bookingid; title = booking.title; startdatetime = booking.startdatetime; enddatetime = booking.enddatetime; arrived = booking.arrived; notshown = booking.notshown; cancelled = booking.cancelled; note = booking.note; cancellednote = booking.cancellednote; mobilephone = booking.mobilephone; homephone = booking.homephone; workphone = booking.workphone; freecarddate = booking.freecarddate; personnumber = booking.personnumber; bookingtype = booking.bookingtype; }
private bool CheckBlockingBookings(DateTime startdatetime, DateTime enddatetime, int bookingtypeid, Rehab.BookingsDataTable otherBookings) { //Find out if the new booking is a blocking booking bool isNewBookingBlocking = false; BookingtypeTableAdapter bookingtypeTableAdapter = new BookingtypeTableAdapter(); int? blocking = bookingtypeTableAdapter.IsBookingtypeBlocking(bookingtypeid); if (blocking.HasValue) { if (blocking.Value == 1) isNewBookingBlocking = true; else if (blocking.Value == 0) isNewBookingBlocking = false; else throw new ApplicationException("Ett fel uppstod vid kontrollen om bokningen kolliderar med någon annan bokning på samma tidpunkt."); } foreach (DataRow dr in otherBookings) { bool isOtherBookingBlocking = false; Rehab.BookingsRow otherBooking = (Rehab.BookingsRow)dr; int? otherBookingBlocking = bookingtypeTableAdapter.IsBookingtypeBlocking(otherBooking.bookingtypeid); if (otherBookingBlocking.HasValue) { if (otherBookingBlocking.Value == 1) isOtherBookingBlocking = true; else if (otherBookingBlocking.Value == 0) isOtherBookingBlocking = false; else throw new ApplicationException("Ett fel uppstod vid kontrollen om bokningen kolliderar med någon annan bokning på samma tidpunkt."); } if (IsBookingsColliding(startdatetime, enddatetime, otherBooking.startdatetime, otherBooking.enddatetime)) { //If the new booking isn't blocking and the other booking isn't blocking either, then it's ok. //But if the new bocking is blocking the other booking isn't //or if the new booking is blocking and the other is too //or finally if the new booking isn't blocking but the other booking is //then we need to check so the start and end time don't collide if (!((isNewBookingBlocking == false) && (isOtherBookingBlocking == false))) { return false; //throw new ApplicationException("Det finns redan en bokning:\n" + otherBooking.title + " den " + otherBooking.startdatetime.ToShortDateString() + " mellan kl." + otherBooking.startdatetime.ToShortTimeString() + " och " + otherBooking.enddatetime.ToShortTimeString() + "\nVar vänlig avboka den tiden först"); } if ((otherBooking.bookingtypeid == (int)Booking.Bookingtypes.Behandling) && (bookingtypeid == (int)Booking.Bookingtypes.Behandling)) { if (otherBooking.cancelled) return true; else return false; //throw new ApplicationException("Det finns redan en behandling inbokad:\n" + otherBooking.title + " den " + otherBooking.startdatetime.ToShortDateString() + " mellan kl." + otherBooking.startdatetime.ToShortTimeString() + " och " + otherBooking.enddatetime.ToShortTimeString() + "\nDet går ej att boka två behandlingar samtidigt."); } if ((otherBooking.bookingtypeid == (int)Booking.Bookingtypes.Akupunktur) && (bookingtypeid == (int)Booking.Bookingtypes.Akupunktur)) { if (otherBooking.cancelled) return true; else return false; //throw new ApplicationException("Det finns redan en akupunktur inbokad:\n" + otherBooking.title + " den " + otherBooking.startdatetime.ToShortDateString() + " mellan kl." + otherBooking.startdatetime.ToShortTimeString() + " och " + otherBooking.enddatetime.ToShortTimeString() + "\nDet går ej att boka två akupunkturer samtidigt."); } } } //There was no colliding booking. return true; }