/// <summary> /// Opens Dialog for Legal Values or Comment Legal column. /// </summary> /// <param name="sender">Object that fired the event</param> /// <param name="e">.NET supplied event args</param> private void btnDataSource_Click(object sender, EventArgs e) { if (hti != null) { if (hti.Type == DataGrid.HitTestType.ColumnHeader) { object currentColumn = gridColumns[currentGridColumn]; currentGridColumn = hti.Column + iColumnOffset; LegalValuesDialog sourceTableDialog = null; switch ((int)cmbFieldType.SelectedValue) { case ((int)MetaFieldType.CommentLegal): DDLColumnOfCommentLegal dDLColumnOfCommentLegal = new Epi.Fields.DDLColumnOfCommentLegal((GridField)Grid); if (currentColumn is DDLColumnOfCommentLegal) dDLColumnOfCommentLegal = (DDLColumnOfCommentLegal)currentColumn; sourceTableDialog = new CommentLegalDialog(dDLColumnOfCommentLegal, form, txtFieldName.Text, page); break; case ((int)MetaFieldType.LegalValues): DDLColumnOfLegalValues dDLColumnOfLegalValues = new Epi.Fields.DDLColumnOfLegalValues((GridField)Grid); if (currentColumn is DDLColumnOfLegalValues) dDLColumnOfLegalValues = (DDLColumnOfLegalValues)currentColumn; sourceTableDialog = new LegalValuesDialog(dDLColumnOfLegalValues, form, txtFieldName.Text, page); break; } if (sourceTableDialog != null) { ShowDDLFieldDialog(sourceTableDialog); currentColumn = ((LegalValuesDialog)sourceTableDialog).DdlColumn; } } else { if (cmbFieldType.SelectedValue.Equals((int)MetaFieldType.CommentLegal)) { TableBasedDropDownColumn column = new DDLColumnOfCommentLegal(grid); CommentLegalDialog commentLegal = new CommentLegalDialog(column, form, txtFieldName.Text, page); ShowDDLFieldDialog(commentLegal); } if (cmbFieldType.SelectedValue.Equals((int)MetaFieldType.LegalValues)) { TableBasedDropDownColumn column = new DDLColumnOfLegalValues(grid); LegalValuesDialog legalValues = new LegalValuesDialog(column, form, txtFieldName.Text, page); ShowDDLFieldDialog(legalValues); } } } else { if (cmbFieldType.SelectedValue.Equals((int)MetaFieldType.CommentLegal)) { TableBasedDropDownColumn column = new DDLColumnOfCommentLegal(grid); CommentLegalDialog commentLegal = new CommentLegalDialog(column, form, txtFieldName.Text, page); ShowDDLFieldDialog(commentLegal); } if (cmbFieldType.SelectedValue.Equals((int)MetaFieldType.LegalValues)) { TableBasedDropDownColumn column = new DDLColumnOfLegalValues(grid); LegalValuesDialog legalValues = new LegalValuesDialog(column, form, txtFieldName.Text, page); ShowDDLFieldDialog(legalValues); } } btnSaveColumn.Enabled = (!String.IsNullOrEmpty(txtDataSource.Text)); }
/// <summary> /// Display the DDLField*Dialog that creates/uses the code table. /// </summary> /// <param name="legalDialog">DDField*Dialog</param> private void ShowDDLFieldDialog(LegalValuesDialog legalDialog) { DialogResult result; if (legalDialog is CommentLegalDialog) { result = ((CommentLegalDialog)legalDialog).ShowDialog(); if (result == DialogResult.OK) { if (!string.IsNullOrEmpty(((CommentLegalDialog)legalDialog).SourceTableName) && !string.IsNullOrEmpty(((CommentLegalDialog)legalDialog).TextColumnName)) { txtDataSource.Text = ((CommentLegalDialog)legalDialog).SourceTableName + " :: " + ((CommentLegalDialog)legalDialog).TextColumnName; shouldSort = ((CommentLegalDialog)legalDialog).ShouldSort; sourceTableName = ((CommentLegalDialog)legalDialog).SourceTableName; textColumnName = ((CommentLegalDialog)legalDialog).TextColumnName; isExclusiveTable = ((CommentLegalDialog)legalDialog).IsExclusiveTable; } else { txtDataSource.Text = string.Empty; sourceTableName = string.Empty; textColumnName = string.Empty; } } } else { result = legalDialog.ShowDialog(); if (!string.IsNullOrEmpty(legalDialog.SourceTableName) && !string.IsNullOrEmpty(legalDialog.TextColumnName)) { txtDataSource.Text = legalDialog.SourceTableName + " :: " + legalDialog.TextColumnName; shouldSort = legalDialog.ShouldSort; sourceTableName = legalDialog.SourceTableName; textColumnName = legalDialog.TextColumnName; isExclusiveTable = legalDialog.IsExclusiveTable; } else { txtDataSource.Text = string.Empty; sourceTableName = string.Empty; textColumnName = string.Empty; } } }