Esempio n. 1
0
        /// <summary>
        /// Builds a list of Patient Survey Items (including pages, sections, questions if applicable).
        /// </summary>
        /// <param name="surveyId">The Patient's SurveyId</param>
        /// <param name="surveyType">The type of the Patient's Survey</param>
        private void BuildPages(int surveyId, string surveyType)
        {
            // get a list of meta surveys which match patient survey type
            var metaSurveys = BusinessObject.GetByFields <MetadataSurvey>(
                new Dictionary <string, object>()
            {
                { MetadataSurvey.SurveyType, surveyType }
            });

            // use advanced layout
            if (metaSurveys.Count() > 0)
            {
                // use first meta survey to generate advanced survey
                metaSurveyId = (int)metaSurveys.First()[MetadataSurvey.MetadataSurveyId];
                DataView pagesView = _surveyData.GetPatientMetaSurveyPages(metaSurveyId.Value, surveyId).DefaultView;
                // set page count
                pageCount = pagesView.Count;

                // build pages
                PagesRptr.DataSource = pagesView;
                PagesRptr.DataBind();

                //var visibleQuestions = from page in PagesRptr.Items.Cast<RepeaterItem>()
                //                       let sectionRptr = page.FindControl("SectionsRptr") as Repeater
                //                       where sectionRptr.Items.Count > 0 && sectionRptr.Visible
                //                       select page;
                //sectionsRptr.Visible = visibleQuestions.Count() > 0;


                SimpleView.Visible  = false;
                ComplexView.Visible = true;
            }
            // use simple layout
            else
            {
                BindSurveyItems(surveyId);
            }
        }
        private void BuildPages(int count)
        {
            int activePageNumber = PageNumber;
            int pageCount        = count < 2 ? 1 : ((count / PAGE_SIZE) + (count % PAGE_SIZE == 0 ? 0 : 1));

            int[] pages = new int[pageCount];
            for (int i = 0; i < pageCount; i++)
            {
                pages[i] = i + 1;
            }
            string pid      = PatientItemId + "";
            var    pageData = from pageNum in pages
                              select new
            {
                Number = pageNum,
                Start  = GetStart(pageNum),
                End    = GetEnd(pageNum),
                URL    = string.Format("?patientItemId={0}&page={1}", pid, pageNum),
                Active = pageNum == activePageNumber
            };

            PagesRptr.DataSource = pageData;
            PagesRptr.DataBind();
        }