private void btnOk_Click(object sender, EventArgs e)
        {
            try
              {
            //	---	Check input data
            bool isValidated = CheckData();
            if (!isValidated)
            {
              DialogResult = DialogResult.None;
              return;
            }

            if (m_CurrentDetail == null)
            {
              // check existing question:
              bool existID = false;
              bool existOrder = false;
              string detailId = txtID.Text;
              int order = Convert.ToInt32(txtOrder.Text);
              int pageIndex = Convert.ToInt32(Convert.ToInt32(cmbPage.SelectedValue));
              foreach (TemplateDetail d in m_ExistingDetails.All)
              {
            if (d.ID.Equals(detailId)) existID = true;
            if ((d.PageIndex == pageIndex) && (d.Order == order))
            {
              existOrder = true;
            }
              }

              if (existID)
              {
            MessageBox.Show("A megadott azonosítóval már létezik kérdés.", "NDI HelpDesk Adminisztrátor",
                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
            DialogResult = DialogResult.None;
            txtID.Focus();
            return;
              }

              if (existOrder)
              {
            MessageBox.Show("A megadott lapon belüli sorszámmal már létezik kérdés.", "NDI HelpDesk Adminisztrátor",
                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
            DialogResult = DialogResult.None;
            txtOrder.Focus();
            return;
              }
              m_CurrentDetail = new TemplateDetail(detailId, m_TemplateID);
            }

            #region Inaktív oldalhoz nem lehet aktív kérdést beszúrni ...

            string hash = m_TemplateID.ToString() + "<#>" + cmbPage.SelectedValue.ToString();

            TemplatePage selectedPage = (TemplatePage) m_Pages[hash];

            if ((cbxActivate.Checked == true) && (selectedPage.IsActive == false))
            {
              //figyelmeztetés
              DialogResult msgResult =
            MessageBox.Show(
              "A lap amelyhez a kérdés tartozik jelenleg nem aktív ezért nem adható hozzá aktív kérdés. \n Aktíváljuk a lapot?",
              "NDI HelpDesk Adminisztrátor",
              MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

              if (msgResult == DialogResult.Cancel)
              {
            DialogResult = DialogResult.None;
            return;
              }
              else
              {
            DialogResult = msgResult;
              }
            }

            #endregion

            m_CurrentDetail.Question = txtQuestion.Text;
            m_CurrentDetail.QuestionDataType = (QuestionDataType) cmbDataType.SelectedValue;
            m_CurrentDetail.QuestionLayout = (QuestionLayout) cmbLayout.SelectedValue;
            m_CurrentDetail.Description = txtDescription.Text;
            m_CurrentDetail.IsActive = cbxActivate.Checked;
            m_CurrentDetail.IsFilterCondition = cbxIsFilterCondition.Checked;
            m_CurrentDetail.PageIndex = Convert.ToInt32(cmbPage.SelectedValue);
            m_CurrentDetail.Order = Convert.ToInt32(txtOrder.Text);

            // validation constraints:
            QuestionConstraint constr = new QuestionConstraint();
            if (txtMaxLength.Text.Length > 0)
            {
              constr.MaxLength = Convert.ToInt32(txtMaxLength.Text);
            }
            constr.Mandatory = cbxMandatory.Checked;
            constr.RangeFrom = txtFrom.Text;
            constr.RangeTo = txtTo.Text;
            constr.Validator = txtRegExp.Text;
            constr.ExpectedFormat = txtExpectedFormat.Text;
            m_CurrentDetail.QuestionConstraint = constr;

            // ListItems
            QuestionListItems list = new QuestionListItems();
            list.ControlRows = Convert.ToInt32(txtControlHeight.Text);
            list.Width = Convert.ToInt32(txtControlWidth.Text);
            if (rbtOrderByItemIndex.Checked)
            {
              list.ItemOrder = ListItemOrder.ByItemIndex;
            }
            else
            {
              list.ItemOrder = ListItemOrder.ByItemName;
            }
            int i = 0;
            foreach (ListViewItem lvItem in lvDetailListItems.Items)
            {
              QuestionListItem qli = new QuestionListItem();
              qli.ItemName = lvItem.Text;
              qli.Selected = lvItem.Selected;
              qli.ItemIndex = i;
              list.Add(qli);
              i += 1;
            }
            m_CurrentDetail.QuestionItemList = list;
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Hiba történt a kérdés mentése során.", ex);
            //	---	Handle dialogresult
            DialogResult = DialogResult.None;
              }
        }
        private void ShowEmptyQuestionForm(Guid templateID)
        {
            ITemplateService templateService = ServiceFactory.GetTemplateService();
              Template template = templateService.TemplateSelect(templateID);
              TemplateControl1.TemplateName = template.Name;
              //TemplateControl1.ValidationEnabled = false;
              Questions questions = new Questions();
              foreach (TemplateDetail templateDetail in template.Details.All)
              {
            if (templateDetail.IsFilterCondition && templateDetail.IsActive)
            {
              IQuestion q = (IQuestion) templateDetail;

              // Kötelezõséget levesszük:
              QuestionConstraint constr = q.QuestionConstraint;
              constr.Mandatory = false;
              q.QuestionConstraint = constr;

              // A listákat kiegészítjük:
              if (q.QuestionDataType == QuestionDataType.List)
              {
            foreach (QuestionListItem l in q.QuestionItemList.Items)
            {
              l.Selected = false;
            }
            if (q.QuestionLayout == QuestionLayout.Combo)
            {
              QuestionListItem li = new QuestionListItem();
              li.ItemIndex = -1;
              li.ItemName = "-- Összes --";
              li.Selected = true;
              q.QuestionItemList.Add(li);
              q.QuestionItemList.ItemOrder = ListItemOrder.ByItemIndex;
            }
            if (q.QuestionLayout == QuestionLayout.Radio)
            {
              QuestionListItem li = new QuestionListItem();
              li.ItemIndex = -1;
              li.ItemName = "-- Összes --";
              li.Selected = true;
              q.QuestionItemList.Add(li);
              q.QuestionItemList.ItemOrder = ListItemOrder.ByItemIndex;
            }
              }

              questions.Add(q);
            }
              }
              if (questions.Count > 0)
              {
            TemplateControl1.Visible = true;
            btnSearch.Enabled = true;
            btnExportCsv.Enabled = true;
            btnExportRtf.Enabled = true;
            btn_Search.Visible = true;
            btn_ExportCsv.Visible = true;
            btn_ExportRtf.Visible = true;
            btn_SearchClear.Visible = true;
              }
              else
              {
            TemplateControl1.Visible = false;
            btn_Search.Visible = false;
            btn_ExportCsv.Visible = false;
            btn_ExportRtf.Visible = false;
            btn_SearchClear.Visible = false;
            btnSearch.Enabled = false;
            btnExportCsv.Enabled = false;
            btnExportRtf.Enabled = false;
              }
              TemplateControl1.Questions = questions;
              TemplateControl1.State = ControlState.Input;
              TemplateControl1.AllowPaging = false;
        }
 /// <summary>
 /// Add new QuestionListItem to the list
 /// </summary>
 /// <param name="item">Item to add</param>
 /// <returns>Index of the item in the list</returns>
 // -------------------------------------------------------------------------------------
 public int Add(QuestionListItem item)
 {
     return base.Add(item);
 }
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Remove item from the list
 /// </summary>
 /// <param name="item">Item to remove</param>
 // -------------------------------------------------------------------------------------
 public void Remove(QuestionListItem item)
 {
     base.Remove(item);
 }
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Constructor loads properties from an XML string
        /// </summary>
        /// <param name="XML">XML string with property values</param>
        // -------------------------------------------------------------------------------------
        public QuestionListItems(string XML)
            : base()
        {
            try
              {
            m_Width = ControlWidth;
            m_Rows = Rows;

            if (XML == string.Empty)
              return;

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(XML);

            if (doc.DocumentElement == null)
              return;
            if (doc.DocumentElement.Name != LIST_ROOT)
              throw new InvalidParameterException("Invalid root element: " + XML);

            if (doc.DocumentElement.SelectSingleNode("./" + ORDER) != null)
            {
              m_ItemOrder = (ListItemOrder) Enum.Parse(typeof (ListItemOrder),
                                                   doc.DocumentElement.SelectSingleNode("./" + ORDER).InnerXml);
            }

            if (doc.DocumentElement.SelectSingleNode("./" + WIDTH) != null)
            {
              m_Width = Convert.ToInt32(doc.DocumentElement.SelectSingleNode("./" + WIDTH).InnerXml);
            }

            if (doc.DocumentElement.SelectSingleNode("./" + ROWS) != null)
            {
              m_Rows = Convert.ToInt32(doc.DocumentElement.SelectSingleNode("./" + ROWS).InnerXml);
            }

            if (doc.DocumentElement.SelectSingleNode("./" + ITEMS) != null)
            {
              XmlNode listNode = doc.DocumentElement.SelectSingleNode("./" + ITEMS);
              foreach (XmlNode QuestionListItemNode in listNode.ChildNodes)
              {
            QuestionListItem questionListItem = new QuestionListItem(QuestionListItemNode);
            Add(questionListItem);
              }
            }
              }
              catch (Exception e)
              {
            if (e is InvalidParameterException)
              throw e;
            else
            {
              InvalidParameterException invalidParameterException =
            new InvalidParameterException(XML);
              throw invalidParameterException;
            }
              }
        }