Esempio n. 1
0
 private void InsertJoinInto(DataTable destTable, DataTable sourceTable,
                             string fieldList, string rowFilter, string sort)
 {
     if (fieldList == null)
     {
         return;
     }
     else
     {
         ParseFieldList(fieldList, true);
         DataRow[] Rows = sourceTable.Select(rowFilter, sort);
         foreach (DataRow SourceRow in Rows)
         {
             DataRow DestRow = destTable.NewRow();
             foreach (FieldInfo Field in m_FieldInfo)
             {
                 if (Field.RelationName == null)
                 {
                     DestRow[Field.FieldName] = SourceRow[Field.FieldName];
                 }
                 else
                 {
                     DataRow ParentRow = SourceRow.GetParentRow(Field.RelationName);
                     DestRow[Field.FieldName] = ParentRow[Field.FieldName];
                 }
             }
             destTable.Rows.Add(DestRow);
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Calling convention:
 ///		dsHelper.InsertJoinInto(ds.Tables["TestTable"], ds.Tables["Employees"],
 ///				"FirstName FName,LastName LName,DepartmentEmployee.DepartmentName Department",
 ///						"EmployeeID &lt; 5", "BirthDate");
 /// </summary>
 public void InsertJoinInto(DataTable DestTable, DataTable SourceTable,
                            string FieldList, string RowFilter, string Sort)
 {
     /*
      * Copies the selected rows and columns from SourceTable and inserts them into DestTable
      * FieldList has same format as CreatejoinTable
      */
     if (FieldList == null)
     {
         throw new ArgumentException("You must specify at least one field in the field list.");
         //InsertInto(DestTable, SourceTable, RowFilter, Sort);
     }
     else
     {
         ParseFieldList(FieldList, true);
         DataRow[] Rows = SourceTable.Select(RowFilter, Sort);
         foreach (DataRow SourceRow in Rows)
         {
             DataRow DestRow = DestTable.NewRow();
             foreach (FieldInfo Field in m_FieldInfo)
             {
                 if (Field.RelationName == null)
                 {
                     DestRow[Field.FieldName] = SourceRow[Field.FieldName];
                 }
                 else
                 {
                     DataRow ParentRow = SourceRow.GetParentRow(Field.RelationName);
                     DestRow[Field.FieldName] = ParentRow[Field.FieldName];
                 }
             }
             DestTable.Rows.Add(DestRow);
         }
     }
 }
Esempio n. 3
0
        /**//// <summary>
        /// 该方法根据给定的字段列表(FieldList)和表名(TableName),创建表结构,并返回表对象
        /// 给定的字段可来自创建了关系的两张表,如果是源表(子表)中的字段,直接写字段名即可。
        /// 如果是关系表(父表)中的字段,
        /// 字段前面须加上关系名称,格式如:relationname.fieldname
        /// FieldList语法:[relationname.]fieldname[ alias][,[relationname.]fieldname[ alias]]
        /// </summary>
        /// <param name="TableName">生成新结构表的表名</param>
        /// <param name="SourceTable">源表名(子表)</param>
        /// <param name="FieldList">生成新结构表的目标字段</param>
        /// <returns>具有目标结构的表对象</returns>
        public DataTable CreateJoinTable(string TableName, DataTable SourceTable, string FieldList)
        {
            if (FieldList == null)
            {
                throw new ArgumentException("You must specify at least one field in the field list.");
            }
            else
            {
                DataTable dt = new DataTable(TableName);
                ParseFieldList(FieldList, true);
                foreach (FieldInfo Field in m_FieldInfo)
                {
                    if (Field.RelationName == null)
                    {
                        DataColumn dc = SourceTable.Columns[Field.FieldName];
                        dt.Columns.Add(dc.ColumnName, dc.DataType, dc.Expression);
                    }
                    else
                    {
                        DataColumn dc = SourceTable.ParentRelations[Field.RelationName].ParentTable.Columns[Field.FieldName];
                        dt.Columns.Add(dc.ColumnName, dc.DataType, dc.Expression);
                    }
                }
                if (ds != null)
                {
                    ds.Tables.Add(dt);
                }
                return(dt);
            }
        }

        /**//// <summary>
        /// 该方法用于关联查询,可以指定条件(RowFilter),以及排序字段(Sort);
        /// 直接将查询结果存储到DestTable表对象中\n
        /// 在FieldList中的字段可以是关系表中的字段,但是它的前面必须加上关系名称,格式如:relationname.fieldname
        /// 用于指定查询条件的字段和用于排序的字段只能是源表中的字段,不能是关系表中的字段
        /// FieldList语法:[relationname.]fieldname[ alias][,[relationname.]fieldname[ alias]]
        /// </summary>
        /// <param name="DestTable">用于存储查询结果的表对象</param>
        /// <param name="SourceTable">源表名(子表)</param>
        /// <param name="FieldList">查询结果的目标字段</param>
        /// <param name="RowFilter">查询条件</param>
        /// <param name="Sort">排序字段</param>
        public void InsertJoinInto(DataTable DestTable, DataTable SourceTable, string FieldList, string RowFilter, string Sort)
        {
            if (FieldList == null)
            {
                throw new ArgumentException("You must specify at least one field in the field list.");
            }
            else
            {
                ParseFieldList(FieldList, true);
                DataRow[] Rows = SourceTable.Select(RowFilter, Sort);
                foreach (DataRow SourceRow in Rows)
                {
                    DataRow DestRow = DestTable.NewRow();
                    foreach (FieldInfo Field in m_FieldInfo)
                    {
                        if (Field.RelationName == null)
                        {
                            DestRow[Field.FieldName] = SourceRow[Field.FieldName];
                        }
                        else
                        {
                            DataRow ParentRow = SourceRow.GetParentRow(Field.RelationName);
                            DestRow[Field.FieldName] = ParentRow[Field.FieldName];
                        }
                    }
                    DestTable.Rows.Add(DestRow);
                }
            }
        }
Esempio n. 4
0
        private DicomDataSet GetDicomDataSet( )
        {
            DicomDataSet ds;

            if (SourceRow.IsDatasetPathNull( ))
            {
                ds = GetEventDataset(( int )SourceRow.EventID);
            }
            else
            {
                ds = new DicomDataSet(  );

                ds.Load(SourceRow.DatasetPath, DicomDataSetLoadFlags.None);
            }

            return(ds);
        }
Esempio n. 5
0
        public void InsertJoinInto(DataTable DestTable, DataTable SourceTable, string FieldList, string RowFilter, string Sort)
        {
            /*
             * Copies the selected rows and columns from SourceTable and inserts them into DestTable
             * FieldList has same format as CreatejoinTable
             */
            if (FieldList == null)
            {
                throw new ArgumentException("You must specify at least one field in the field list.");
                //InsertInto(DestTable, SourceTable, RowFilter, Sort);
            }
            else
            {
                ParseFieldList(FieldList, true);
                DataRow[] Rows = SourceTable.Select(RowFilter, Sort);
                foreach (DataRow SourceRow in Rows)
                {
                    DataRow DestRow = DestTable.NewRow();
                    foreach (FieldInfo Field in m_FieldInfo)
                    {
                        if (Field.RelationName == null)
                        {
                            DestRow[Field.FieldName] = SourceRow[Field.FieldName];
                        }
                        else
                        {
                            // beware of porjects having project category set to 1 because this entry is already removed before joining the tables
                            DataRow[] childsR  = SourceRow.GetChildRows(Field.RelationName);
                            DataRow   ChildRow = SourceRow.GetChildRows(Field.RelationName)[0];
                            DestRow[Field.FieldName] = ChildRow[Field.FieldName];
                        }
                    }

                    //string prjNB = DestRow.Field<string>("projectnb");  DEBUG USE
                    DestTable.Rows.Add(DestRow);
                }
            }
        }