示例#1
0
 private void AddPagesToTemplateControl(Guid TemplateID)
 {
     ITemplateService templateService = ServiceFactory.GetTemplateService();
       TemplatePageContainer templatePageContainer = templateService.PageOfTemplateSelectByIsactive(TemplateID, true);
       TemplatePages pages = new TemplatePages();
       foreach (TemplatePage page in templatePageContainer.All)
       {
     QuestionHelper.TemplatePage templatePage = new QuestionHelper.TemplatePage();
     templatePage.PageIndex = page.PageIndex;
     templatePage.PageName = page.Name;
     pages.Add(templatePage);
       }
       TemplateControl1.TemplatePages = pages;
 }
        private void RetrieveData()
        {
            try
              {
            //	---	Fill the control
            IQuestionFormService qfSrv = ServiceFactory.GetQuestionFormService();
            ITemplateService templSrv = ServiceFactory.GetTemplateService();
            Template template = templSrv.TemplateSelect(m_QuestionForm.TemplateRef);

            templCtrlPreview.State = ControlState.ReadOnly;
            templCtrlPreview.TemplateName = template.Name;

            QuestionFormDetailContainer answers = qfSrv.SelectChildrenByDetailOfQuestionForm(m_QuestionFormID);
            Questions questionsPreview = new Questions();
            foreach (TemplateDetail templateDetail in template.Details.All)
            {
              string hash = m_QuestionForm.ID.ToString() + "<#>" + templateDetail.ID + "<#>" +
                        m_QuestionForm.TemplateRef.ToString();
              QuestionFormDetail detail = (QuestionFormDetail) answers[hash];
              if (detail != null)
              {
            templateDetail.Answer = detail.Answer;
              }
              questionsPreview.Add((IQuestion) templateDetail);
            }
            templCtrlPreview.Questions = questionsPreview;

            TemplatePages pages = new TemplatePages();
            foreach (TemplatePage page in template.Pages.All)
            {
              QuestionHelper.TemplatePage templatePage = new QuestionHelper.TemplatePage();
              templatePage.PageIndex = page.PageIndex;
              templatePage.PageName = page.Name;
              pages.Add(templatePage);
            }
            templCtrlPreview.TemplatePages = pages;
            templCtrlPreview.LoadAnswer();
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Hiba az adatok lekérdezése során", ex);
              }
        }
        private void ShowQuestionForm(Guid templateID, Guid questionFormID)
        {
            ITemplateService templateService = ServiceFactory.GetTemplateService();
              IQuestionFormService questionFormService = ServiceFactory.GetQuestionFormService();

              QuestionForm form = questionFormService.QuestionFormSelect(questionFormID);
              Template template = templateService.TemplateSelect(templateID);
              lblLastModified.Text = form.LastModifiedByUser.ToString();
              chkIsActual.Checked = form.IsActual;
              TemplateControl1.TemplateName = template.Name;
              TemplateControl1.State = ControlState.ReadOnly;

              Questions questions = new Questions();
              foreach (TemplateDetail templateDetail in template.Details.All)
              {
            if (templateDetail.IsActive)
            {
              string hash = form.ID.ToString() + "<#>" + templateDetail.ID + "<#>" + templateID.ToString();
              QuestionFormDetail detail = (QuestionFormDetail) form.Details[hash];
              if (detail != null)
              {
            templateDetail.Answer = detail.Answer;
              }
              questions.Add(templateDetail);
            }
              }
              TemplateControl1.Questions = questions;

              TemplatePages pages = new TemplatePages();
              foreach (TemplatePage page in template.Pages.All)
              {
            Ndi.HelpDesk.QuestionHelper.TemplatePage templatePage = new Ndi.HelpDesk.QuestionHelper.TemplatePage();
            templatePage.PageIndex = page.PageIndex;
            templatePage.PageName = page.Name;
            pages.Add(templatePage);
              }
              TemplateControl1.TemplatePages = pages;

              TemplateControl1.LoadAnswer();
        }
        private void frmTemplatePreview_Load(object sender, EventArgs e)
        {
            try
              {
            TemplateControl1.ValidationEnabled = false;
            TemplateControl1.State = ControlState.Input;
            TemplateControl1.TemplateName = m_Template.Name;

            Questions questions = new Questions();
            foreach (TemplateDetail templateDetail in m_Template.Details.Current)
            {
              if (templateDetail.IsActive)
              {
            questions.Add((IQuestion) templateDetail);
              }
            }
            TemplateControl1.Questions = questions;

            TemplatePages pages = new TemplatePages();
            foreach (TemplatePage page in m_Template.Pages.Current)
            {
              QuestionHelper.TemplatePage templatePage = new QuestionHelper.TemplatePage();
              templatePage.PageIndex = page.PageIndex;
              templatePage.PageName = page.Name;
              pages.Add(templatePage);
            }
            TemplateControl1.TemplatePages = pages;
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba a sablon megejelnítése során.", ex);
              }
        }
        private void ShowEmptyQuestionForm(Guid templateID)
        {
            ITemplateService templateService = ServiceFactory.GetTemplateService();

              Template template = templateService.TemplateSelect(templateID);

              TemplateControl1.TemplateName = template.Name;
              TemplateControl1.State = ControlState.Input;

              Questions questions = new Questions();
              foreach (TemplateDetail templateDetail in template.Details.All)
              {
            if (templateDetail.IsActive)
            {
              questions.Add(templateDetail);
            }
              }
              TemplateControl1.Questions = questions;

              TemplatePages pages = new TemplatePages();
              foreach (TemplatePage page in template.Pages.All)
              {
            Ndi.HelpDesk.QuestionHelper.TemplatePage templatePage = new Ndi.HelpDesk.QuestionHelper.TemplatePage();
            templatePage.PageIndex = page.PageIndex;
            templatePage.PageName = page.Name;
            pages.Add(templatePage);
              }
              TemplateControl1.TemplatePages = pages;
              //Ha még csak most tölti ki, akkor nem látszik, hogy naprakész-e
              chkIsActual.Visible = false;
        }
        private void ShowEmptyQuestionForm(Guid templateID)
        {
            ITemplateService templateService = ServiceFactory.GetTemplateService();
              Template template = templateService.TemplateSelect(templateID);
              TemplateControl1.TemplateName = template.Name;
              TemplateControl1.State = ControlState.Input;

              gridIndex.DataSource = template.Pages.All.Items;
              gridIndex.DataBind();

              ShowQuestions();

              Questions questions = new Questions();

              foreach (TemplateDetail templateDetail in template.Details.All)
              {
            if (templateDetail.IsActive)
            {
              questions.Add(templateDetail);
            }
              }
              TemplateControl1.Questions = questions;

              TemplatePages pages = new TemplatePages();
              foreach (TemplatePage page in template.Pages.All)
              {
            Ndi.HelpDesk.QuestionHelper.TemplatePage templatePage = new Ndi.HelpDesk.QuestionHelper.TemplatePage();
            templatePage.PageIndex = page.PageIndex;
            templatePage.PageName = page.Name;
            pages.Add(templatePage);
              }
              TemplateControl1.TemplatePages = pages;
        }
        private void RetrieveData()
        {
            try
              {
            //	---	Fill the control
            IPendingQuestionFormService pendingSrv = ServiceFactory.GetPendingQuestionFormService();
            PendingQuestionFormDetailContainer answers =
              pendingSrv.SelectChildrenByDetailOfPendingQuestionForm(m_PendingQuestionFormID);
            ITemplateService templSrv = ServiceFactory.GetTemplateService();
            Template template = templSrv.TemplateSelect(m_PendingQuestionForm.TemplateRef);

            txtStatus.Text = QuestionFormStatus.GetNameById(m_PendingQuestionForm.Status);
            txtSentBy.Text = m_PendingQuestionForm.SentBy;
            txtSentDate.Text = m_PendingQuestionForm.SentDate.ToString();
            txtDecidedBy.Text = m_PendingQuestionForm.DecidedBy;
            if (!m_PendingQuestionForm.DecidedDate.IsNull)
            {
              txtDecidedDate.Text = m_PendingQuestionForm.DecidedDate.ToString();
            }
            txtRejectComment.Text = m_PendingQuestionForm.RejectComment;

            templCtrlPreview.State = ControlState.ReadOnly;
            templCtrlEdit.State = ControlState.Input;
            templCtrlPreview.TemplateName = template.Name;
            templCtrlEdit.TemplateName = template.Name;

            Questions questionsPreview = new Questions();
            Questions questionsEdit = new Questions();
            foreach (TemplateDetail templateDetail in template.Details.All)
            {
              if (templateDetail.IsActive)
              {
            string hash = m_PendingQuestionForm.ID.ToString() + "<#>" + templateDetail.ID + "<#>" +
                          m_PendingQuestionForm.TemplateRef.ToString();
            PendingQuestionFormDetail detail = (PendingQuestionFormDetail) answers[hash];
            if (detail != null)
            {
              templateDetail.Answer = detail.Answer;
            }
            questionsPreview.Add((IQuestion) templateDetail);
            questionsEdit.Add((IQuestion) templateDetail);
              }
            }
            templCtrlPreview.Questions = questionsPreview;
            templCtrlEdit.Questions = questionsEdit;

            TemplatePages pages = new TemplatePages();
            foreach (TemplatePage page in template.Pages.All)
            {
              QuestionHelper.TemplatePage templatePage = new QuestionHelper.TemplatePage();
              templatePage.PageIndex = page.PageIndex;
              templatePage.PageName = page.Name;
              pages.Add(templatePage);
            }
            templCtrlPreview.TemplatePages = pages;
            templCtrlEdit.TemplatePages = pages;

            // disable controls based on status:
            if (!(m_PendingQuestionForm.Status.Equals(QuestionFormStatus.New_WaitingForDecision)
              || m_PendingQuestionForm.Status.Equals(QuestionFormStatus.Updated_WaitingForDecision)))
            {
              txtRejectComment.Enabled = false;
              btnAccept.Visible = false;
              btnReject.Visible = false;
              btnCancel.Text = "Bezár";
              btnSendBack.Visible = false;

              Controls.Remove(templCtrlEdit);
              Controls.Remove(splitter1);
              templCtrlPreview.Dock = DockStyle.Fill;
            }
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Hiba az adatok lekérdezése során", ex);
              }
        }