예제 #1
0
        public void Clear()
        {
            DataTable Table  = new DataTable("test_table");
            DataTable Table2 = new DataTable("test_table2");
            DataSet   Set    = new DataSet();

            Set.Tables.Add(Table);
            Set.Tables.Add(Table2);
            DataColumnCollection Cols  = Table.Columns;
            DataColumnCollection Cols2 = Table2.Columns;

            Cols.Add();
            Cols.Add("testi");

            Cols.Clear();
            Assert.AreEqual(0, Cols.Count, "test#01");

            Cols.Add();
            Cols.Add("testi");
            Cols2.Add();
            Cols2.Add();

            DataRelation Rel = new DataRelation("Rel", Cols [0], Cols2 [0]);

            Set.Relations.Add(Rel);
            try {
                Cols.Clear();
                Assert.Fail("test#02");
            } catch (Exception e) {
                Assert.AreEqual(typeof(ArgumentException), e.GetType(), "test#03");
                // Never premise English.
                //Assert.AreEqual ("Cannot remove this column, because it is part of the parent key for relationship Rel.", e.Message, "test#04");
            }
        }
예제 #2
0
        public void Clear()
        {
            DataTable table  = new DataTable("test_table");
            DataTable table2 = new DataTable("test_table2");
            DataSet   set    = new DataSet();

            set.Tables.Add(table);
            set.Tables.Add(table2);
            DataColumnCollection cols  = table.Columns;
            DataColumnCollection cols2 = table2.Columns;

            cols.Add();
            cols.Add("testi");

            cols.Clear();
            Assert.Equal(0, cols.Count);

            cols.Add();
            cols.Add("testi");
            cols2.Add();
            cols2.Add();

            DataRelation rel = new DataRelation("Rel", cols[0], cols2[0]);

            set.Relations.Add(rel);
            // Cannot remove this column, because it is part of the parent key for relationship Rel.
            Assert.Throws <ArgumentException>(() => cols.Clear());
        }
예제 #3
0
        [Fact] // Add (String)
        public void Add3_ColumnName_Null()
        {
            DataTable            table = new DataTable();
            DataColumnCollection cols  = table.Columns;
            DataColumn           col;

            col = cols.Add((string)null);
            Assert.Equal(1, cols.Count);
            Assert.Equal("Column1", col.ColumnName);
            Assert.Same(table, col.Table);

            col = cols.Add((string)null);
            Assert.Equal(2, cols.Count);
            Assert.Equal("Column2", col.ColumnName);
            Assert.Same(table, col.Table);

            cols.RemoveAt(1);

            col = cols.Add((string)null);
            Assert.Equal(2, cols.Count);
            Assert.Equal("Column2", col.ColumnName);
            Assert.Same(table, col.Table);

            cols.Clear();

            col = cols.Add((string)null);
            Assert.Equal(1, cols.Count);
            Assert.Equal("Column1", col.ColumnName);
            Assert.Same(table, col.Table);
        }
예제 #4
0
        [Test]         // Add (String)
        public void Add3_ColumnName_Null()
        {
            DataTable            table = new DataTable();
            DataColumnCollection cols  = table.Columns;
            DataColumn           col;

            col = cols.Add((string)null);
            Assert.AreEqual(1, cols.Count, "#A1");
            Assert.AreEqual("Column1", col.ColumnName, "#A2");
            Assert.AreSame(table, col.Table, "#A3");

            col = cols.Add((string)null);
            Assert.AreEqual(2, cols.Count, "#B1");
            Assert.AreEqual("Column2", col.ColumnName, "#B2");
            Assert.AreSame(table, col.Table, "#B3");

            cols.RemoveAt(1);

            col = cols.Add((string)null);
            Assert.AreEqual(2, cols.Count, "#C1");
            Assert.AreEqual("Column2", col.ColumnName, "#C2");
            Assert.AreSame(table, col.Table, "#C3");

            cols.Clear();

            col = cols.Add((string)null);
            Assert.AreEqual(1, cols.Count, "#D1");
            Assert.AreEqual("Column1", col.ColumnName, "#D2");
            Assert.AreSame(table, col.Table, "#D3");
        }
예제 #5
0
        private void tab1a12_Enter(object sender, EventArgs e)
        {
            ds = new DataSet();

            RemplirTable("Transaction");
            source.DataSource = ds.Tables["Transaction"];
            RemplirTable("TypeTransaction");
            RemplirTable("Beneficiaires");
            RemplirTable("Personne");

            cboDateTransac.DataBindings.Clear();
            cboDateTransac.DataBindings.Add(new Binding("Text", source, "DateTransaction"));
            lblCodeType.DataBindings.Clear();
            lblCodeType.DataBindings.Add(new Binding("Text", source, "codeTransaction"));
            lblDescri.DataBindings.Clear();
            lblDescri.DataBindings.Add(new Binding("Text", source, "description"));
            lblCout.DataBindings.Clear();
            lblCout.DataBindings.Add(new Binding("Text", source, "montant"));
            cboxPercue.DataBindings.Clear();
            cboxPercue.DataBindings.Add(new Binding("Checked", source, "recetteON"));
            cboxRecette.DataBindings.Clear();
            cboxRecette.DataBindings.Add(new Binding("Checked", source, "percuON"));

            source.CurrentItemChanged += Source_CurrentItemChanged;
            Source_CurrentItemChanged(null, null);

            dtgSupprimer.DataSource = dt;
            dtgModif.DataSource     = dt;


            DataColumnCollection cols = searchTable.Columns;

            cols.Clear();
            cols.Add("Identifiant", typeof(int));
            cols.Add("Date", typeof(DateTime));
            cols.Add("Libellé", typeof(string));
            cols.Add("Montant", typeof(double));
            cols.Add("Recette", typeof(bool));
            cols.Add("Perçu", typeof(bool));
            cols.Add("Type", typeof(int));

            dgvRecap.DataSource = searchTable;

            btnRecapRaz_Click(null, null);

            ds.Tables["Transaction"].RowChanged += FrmAppli_RowChanged;
        }
예제 #6
0
        public static bool InitTableSchemaFromDataRule(DataTable table, DataRule dr, string alias)
        {
            if (table == null || dr == null)
            {
                return(false);
            }

            try
            {
                DataTable ruletable = dr.GetFieldRule();
                if (ruletable == null)
                {
                    return(false);
                }

                DataRule olddr = TableUtil.GetDataRule(table);
                if (olddr != null)
                {
                    table.TableNewRow   -= new DataTableNewRowEventHandler(olddr.OnTableNewRow);
                    table.ColumnChanged -= new DataColumnChangeEventHandler(olddr.OnColumnChanged);
                }

                table.TableNewRow   += new DataTableNewRowEventHandler(dr.OnTableNewRow);
                table.ColumnChanged += new DataColumnChangeEventHandler(dr.OnColumnChanged);

                table.TableName = dr.RuleName;

                TableUtil.SetProperty(table, SysConstant.scDataRule, dr);
                TableUtil.SetProperty(table, SysConstant.scBindAlias, alias);
                TableUtil.SetProperty(table, SysConstant.scPageManager, new PageManager(table));

                DataColumnCollection columns = table.Columns;
                DataColumn           column;
                RuleColumn           rulecolumn;

                DataRowCollection rows = ruletable.Rows;

                if (columns.Count > 0)
                {
                    if (table.Rows.Count > 0)
                    {
                        table.Rows.Clear();
                    }

                    columns.Clear();
                }

                for (int i = 0; i < rows.Count; i++)
                {
                    rulecolumn = RuleColumn.FromDataRow(rows[i]);

                    column = new DataColumn(rulecolumn.ColumnName);

                    TableUtil.SetProperty(column, SysConstant.scRuleColumn, rulecolumn);

                    column.Caption = rulecolumn.Label;

                    column.DataType = DataTypes.ToType(rulecolumn.DataType);

                    if (rulecolumn.DataType == DataTypes.dtString)
                    {
                        column.MaxLength = rulecolumn.Size;
                    }

                    if (rulecolumn.HasDefValue)
                    {
                        column.AllowDBNull = rulecolumn.IsNullable;
                    }

                    columns.Add(column);
                }
                return(true);
            }
            catch (Exception e)
            {
                throw new Exception("SDP-ST02 填充元数据出错:" + e.Message);
            }
        }
 public void Clear()
 {
     _columns.Clear();
 }
예제 #8
0
 /// <summary>
 /// This sub removes all columns from the collection.
 /// </summary>
 public void Clear()
 {
     m_Columns.Clear();
 }
예제 #9
0
 /// <summary>
 /// Clears the collection of any columns.
 /// </summary>
 public void Clear()
 {
     _dataColumnCollection.Clear();
 }