예제 #1
0
        internal override Column CopyTo(Column column)
        {
            if (column.ColumnType == ColumnType.Foreignkey)
            {
                Foreignkey fk = (Foreignkey)base.CopyTo(column);
                fk.m_ForeignkeyTable     = m_ForeignkeyTable;
                fk.m_ConnectionString    = m_ConnectionString;
                fk.m_ConnectionStringSet = m_ConnectionStringSet;
                fk.m_ValueColumn         = m_ValueColumn;

                fk.m_Foreignkeytype      = m_Foreignkeytype;
                fk.m_SelectMenuWidth     = m_SelectMenuWidth;
                fk.m_SelectMenuMaxHeight = m_SelectMenuMaxHeight;

                fk.m_FilterExpression = m_FilterExpression;
                fk.m_TreeParentId     = m_TreeParentId;
                fk.m_SortExpression   = m_SortExpression;

                fk.m_EnableOnlyTreeLeaf     = m_EnableOnlyTreeLeaf;
                fk.m_RecordsPerRow          = m_RecordsPerRow;
                fk.m_TreeStructureSeperator = m_TreeStructureSeperator;
                fk.m_RememberState          = m_RememberState;
                fk.m_identityColumn         = m_identityColumn;
                return(fk);
            }
            return(base.CopyTo(column));
        }
예제 #2
0
        internal override Column Duplicate()
        {
            Foreignkey c = new Foreignkey(ColumnId, m_Table);

            CopyTo(c);
            return(c);
        }
예제 #3
0
        internal override void CopyFrom(Column column)
        {
            base.CopyFrom(column);
            if (column.ColumnType != ColumnType.Foreignkey)
            {
                return;
            }
            Foreignkey fk = (Foreignkey)column;

            m_ForeignkeyTable = fk.m_ForeignkeyTable;

            m_ValueColumn = fk.m_ValueColumn;

            m_ConnectionString       = fk.m_ConnectionString;
            m_ConnectionStringSet    = fk.m_ConnectionStringSet;
            m_Foreignkeytype         = fk.m_Foreignkeytype;
            m_SelectMenuWidth        = fk.m_SelectMenuWidth;
            m_SelectMenuMaxHeight    = fk.m_SelectMenuMaxHeight;
            m_FilterExpression       = fk.m_FilterExpression;
            m_TreeParentId           = fk.m_TreeParentId;
            m_SortExpression         = fk.m_SortExpression;
            m_EnableOnlyTreeLeaf     = fk.m_EnableOnlyTreeLeaf;
            m_RecordsPerRow          = fk.m_RecordsPerRow;
            m_TreeStructureSeperator = fk.m_TreeStructureSeperator;
            m_RememberState          = fk.m_RememberState;
            m_identityColumn         = fk.m_identityColumn;
        }
예제 #4
0
        public void SetDataSourceForeignKeyStringArray()
        {
            Grid mastergrid = new Grid();

            mastergrid.ID = "test";
            mastergrid.Page = Testpage;

            mastergrid.DisplayView = DisplayView.Detail;
            Testpage.Controls.Add(mastergrid);

            Foreignkey column = new Foreignkey("ForeignkeyItems", mastergrid.MasterTable);
            column.NullText = "Select Category";
            column.Required = true;
            mastergrid.MasterTable.Columns.Add(column);

            WebGrid.Data.Table fktable = new WebGrid.Data.Table(mastergrid, true);
            string[] names = new[] { "Tom", "Dick", "Harry", "Thomas", "Anders", "Carl", "Trond", "Eli", "Eva" };
            fktable.DataSource = names;

            ((Foreignkey)mastergrid["ForeignkeyItems"]).Table = fktable;

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            mastergrid.RenderControl(gridwriter);

            Assert.AreEqual(mastergrid.MasterTable.Rows.Count, 1);
            Assert.IsTrue(mastergrid.MasterTable.GotSchema);
            Assert.AreEqual(((Foreignkey)mastergrid["ForeignkeyItems"]).Table.Rows.Count, names.Length);
        }
예제 #5
0
        public void SetDataSourceForeignKeyGetDataForce()
        {
            Grid mastergrid = new Grid();

            mastergrid.ID = "test";
            mastergrid.Page = Testpage;

            mastergrid.DisplayView = DisplayView.Detail;
            Testpage.Controls.Add(mastergrid);

            Foreignkey column = new Foreignkey("ForeignkeyItems", mastergrid.MasterTable);
            column.NullText = "Select Category";
            column.Required = true;
            mastergrid.MasterTable.Columns.Add(column);

            WebGrid.Data.Table fktable = new WebGrid.Data.Table(mastergrid, true);
            StringDictionary tmp = new StringDictionary();

            tmp.Add("Category 1", "1");
            tmp.Add("Category 2", "2");
            tmp.Add("Category 3", "3");
            tmp.Add("Category 4", "4");
            tmp.Add("Category 5", "5");
            tmp.Add("Category 6", "6");
            tmp.Add("Category 7", "7");
            fktable.DataSource = tmp;

            ((Foreignkey)mastergrid["ForeignkeyItems"]).Table = fktable;
            ((Foreignkey)mastergrid["ForeignkeyItems"]).ValueColumn = "Value";
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            mastergrid.RenderControl(gridwriter);

            Assert.AreEqual(mastergrid.MasterTable.Rows.Count, 1);
            Assert.IsTrue(mastergrid.MasterTable.GotSchema);
            Assert.AreEqual(((Foreignkey)mastergrid["ForeignkeyItems"]).Table.Rows.Count, 7);
            ((Foreignkey) mastergrid["ForeignkeyItems"]).Table.FilterExpression = "Value = 3";

            Assert.AreEqual(((Foreignkey)mastergrid["ForeignkeyItems"]).Table.Rows.Count, 1);
        }
예제 #6
0
 internal override Column Duplicate()
 {
     Foreignkey c = new Foreignkey(ColumnId, m_Table);
     CopyTo(c);
     return c;
 }
예제 #7
0
        public void ForeignKeyColumn()
        {
            Grid grid = new Grid();

            Foreignkey column = new Foreignkey("column", grid.MasterTable);
            column.ForeignkeyType = ForeignkeyType.Radiobuttons;
            column.DataSourceId = "Employees";
            column.NullText = "Select Employees";
            column.Required = true;

            Foreignkey column2 = new Foreignkey("column2", grid.MasterTable);
            column2.ForeignkeyType = ForeignkeyType.Select;
            column2.DataSourceId = "Employees";
            column2.NullText = "Select Employees";

            Foreignkey column3 = new Foreignkey("column3", grid.MasterTable);
            column3.ForeignkeyType = ForeignkeyType.Radiobuttons;
            column3.RecordsPerRow = 2;
            column3.DataSourceId = "Employees";
            Foreignkey column4 = new Foreignkey("column4", grid.MasterTable);
            column4.TreeIndentText = "ReportsTo";
            column4.DataSourceId = "Employees";
            Foreignkey column5 = new Foreignkey("column5", grid.MasterTable);
            column5.TreeIndentText = "ReportsTo";
            column5.DataSourceId = "Employees";
            column5.NullText = "Select Employees";

            Foreignkey column6 = new Foreignkey("column6", grid.MasterTable);
            column6.TreeIndentText = "ReportsTo";
            column6.DataSourceId = "Employees";
            column6.FilterExpression = "[Employees].[ReportsTo] IS NOT NULL";
            column6.NullText = "Select Employees";

            Foreignkey column7 = new Foreignkey("column7", grid.MasterTable);
            column7.TreeIndentText = "ReportsTo";
            column7.DataSourceId = "Employees";
            column7.FilterExpression = "[Employees].[ReportsTo] IS NOT NULL";
            column7.NullText = "Select Employees";
            column7.ForeignkeyType = ForeignkeyType.Radiobuttons;

            Foreignkey column8 = new Foreignkey("column8", grid.MasterTable);
            column8.DataSourceId = "Employees";
            column8.FilterExpression = "[Employees].[ReportsTo] IS NOT NULL";
            column8.NullText = "Select Employees";
            column8.ForeignkeyType = ForeignkeyType.Radiobuttons;

            grid.MasterTable.Columns.Add(column);
            grid.MasterTable.Columns.Add(column2);
            grid.MasterTable.Columns.Add(column3);
            grid.MasterTable.Columns.Add(column4);
            grid.MasterTable.Columns.Add(column5);
            grid.MasterTable.Columns.Add(column6);
            grid.MasterTable.Columns.Add(column7);
            grid.MasterTable.Columns.Add(column8);

            SetupGrid(grid);

            grid.DisplayView = DisplayView.Grid;
            grid.DataSourceId = "Employees";
            grid.ConnectionString = ConnectionAccessOleDb;

            // Allowed Content
            grid.MasterTable.Rows[0]["column"].DisplayValue = "";
             grid.MasterTable.Rows[0]["column2"].DisplayValue = "3";
            grid.MasterTable.Rows[0]["column3"].DisplayValue = "3";
             grid.MasterTable.Rows[0]["column4"].DisplayValue = "3";
            grid.MasterTable.Rows[0]["column5"].DisplayValue = "3";
            grid.MasterTable.Rows[0]["column7"].DisplayValue = "3";
            grid.MasterTable.Rows[0]["column8"].DisplayValue = "3";

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.Greater(grid.MasterTable.Rows.Count, 1);
            Assert.LessOrEqual(grid.SystemMessage.Count, 1); // 15-day license key message
            Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
        }
예제 #8
0
 internal static Column GetColumnFromType(string columnName, Table table, ColumnType columnType)
 {
     Column column;
     switch (columnType)
     {
         case ColumnType.Text:
             column = new Text(columnName, table);
             break;
         case ColumnType.Number:
             column = new Number(columnName, table);
             break;
         case ColumnType.Decimal:
             column = new Decimal(columnName, table);
             break;
         case ColumnType.Checkbox:
             column = new Checkbox(columnName, table);
             break;
         case ColumnType.DateTime:
             column = new DateTime(columnName, table);
             break;
         case ColumnType.Foreignkey:
             column = new Foreignkey(columnName, table);
             break;
         case ColumnType.ManyToMany:
             column = new ManyToMany(columnName, table);
             break;
         case ColumnType.GridColumn:
             column = new GridColumn(columnName, table);
             break;
         case ColumnType.Chart:
             column = new Chart(columnName, table);
             break;
         case ColumnType.File:
             column = new File(columnName, table) { IsInDataSource = false };
             break;
         case ColumnType.Image:
             column = new Image(columnName, table) { IsInDataSource = false };
             break;
         case ColumnType.ToolTip:
             column = new ToolTipColumn(columnName, table) { IsInDataSource = false };
             break;
         case ColumnType.SystemColumn:
             column = new SystemColumn(columnName, Enums.SystemColumn.Undefined, table) { IsInDataSource = false };
             break;
         default:
             column = new UnknownColumn(columnName, table);
             break;
     }
     return column;
 }
예제 #9
0
        public void ForeignKeyColumn()
        {
            Grid grid = new Grid();

            Foreignkey column = new Foreignkey("column", grid.MasterTable);

            column.ForeignkeyType = ForeignkeyType.Radiobuttons;
            column.DataSourceId   = "Employees";
            column.NullText       = "Select Employees";
            column.Required       = true;

            Foreignkey column2 = new Foreignkey("column2", grid.MasterTable);

            column2.ForeignkeyType = ForeignkeyType.Select;
            column2.DataSourceId   = "Employees";
            column2.NullText       = "Select Employees";

            Foreignkey column3 = new Foreignkey("column3", grid.MasterTable);

            column3.ForeignkeyType = ForeignkeyType.Radiobuttons;
            column3.RecordsPerRow  = 2;
            column3.DataSourceId   = "Employees";
            Foreignkey column4 = new Foreignkey("column4", grid.MasterTable);

            column4.TreeIndentText = "ReportsTo";
            column4.DataSourceId   = "Employees";
            Foreignkey column5 = new Foreignkey("column5", grid.MasterTable);

            column5.TreeIndentText = "ReportsTo";
            column5.DataSourceId   = "Employees";
            column5.NullText       = "Select Employees";

            Foreignkey column6 = new Foreignkey("column6", grid.MasterTable);

            column6.TreeIndentText   = "ReportsTo";
            column6.DataSourceId     = "Employees";
            column6.FilterExpression = "[Employees].[ReportsTo] IS NOT NULL";
            column6.NullText         = "Select Employees";

            Foreignkey column7 = new Foreignkey("column7", grid.MasterTable);

            column7.TreeIndentText   = "ReportsTo";
            column7.DataSourceId     = "Employees";
            column7.FilterExpression = "[Employees].[ReportsTo] IS NOT NULL";
            column7.NullText         = "Select Employees";
            column7.ForeignkeyType   = ForeignkeyType.Radiobuttons;

            Foreignkey column8 = new Foreignkey("column8", grid.MasterTable);

            column8.DataSourceId     = "Employees";
            column8.FilterExpression = "[Employees].[ReportsTo] IS NOT NULL";
            column8.NullText         = "Select Employees";
            column8.ForeignkeyType   = ForeignkeyType.Radiobuttons;

            grid.MasterTable.Columns.Add(column);
            grid.MasterTable.Columns.Add(column2);
            grid.MasterTable.Columns.Add(column3);
            grid.MasterTable.Columns.Add(column4);
            grid.MasterTable.Columns.Add(column5);
            grid.MasterTable.Columns.Add(column6);
            grid.MasterTable.Columns.Add(column7);
            grid.MasterTable.Columns.Add(column8);

            SetupGrid(grid);

            grid.DisplayView      = DisplayView.Grid;
            grid.DataSourceId     = "Employees";
            grid.ConnectionString = ConnectionAccessOleDb;

            // Allowed Content
            grid.MasterTable.Rows[0]["column"].DisplayValue  = "";
            grid.MasterTable.Rows[0]["column2"].DisplayValue = "3";
            grid.MasterTable.Rows[0]["column3"].DisplayValue = "3";
            grid.MasterTable.Rows[0]["column4"].DisplayValue = "3";
            grid.MasterTable.Rows[0]["column5"].DisplayValue = "3";
            grid.MasterTable.Rows[0]["column7"].DisplayValue = "3";
            grid.MasterTable.Rows[0]["column8"].DisplayValue = "3";

            StringBuilder  sb         = new StringBuilder();
            StringWriter   sw         = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);

            grid.RenderControl(gridwriter);
            Assert.Greater(grid.MasterTable.Rows.Count, 1);
            Assert.LessOrEqual(grid.SystemMessage.Count, 1); // 15-day license key message
            Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
        }