コード例 #1
0
ファイル: GUtility.cs プロジェクト: Wooyme/HIS-1
        // 将 DataReader 的数据转储到 Grid++Report 的数据集中
        public static void FillRecordToReport(IGridppReport Report, IDataReader dr)
        {
            MatchFieldPairType[] MatchFieldPairs = new MatchFieldPairType[Math.Min(Report.DetailGrid.Recordset.Fields.Count, dr.FieldCount)];
            //根据字段名称与列名称进行匹配,建立DataReader字段与Grid++Report记录集的字段之间的对应关系
            int MatchFieldCount = 0;

            for (int i = 0; i < dr.FieldCount; ++i)
            {
                foreach (IGRField fld in Report.DetailGrid.Recordset.Fields)
                {
                    if (String.Compare(fld.RunningDBField, dr.GetName(i), true) == 0)
                    {
                        MatchFieldPairs[MatchFieldCount].grField          = fld;
                        MatchFieldPairs[MatchFieldCount].MatchColumnIndex = i;
                        ++MatchFieldCount;
                        break;
                    }
                }
            }
            // Loop through the contents of the OleDbDataReader object.
            // 将 DataReader 中的每一条记录转储到Grid++Report 的数据集中去
            while (dr.Read())
            {
                Report.DetailGrid.Recordset.Append();
                for (int i = 0; i < MatchFieldCount; ++i)
                {
                    if (!dr.IsDBNull(MatchFieldPairs[i].MatchColumnIndex))
                    {
                        MatchFieldPairs[i].grField.Value = dr.GetValue(MatchFieldPairs[i].MatchColumnIndex);
                    }
                }
                Report.DetailGrid.Recordset.Post();
            }
        }
コード例 #2
0
        /// <summary>
        /// 将 DataTable 的数据转储到 Grid++Report 的数据集中
        /// </summary>
        /// <param name="Report"></param>
        /// <param name="dt"></param>
        public static void FillRecordToReport(IGridppReport Report, DataTable dt)
        {
            MatchFieldPairType[] MatchFieldPairs = new MatchFieldPairType[Math.Min(Report.DetailGrid.Recordset.Fields.Count, dt.Columns.Count)];

            //根据字段名称与列名称进行匹配,建立DataReader字段与Grid++Report记录集的字段之间的对应关系
            int MatchFieldCount = 0;
            for (int i = 0; i < dt.Columns.Count; ++i)
            {
                foreach (IGRField fld in Report.DetailGrid.Recordset.Fields)
                {
                    if (String.Compare(fld.Name, dt.Columns[i].ColumnName, true) == 0)
                    {
                        MatchFieldPairs[MatchFieldCount].grField = fld;
                        MatchFieldPairs[MatchFieldCount].MatchColumnIndex = i;
                        ++MatchFieldCount;
                        break;
                    }
                }
            }

            // 将 DataTable 中的每一条记录转储到 Grid++Report 的数据集中去
            foreach (DataRow dr in dt.Rows)
            {
                Report.DetailGrid.Recordset.Append();

                for (int i = 0; i < MatchFieldCount; ++i)
                {
                    if (!dr.IsNull(MatchFieldPairs[i].MatchColumnIndex))
                        MatchFieldPairs[i].grField.Value = dr[MatchFieldPairs[i].MatchColumnIndex];
                }

                Report.DetailGrid.Recordset.Post();
            }
        }
コード例 #3
0
        /// <summary>
        /// 将 DataReader 的数据转储到 Grid++Report 的数据集中
        /// </summary>
        /// <param name="Report"></param>
        /// <param name="dr"></param>
        public static void FillRecordToReport(IGridppReport Report, IDataReader dr)
        {
            MatchFieldPairType[] MatchFieldPairs = new MatchFieldPairType[Math.Min(Report.DetailGrid.Recordset.Fields.Count, dr.FieldCount)];

            //根据字段名称与列名称进行匹配,建立DataReader字段与Grid++Report记录集的字段之间的对应关系
            int MatchFieldCount = 0;
            for (int i = 0; i < dr.FieldCount; ++i)
            {
                foreach (IGRField fld in Report.DetailGrid.Recordset.Fields)
                {
                    if (String.Compare(fld.RunningDBField, dr.GetName(i), true) == 0)
                    {
                        MatchFieldPairs[MatchFieldCount].grField = fld;
                        MatchFieldPairs[MatchFieldCount].MatchColumnIndex = i;
                        ++MatchFieldCount;
                        break;
                    }
                }
            }

            // Loop through the contents of the OleDbDataReader object.
            // 将 DataReader 中的每一条记录转储到Grid++Report 的数据集中去
            while (dr.Read())
            {
                Report.DetailGrid.Recordset.Append();

                for (int i = 0; i < MatchFieldCount; ++i)
                {
                    if (!dr.IsDBNull(MatchFieldPairs[i].MatchColumnIndex))
                        MatchFieldPairs[i].grField.Value = dr.GetValue(MatchFieldPairs[i].MatchColumnIndex);
                }

                Report.DetailGrid.Recordset.Post();
            }
        }
コード例 #4
0
 public static void FillParameterToReport(IGridppReport Report, Dictionary<string, string> parameters)
 {
     if (parameters == null) return;
     foreach (KeyValuePair<string, string> val in parameters)
     {
         if (Report.Parameters.IndexByName(val.Key) != -1)
         {
             Report.ParameterByName(val.Key).AsString = val.Value;
         }
     }
 }
コード例 #5
0
 public static void FillParameterToReport(IGridppReport Report, Dictionary <string, string> parameters)
 {
     if (parameters == null)
     {
         return;
     }
     foreach (KeyValuePair <string, string> val in parameters)
     {
         if (Report.Parameters.IndexByName(val.Key) != -1)
         {
             Report.ParameterByName(val.Key).AsString = val.Value;
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// 将 DataTable 的数据转储到 Grid++Report 的数据集中
        /// </summary>
        /// <param name="Report">报表对象</param>
        /// <param name="dt">DataTable对象</param>
        public void FillRecordToReport(IGridppReport report, DataTable dt)
        {
            MatchFieldPairType[] MatchFieldPairs = new MatchFieldPairType[Math.Min(report.DetailGrid.Recordset.Fields.Count, dt.Columns.Count)];
            try
            {
                //根据字段名称与列名称进行匹配,建立DataReader字段与Grid++Report记录集的字段之间的对应关系
                int MatchFieldCount = 0;
                for (int i = 0; i < dt.Columns.Count; ++i)
                {
                    foreach (IGRField fld in report.DetailGrid.Recordset.Fields)
                    {
                        if (string.Compare(fld.Name, dt.Columns[i].ColumnName, true) == 0)
                        {
                            MatchFieldPairs[MatchFieldCount].grField          = fld;
                            MatchFieldPairs[MatchFieldCount].MatchColumnIndex = i;
                            ++MatchFieldCount;
                            break;
                        }
                    }
                }

                // 将 DataTable 中的每一条记录转储到 Grid++Report 的数据集中去
                foreach (DataRow dr in dt.Rows)
                {
                    report.DetailGrid.Recordset.Append();
                    for (int i = 0; i < MatchFieldCount; ++i)
                    {
                        var columnIndex = MatchFieldPairs[i].MatchColumnIndex;
                        if (!dr.IsNull(columnIndex))
                        {
                            MatchFieldPairs[i].grField.Value = dr[columnIndex];
                        }
                    }
                    report.DetailGrid.Recordset.Post();
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                MatchFieldPairs = null;
                dt     = null;
                report = null;
            }
        }
コード例 #7
0
        /// <summary>
        /// 将 字典数据转储到 Grid++Report 的参数中
        /// </summary>
        /// <param name="Report"></param>
        /// <param name="obj"></param>
        public static void AddParamToReport(IGridppReport Report, Dictionary <string, Object> dic)
        {
            //int obj_propertyNum = dic.Count;
            int    rpt_parmNum = Report.Parameters.Count;
            string propertyName, parmName;

            foreach (var item in dic)
            {
                for (int j = 1; j <= rpt_parmNum; j++)
                {
                    propertyName = item.Key;
                    parmName     = Report.Parameters[j].Name;
                    if (propertyName == parmName)
                    {
                        Report.Parameters[j].Value = item.Value;
                    }
                }
            }
        }
コード例 #8
0
        public static void FillRecordToReport(IGridppReport Report, DataTable dt)
        {
            if (dt == null)
            {
                return;
            }
            MatchFieldPairType[] MatchFieldPairs = new MatchFieldPairType[Math.Min(Report.DetailGrid.Recordset.Fields.Count, dt.Columns.Count)];

            //根据字段名称与列名称进行匹配,建立DataReader字段与Grid++Report记录集的字段之间的对应关系
            int MatchFieldCount = 0;

            for (int i = 0; i < dt.Columns.Count; ++i)
            {
                foreach (IGRField fld in Report.DetailGrid.Recordset.Fields)
                {
                    if (String.Compare(fld.Name, dt.Columns[i].ColumnName, true) == 0)
                    {
                        MatchFieldPairs[MatchFieldCount].grField          = fld;
                        MatchFieldPairs[MatchFieldCount].MatchColumnIndex = i;
                        ++MatchFieldCount;
                        break;
                    }
                }
            }


            // 将 DataTable 中的每一条记录转储到 Grid++Report 的数据集中去
            foreach (DataRow dr in dt.Rows)
            {
                Report.DetailGrid.Recordset.Append();

                for (int i = 0; i < MatchFieldCount; ++i)
                {
                    if (!dr.IsNull(MatchFieldPairs[i].MatchColumnIndex))
                    {
                        MatchFieldPairs[i].grField.Value = dr[MatchFieldPairs[i].MatchColumnIndex];
                    }
                }

                Report.DetailGrid.Recordset.Post();
            }
        }
コード例 #9
0
        /// <summary>
        /// List加载数据集
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Report">报表对象</param>
        /// <param name="list">列表数据</param>
        public static void FillRecordToReport <T>(IGridppReport Report, List <T> list)
        {
            Type type = typeof(T);  //反射类型

            MatchFieldPairType[] MatchFieldPairs = new MatchFieldPairType[Math.Min(Report.DetailGrid.Recordset.Fields.Count, type.GetProperties().Length)];

            //根据字段名称与列名称进行匹配,建立字段与Grid++Report记录集的字段之间的对应关系
            int MatchFieldCount = 0;
            int i = 0;

            MemberInfo[] members = type.GetMembers();
            foreach (MemberInfo memberInfo in members)
            {
                foreach (IGRField fld in Report.DetailGrid.Recordset.Fields)
                {
                    if (string.Compare(fld.Name, memberInfo.Name, true) == 0)
                    {
                        MatchFieldPairs[MatchFieldCount].grField          = fld;
                        MatchFieldPairs[MatchFieldCount].MatchColumnIndex = i;
                        ++MatchFieldCount;
                        break;
                    }
                }
                ++i;
            }

            // 将 DataTable 中的每一条记录转储到 Grid++Report 的数据集中去
            foreach (T t in list)
            {
                Report.DetailGrid.Recordset.Append();
                for (i = 0; i < MatchFieldCount; ++i)
                {
                    object objValue = GetPropertyValue(t, MatchFieldPairs[i].grField.Name);
                    if (objValue != null)
                    {
                        MatchFieldPairs[i].grField.Value = objValue;
                    }
                }
                Report.DetailGrid.Recordset.Post();
            }
        }
コード例 #10
0
        /// <summary>
        /// 将 对象 的属性数据转储到 Grid++Report 的参数中
        /// </summary>
        /// <param name="Report"></param>
        /// <param name="obj"></param>
        public static void AddParamToReport(IGridppReport Report, Object obj)
        {
            int    obj_propertyNum = obj.GetType().GetProperties().Length;
            int    rpt_parmNum = Report.Parameters.Count;
            string propertyName, parmName;

            for (int i = 0; i < obj_propertyNum; i++)
            {
                for (int j = 1; j <= rpt_parmNum; j++)
                {
                    propertyName = obj.GetType().GetProperties()[i].Name;
                    parmName     = Report.Parameters[j].Name;

                    if (propertyName == parmName)
                    {
                        object obj1 = obj.GetType().GetProperties()[i].GetValue(obj, null);
                        Report.Parameters[j].Value = obj1;
                    }
                }
            }
        }