Пример #1
0
        public TableBasedDropDownField Clone()
        {
            TableBasedDropDownField clone = (TableBasedDropDownField)this.MemberwiseClone();

            base.AssignMembers(clone);
            return(clone);
        }
Пример #2
0
 /// <summary>
 /// Constructor for the Comment Legal dialog
 /// </summary>
 /// <param name="field">The field associated with this comment legal</param>
 /// <param name="frm">The main form</param>
 /// <param name="name">The name of the field</param>
 /// <param name="currentPage">The current page</param>
 public CommentLegalDialog(TableBasedDropDownField field, MainForm frm, string name, Page currentPage)
     : base(field, frm, name, currentPage)
 {
     InitializeComponent();
     fieldName = name;
     page = currentPage;
     //dgCodes.CaptionText = "Comment Legal values for: " + name;
 }
Пример #3
0
        /// <summary>
        /// Constructor for the class
        /// </summary>
        /// <param name="field">field</param>
        /// <param name="currentFieldName">The name of the field</param>
        /// <param name="frm">Form</param>
        /// <param name="currentPage">Page</param>
        public DataSourceSelector(TableBasedDropDownField field, string currentFieldName, MainForm frm, Page currentPage)
            : base(frm)
        {
            #region Input Validation
            if (string.IsNullOrEmpty(currentFieldName))
            {
                throw new ArgumentNullException("currentFieldName");
            }
            #endregion Input validation

            InitializeComponent();
            page = currentPage;
            TableBasedDropDownField ddlField = (TableBasedDropDownField)field;

            if (!string.IsNullOrEmpty(field.SourceTableName))
            {
                codeTable = ddlField.GetSourceData();
            }

            this.field = field;

            if (field.FieldType == MetaFieldType.CommentLegal)
            {
                isCommentLegal = true;
            }
            else
            {
                isCommentLegal = false;
            }

            this.fieldName = currentFieldName;
            dgCodeTable.CaptionText += currentFieldName;

            try
            {
                if (!string.IsNullOrEmpty(field.SourceTableName))
                {
                    tableName = field.SourceTableName;
                    columnName = field.TextColumnName;
                    dgCodeTable.PreferredColumnWidth = Convert.ToInt32(dgCodeTable.Width * .87);
                    dgCodeTable.DataSource = field.GetSourceData();
                    btnCreate.Enabled = false;
                    btnExisting.Enabled = false;
                }
                else
                {
                    btnCreate.Enabled = true;
                    btnExisting.Enabled = true;
                }
            }
            catch
            {
                //TODO: move string to sharedstrings.resx
                throw new SystemException("Error loading data.");
            }
        }
Пример #4
0
 /// <summary>
 /// Contructor of the CodesDialog
 /// </summary>
 /// <param name="field">The field</param>
 /// <param name="frm">The main form</param>
 /// <param name="name">The field name</param>
 /// <param name="currentPage">The current page</param>
 /// <param name="selectedItems">The names of the fields from the Code Field Definition dialog</param>
 public CodesDialog(TableBasedDropDownField field, MainForm frm, string name, Page currentPage, NamedObjectCollection<Field> selectedItems)
     : base(field, frm, name, currentPage)
 {
     InitializeComponent();
     fieldName = name;
     page = currentPage;
     ddlField = (DDLFieldOfCodes)field;
     selectedFields = selectedItems;
     SetDataSource(ddlField);
     SetDgCodes(dgCodes, fieldName);
     dgCodes.Visible = true;
     relateCondition = ddlField.RelateConditionString;
 }
Пример #5
0
        public LegalValuesDialog(MainForm frm, string name, Page currentPage)
            : base(frm)
        {
            InitializeComponent();
            InitContextMenu();
            fieldName = name;
            page = currentPage;
            ddlField = new DDLFieldOfLegalValues(page);
            ddlField.Name = name;
            //dgCodes.CaptionText += "  " + name;
            //dgCodes.PreferredColumnWidth = Convert.ToInt32(dgCodes.Width * COLUMN_WIDTH_MULTIPLE);

            if (!string.IsNullOrEmpty(ddlField.SourceTableName))
            {
                codeTable = ddlField.GetSourceData();
                sourceTableName = ddlField.SourceTableName;
                textColumnName = ddlField.TextColumnName;
            }
        }
Пример #6
0
        private List<Control> GetControls(TableBasedDropDownField field, Size canvasSize)
        {
            string displayMember = field.TextColumnName.Trim();
            string valueMember;

            if (field is DDLFieldOfCodes)
            {
                valueMember = field.CodeColumnName.Trim();
                ((DDLFieldOfCodes)field).ControlFactory = this;
            }
            else if (field is DDListField)
            {
                valueMember = field.CodeColumnName.Trim();
                ((DDListField)field).ControlFactory = this;
            }
            else
            {
                valueMember = field.TextColumnName.Trim();
            }

            ComboBox comboBox = new Epi.Windows.Enter.Controls.LegalValuesComboBox();

            SetControlProperties(comboBox, field, canvasSize);

            if (field is DDListField)
            {
                comboBox.DropDownStyle = ComboBoxStyle.Simple;
            }
            else
            {
                comboBox.DropDownStyle = ComboBoxStyle.DropDown;
            }

            comboBox.Sorted = field.ShouldSort;

            if (!string.IsNullOrEmpty(displayMember))
            {
                comboBox.DisplayMember = null;
                comboBox.ValueMember = null;

                if (cachedListValues == null)
                {
                    cachedListValues = new Dictionary<string, DataTable>();
                }
                DataTable displayTable;
                if (cachedListValues.ContainsKey(displayMember + "," + field.SourceTableName))
                {
                    displayTable = cachedListValues[displayMember + "," + field.SourceTableName];
                }
                else
                {
                    displayTable = field.GetDisplayTable("", "", displayMember);
                    cachedListValues.Add(displayMember + "," + field.SourceTableName, displayTable);
                }

                if (displayTable != null)
                {
                    comboBox.BeginUpdate();
                    comboBox.Items.AddRange(displayTable.AsEnumerable().Select(row => row.Field<string>("Item") ?? string.Empty).ToArray());
                    comboBox.EndUpdate();

                    if (displayTable.Rows.Count > 0)
                    {
                        if (field.CurrentRecordValueObject == null || string.IsNullOrEmpty(field.CurrentRecordValueString))
                        {
                            comboBox.SelectedIndex = -1;
                        }
                        else
                        {
                            comboBox.SelectedItem = field.CurrentRecordValueString;
                        }
                    }
                }
            }

            Label prompt = GetPrompt(comboBox, field, canvasSize);
            List<Control> controls = new List<Control>();
            controls.Add(prompt);
            controls.Add(comboBox);

            field.Control = comboBox;

            if (!fieldControls.ContainsKey(field))
            {
                fieldControls.Add(field, controls);
            }
            else
            {
                fieldControls.Remove(field);
                fieldControls.Add(field, controls);
            }

            return controls;
        }
Пример #7
0
 /// <summary>
 /// Contructor of the CodesDialog
 /// </summary>
 /// <param name="field">The field</param>
 /// <param name="frm">The main form</param>
 /// <param name="name">The field name</param>
 /// <param name="currentPage">The current page</param>
 /// <param name="selectedItems">The names of the fields from the Code Field Definition dialog</param>
 public ListDialog(TableBasedDropDownField field, MainForm frm, string name, Page currentPage, NamedObjectCollection<Field> selectedItems)
     : base(frm, name, currentPage)
 {
     InitializeComponent();
     fieldName = name;
     page = currentPage;
     ddlField = (DDListField)field;
     this.Text = "List Field";
     //if (!(string.IsNullOrEmpty(sourceTableName)))
     //{
     //    codeTable = ddlField.GetSourceData();
     //}
     selectedFields = selectedItems;
     SetDataSource(ddlField);
     SetDgCodes(dgCodes, fieldName);
 }
Пример #8
0
        public LegalValuesDialog(TableBasedDropDownField field, MainForm frm, string name, Page currentPage)
            : base(frm)
        {
            InitializeComponent();
            fieldName = name;
            page = currentPage;
            creationMode = CreationMode.Edit;
            //dgCodes.CaptionText += "  " + name;
            //dgCodes.PreferredColumnWidth = Convert.ToInt32(dgCodes.Width * COLUMN_WIDTH_MULTIPLE);
            ddlField = field;

            if (!string.IsNullOrEmpty(field.SourceTableName))
            {
                codeTable = field.GetSourceData();
                sourceTableName = field.SourceTableName;
                textColumnName = field.TextColumnName;
            }

            InitContextMenu();
        }
Пример #9
0
 public LegalValuesDialog(MainForm frm, RenderableField field, Page currentPage)
     : base(frm)
 {
     InitializeComponent();
     page = currentPage;
     ddlField = (DDLFieldOfLegalValues)field;
     codeTable = ddlField.GetSourceData();
     cbxSort.Checked = ddlField.ShouldSort;
     fieldName = ddlField.Name;
     //dgCodes.PreferredColumnWidth = Convert.ToInt32(dgCodes.Width * COLUMN_WIDTH_MULTIPLE);
 }
Пример #10
0
        public LegalValuesDialog(RenderableField field, Page currentPage)
        {
            InitializeComponent();

            if (string.IsNullOrEmpty(field.ToString()))
            {
                throw new ArgumentNullException("field");
            }
            if (string.IsNullOrEmpty(currentPage.ToString()))
            {
                throw new ArgumentNullException("currentPage");
            }

            ddlField = (DDLFieldOfLegalValues)field;
            page = currentPage;
            codeTable = ddlField.GetSourceData();
            cbxSort.Checked = ddlField.ShouldSort;
            fieldName = ddlField.Name;
            sourceTableName = ddlField.SourceTableName;
            textColumnName = ddlField.TextColumnName;
        }
Пример #11
0
        /// <summary>
        /// Constructor for the class
        /// </summary>
        /// <param name="field">The field</param>
        /// <param name="currentFieldName">The name of the field</param>
        public DataSourceSelector(DDLFieldOfLegalValues field, string currentFieldName)
        {
            #region Input Validation
            if (string.IsNullOrEmpty(currentFieldName))
            {
                throw new ArgumentNullException("currentFieldName");
            }
            #endregion Input validation

            InitializeComponent();
            this.field = field;
            this.fieldName = currentFieldName;
            dgCodeTable.CaptionText += currentFieldName;

            try
            {
                if (!string.IsNullOrEmpty(field.SourceTableName))
                {
                    tableName = field.SourceTableName;
                    columnName = field.TextColumnName;
                    dgCodeTable.PreferredColumnWidth = Convert.ToInt32(dgCodeTable.Width * .87);
                    dgCodeTable.DataSource = field.GetSourceData();
                    btnCreate.Enabled = false;
                    btnExisting.Enabled = false;
                }
            }
            catch
            {
                //TODO: move string to sharedstrings.resx
                throw new SystemException("Error loading data.");
            }
        }