Exemplo n.º 1
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.");
            }
        }
Exemplo n.º 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;
 }
Exemplo n.º 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.");
            }
        }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 private void MapSourceTableName(TableBasedDropDownField field)
 {
     if (field == null)
     {
         return;
     }
     if (context.TableNameMap.TryGetValue(field.SourceTableName, out string tableName))
     {
         field.SourceTableName = tableName;
     }
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
        private List <Control> GetControls(TableBasedDropDownField field, Size canvasSize)
        {
            string displayMember = field.TextColumnName.Trim();
            string valueMember;

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

            DragableComboBox comboBox = new DragableComboBox();

            comboBox.Width = defaultControlWidth;
            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))
            {
                DataTable dataTable = field.GetSourceData();

                if (dataTable != null)
                {
                    DataBind(comboBox, dataTable, displayMember, valueMember);
                }
            }
            DragableLabel  prompt   = GetPrompt(comboBox, field, canvasSize);
            List <Control> controls = new List <Control>();

            controls.Add(prompt);
            controls.Add(comboBox);
            return(controls);
        }
Exemplo n.º 8
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);
 }
Exemplo n.º 9
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;
            }
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            TableBasedDropDownField ddlField = (TableBasedDropDownField)field;

            //if this is a new code table, use tableName
            //otherwise, use sourceTableName
            if (!string.IsNullOrEmpty(tableName))
            {
                field.SourceTableName = tableName;
            }
            else if (!string.IsNullOrEmpty(sourceTableName))
            {
                field.SourceTableName = sourceTableName;
            }
            else
            {
                throw new ArgumentNullException("Table name for code table");
            }

            //if this is a new code table, use columnName
            //otherwise, use textColumnName
            if (!string.IsNullOrEmpty(columnName))
            {
                field.TextColumnName = columnName;
            }
            else if (!string.IsNullOrEmpty(textColumnName))
            {
                field.TextColumnName = textColumnName;
            }
            else
            {
                throw new ArgumentNullException("Column name for code table");
            }

            if ((!string.IsNullOrEmpty(tableName)) && (!string.IsNullOrEmpty(columnName)))
            {
                field.GetMetadata().CreateCodeTable(tableName, columnName);
                field.GetMetadata().SaveCodeTableData((DataTable)dgCodeTable.DataSource, tableName, columnName);
            }
            if (!string.IsNullOrEmpty(field.SourceTableName))
            {
                codeTable = ddlField.GetSourceData();
            }

            if (codeTable != null)
            {
                foreach (DataRow row in codeTable.Rows)
                {
                    if (isCommentLegal)
                    {
                        if (((row.ItemArray[0].ToString().IndexOf("-") == -1)))
                        {
                            string msg = SharedStrings.SEPARATE_COMMENT_LEGAL_WITH_HYPEN + ": \n" + row.ItemArray[0].ToString();
                            MsgBox.ShowError(msg);
                            return;
                        }
                    }
                }
            }

            this.DialogResult = DialogResult.OK;
            this.Hide();
        }