protected void btnDelete_Command(object sender, CommandEventArgs e)
    {
        int booking_id = Convert.ToInt32(e.CommandArgument);

        BookingDB.Delete(booking_id);
        UpdateList();
    }
Exemplo n.º 2
0
    protected Tuple <Booking, PatientReferrer, bool, string, HealthCard> LoadRow(DataRow row)
    {
        Booking booking = BookingDB.Load(row, "booking_", true, false);

        booking.Offering = OfferingDB.Load(row, "offering_");

        PatientReferrer pr = PatientReferrerDB.Load(row, "pr_");

        pr.RegisterReferrer                       = RegisterReferrerDB.Load(row, "regref_");
        pr.RegisterReferrer.Referrer              = ReferrerDB.Load(row, "referrer_");
        pr.RegisterReferrer.Referrer.Person       = PersonDB.Load(row, "referrer_person_");
        pr.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(row, "referrer_person_title_title_id", "referrer_person_title_descr");
        if (row["organisation_organisation_id"] != DBNull.Value)
        {
            pr.RegisterReferrer.Organisation = OrganisationDB.Load(row, "organisation_");
        }
        pr.Patient              = PatientDB.Load(row, "patient_");
        pr.Patient.Person       = PersonDB.Load(row, "patient_person_");
        pr.Patient.Person.Title = IDandDescrDB.Load(row, "patient_person_title_title_id", "patient_person_title_descr");

        bool   refHasEmail = Convert.ToInt32(row["ref_has_email"]) == 1;
        string refEmail    = row["ref_email"] == DBNull.Value ? null : Convert.ToString(row["ref_email"]);

        HealthCard hc = HealthCardDB.Load(row, "hc_");

        return(new Tuple <Booking, PatientReferrer, bool, string, HealthCard>(booking, pr, refHasEmail, refEmail, hc));
    }
Exemplo n.º 3
0
    protected void UpdateGenerateSystemLetters()
    {
        int bookingCountToGenerateSystemLetters = BookingDB.GetBookingCountToGenerateSystemLetters(DateTime.MinValue, DateTime.MinValue, GetFormID());

        lblBookingsYetToGenerateSystemLetters.Text = bookingCountToGenerateSystemLetters.ToString();
        btnGenerateSystemLetters.Visible           = bookingCountToGenerateSystemLetters > 0;
    }
Exemplo n.º 4
0
    public bool HasFutureBookings(Staff staff, System.Web.UI.HtmlControls.HtmlInputCheckBox chkBox, DayOfWeek dayOfWeek)
    {
        if (chkBox.Checked)
        {
            return(false);
        }

        Booking[] bookings = BookingDB.GetFutureBookings(staff, null, dayOfWeek.ToString(), new TimeSpan(0, 0, 0), new TimeSpan(23, 59, 59));
        if (bookings.Length == 0)
        {
            return(false);
        }

        string space        = "          ";
        string bookingDates = string.Empty;

        for (int i = 0; i < bookings.Length; i++)
        {
            bookingDates += "<br />" + space + bookings[i].DateStart.ToString(@"ddd MMM d, yyy HH:mm");
        }

        lblErrorMessage.Text    = "Can not select " + dayOfWeek.ToString() + "  as not working until the bookings on the following days have been moved or deleted:" + "<br />" + bookingDates + "<br />";
        lblErrorMessage.Visible = true;
        return(true);
    }
Exemplo n.º 5
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        Booking booking    = BookingDB.GetByID(GetFormBooking());
        bool    isAgedCare = booking.Organisation.IsAgedCare;


        string tmpLettersDirectory = FileHelper.GetTempDirectoryName(Letter.GetTempLettersDirectory());

        Directory.CreateDirectory(tmpLettersDirectory);

        string templateFileName = isAgedCare ? "ACTreatmentList.docx" : "TreatmentList.docx";
        string originalFile     = Letter.GetLettersDirectory() + templateFileName;
        string tmpOutputFile    = tmpLettersDirectory + "TreatmentList.pdf"; // System.IO.Path.GetExtension(originalFile));

        if (!File.Exists(originalFile))
        {
            SetErrorMessage("Template File '" + templateFileName + "' does not exist.");
            return;
        }

        MergeFile(isAgedCare, originalFile, tmpOutputFile);

        Letter.FileContents fileContents = new Letter.FileContents(System.IO.File.ReadAllBytes(tmpOutputFile), "TreatmentList.pdf");
        File.Delete(tmpOutputFile);
        System.IO.File.SetAttributes(tmpLettersDirectory, FileAttributes.Normal);
        System.IO.Directory.Delete(tmpLettersDirectory, true);

        // Nothing gets past the "DownloadDocument" method because it outputs the file
        // which is writing a response to the client browser and calls Response.End()
        // So make sure any other code that functions goes before this
        Letter.DownloadDocument(Response, fileContents.Contents, fileContents.DocName);
    }
Exemplo n.º 6
0
    protected void btnGenerateSystemLetters_Click(object sender, EventArgs e)
    {
        System.Collections.ArrayList fileContentsList = new System.Collections.ArrayList();

        Booking[] bookings = BookingDB.GetBookingsToGenerateSystemLetters(DateTime.MinValue, DateTime.MinValue, GetFormID());
        for (int i = 0; i < bookings.Length; i++)
        {
            // send referrer letters

            PatientReferrer[] patientReferrers = PatientReferrerDB.GetActiveEPCPatientReferrersOf(bookings[i].Patient.PatientID);
            if (patientReferrers.Length > 0)
            {
                HealthCard hc = HealthCardDB.GetActiveByPatientID(bookings[i].Patient.PatientID);
                bool       needToGenerateTreatmentLetter = patientReferrers[patientReferrers.Length - 1].RegisterReferrer.ReportEveryVisitToReferrer;

                Letter.FileContents[] bookingFileContentsList = bookings[i].GetSystemLettersList(Letter.FileFormat.Word, bookings[i].Patient, hc, bookings[i].Offering.Field.ID, patientReferrers[patientReferrers.Length - 1].RegisterReferrer.Referrer, true, bookings[i].NeedToGenerateFirstLetter, bookings[i].NeedToGenerateLastLetter, needToGenerateTreatmentLetter, false, Convert.ToInt32(Session["SiteID"]), Convert.ToInt32(Session["StaffID"]), 1);
                fileContentsList.AddRange(bookingFileContentsList);
                BookingDB.UpdateSetGeneratedSystemLetters(bookings[i].BookingID, bookings[i].NeedToGenerateFirstLetter, bookings[i].NeedToGenerateLastLetter, true);
            }
        }

        Letter.FileContents mergedFileContents = Letter.FileContents.Merge((Letter.FileContents[])fileContentsList.ToArray(typeof(Letter.FileContents)), "Treatment Letters.doc"); // .pdf
        if (mergedFileContents != null)
        {
            Session["downloadFile_Contents"] = mergedFileContents.Contents;
            Session["downloadFile_DocName"]  = mergedFileContents.DocName;
            Page.ClientScript.RegisterStartupScript(this.GetType(), "download", "<script language=javascript>window.open('DownloadFile.aspx','_blank','status=1,toolbar=0,menubar=0,location=1,scrollbars=1,resizable=1,width=30,height=30');</script>");
        }

        UpdateGenerateSystemLetters();
    }
Exemplo n.º 7
0
    protected void GrdRegistration_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Label lblId = (Label)GrdRegistration.FooterRow.FindControl("lblId");

        RegisterStaff registerStaff = RegisterStaffDB.GetByID(Convert.ToInt32(lblId.Text));

        if (BookingDB.GetCountByProviderAndOrg(registerStaff.Staff.StaffID, registerStaff.Organisation.OrganisationID) > 0)
        {
            SetErrorMessage("Can not remove registration of '" + registerStaff.Staff.Person.FullnameWithoutMiddlename + "' to '" + registerStaff.Organisation.Name + "' because there exists a booking for this provider there.");
            return;
        }

        try
        {
            RegisterStaffDB.UpdateInactive(Convert.ToInt32(lblId.Text), false);
        }
        catch (ForeignKeyConstraintException fkcEx)
        {
            if (Utilities.IsDev())
            {
                HideTableAndSetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message);
            }
            else
            {
                HideTableAndSetErrorMessage("Can not delete because other records depend on this");
            }
        }

        FillGrid();
    }
    protected void GrdBooking_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Reverse")
        {
            try
            {
                UserView userView = UserView.GetInstance();

                int     booking_id = Convert.ToInt32(e.CommandArgument);
                Booking booking    = BookingDB.GetByID(booking_id);

                string errorString = string.Empty;
                if (!booking.CanReverse(userView.IsAdminView, out errorString))
                {
                    throw new CustomMessageException(errorString);
                }

                booking.Reverse(UserView.GetInstance().IsAdminView, Convert.ToInt32(Session["StaffID"]));

                FillGrid();
            }
            catch (CustomMessageException ex)
            {
                SetErrorMessage(ex.Message);
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
    }
Exemplo n.º 9
0
    protected void FillGrid()
    {
        UserView userView = UserView.GetInstance();

        DateTime fromDate = IsValidDate(txtStartDate.Text) ? GetDate(txtStartDate.Text)                              : DateTime.MinValue;
        DateTime toDate   = IsValidDate(txtEndDate.Text)   ? GetDate(txtEndDate.Text).Add(new TimeSpan(23, 59, 59))  : DateTime.MinValue;


        if (!IsValidDate(txtStartDate.Text))
        {
            SetErrorMessage("Please Enter A Valid Start Date");
            SetGrid();
            return;
        }
        if (!IsValidDate(txtEndDate.Text))
        {
            SetErrorMessage("Please Enter A Valid End Date");
            SetGrid();
            return;
        }


        DataTable dt = BookingDB.GetReport_StaffTimetable(fromDate, toDate, chkIncBookings.Checked, userView.IsAgedCareView || chkIncAllSites.Checked, userView.IsClinicView || chkIncAllSites.Checked, Convert.ToInt32(ddlOrgs.SelectedValue), Convert.ToInt32(ddlProviders.SelectedValue));

        Session["data_summaryReport"] = dt;

        SetGrid();
    }
Exemplo n.º 10
0
    protected void DisallowAddEditIfNoPermissions()
    {
        // if its a booking note
        // only allow add/edit if by the provider of the booking, or by a "principle" staff memeber

        UserView userView        = UserView.GetInstance();
        int      loggedInStaffID = Session["StaffID"] == null ? -1 : Convert.ToInt32(Session["StaffID"]);

        Booking booking = BookingDB.GetByEntityID(GetFormID());

        if (booking != null)
        {
            bool canAddEdit = (booking.Provider != null && loggedInStaffID == booking.Provider.StaffID) || userView.IsPrincipal || userView.IsStakeholder;
            if (!canAddEdit)
            {
                GrdNote.FooterRow.Visible = false;
                for (int i = 0; i < GrdNote.Columns.Count; i++)
                {
                    if (GrdNote.Columns[i].HeaderText.Trim() == ".")
                    {
                        GrdNote.Columns[i].Visible = false;
                    }
                }
            }
        }
    }
Exemplo n.º 11
0
 public static int NumForeignKeyDependencies(int entity_id)
 {
     return(SiteDB.GetCountByEntityID(entity_id) +
            PersonDB.GetCountByEntityID(entity_id) +
            OrganisationDB.GetCountByEntityID(entity_id) +
            BookingDB.GetCountByEntityID(entity_id) +
            InvoiceDB.GetCountByEntityID(entity_id));
 }
Exemplo n.º 12
0
        public void TestFindNull()
        {
            var db = new BookingDB();

            (int, BookingType)key = (1, BookingType.Event);
            var returnedValues = db.Find(key);

            Assert.Null(returnedValues);
        }
Exemplo n.º 13
0
    public string GetDebtor(bool asLink = false)
    {
        string name = null;
        string url  = null;

        if (this.PayerOrganisation != null)
        {
            name = this.PayerOrganisation.Name;
            if (this.PayerOrganisation.OrganisationID != -1 && this.PayerOrganisation.OrganisationID != -2 || this.PayerOrganisation.OrganisationType.OrganisationTypeID != 150)
            {
                url = "OrganisationDetailV2.aspx?type=view&id=" + this.PayerOrganisation.OrganisationID;
            }
        }
        else if (this.PayerPatient != null)
        {
            name = this.PayerPatient.Person.FullnameWithoutMiddlename;
            url  = "PatientDetailV2.aspx?type=view&id=" + this.PayerPatient.PatientID;
        }
        else
        {
            if (this.Booking != null && this.Booking.Patient != null)
            {
                // can add this query each row because in the whole system there is only 32 invoices that get to here
                // since the rest keep the patient as the payer_patient
                // and doing this for only 32 rows avoids pulling all the extra data for all invoices so its faster doing this
                Booking booking = BookingDB.GetByID(this.Booking.BookingID);
                name = booking.Patient.Person.FullnameWithoutMiddlename;
                url  = "PatientDetailV2.aspx?type=view&id=" + booking.Patient.PatientID;
            }
            else // no debtor for some cash invoices
            {
                ;
            }
        }


        if (!asLink)
        {
            return(name == null ? string.Empty : name);
        }
        else
        {
            if (name == null)
            {
                return(string.Empty);
            }
            else if (url == null)
            {
                return(name);
            }
            else
            {
                return("<a href=\"#\" onclick=\"open_new_tab('" + url + "');return false;\">" + name + "</a>");
            }
        }
    }
Exemplo n.º 14
0
    protected void FillGrid()
    {
        Booking booking = BookingDB.GetByID(GetFormBooking());

        DataTable dt = Letter.GenerateInvoiceLines_ByBookingID(GetFormBooking(chkIncAddOns.Checked), booking.Organisation.IsAgedCare);

        // add to sort on room correctly
        dt.Columns.Add("PaddedRoom", typeof(String));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            dt.Rows[i]["PaddedRoom"] = dt.Rows[i]["Room"] == DBNull.Value ? DBNull.Value : (object)PadRoomNbr(dt.Rows[i]["Room"].ToString().Trim(), true);
        }

        Session["invoicelistac_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["invoicelistac_sortexpression"] != null && Session["invoicelistac_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort         = Session["invoicelistac_sortexpression"].ToString();
                GrdBooking.DataSource = dataView;
            }
            else
            {
                GrdBooking.DataSource = dt;
            }


            try
            {
                GrdBooking.DataBind();
            }
            catch (Exception ex)
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdBooking.DataSource = dt;
            GrdBooking.DataBind();

            int TotalColumns = GrdBooking.Rows[0].Cells.Count;
            GrdBooking.Rows[0].Cells.Clear();
            GrdBooking.Rows[0].Cells.Add(new TableCell());
            GrdBooking.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdBooking.Rows[0].Cells[0].Text       = "No Record Found";
        }

        if (!booking.Organisation.IsAgedCare)
        {
            GrdBooking.Columns[1].Visible = false;
        }
    }
    protected void UpdateList(Organisation org, Staff staff)
    {
        DataTable bookings = BookingDB.GetDataTable_Between(DateTime.MinValue, DateTime.MinValue, staff == null || !chkOnlyThisProvider.Checked ? null : new Staff[] { staff }, org == null || !chkOnlyThisOrganistion.Checked ? null : new Organisation[] { org }, null, null, false, null, true);

        for (int i = bookings.Rows.Count - 1; i >= 0; i--)
        {
            if (staff == null && bookings.Rows[i]["booking_provider"] != DBNull.Value)
            {
                bookings.Rows.RemoveAt(i);
                continue;
            }
            if (staff != null && chkOnlyThisProvider.Checked && (bookings.Rows[i]["booking_provider"] == DBNull.Value || Convert.ToInt32(bookings.Rows[i]["booking_provider"]) != staff.StaffID))
            {
                bookings.Rows.RemoveAt(i);
                continue;
            }
            if (org == null && bookings.Rows[i]["booking_organisation_id"] != DBNull.Value)
            {
                bookings.Rows.RemoveAt(i);
                continue;
            }
            if (org != null && chkOnlyThisOrganistion.Checked && (bookings.Rows[i]["booking_organisation_id"] == DBNull.Value || Convert.ToInt32(bookings.Rows[i]["booking_organisation_id"]) != org.OrganisationID))
            {
                bookings.Rows.RemoveAt(i);
                continue;
            }
        }

        DataView dataView = new DataView(bookings);

        dataView.Sort = "booking_date_start DESC";
        bookings      = dataView.ToTable();

        DataTable individualBookings = bookings.Copy();
        DataTable recurringBookings  = bookings.Copy();

        for (int i = bookings.Rows.Count - 1; i >= 0; i--)
        {
            if (Convert.ToBoolean(bookings.Rows[i]["booking_is_recurring"]))
            {
                individualBookings.Rows.RemoveAt(i);
            }
            else
            {
                recurringBookings.Rows.RemoveAt(i);
            }
        }

        lstIndividualBookings.DataSource = individualBookings;
        lstIndividualBookings.DataBind();

        lstRecurringBookings.DataSource = recurringBookings;
        lstRecurringBookings.DataBind();
    }
Exemplo n.º 16
0
        private void savetodb()
        {
            //add customer to Database
            BookingDB book = new BookingDB(db);

            if (existingcustomer == null) //if no existing customer
            {
                book.Addcustomer(cust.Forename, cust.Surname, cust.TeleNo, cust.Postcode, cust.Address);
            }
            else
            {
                cust = existingcustomer;
            }

            if (existingkid != null) // if existing kid
            {
                foreach (DateTime date in finishedbookings[0].Mondays)
                {
                    if (alreadybooked.Contains(date))
                    {
                        finishedbookings[0].Mondays.Remove(date);
                        book.UpdateDate(date, existingkid.Forename, existingkid.Surname);
                    }
                }
                book.AddDate(finishedbookings[0].Mondays, existingkid.Forename, existingkid.Surname); // add dates to db
                if (Dates2Remove.Count > 0)
                {
                    book.removeDate(Dates2Remove, existingkid.Forename, existingkid.Surname); //remove dates that have been unbooked
                }
            }
            else //else add new kids/bookings
            {
                int i = 0;
                foreach (Kid child in kids)
                {
                    book.Addkid(child.Forename, child.Surname, child.DOB, cust.Forename, cust.Surname);
                    book.AddBooking(child.Forename, MiscFunctions.getgroupfromage(child.DOB), finishedbookings[i].Days[0], finishedbookings[i].Days[1], finishedbookings[i].Days[2], finishedbookings[i].Days[3], finishedbookings[i].Days[4], child.Surname);
                    book.AddDate(finishedbookings[i].Mondays, child.Forename, child.Surname);
                    if (Dates2Remove.Count > 0)
                    {
                        book.removeDate(Dates2Remove, child.Forename, child.Surname);
                    }
                    i++;
                }
            }



            MessageBox.Show("Booking completed");
            CrecheMenu next = new Gui.CrecheMenu();

            this.Hide();
            next.Show();
        }
Exemplo n.º 17
0
 private Booking GetFormBooking()
 {
     try
     {
         string id = Request.QueryString["id"];
         return((id == null || !Regex.IsMatch(id, @"^\d+$")) ? null : BookingDB.GetByID(Convert.ToInt32(id)));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 18
0
    private Booking GetFormBooking()
    {
        if (!IsValidFormBooking())
        {
            throw new Exception("Invalid booking id");
        }

        int     id      = Convert.ToInt32(Request.QueryString["booking_id"]);
        Booking booking = BookingDB.GetByID(id);

        return(booking);
    }
Exemplo n.º 19
0
        public void TestDbIsNotEmpty()
        {
            var db = new BookingDB();

            (int, BookingType)key = (1, BookingType.Event);
            List <int> values = new List <int>()
            {
                101, 102, 103
            };

            db.AddOrUpdate(key, values);

            Assert.False(db.IsEmpty());
        }
    protected void GrdLetterPrintHistory_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataTable dt       = Session["letterprinthistory_data"] as DataTable;
        bool      tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value);

        if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow)
        {
            Label     lblId     = (Label)e.Row.FindControl("lblId");
            DataRow[] foundRows = dt.Select("lph_letter_print_history_id=" + lblId.Text);
            DataRow   thisRow   = foundRows[0];

            LetterPrintHistory letterPrintHistory = LetterPrintHistoryDB.LoadAll(thisRow);

            Button btnRetrieveFlatFile = (Button)e.Row.FindControl("btnRetrieveFlatFile");
            if (btnRetrieveFlatFile != null && btnRetrieveFlatFile.CssClass != "hiddencol")
            {
                string historyDir  = Letter.GetLettersHistoryDirectory(thisRow["lph_organisation_id"] == DBNull.Value ? 0 : Convert.ToInt32(thisRow["lph_organisation_id"]));
                string filePath    = historyDir + letterPrintHistory.LetterPrintHistoryID + System.IO.Path.GetExtension(letterPrintHistory.DocName);
                string filePathPDF = historyDir + letterPrintHistory.LetterPrintHistoryID + ".pdf";

                btnRetrieveFlatFile.Visible = System.IO.File.Exists(filePath) || System.IO.File.Exists(filePathPDF);
            }


            HyperLink lnkBookingSheetForPatient = (HyperLink)e.Row.FindControl("lnkBookingSheetForPatient");
            if (lnkBookingSheetForPatient != null)
            {
                if (thisRow["lph_booking_id"] == DBNull.Value)
                {
                    lnkBookingSheetForPatient.Visible = false;
                }
                else
                {
                    int     booking_id = Convert.ToInt32(thisRow["lph_booking_id"]);
                    Booking booking    = BookingDB.GetByID(booking_id);
                    lnkBookingSheetForPatient.NavigateUrl = booking.GetBookingSheetLinkV2();
                }
            }


            Utilities.AddConfirmationBox(e);
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow);
            }
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
        }
    }
Exemplo n.º 21
0
        public void TestRemove()
        {
            var db = new BookingDB();

            (int, BookingType)key = (1, BookingType.Event);
            List <int> values = new List <int>()
            {
                101, 102, 103
            };

            db.AddOrUpdate(key, values);
            db.Remove(key);

            Assert.Null(db.Find(key));
        }
Exemplo n.º 22
0
    public static void UpdateInactive(int register_staff_id, bool checkFKConstraint = true)
    {
        if (checkFKConstraint)
        {
            RegisterStaff registerStaff = RegisterStaffDB.GetByID(register_staff_id);
            if (BookingDB.GetCountByProviderAndOrg(registerStaff.Staff.StaffID, registerStaff.Organisation.OrganisationID, "0") > 0)
            {
                throw new CustomMessageException("Can not remove registration of '" + registerStaff.Staff.Person.FullnameWithoutMiddlename + "' to '" + registerStaff.Organisation.Name + "' because there exists incomplete bookings for this provider there.");
            }
        }

        string sql = "UPDATE RegisterStaff SET is_deleted = 1 WHERE register_staff_id = " + register_staff_id.ToString();

        DBBase.ExecuteNonResult(sql);
    }
Exemplo n.º 23
0
        public void TestFindAfterAdding()
        {
            var db = new BookingDB();

            (int, BookingType)key = (1, BookingType.Event);
            List <int> values = new List <int>()
            {
                101, 102, 103
            };

            db.AddOrUpdate(key, values);
            var returnedValues = db.Find(key);

            Assert.Equal(values, returnedValues);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Utilities.SetNoCache(Response);
        }

        try
        {
            if (Session == null || Session["DB"] == null)
            {
                throw new SessionTimedOutException();
            }

            string booking_id = Request.QueryString["booking_id"];

            if (booking_id == null || !Regex.IsMatch(booking_id, @"^\d+$"))
            {
                throw new CustomMessageException("Booking id does not exist or is not a number");
            }

            Booking booking = BookingDB.GetByID(Convert.ToInt32(booking_id));
            if (booking == null)
            {
                throw new CustomMessageException("Booking is null");
            }


            Patient patient = booking.Patient;
            if (booking.Patient == null)
            {
                Response.Write("-1");
            }
            else
            {
                Response.Write(booking.Patient.PatientID.ToString());
            }
        }
        catch (SessionTimedOutException)
        {
            Utilities.UnsetSessionVariables();
            Response.Write("SessionTimedOutException");
        }
        catch (Exception ex)
        {
            Response.Write((Utilities.IsDev() ? "Exception: " + ex.ToString() : "Error - please contact system administrator."));
        }
    }
 private Booking GetFormBooking()
 {
     try
     {
         string bookingID = Request.QueryString["booking"];
         if (bookingID == null || !Regex.IsMatch(bookingID, @"^\d+$"))
         {
             throw new CustomMessageException("Invalid booking id");
         }
         return(BookingDB.GetByID(Convert.ToInt32(Request.QueryString["booking"])));
     }
     catch (CustomMessageException ex)
     {
         HideTableAndSetErrorMessage(Utilities.IsDev() ? ex.Message : "");
         return(null);
     }
 }
Exemplo n.º 26
0
        //remove the selected booking
        private void btndelete_Click(object sender, EventArgs e)
        {
            if (bookinglistbox.Items.Count < 1)
            {
                MessageBox.Show("Add a booking first!");
                return;
            }
            DateTime        date  = Convert.ToDateTime(bookinglistbox.Text);
            List <DateTime> dates = new List <DateTime>();

            dates.Add(date);
            BookingDB bdb = new BookingDB(db);

            bdb.removeDate(dates, kids[kidslistbox.SelectedIndex].Forename, kids[kidslistbox.SelectedIndex].Surname);
            MessageBox.Show("Success");
            populateDates();
        }
Exemplo n.º 27
0
        //once the kid is selected setup the view
        private void btncheck_Click(object sender, EventArgs e)
        {
            bookingpnl1.Visible = false;
            bookingpnl2.Visible = true;
            fnamelbl.Text       = "Forename: " + kids[kidslistbox.SelectedIndex].Forename;
            snamelbl.Text       = "Surname: " + kids[kidslistbox.SelectedIndex].Surname;
            doblbl.Text         = "DOB: " + kids[kidslistbox.SelectedIndex].DOB;
            agelbl.Text         = "Age: " + calculateAge() + " months old";
            agegrouplbl.Text    = "Age Group Name: " + MiscFunctions.getgroupfromage(kids[kidslistbox.SelectedIndex].DOB);

            //gather bookings
            List <custBooking> bookings = new List <custBooking>();
            BookingDB          booking  = new BookingDB(db);

            bookings = booking.getallbookingsforkid(kids[kidslistbox.SelectedIndex].Forename, kids[kidslistbox.SelectedIndex].Surname);
            populateDates();
        }
Exemplo n.º 28
0
    public static SMSHistoryData LoadAll(DataRow row)
    {
        SMSHistoryData s = Load(row);

        if (row["booking_booking_id"] != DBNull.Value)
        {
            s.Booking = BookingDB.Load(row, "booking_", false, false);
        }
        if (row["patient_patient_id"] != DBNull.Value)
        {
            s.Patient              = PatientDB.Load(row, "patient_");
            s.Patient.Person       = PersonDB.Load(row, "person_patient_");
            s.Patient.Person.Title = IDandDescrDB.Load(row, "title_patient_title_id", "title_patient_descr");
        }

        return(s);
    }
Exemplo n.º 29
0
    protected void GetClashOneTimeBooking()
    {
        string org_id          = Request.QueryString["org"];
        string staff_id        = Request.QueryString["staff"];
        string booking_id      = Request.QueryString["edit_booking_id"];
        string booking_type_id = Request.QueryString["booking_type_id"];

        string start_datetime = Request.QueryString["start_datetime"];
        string end_datetime   = Request.QueryString["end_datetime"];


        if (start_datetime == null || !Regex.IsMatch(start_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$") ||
            end_datetime == null || !Regex.IsMatch(end_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$") ||
            org_id == null || !Regex.IsMatch(org_id, @"^\-?\d+$") ||
            staff_id == null || !Regex.IsMatch(staff_id, @"^\-?\d+$") ||
            booking_id == null || !Regex.IsMatch(booking_id, @"^\-?\d+$"))
        {
            throw new CustomMessageException();
        }

        Organisation org     = OrganisationDB.GetByID(Convert.ToInt32(org_id));
        Staff        staff   = StaffDB.GetByID(Convert.ToInt32(staff_id));
        Booking      booking = booking_id == "-1" ? null : BookingDB.GetByID(Convert.ToInt32(booking_id));

        if (booking != null && booking_type_id == "-1")
        {
            booking_type_id = booking.BookingTypeID.ToString();
        }

        if ((org_id != "0" && org == null) ||
            (staff_id != "-1" && staff == null) ||
            (booking_id != "-1" && booking == null) ||
            (booking_type_id == null || (booking_type_id != "34" && booking_type_id != "340" && booking_type_id != "341" && booking_type_id != "342")))
        {
            throw new CustomMessageException();
        }

        DateTime startDateTime = ConvertStringToDateTime(start_datetime);
        DateTime endDateTime   = ConvertStringToDateTime(end_datetime);

        Booking[] bookings            = BookingDB.GetToCheckOverlap_OneTime(startDateTime, endDateTime, staff, org, booking_type_id == "342", true, false);
        Booking[] overlappingBookings = Booking.GetOverlappingBookings(bookings, startDateTime, endDateTime, booking);
        Response.Write(GetLinks(overlappingBookings));
    }
Exemplo n.º 30
0
 public Booking(Customer existingcustomer, Kid existingkid)
 {
     //estabilsh db connection
     db = new Database();
     db.connect();
     InitializeComponent();
     this.existingcustomer = existingcustomer;
     this.existingkid      = existingkid;
     //if customer already exist we dont need to create a new one
     if (existingcustomer != null)
     {
         book1pnl.Visible = false;
     }
     //if kid already exist we do not need to create a new one
     if (existingkid != null && !book1pnl.Visible)
     {
         BookingDB bookingdb = new BookingDB(db);
         alreadybooked = bookingdb.getalldates(existingkid.Forename, existingkid.Surname).Mondays;
         foreach (DateTime booking in alreadybooked)
         {
             calculatePrice(booking, false);
             childsprice = finalprice;
         }
         //setup dates for DOB
         DOBpicker.MinDate = DateTime.Now.AddMonths(-48);
         DOBpicker.MaxDate = DateTime.Now.AddMonths(-6);
         //setup booking
         populatemonthscbx(true);
         populateyearscbx();
         initaliseweeks(DateTime.Now);
         book6pnl.Visible = true;
     }
     else
     {
         //if existing customer but no existing kid
         book2pnl.Visible = true;
         book3pnl.Visible = true;
         //setup dates for DOB
         DOBpicker.MinDate = DateTime.Now.AddMonths(-48);
         DOBpicker.MaxDate = DateTime.Now.AddMonths(-6);
     }
 }