private void cmdGenerate_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow aRow in dgvColumns.Rows)
            {
                MappingGeneratorDataItem mgdi           = (MappingGeneratorDataItem)aRow.Cells["colMappingGeneratorItem"].Value;
                data_mapping_field       _workingObject = new data_mapping_field();
                if ((!mgdi.Exists) && (mgdi.Map_Field))
                {
                    // Create a mapping field
                    _workingObject            = new data_mapping_field();
                    _workingObject.table_name = mgdi.Table_Name;
                    _workingObject.field_name = mgdi.Field_Name;
                    _workingObject.field_type = mgdi.Field_Type;
                    _workingObject.Save();
                }
                else if (mgdi.Exists && !mgdi.Map_Field)
                {
                    // Remove a mapping field
                    _workingObject = mgdi.ExistingMapping;
                    _workingObject.Delete();
                }
            }

            MessageBox.Show(this, "The requested changes have been processed.", "Operation Complete");
            Close();
        }
 private static bool HasAMatch(data_mapping_field mapping_field, string field_name, string table_name)
 {
     if ((mapping_field.field_name == field_name) &&
         (mapping_field.table_name == table_name))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #3
0
        private string GetLinkedField(data_mapping_field mappingFields)
        {
            foreach (data_mapping_schema_data aMapping in _formSchema.LinkedSchemaData)
            {
                if (aMapping.mapping_field_id == mappingFields.id)
                {
                    return(aMapping.mapped_to_text);
                }
            }

            return("");
        }
Пример #4
0
        /// <summary>
        /// Loads the data for the current schema, or the first schema. If no schema is found,
        /// creates a default schema
        /// </summary>
        private void LoadData()
        {
            #region Fields
            txtSchemaName.Text        = _formSchema.schema_name;
            cmbDataType.SelectedIndex = (int)_formSchema.data_type;
            txtSQL.Text                   = _formSchema.sqlstatement;
            txtServerName.Text            = _formSchema.server_name;
            txtDatabaseName.Text          = _formSchema.database_name;
            txtUserName.Text              = _formSchema.user_name;
            chkAllowSavePassword.Checked  = System.Convert.ToBoolean(_formSchema.allow_password_save);
            txtPassword.Text              = _formSchema.pw;
            txtClaimIDColumn.Text         = _formSchema.claim_id_column;
            txtCompanyNameColumn.Text     = _formSchema.company_namecolumn;
            txtDateColumn.Text            = _formSchema.date_column;
            txtSQLSecondary.Text          = _formSchema.sqlstatementsecondaries;
            txtSQLPredeterm.Text          = _formSchema.sqlstatementpredeterms;
            txtSQLSecondaryPredeterm.Text = _formSchema.sqlstatementsecondarypredeterms;
            txtClaimDBColumn.Text         = _formSchema.claim_db_column;

            #endregion
            List <FieldMappingDisplay> allMappedFields = new List <FieldMappingDisplay>();
            FieldMappingDisplay        fmd;
            data_mapping_field         mappingFields = new data_mapping_field();
            DataTable allFields = mappingFields.Search(mappingFields.SearchSQL + " ORDER BY table_name, field_name");

            foreach (DataRow aField in allFields.Rows)
            {
                fmd           = new FieldMappingDisplay();
                mappingFields = new data_mapping_field();
                mappingFields.Load(aField);
                fmd.FieldName = mappingFields.field_name;
                fmd.TableName = mappingFields.table_name;
                fmd.FieldData = mappingFields;

                fmd.LinkedField = GetLinkedField(mappingFields);

                allMappedFields.Add(fmd);
            }

            dgvMappings.DataSource = allMappedFields;
            _dataChanged           = false;
        }
        public frmGenerateMappings()
        {
            InitializeComponent();
            _existingFields  = new List <data_mapping_field>();
            _workingObject   = new data_mapping_field();
            _generatedFields = new List <MappingGeneratorDataItem>();
            MappingGeneratorDataItem _workingItem;

            // Get existing data mappings
            DataTable allFields = _workingObject.Search(_workingObject.SearchSQL + " ORDER BY table_name, field_name");

            foreach (DataRow aRow in allFields.Rows)
            {
                _workingObject = new data_mapping_field();
                _workingObject.Load(aRow);
                _existingFields.Add(_workingObject);
            }


            for (int i = 0; i < 4; i++)
            {
                string tableName;
                switch (i)
                {
                case 0:
                    tableName = "claims";
                    break;

                case 1:
                    tableName = "companies";
                    break;

                case 2:
                    tableName = "company_contact_info";
                    break;

                case 3:
                    tableName = "procedures";
                    break;

                default:
                    throw new Exception("Unitialized table in generate mappings.");
                }

                // Retrieve column information
                // Use Connection object for the DataAdapter to retrieve all tables from selected Database
                DataTable columnsTable = _workingObject.Search("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + tableName + "' ORDER BY Column_Name");
                foreach (DataRow aColumn in columnsTable.Rows)
                {
                    _workingItem                 = new MappingGeneratorDataItem();
                    _workingItem.Table_Name      = tableName;
                    _workingItem.Field_Name      = aColumn["Column_Name"].ToString();
                    _workingItem.Field_Type      = aColumn["Data_Type"].ToString();
                    _workingItem.ExistingMapping = _existingFields.Find(delegate(data_mapping_field dmf)
                                                                        { return((dmf.table_name == _workingItem.Table_Name) && (dmf.field_name == _workingItem.Field_Name)); });
                    _workingItem.Exists    = _workingItem.ExistingMapping != null;
                    _workingItem.Map_Field = _workingItem.Exists;
                    _generatedFields.Add(_workingItem);
                }
            }
        }