Ejemplo n.º 1
0
 /// <summary>Adds a specified <see cref="InfoOutputParentChildDataTable"/> object, i.e. a parent and child <see cref="DataTable"/> object with a 1:n relation.
 /// </summary>
 /// <param name="value">Homogeneous informations in some <see cref="InfoOutputParentChildDataTable"/> representation.</param>
 /// <exception cref="ArgumentNullException">Thrown, if <paramref name="value"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Thrown, if the table name(s) of <paramref name="value"/> is empty.</exception>
 public void Add(InfoOutputParentChildDataTable value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if ((value.ParentDataTable == null) || (value.ParentDataTable.TableName == null) || (value.ParentDataTable.TableName.Length == 0))
     {
         throw new ArgumentException(String.Format(ExceptionMessages.ArgumentIsNotWellDefined, "Parent DataTable name"), "value");
     }
     m_ParentChildTables.Add(value.ParentDataTable.TableName, value);
 }
Ejemplo n.º 2
0
        /// <summary>Handles the Click event of the bCreateObject control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void bCreateObject_Click(object sender, EventArgs e)
        {
            SimpleDataObject simpleDataObject = new SimpleDataObject();

            InfoOutput infoOutput = new InfoOutput();

            simpleDataObject.FillInfoOutput(infoOutput);

            InfoOutputPackage generalPackage = infoOutput.GetGeneralPackage();

            InfoOutputParentChildDataTable parentChildDataTable = generalPackage.GetParentChildDataTable("ParentTable");

            InitializeDataGridViews(parentChildDataTable);
        }
Ejemplo n.º 3
0
        /// <summary>Initialize the <see cref="DataGridView"/> controls.
        /// </summary>
        /// <param name="data">The data in its <see cref="DataTable"/> representation.</param>
        /// <remarks>There is no such implementation in the Dodoni.net project, because it depends on System.Windows.Forms which should be avoided in the
        /// Dodoni.BasicComponents.</remarks>
        private void InitializeDataGridViews(InfoOutputParentChildDataTable data)
        {
            m_ParentBindingSource.DataSource = data.DataSet;
            m_ParentBindingSource.DataMember = data.ParentDataTable.TableName;

            m_ChildBindingSource.DataSource = m_ParentBindingSource;
            m_ChildBindingSource.DataMember = data.Relation.RelationName;

            dataGridViewParent.DataSource = m_ParentBindingSource;
            dataGridViewParent.Columns[dataGridViewParent.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            dataGridViewChild.DataSource = m_ChildBindingSource;
            dataGridViewChild.Columns[dataGridViewChild.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
        }
Ejemplo n.º 4
0
        /// <summary>Gets informations of the current object as a specific <see cref="InfoOutput"/> instance.
        /// </summary>
        /// <param name="infoOutput">The <see cref="InfoOutput"/> object which is to be filled with informations concering the current instance.</param>
        /// <param name="categoryName">The name of the category, i.e. all informations will be added to these category.</param>
        public void FillInfoOutput(InfoOutput infoOutput, string categoryName = InfoOutput.GeneralCategoryName)
        {
            /* creates two simple data tables: */
            DataTable parentDataTable = new DataTable("ParentTable");

            parentDataTable.Columns.Add("Name", typeof(String));
            DataColumn masterColumn = new DataColumn("ID")
            {
                DataType = typeof(int)
            };

            parentDataTable.Columns.Add(masterColumn);
            masterColumn.ColumnMapping = MappingType.Hidden;


            DataTable childDataTable = new DataTable("ChildTable");

            childDataTable.Columns.Add("Value", typeof(DateTime));
            DataColumn slaveColumn = new DataColumn("ID")
            {
                DataType = typeof(int)
            };

            childDataTable.Columns.Add(slaveColumn);
            slaveColumn.ColumnMapping = MappingType.Hidden;

            /* add some simple data: */
            parentDataTable.Rows.Add("The child should show exactly 2 dates", 4);
            parentDataTable.Rows.Add("Exactly 1 date", 7);

            childDataTable.Rows.Add(new DateTime(2010, 10, 24), 4);
            childDataTable.Rows.Add(new DateTime(2012, 5, 15), 4);

            childDataTable.Rows.Add(new DateTime(1998, 2, 8), 7);

            /* store the parent-child data table in the package: */

            InfoOutputParentChildDataTable parentChildDataTable = new InfoOutputParentChildDataTable(parentDataTable, childDataTable, masterColumn, slaveColumn);

            InfoOutputPackage package = infoOutput.AcquirePackage(categoryName);

            package.Add(parentChildDataTable);
        }
Ejemplo n.º 5
0
 /// <summary>Gets a specific <see cref="InfoOutputParentChildDataTable"/> object, i.e. one parent and one child <see cref="DataTable"/> object,
 /// connected with respect to a specified relation.
 /// </summary>
 /// <param name="parentDataTableName">The name of the parent data table.</param>
 /// <param name="value">The value.</param>
 /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns>
 public bool TryGetParentChildDataTable(string parentDataTableName, out InfoOutputParentChildDataTable value)
 {
     return(m_ParentChildTables.TryGetValue(parentDataTableName, out value));
 }