예제 #1
0
        /// <summary>
        /// On load
        /// </summary>
        /// <param name="e">eventargs</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            textTableName.Text = TableName;
            textViewName.Text  = ViewName;

            DataTable DT = DbDriver.GetTopTwoTable(TableName);//.GetTableData(TableName);

            foreach (KeyValuePair <string, string> columnKvp in columnMapping)
            {
                string sourceColumnName = columnKvp.Key;
                string validColumName   = columnKvp.Value;

                DataColumn column = DT.Columns[sourceColumnName];

                if (column.ColumnName.ToUpperInvariant() == "UNIQUEKEY" || column.ColumnName.ToUpperInvariant() == "RECSTATUS" || column.ColumnName.ToUpperInvariant() == "GLOBALRECORDID" || column.ColumnName.ToUpperInvariant() == "FKEY")
                {
                    continue;
                }

                string message = string.Empty;
                if (!Util.IsValidFieldName(validColumName, ref message))
                {
                    continue;
                }

                listTableFields.Items.Add(validColumName);
            }
        }
예제 #2
0
        private void btnImportListValues_Click(object sender, EventArgs e)
        {
            Epi.Windows.Dialogs.BaseReadDialog dlg = new Epi.Windows.Dialogs.BaseReadDialog(this);

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (dlg.SelectedDataSource is Project)
                {
                    Epi.Windows.MsgBox.ShowInformation(ImportExportSharedStrings.ERROR_CODE_TABLE_PROJECT_IMPORT_NOT_ALLOWED);
                }
                else
                {
                    Epi.Data.IDbDriver db = (Epi.Data.IDbDriver)dlg.SelectedDataSource;
                    if (string.IsNullOrEmpty(dlg.SQLQuery))
                    {
                        DataTable     DT          = db.GetTopTwoTable(dlg.SelectedDataMember);
                        List <string> columnNames = new List <string>();
                        foreach (DataColumn dc in DT.Columns)
                        {
                            columnNames.Add(dc.ColumnName);
                        }
                        Epi.Windows.ImportExport.Dialogs.FieldSelectionDialog fsd = new Windows.ImportExport.Dialogs.FieldSelectionDialog(columnNames);
                        DialogResult fieldDialogResult = fsd.ShowDialog();
                        if (fieldDialogResult == System.Windows.Forms.DialogResult.OK)
                        {
                            string selectedColumn = fsd.SelectedField;
                            string codeTableName  = "code" + dlg.SelectedDataMember + selectedColumn;

                            try
                            {
                                DT           = db.GetTableData(dlg.SelectedDataMember);
                                DT.TableName = codeTableName;
                                codeTables.Add(DT);

                                codeTableList.Add(codeTableName);
                                ((DataGridViewComboBoxColumn)dgvFormFields.Columns["ListSourceTableName"]).Items.Clear();

                                foreach (string s in codeTableList)
                                {
                                    ((DataGridViewComboBoxColumn)dgvFormFields.Columns["ListSourceTableName"]).Items.Add(s);
                                }
                            }
                            catch (OutOfMemoryException)
                            {
                                Epi.Windows.MsgBox.ShowError(ImportExportSharedStrings.ERROR_OUT_OF_MEMORY_CODE_TABLE);
                                DT.Rows.Clear();
                            }
                        }
                    }
                    else
                    {
                        Epi.Windows.MsgBox.ShowInformation(ImportExportSharedStrings.ERROR_CODE_TABLE_QUERY_IMPORT_NOT_ALLOWED);
                    }
                }
            }
        }