/// <summary> /// Edit constructor /// </summary> public frmTemplateDetailEdit(TemplateDetail Detail, TemplatePageContainer pages) { // Required for Windows Form Designer support InitializeComponent(); m_CurrentDetail = Detail; m_Pages = pages; }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="IDVal">Value of 'cID' field</param> /// <param name="TemplateRefVal">Value of 'uTemplateRef' field</param> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public TemplateDetail(DBString IDVal, DBGuid TemplateRefVal, TemplateDetail origInstance) : base(IDVal, TemplateRefVal, origInstance) { }
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; } }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public TemplateDetail(TemplateDetail origInstance) : base(origInstance) { }
public virtual void TemplateDetailUpdate(TemplateDetail entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { int count; m_DataContext.ndihdTemplateDetailUpdate(entity.ID, entity.TemplateRef, entity.Question, entity.DataType, entity.Layout, entity.Constraint, entity.ItemList, entity.Description, entity.Order, entity.PageIndex, entity.IsActive, entity.IsFilterCondition, out count); if (count == 0) throw new ServiceUpdateException(); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public virtual TemplateDetail TemplateDetailSelect(DBString IDVal, DBGuid TemplateRefVal) { TraceCallEnterEvent.Raise(); try { TemplateDetail result = null; DataSet entitySet = m_DataContext.ndihdTemplateDetailSelect(IDVal, TemplateRefVal); if (entitySet.Tables[0].Rows.Count != 0) { result = new TemplateDetail(entitySet); } TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public virtual void TemplateDetailDelete(TemplateDetail entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { m_DataContext.ndihdTemplateDetailDelete(entity.ID, entity.TemplateRef); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
private string ConvertTemplateDetailToXML(TemplateDetail detail) { StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.WriteStartElement("TemplateDetail"); xtw.WriteAttributeString("ID", detail.ID.AsXmlString); xtw.WriteAttributeString("TemplateRef", detail.TemplateRef.AsXmlString); xtw.WriteStartElement("Question"); xtw.WriteCData(detail.Question.AsXmlString); xtw.WriteEndElement(); xtw.WriteStartElement("Answer"); xtw.WriteCData(detail.Answer.AsXmlString); xtw.WriteEndElement(); xtw.WriteStartElement("DataType"); xtw.WriteCData(detail.DataType.AsXmlString); xtw.WriteEndElement(); xtw.WriteStartElement("Layout"); xtw.WriteCData(detail.Layout.AsXmlString); xtw.WriteEndElement(); xtw.WriteStartElement("Constraint"); xtw.WriteRaw(detail.Constraint.AsXmlString); xtw.WriteEndElement(); xtw.WriteStartElement("ItemList"); xtw.WriteRaw(detail.ItemList.AsXmlString); xtw.WriteEndElement(); xtw.WriteStartElement("Description"); xtw.WriteCData(detail.Description.AsXmlString); xtw.WriteEndElement(); xtw.WriteElementString("Order", detail.Order.AsXmlString); xtw.WriteElementString("PageIndex", detail.PageIndex.AsXmlString); xtw.WriteElementString("IsActive", detail.IsActive.ToString()); xtw.WriteElementString("IsFilterCondition", detail.IsFilterCondition.ToString()); xtw.WriteEndElement(); return sw.ToString(); }