Example #1
0
        void FilterColumns(DataRow CustomObj)
        {
            string    filtertable = "(name='dbo." + CustomObj["objectname"].ToString() + "')";
            DataTable ComboT      = (DataTable)comboCol.DataSource;
            string    CurrColName = DS.Tables["viewcolumn"].Rows[0]["colname"].ToString();

            DataRow [] All = ComboT.Select("field<>''");
            foreach (DataRow Col in All)
            {
                string filterfield       = "(column='" + Col["field"].ToString() + "')";
                string filter            = filtertable + "AND" + filterfield;
                string excludeclassified = "(colname<>'" + CurrColName + "')AND" +
                                           "(realtable='" + Col["tablename"].ToString() + "')AND" +
                                           "(realcolumn='" + Col["field"].ToString() + "')";
                if (SourceTable.Select(excludeclassified).Length > 0)
                {
                    Col.Delete();
                    continue;
                }

                //esclude le chiavi delle tabelle secondarie
                if (comboTab.SelectedValue.ToString() != MainTable)
                {
                    if (Col["iskey"].ToString().ToUpper() == "S")
                    {
                        Col.Delete();
                        continue;
                    }
                }

                if (AllowedColumns.Select(filter).Length > 0)
                {
                    continue;
                }
                Col.Delete();
            }
            DS.columntypes.AcceptChanges();
        }