예제 #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.");
            }
        }
예제 #2
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.");
            }
        }
예제 #3
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);
 }
예제 #4
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);
        }
예제 #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
        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();
        }
예제 #7
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;
        }
예제 #8
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();
        }