protected void ButtonArchive_Click(object sender, EventArgs e)
    {
        DataView dv = (DataView) ObjectDataSourceArchive.Select();
        bookings = (Rehab.BookingsDataTable)dv.Table;

        foreach (DataRow dr in bookings)
        {
            booking = (Rehab.BookingsRow)dr;

            if (booking.startdatetime.Year.ToString() != DropDownListYeartoArchive.SelectedValue)
            {
                LabelErrorInfo.Text = "En eller flera bokningar tillhör ett annat år än det som valdes att arkivera till. De/dessa bokningar arkiverades inte.";
                LabelErrorInfo.Visible = true;
            }
            else
            {

                ObjectDataSourceArchive.Insert();

                ObjectDataSourceArchive.Delete();
            }
        }

        LabelResult.Text = nrofBookingsArchived + " bokningar arkiverades!";
    }
    protected void Page_PreRender(object sender, EventArgs e)
    {
        DataView dv = (DataView)ObjectDataSourceArchive.Select();
        bookings = (Rehab.BookingsDataTable)dv.Table;
        int nrofOldBookings = bookings.Count;

        dv = (DataView)ObjectDataSourceAllBookings.Select();
        bookings = (Rehab.BookingsDataTable)dv.Table;
        int nrofBookings = bookings.Count;

        LabelNrofBookings.Text = "Det finns totalt " + nrofBookings + " bokningar i den primära tabellen, varav " + nrofOldBookings + " är äldre än " + TextBoxDate.Text + ".";
    }
示例#3
0
    public bool AddBooking(int patientid, string title, DateTime startdatetime, 
        DateTime enddatetime, string note, int bookingtypeid)
    {
        Rehab.BookingsDataTable bookings = new Rehab.BookingsDataTable();
        Rehab.BookingsRow booking = bookings.NewBookingsRow();

        if ((startdatetime == null) || (enddatetime == null))
            throw new ApplicationException("Start-och sluttid för bokningen måste vara angivet.");

        //Do business logic validation here
        PatientsTableAdapter patientsTableAdapter = new PatientsTableAdapter();
        Rehab.PatientsDataTable patients = patientsTableAdapter.GetDataByPatientID(patientid);
        if (patients.Count == 0)
            throw new ApplicationException("Bokningen försöker göras med en patient som inte finns.");

        ValidateBookingDateTime(startdatetime, enddatetime);

        //Get other bookings this day and see if the interfere with the new booking
        Rehab.BookingsDataTable otherBookings = GetBookingsByDate(startdatetime);

        bool isBookingPossible = false;
        DateTime newStartdatetime = startdatetime;
        DateTime newEnddatetime = enddatetime;

        while ((!isBookingPossible) && (startdatetime < new DateTime(startdatetime.Year, startdatetime.Month, startdatetime.Day, 19, 0 , 0)))
        {
            isBookingPossible = CheckBlockingBookings(newStartdatetime, newEnddatetime, bookingtypeid, otherBookings);

            if (!isBookingPossible)
            {
                newStartdatetime =  newStartdatetime.AddMinutes((double)30);
                newEnddatetime = newEnddatetime.AddMinutes((double)30);
            }
        }

        if (isBookingPossible)
        {
            if (newStartdatetime != startdatetime)
                throw new Common.CollidingBookingException(startdatetime, enddatetime, newStartdatetime, newEnddatetime);
        }
        else
            throw new ApplicationException("Det finns ingen ledig tid idag från det angivna klockslaget.");

        booking.startdatetime = startdatetime;
        booking.enddatetime = enddatetime;
        booking.patientid = patientid;
        booking.title = title;
        booking.bookingtypeid = bookingtypeid;

        booking.arrived = false;
        booking.notshown = false;

        booking.cancelled = false;
        booking.SetcancellednoteNull();

        if (note == null)
            booking.SetnoteNull();
        else
            booking.note = note;

        booking.createdatetime = DateTime.Now;

        bookings.AddBookingsRow(booking);
        int affectedRows = Adapter.Update(bookings);

        return affectedRows == 1;
    }
示例#4
0
    public Rehab.BookingsDataTable GetBookingsByBookingID(int? bookingID)
    {
        Rehab.BookingsDataTable bookings = new Rehab.BookingsDataTable();

        if (bookingID != null)
        {
            if (bookingID.Value > -1)
                bookings = Adapter.GetBookingsByBookingID(bookingID.Value);

        }

        return bookings;
    }