Пример #1
0
        protected void btnEditMetaTable_onClick(object sender, EventArgs e)
        {
            //set edit table view
            viewMode = "editTable";
            setViewMode();
            int tableId;

            if (((WebControl)sender).ID == "btnEditMetaTable" || ((WebControl)sender).ID == "btnNewTableCreatedNext")
            {
                tableId = int.Parse(ddlTableDefs.SelectedValue);
                ddlEtTableName.ClearSelection();
                ddlEtTableName.SelectedValue = tableId.ToString();
            }
            else
            {
                tableId = int.Parse(ddlEtTableName.SelectedValue);
                ddlTableDefs.SelectedValue = tableId.ToString();
            }
            MetadataNewDa MNDa        = new MetadataNewDa();
            DataTable     tableDefsDt = MNDa.GetMetaTable(tableId);
            DataRow       dr          = tableDefsDt.Rows[0];

            lblEtTableId.Text = tableId.ToString();
            string tableName = dr["TableName"].ToString();

            txtEtTableLabel.Text       = dr["TableLabel"].ToString();
            txtEtTableDescription.Text = dr["TableDescription"].ToString();
            lblEtTableName.Text        = tableName;

            updateEditTableView(tableId, tableName);
        }
Пример #2
0
        protected void dgOptionsForAnAttribute_ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            viewMode = "EditAnAttribute";
            setViewMode();

            string optionValue;
            int    attributeId;

            attributeId = int.Parse(txtEditAnAttributeId.Text);
            MetadataNewDa MNDa = new MetadataNewDa();

            switch (e.CommandName)
            {
            case "Delete":

                optionValue = ((Literal)e.Item.Cells[0].Controls[1]).Text;
                MNDa.DeleteAttributeValueOption(attributeId, optionValue);
                loadAttributeValueOptionsForAnAttribute(attributeId);
                break;

            case "Add":
                optionValue = ((TextBox)e.Item.FindControl("txtNewOption")).Text;
                MNDa.AddAttributeValueOption(attributeId, optionValue);
                loadAttributeValueOptionsForAnAttribute(attributeId);
                break;
            }
        }
Пример #3
0
        private void loadAttributeSwitchOptionsForJS()
        {
            //should use stringbuilder instead for optimization
            MetadataNewDa MNDa = new MetadataNewDa();

            dtAttributes = MNDa.GetAttributes();
            string strOut = "";

            for (int i = 0; i < dtAttributes.Rows.Count; i++)
            {
                DataTable attributeValueOptionsDT = MNDa.GetAttributeValueOptionsForAnAttribute(int.Parse(dtAttributes.Rows[i]["AttributeId"].ToString()));
                if (attributeValueOptionsDT.Rows.Count > 0)
                {
                    string conc = "";
                    strOut = strOut + "case '" + dtAttributes.Rows[i]["AttributeId"].ToString() + "': valueOptions = new Array(";
                    for (int j = 0; j < attributeValueOptionsDT.Rows.Count; j++)
                    {
                        strOut = strOut + conc + "'" + attributeValueOptionsDT.Rows[j]["AttributeOptionValue"].ToString() + "'";
                        conc   = ",";
                    }
                    strOut = strOut + ");break;";
                }
            }
            attTxtAttributeValueOptionsSwitch.Text = attTxtAttributeValueOptionsSwitch.Text + strOut;
        }
Пример #4
0
        protected void btnAddAnAttribute_onClick(object sender, EventArgs e)
        {
            string        newAttName = txtNewAttributeName.Text;
            string        result     = "";
            MetadataNewDa MNDa       = new MetadataNewDa();

            if (newAttName.Length > 0)
            {
                if (MNDa.AttributeExists(newAttName))
                {
                    result = "An attribute called '" + newAttName + "' already exists. The new attribute was not created.";
                    btnCreateNewAttributeNext.Visible = false;
                }
                {
                    try
                    {
                        MNDa.CreateNewAttribute(newAttName);
                        result = "The new attribute '" + newAttName + "' was successfully created.";
                        btnCreateNewAttributeNext.Visible = true;
                    }
                    catch (Exception err)
                    {
                        result = "An error occured while creating the new attribute '" + newAttName + "'. The attribute was not added.";
                        btnCreateNewAttributeNext.Visible = false;
                    }
                }
            }
            lblCreateNewAttributeResult.Text = result;
            lblCreateNewAttributeName.Text   = newAttName;
            lblCreateNewAttributeId.Text     = MNDa.GetAnAttribute(newAttName).Rows[0]["AttributeId"].ToString();
            viewMode = "createNewAttributeStep2";
            setViewMode();
        }
Пример #5
0
        private void loadTableColumns(int tableId, string tableName)
        {
            MetadataNewDa MNDa = new MetadataNewDa();
            DataTable     cols = MNDa.GetTableColumns(tableId, tableName);

            if (cols.Rows.Count < 1)
            {
                lblEtNotUsedFields.Visible = true;
                lblEtNotUsedFields.Text    = "None";
                dgEtFieldsNotUsed.Visible  = false;
                btnEtAddSelectedColumnsToMetaFields.Visible     = false;
                btnEtAddSelectedColumnsToMetaFieldsInfo.Visible = false;
            }
            else
            {
                lblEtNotUsedFields.Visible   = false;
                lblEtNotUsedFields.Text      = "";
                dgEtFieldsNotUsed.DataSource = cols.DefaultView;
                dgEtFieldsNotUsed.DataBind();
                dgEtFieldsNotUsed.Visible = true;
                btnEtAddSelectedColumnsToMetaFields.Visible     = true;
                btnEtAddSelectedColumnsToMetaFieldsInfo.Visible = true;
                lblEtNotUsedFields.Text    = "Add selected items as meta fields:&nbsp;";
                lblEtNotUsedFields.Visible = true;
            }
            btnEtAddSelectedColumnsToMetaFieldsCancel.Visible = btnEtAddSelectedColumnsToMetaFields.Visible;
        }
Пример #6
0
        private void loadTableDefs()
        {
            MetadataNewDa MNDa        = new MetadataNewDa();
            DataTable     tableDefsDt = MNDa.GetMetaTables();

            ddlTableDefs.Items.Clear();
            ddlEtTableName.Items.Clear();
            for (int i = 0; i < tableDefsDt.Rows.Count; i++)
            {
                string   id         = tableDefsDt.Rows[i]["TableId"].ToString();
                string   tableName  = tableDefsDt.Rows[i]["TableName"].ToString();
                string   tableLabel = tableDefsDt.Rows[i]["TableLabel"].ToString();
                ListItem li         = new ListItem(tableName + " (" + tableLabel + ")", id);
                ListItem li2        = new ListItem(li.Text, li.Value);
                ddlTableDefs.Items.Add(li);
                ddlEtTableName.Items.Add(li2);
            }
            ddlTableDefs.Items.Insert(0, "  ");
            ddlTableDefs.SelectedIndex = 0;

            DataTable atts = MNDa.GetAttributes();

            ddlEditAnAttribute.Items.Clear();
            ddlEditAnAttribute.DataSource     = atts;
            ddlEditAnAttribute.DataTextField  = "AttributeName";
            ddlEditAnAttribute.DataValueField = "AttributeId";
            ddlEditAnAttribute.DataBind();
        }
Пример #7
0
        protected void loadAttributeValueOptionsForAnAttribute(int attributeId)
        {
            MetadataNewDa MNDa = new MetadataNewDa();

            DataTable dtAO = MNDa.GetAttributeValueOptionsForAnAttributeWithUsageInfo(attributeId);

            dgOptionsForAnAttribute.DataSource = dtAO.DefaultView;
            dgOptionsForAnAttribute.DataBind();
        }
Пример #8
0
        protected void btnEtAddSelectedColumnsToMetaFields_onClick(object sender, EventArgs e)
        {
            //set create table view
            viewMode = "editTable";
            setViewMode();
            int    tableId   = int.Parse(ddlTableDefs.SelectedValue);
            string tableName = lblEtTableName.Text;


            string fieldName;
            string fieldDataType;
            int    maxLength = -1;
            int    order;

            MetadataNewDa MNDa = new MetadataNewDa();

            if (MNDa.MetaFieldOrderTableHasOrderedFields(tableId))
            {
                order = -1;
            }
            else
            {
                order = 1;
            }
            foreach (DataGridItem i in dgEtFieldsNotUsed.Items)
            {
                CheckBox deleteChkBxItem = (CheckBox)i.FindControl("chkSelection");

                if (deleteChkBxItem.Checked)
                {
                    string strMaxLength;
                    fieldName     = i.Cells[1].Text;
                    fieldDataType = ParseSQLDatatypeToCsharp(i.Cells[2].Text);
                    strMaxLength  = i.Cells[3].Text;
                    if (PageUtil.IsInteger(strMaxLength))
                    {
                        maxLength = int.Parse(strMaxLength);
                    }
                    else
                    {
                        maxLength = -1;
                    }
                    if (order > 0)
                    {
                        MNDa.AddMetaField(tableId, fieldName, fieldDataType, maxLength, false, false, order);
                        order++;
                    }
                    else
                    {
                        MNDa.AddMetaField(tableId, fieldName, fieldDataType, maxLength, false, false);
                    }
                }
            }
            updateEditTableView(tableId, tableName);
        }
Пример #9
0
        protected void btnEtSave_onClick(object sender, EventArgs e)
        {
            //set create table view
            viewMode = "editTable";
            setViewMode();
            int tableId = int.Parse(ddlTableDefs.SelectedValue);

            MetadataNewDa MNDa = new MetadataNewDa();

            MNDa.UpdateMetaTable(tableId, txtEtTableDescription.Text, txtEtTableLabel.Text);
        }
Пример #10
0
        private void loadTableDefs()
        {
            MetadataNewDa MNDa        = new MetadataNewDa();
            DataTable     tableDefsDt = MNDa.GetMetaTables();

            ddlTableDefs.DataSource    = tableDefsDt;
            ddlTableDefs.DataTextField = "TableName";

            ddlTableDefs.DataValueField = "TableId";

            ddlTableDefs.DataBind();
            ddlTableDefs.Items.Insert(0, "  ");
            ddlTableDefs.SelectedIndex = 0;
            emptyFieldNames();
        }
Пример #11
0
 private void loadAttributeValueOptions()
 {
     if (hstAttributeValueOptions.Count == 0)
     {
         MetadataNewDa MNDa = new MetadataNewDa();
         dtAttributes = MNDa.GetAttributes();
         for (int i = 0; i < dtAttributes.Rows.Count; i++)
         {
             DataTable attributeValueOptionsDT = MNDa.GetAttributeValueOptionsForAnAttribute(int.Parse(dtAttributes.Rows[i]["AttributeId"].ToString()));
             try
             {
                 hstAttributeValueOptions.Add(dtAttributes.Rows[i]["AttributeName"], attributeValueOptionsDT);
             }
             catch (Exception e) {}
         }
     }
 }
Пример #12
0
        protected void btnCreateMetaTable_onClick(object sender, EventArgs e)
        {
            //set create table view
            viewMode = "newTabelStep2";
            string        tableName = ddlNewMetaTableBaseTable.SelectedValue;
            MetadataNewDa MNDa      = new MetadataNewDa();
            int           tableId   = MNDa.AddMetaTable(tableName);

            lbNewTableResult.Text          = "A new meta table based on '" + tableName + "' was created.<BR><BR>Click 'Next' to continue to edit meta table data and meta fields for the new meta table.<BR><BR>";
            lbNewTableResultTableId.Text   = tableId.ToString();
            lbNewTableResultTableName.Text = tableName;
            loadTableDefs();
            ddlTableDefs.SelectedIndex = ddlTableDefs.Items.IndexOf(ddlTableDefs.Items.FindByValue(tableId.ToString()));
            setViewMode();
            btnNewTableCreatedNext.Enabled         = true;
            ddlNewMetaTableBaseTable.SelectedIndex = 0;
        }
Пример #13
0
        /// <summary>
        /// Builds a list of available MetadataTables
        /// </summary>
        protected override void PopulateAttributeValues()
        {
            MetadataDa da        = new MetadataDa();
            var        allTables = da.GetAllTableMetadata(null, QueryDiseaseId).AsEnumerable();

            // restrict to disease specific tables
            if (QueryDiseaseId.HasValue)
            {
                allTables = allTables.Where(r => !r.IsNull(Disease.DiseaseId));
            }
            // build a list of unique metadata tables with there associated metadata
            var tableToAttributes = from row in allTables
                                    let tableId = (int)row[MetadataTable.TableId]
                                                  group row by tableId into groupByTable
                                                  let tableName = groupByTable.First()[MetadataTable.TableName_Field].ToString()
                                                                  orderby tableName ascending
                                                                  select new
            {
                TableId           = groupByTable.Key,
                TableName         = tableName,
                Data              = groupByTable,
                DiseaseAttributes = from record in groupByTable
                                    where !record.IsNull(DiseaseAttributeValue.DiseaseAttributeValueId)
                                    select record
            };

            MetadataGrid.DataSource = tableToAttributes;
            MetadataGrid.DataBind();

            // build missing metadata tables
            MetadataNewDa MNDa     = new MetadataNewDa();
            DataTable     tablesDt = MNDa.GetAllTablesInDB();
            // create display column for formatting
            DataView view = tablesDt.DefaultView;

            view.RowFilter = "TABLE_TYPE = 'BASE TABLE'";
            view.Sort      = "TABLE_NAME ASC";

            NewMetadataTablesGrid.DataSource = view;
            NewMetadataTablesGrid.DataBind();
        }
Пример #14
0
        protected void btnEditAnAttribute_onClick(object sender, EventArgs e)
        {
            MetadataNewDa MNDa = new MetadataNewDa();

            viewMode = "EditAnAttribute";
            setViewMode();
            int    attributeId = -1;
            Button btn         = (Button)sender;

            switch (btn.Text)
            {
            case "Edit attribute":
                attributeId = int.Parse(ddlEditAnAttribute.SelectedValue);
                break;

            case "Next":
                attributeId = int.Parse(lblCreateNewAttributeId.Text);
                break;

            case "Save":
                attributeId = int.Parse(txtEditAnAttributeId.Text);
                string attributeName = txtEditAnAttributeName.Text;
                if (attributeName.Length > 0)
                {
                    MNDa.UpdateAttributeName(attributeId, attributeName);
                }
                break;

            case "Cancel":
                attributeId = int.Parse(txtEditAnAttributeId.Text);
                break;
            }
            DataTable dtA = MNDa.GetAnAttribute(attributeId);

            txtEditAnAttributeId.Text   = dtA.Rows[0]["AttributeId"].ToString();
            txtEditAnAttributeName.Text = dtA.Rows[0]["AttributeName"].ToString();

            loadAttributeValueOptionsForAnAttribute(attributeId);
        }
Пример #15
0
        /// <summary>
        /// Resequences the FieldOrders of the MetadataFields effected by the movement of a MetadataField
        /// </summary>
        /// <param name="fieldOrder">the new  order of the moved field</param>
        /// <param name="previousFieldOrder">the order of the field before it was moved</param>
        /// <param name="tableId">the id of the table of the field that was moved</param>
        /// <param name="fieldId">the id of the field that was moved</param>
        private void UpdateFieldOrders(int fieldOrder, int previousFieldOrder, int tableId, int fieldId, bool fieldSuppressed)
        {
            MetadataNewDa MNDa = new MetadataNewDa();

            int numPositionChange;

            // how many positions has the field moved up or down?
            if (previousFieldOrder == -1) // -1 means field order was previously Null
            {
                numPositionChange = -1;
            }
            else
            {
                numPositionChange = fieldOrder - previousFieldOrder;
            }


            if (numPositionChange != 0 || fieldSuppressed) // make sure field moved
            {
                DataSet ReorderRecords = MNDa.GetFieldsForReodering(tableId, fieldId, fieldOrder, numPositionChange);

                int newFieldOrder = 1;                              // field was moved up from previous position

                if (numPositionChange < 0)                          // but if the field was moved down
                {
                    newFieldOrder = fieldOrder + 1;                 //move all fields above and equal to the new field order up one position
                }
                else if (numPositionChange == 0 && fieldSuppressed) // the position wasn't changed but the field was suppressed! reorder everything under where it was
                {
                    newFieldOrder = fieldOrder;
                }

                foreach (DataRow dr in ReorderRecords.Tables[0].Rows)
                {
                    MNDa.IncreaseMetaFieldOrderNumberByOne((int)dr[BOL.MetadataField.FieldId], newFieldOrder);
                    newFieldOrder++;
                }
            }
        }
Пример #16
0
        private void loadMetaFields(int metaTableId)
        {
            //The relationship handling should maybe be moved to MetadataNewDa instead, returning the complete Dataset
            MetadataNewDa MNDa = new MetadataNewDa();
            DataSet       ds   = new DataSet();

            DataTable ParentFields = new DataTable();

            ParentFields = MNDa.GetMetaFieldsForAMetaTable(ParentFields, metaTableId);


            if (ParentFields.Rows.Count < 1)
            {
                lblEtFields.Visible = true;
                lblEtFields.Text    = "None";
                dgEtFields.Visible  = false;
            }
            else
            {
                ParentFields.TableName = "ParentTable";

                DataTable ChildAttributes = new DataTable();
                ChildAttributes           = MNDa.GetAttributeValuesForAMetaTable(ChildAttributes, metaTableId);
                ChildAttributes.TableName = "ChildTable";

                ds.Tables.Add(ParentFields);
                ds.Tables.Add(ChildAttributes);

                DataRelation dr = new DataRelation("ParentTable_ChildTable", ParentFields.Columns["FieldId"], ChildAttributes.Columns["FieldId"], false);
                dr.Nested = true;
                ds.Relations.Add(dr);

                lblEtFields.Visible   = false;
                dgEtFields.DataSource = ds;
                dgEtFields.DataBind();
                dgEtFields.Visible = true;
            }
        }
Пример #17
0
        private void loadSystemTables()
        {
            MetadataNewDa MNDa     = new MetadataNewDa();
            DataTable     tablesDt = MNDa.GetAllTablesInDB();
            // create display column for formatting
            DataView view = tablesDt.DefaultView;

            view.RowFilter = "TABLE_TYPE = 'BASE TABLE'";
            view.Sort      = "TABLE_NAME ASC";

            ddlNewMetaTableBaseTable.DataSource = view;
            ddlNewMetaTableBaseTable.DataBind();

            //ddlNewMetaTableBaseTable.Items.Clear();
            //for (int i = 0;i < tablesDt.Rows.Count;i++)
            //{
            //    string tableName = tablesDt.Rows[i]["TABLE_NAME"].ToString();
            //    string tablesType = tablesDt.Rows[i]["TABLE_TYPE"].ToString();
            //    ListItem li = new ListItem(tableName + " (" + tablesType + ")",tableName);
            //    ddlNewMetaTableBaseTable.Items.Add(li);
            //}
            //ddlNewMetaTableBaseTable.Items.Insert(0,"  ");
            //ddlNewMetaTableBaseTable.SelectedIndex = 0;
        }
Пример #18
0
        protected void btnEtDeleteTable_onClick(object sender, EventArgs e)
        {
            MetadataNewDa MNDa       = new MetadataNewDa();
            bool          okToDelete = true;
            int           tableId    = int.Parse(ddlTableDefs.SelectedValue);

            okToDelete = !MNDa.TableHasDataSavedInVirtualMetaField(tableId);

            if (okToDelete)
            {
                viewMode = "start";
                setViewMode();
                MNDa.DeleteMetaTableAndAssociatedData(tableId);
                ddlTableDefs.SelectedIndex = 0;
                loadTableDefs();
            }
            else
            {
                viewMode = "errorMessage";
                setViewMode();
                lblErrorHeading.Text = "Could not delete meta table";
                lblErrorMessage.Text = "One or more virtual meta field in the selected meta table has data saved in a virtual table. The meta table was not deleted.";
            }
        }
Пример #19
0
        /// <summary>
        /// Builds a list of available MetadataTables
        /// </summary>
        protected override void PopulateAttributeValues()
        {
            if (tableId.HasValue)
            {
                // populate main table attributes
                PopulateTableAttributes();

                // populate table field attributes
                MetadataDa da = new MetadataDa();
                DataTable  dt = da.GetFieldMetadata(tableId.Value, QueryDiseaseId);

                // build a list of unique metadata tables with there associated metadata
                var tableToAttributes = from row in dt.AsEnumerable()
                                        let fieldId = (int)row[MetadataField.FieldId]
                                                      group row by fieldId into groupByField
                                                      let filedName = groupByField.First()[MetadataField.FieldName].ToString()
                                                                      let fieldOrderMetadata = from record in groupByField
                                                                                               let attributeName = record[MetadataFieldAttribute.AttributeName].ToString()
                                                                                                                   let attributeValue = record[MetadataFieldAttributeValue.AttributeValue].ToString()
                                                                                                                                        // filter by FieldOrder attribute
                                                                                                                                        where attributeName.Equals(MetadataField.FieldOrder, StringComparison.OrdinalIgnoreCase) && PageUtil.IsInteger(attributeValue)
                                                                                                                                        // filter by disease (or defaul=NULL)
                                                                                                                                        where (!QueryDiseaseId.HasValue && record.IsNull(Disease.DiseaseId)) || (QueryDiseaseId.HasValue && !record.IsNull(Disease.DiseaseId))
                                                                                                                                        let fieldOrder = int.Parse(attributeValue)
                                                                                                                                                         select fieldOrder
                                                                                                                                                         // sort by field sort order, with null to bottom
                                                                                                                                                         let fieldOrder = fieldOrderMetadata.Count() > 0 ? fieldOrderMetadata.First() : int.MaxValue
                                                                                                                                                         //let sort = !string.IsNullOrEmpty(fieldSort) ? int.Parse(fieldSort) : int.MaxValue
                                                                                                                                                                          orderby fieldOrder ascending, filedName ascending
                    select new
                {
                    TableId    = tableId,
                    FieldId    = groupByField.Key,
                    FieldName  = filedName,
                    FieldOrder = fieldOrder,
                    //FieldSuppress = false,
                    Data = groupByField,
                    DiseaseAttributes = from record in groupByField
                                        where !record.IsNull(DiseaseAttributeValue.DiseaseAttributeValueId)
                                        select record
                };
                MetadataGrid.DataSource = tableToAttributes;
                MetadataGrid.DataBind();

                // build fields without metadata
                MetadataTable biz = new MetadataTable();
                biz.Get(tableId.Value);

                MetadataNewDa MNDa = new MetadataNewDa();
                DataTable     cols = MNDa.GetTableColumns(tableId.Value, biz[MetadataTable.TableName_Field].ToString());
                // build a list of actual fields not yet assigned metadata
                var nonMetadataFields = from row in cols.AsEnumerable()
                                        select new
                {
                    COLUMN_NAME  = row["COLUMN_NAME"].ToString(),
                    DATA_TYPE    = row["DATA_TYPE"].ToString(),
                    CHAR_MAX_LEN = row["CHAR_MAX_LEN"].ToString(),
                    IS_VIRTUAL   = false
                };
                // build blank rows for new virtual fields
                var blankVirtualFields = from i in Enumerable.Range(0, 1)
                                         select new
                {
                    COLUMN_NAME  = string.Empty,
                    DATA_TYPE    = string.Empty,
                    CHAR_MAX_LEN = string.Empty,
                    IS_VIRTUAL   = true
                };
                var dataSource = nonMetadataFields.Concat(blankVirtualFields);
                NonMetadataFields.DataSource = dataSource;
                NonMetadataFields.DataBind();
            }
        }
Пример #20
0
        protected void PublishTableAudit(object sender, EventArgs e)
        {
            bool onlyShowTables   = AuditOptions.Items[0].Selected;
            bool onlyShowConflict = AuditOptions.Items[1].Selected;

            MetadataNewDa da   = new MetadataNewDa();
            var           pdec = new Caisis.Controller.PatientDataEntryController(null);

            DataTable dt = da.GetAllTableAndColumns();
            var       db = from row in dt.AsEnumerable()
                           let table                                                          = row["TABLE_NAME"].ToString()
                                                              let field                       = row["COLUMN_NAME"].ToString()
                                                                                     let pair = new { Table = table, Field = field }
            group pair by pair.Table into g
                      select new
            {
                Table  = g.Key,
                Fields = g.Select(t => t.Field)
            };
            var dbTableNames = db.ToDictionary(a => a.Table, a => a.Fields);

            var biz = from table in BusinessObject.GetAllTableNames()
                      from field in BusinessObject.GetFieldNames(table)
                      group field by table into g
                      select new
            {
                Table  = g.Key,
                Fields = g
            };
            var bizTableName       = biz.ToDictionary(a => a.Table, a => a.Fields.Select(f => f));
            var allTables          = dbTableNames.Keys.Union(bizTableName.Keys).Distinct();
            var tableAndFieldAudit = from table in allTables
                                     let indb                         = dbTableNames.ContainsKey(table)
                                                            let inbiz = bizTableName.ContainsKey(table)
                                                                        let dbFields = indb ? dbTableNames[table] : new string[0]
                                                                                       let bizFields = inbiz ? bizTableName[table] : new string[0]
                                                                                                       let allFields = dbFields.Union(bizFields).Distinct()
                                                                                                                       from field in allFields
                                                                                                                       orderby table, field
            let fieldInDB = indb && dbFields.Contains(field)
                            let fieldInBiz = inbiz && bizFields.Contains(field)
                                             where !onlyShowConflict || fieldInDB != fieldInBiz || (fieldInDB == false && fieldInBiz == false)
                                             select new
            {
                Table = table,
                Field = field,
                InDB  = fieldInDB,
                InBiz = fieldInBiz
            };

            if (onlyShowTables)
            {
                tableAndFieldAudit = from t in tableAndFieldAudit
                                     group t by t.Table into g
                                     select new
                {
                    Table = g.Key,
                    Field = "",
                    InDB  = g.Where(b => b.InDB).Count() == g.Count(),
                    InBiz = g.Where(b => b.InBiz).Count() == g.Count()
                };
            }

            AuditTableGrid.DataSource = tableAndFieldAudit;
            AuditTableGrid.DataBind();
        }
Пример #21
0
        protected void dgEtFieldsAttributes_ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            int    attributeId;
            int    tableId   = int.Parse(ddlTableDefs.SelectedValue);
            string tableName = lblEtTableName.Text;

            MetadataNewDa MNDa = new MetadataNewDa();

            switch (e.CommandName)
            {
            case "Delete":

                attributeId = int.Parse(e.Item.Cells[0].Text);
                MNDa.DeleteAttribute(attributeId);

                break;

            case "SaveAttributes":
                DataGrid dgAttributes = (DataGrid)source;
                foreach (DataGridItem dgi in dgAttributes.Items)
                {
                    if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem)
                    {
                        int          fieldAttributeId = int.Parse(dgi.Cells[0].Text);
                        DropDownList ddl = (DropDownList)dgi.FindControl("attDdlAttributeValue");
                        TextBox      txt = (TextBox)dgi.FindControl("attTxtAttributeValue");
                        string       theValue;
                        if (((TextBox)dgi.FindControl("attTxtAttributeValueCtrlUsed")).Text == "txt")
                        {
                            theValue = txt.Text;
                        }
                        else
                        {
                            theValue = ddl.SelectedValue;
                        }

                        theValue = PageUtil.EscapeSingleQuotesForSql(theValue);
                        MNDa.UpdateAttribute(fieldAttributeId, theValue);
                    }
                }
                TextBox txtNewAttributesList = (TextBox)Page.FindControl("attTxtNewAttributesList");

                string[] atts = txtNewAttributesList.Text.Split(char.Parse("@"));
                for (int k = 0; k < atts.Length; k++)
                {
                    string[] anAtt = atts[k].Split(char.Parse(";"));
                    if (anAtt.Length == 3 && PageUtil.IsInteger(anAtt[0]) && PageUtil.IsInteger(anAtt[1]))
                    {
                        string attValue = PageUtil.EscapeSingleQuotesForSql(anAtt[2]);

                        MNDa.DeleteAttribute(int.Parse(anAtt[0]), int.Parse(anAtt[1]));
                        MNDa.AddAttribute(int.Parse(anAtt[0]), int.Parse(anAtt[1]), attValue);
                    }
                }
                txtNewAttributesList.Text = "";
                break;
            }
            viewMode = "editTable";
            setViewMode();
            updateEditTableView(tableId, tableName);
        }
Пример #22
0
        protected void dgEtFieldsAttributes_ItemDataBound(Object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            ListItemType lt = e.Item.ItemType;

            if (lt == ListItemType.Header)
            {
                loadAttributeValueOptions();
            }
            else if (lt == ListItemType.Item || lt == ListItemType.AlternatingItem)
            {
                DataRowView dv = e.Item.DataItem as DataRowView;

                DropDownList ddl3    = (DropDownList)e.Item.FindControl("attDdlAttributeValue");
                DataTable    options = (DataTable)hstAttributeValueOptions[dv["AttributeName"].ToString()];
                if (options.Rows.Count > 0)
                {
                    ddl3.DataSource     = options;
                    ddl3.DataTextField  = "AttributeOptionValue";
                    ddl3.DataValueField = "AttributeOptionValue";
                    ddl3.DataBind();
                    PreSelectDropDown("attDdlAttributeValue", "AttributeValue", e.Item);

                    ddl3.Visible = true;
                    ((TextBox)e.Item.FindControl("attTxtAttributeValue")).Visible      = false;
                    ((TextBox)e.Item.FindControl("attTxtAttributeValueCtrlUsed")).Text = "ddl";
                }
                else
                {
                    ddl3.Visible = false;
                    ((TextBox)e.Item.FindControl("attTxtAttributeValue")).Visible      = true;
                    ((TextBox)e.Item.FindControl("attTxtAttributeValueCtrlUsed")).Text = "txt";
                }

                // handle display of attribute name
                Literal attLitAttributeName;
                attLitAttributeName      = (System.Web.UI.WebControls.Literal)e.Item.FindControl("attLitAttributeName");
                attLitAttributeName.Text = dv["AttributeName"].ToString();

                if (attLitAttributeName.Text.Equals("LookupCode"))
                {
                    string lookupCodeValue = dv["AttributeValue"].ToString();
                    attLitAttributeName.Text += " <img src=\"../Images/Icon_Plus.gif\" style=\"cursor: pointer;\" onclick=\"launchLookupCodeFrame('" + lookupCodeValue + "')\">";
                }
            }
            else if (lt == ListItemType.Footer)
            {
                DataGrid dg = (DataGrid)sender;
                ((TextBox)e.Item.FindControl("attTxtFieldIdFooter")).Text = dg.ToolTip;
                DropDownList  ddlUnusedAttributes = (DropDownList)e.Item.FindControl("attDdlAddAttributeUnusedAttributes");
                MetadataNewDa MNDa             = new MetadataNewDa();
                DataTable     unusedAttributes = MNDa.GetAttributesNotUsedForAMetaField(int.Parse(dg.ToolTip));
                ddlUnusedAttributes.Items.Clear();
                ddlUnusedAttributes.DataSource     = unusedAttributes;
                ddlUnusedAttributes.DataTextField  = "AttributeName";
                ddlUnusedAttributes.DataValueField = "AttributeId";
                ddlUnusedAttributes.DataBind();
                Button btnAdd = (Button)e.Item.FindControl("attBtnEditAttributeSave");
                btnAdd.Attributes.Add("OnClick", "javascript: return prepareToSaveNewAttributes(this);");

                Button attBtnEditAttribute;
                Button attBtnEditAttributeCancel;
                Button attBtnAddAttribute;
                attBtnEditAttribute = (Button)e.Item.FindControl("attBtnEditAttribute");
                attBtnEditAttribute.Attributes.Add("OnClick", "javascript: return EditAttributes(this);");
                attBtnAddAttribute = (Button)e.Item.FindControl("attBtnAddAttribute");
                attBtnAddAttribute.Attributes.Add("OnClick", "javascript: return AddNewAttribute(this);");
                attBtnEditAttributeCancel = (Button)e.Item.FindControl("attBtnEditAttributeCancel");
                attBtnEditAttributeCancel.Attributes.Add("OnClick", "javascript: return EditAttributesCancel(this);");
            }
        }
Пример #23
0
        protected void dgEtFields_ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            bool isVirtual;
            bool fieldSuppress;
            int  fieldOrder;
            int  fieldId;

            try
            {
                fieldId = int.Parse(e.Item.Cells[1].Text);
            }
            catch
            {
                fieldId = -1;
            }
            int           tableId   = int.Parse(ddlTableDefs.SelectedValue);
            string        tableName = lblEtTableName.Text;
            MetadataNewDa MNDa      = new MetadataNewDa();

            switch (e.CommandName)
            {
            case "Expand":
                viewMode = "editTable";
                setViewMode();

                PlaceHolder exp;
                exp         = e.Item.Cells[2].FindControl("Expanded") as PlaceHolder;
                exp.Visible = !exp.Visible;
                break;

            case "Edit":
                string fieldName     = ((TextBox)e.Item.Cells[2].Controls[1]).Text;
                string fieldDataType = ((DropDownList)e.Item.Cells[3].Controls[1]).SelectedValue;
                fieldSuppress = ((CheckBox)e.Item.Cells[5].Controls[1]).Checked;
                isVirtual     = ((CheckBox)e.Item.Cells[4].Controls[1]).Checked;
                try
                {
                    fieldOrder = int.Parse(((DropDownList)e.Item.Cells[6].Controls[1]).SelectedValue);
                }
                catch
                {
                    fieldOrder = -1;
                }
                viewMode = "editTable";
                setViewMode();


                DataRow fieldDr            = MNDa.GetMetadataField(fieldId);
                int     previousFieldOrder = -1;

                if (fieldDr[BOL.MetadataField.FieldOrder] != null && PageUtil.IsInteger(fieldDr[BOL.MetadataField.FieldOrder].ToString()))
                {
                    previousFieldOrder = (int)fieldDr[BOL.MetadataField.FieldOrder];
                }


                // This call updates the field order correctly
                MNDa.UpdateMetaField(fieldId, fieldName, fieldDataType, fieldSuppress, fieldOrder);

                // Resequence fields
                this.UpdateFieldOrders(fieldOrder, previousFieldOrder, tableId, fieldId, fieldSuppress);

                if (isVirtual)
                {
                    // refresh virtual field map
                    //Caisis.BOL.BusinessObjectFactory.RebuildVirtualFieldMap();
                    Caisis.BOL.BusinessObject.RebuildVirtualFields();
                }

                updateEditTableView(tableId, tableName);
                break;

            case "Delete":
                bool okToDelete = true;
                isVirtual = ((CheckBox)e.Item.Cells[4].Controls[1]).Checked;
                fieldId   = int.Parse(e.Item.Cells[1].Text);

                if (isVirtual)
                {
                    okToDelete = !MNDa.VirtualMetaFieldHasSavedData(fieldId);
                }
                if (okToDelete)
                {
                    viewMode = "editTable";
                    setViewMode();

                    MNDa.DeleteMetaField(fieldId);

                    if (isVirtual)
                    {
                        // refresh virtual field map
                        //Caisis.BOL.BusinessObjectFactory.RebuildVirtualFieldMap();
                        Caisis.BOL.BusinessObject.RebuildVirtualFields();
                    }

                    //MNDa.MetaFieldOrderRenumber(tableId);
                    updateEditTableView(tableId, tableName);
                }
                else
                {
                    viewMode = "errorMessage";
                    setViewMode();
                    lblErrorHeading.Text = "Could not delete virtual meta field";
                    lblErrorMessage.Text = "The selected virtual meta field has data saved in virtual table. The virtual meta field was not deleted.";
                }
                break;

            case "AddNewField":
                TextBox      efTxtNewVirtualField;
                DropDownList efDdlNewVirtualFieldDataType;
                CheckBox     efCbxNewFieldIsVirtual;
                CheckBox     efCbxNewFieldSuppress;
                DropDownList efDdlNewFieldOrder;

                efTxtNewVirtualField         = (TextBox)e.Item.FindControl("efTxtNewVirtualField");
                efDdlNewVirtualFieldDataType = (DropDownList)e.Item.FindControl("efDdlNewVirtualFieldDataType");
                efCbxNewFieldIsVirtual       = (CheckBox)e.Item.FindControl("efCbxNewFieldIsVirtual");
                efCbxNewFieldSuppress        = (CheckBox)e.Item.FindControl("efCbxNewFieldSuppress");
                efDdlNewFieldOrder           = (DropDownList)e.Item.FindControl("efDdlNewFieldOrder");

                string newFieldName = efTxtNewVirtualField.Text;
                string dataType     = efDdlNewVirtualFieldDataType.SelectedValue;
                fieldSuppress = ((CheckBox)e.Item.Cells[5].Controls[1]).Checked;
                string strFieldOrder = ((DropDownList)e.Item.Cells[6].Controls[1]).SelectedValue;
                fieldOrder = -1;
                try
                {
                    fieldOrder = int.Parse(((DropDownList)e.Item.Cells[6].Controls[1]).SelectedValue);
                }
                catch {};
                if (fieldOrder > -1)
                {
                    fieldId = MNDa.AddMetaField(tableId, newFieldName, dataType, -1, true, fieldSuppress, fieldOrder);
                    MNDa.MetaFieldOrderRenumber(tableId);
                }
                else
                {
                    fieldId = MNDa.AddMetaField(tableId, newFieldName, dataType, -1, true, fieldSuppress);
                }

                // refresh virtual field map
                //Caisis.BOL.BusinessObjectFactory.RebuildVirtualFieldMap();
                Caisis.BOL.BusinessObject.RebuildVirtualFields();

                viewMode = "editTable";
                setViewMode();
                updateEditTableView(tableId, tableName);
                break;

            case "AddNewFieldCancel":
                viewMode = "editTable";
                setViewMode();
                updateEditTableView(tableId, tableName);
                break;
            }
        }