Beispiel #1
0
        private void ReloadData()
        {
            //先判断_curBizData中是否含有Dictionary和DataRow类型的数据,如果有,则直接提取到_curBizData中

            foreach (KeyValuePair <string, object> kvSource in _curBizData)
            {
                Dictionary <string, object> dicData = kvSource.Value as Dictionary <string, object>;

                if (dicData != null)
                {
                    foreach (KeyValuePair <string, object> kv in dicData)
                    {
                        if (_curBizData.ContainsKey(kv.Key))
                        {
                            continue;
                        }
                        _curBizData.Add(kv.Key, kv.Value);
                    }
                }

                DataRow dr = kvSource.Value as DataRow;

                if (dr != null)
                {
                    foreach (DataColumn dc in dr.Table.Columns)
                    {
                        if (_curBizData.ContainsKey(dc.ColumnName))
                        {
                            continue;
                        }
                        _curBizData.Add(dc.ColumnName, dr[dc]);
                    }
                }
            }

            //如果配置了查询,则先重查询中获取数据
            if (string.IsNullOrEmpty(_summaryDesign.DBSource.查询语句) == false)
            {
                DataTable dtInfo = SqlHelper.GetDataSource(_summaryDesign.DBSource.查询语句, _summaryDesign.DBSource.数据源别名, _dbQuery, QueryParValueEvent);

                if (dtInfo != null && dtInfo.Rows.Count > 0)
                {
                    foreach (DataColumn dc in dtInfo.Columns)
                    {
                        if (_curBizData.ContainsKey(dc.ColumnName))
                        {
                            _curBizData[dc.ColumnName] = dtInfo.Rows[0][dc];
                        }
                        else
                        {
                            _curBizData.Add(dc.ColumnName, dtInfo.Rows[0][dc]);
                        }
                    }
                }
            }


            ReloadDictionary(_curBizData as Dictionary <string, object>);
        }
        private void ReloadData()
        {
            //先判断_curBizData中是否含有Dictionary和DataRow类型的数据,如果有,则直接提取到_curBizData中

            foreach (KeyValuePair <string, object> kvSource in _curBizData)
            {
                Dictionary <string, object> dicData = kvSource.Value as Dictionary <string, object>;

                if (dicData != null)
                {
                    foreach (KeyValuePair <string, object> kv in dicData)
                    {
                        if (_curBizData.ContainsKey(kv.Key))
                        {
                            continue;
                        }
                        _curBizData.Add(kv.Key, kv.Value);
                    }
                }

                DataRow dr = kvSource.Value as DataRow;

                if (dr != null)
                {
                    foreach (DataColumn dc in dr.Table.Columns)
                    {
                        if (_curBizData.ContainsKey(dc.ColumnName))
                        {
                            continue;
                        }
                        _curBizData.Add(dc.ColumnName, dr[dc]);
                    }
                }
            }

            //如果配置了查询,则先重查询中获取数据
            if (string.IsNullOrEmpty(_infoDesign.查询语句) == false)
            {
                DataTable dtInfo = SqlHelper.GetDataSource(_infoDesign.查询语句, _infoDesign.数据源别名, _dbQuery, QueryParValueEvent);

                if (dtInfo != null && dtInfo.Rows.Count > 0)
                {
                    foreach (DataColumn dc in dtInfo.Columns)
                    {
                        if (_curBizData.ContainsKey(dc.ColumnName))
                        {
                            _curBizData[dc.ColumnName] = dtInfo.Rows[0][dc];
                        }
                        else
                        {
                            _curBizData.Add(dc.ColumnName, dtInfo.Rows[0][dc]);
                        }
                    }
                }
            }

            int    strSize          = 18;
            string strFormatContext = @"{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fcharset134 \'cb\'ce\'cc\'e5;}}" +
                                      @"{\colortbl ;\red255\green104\blue104;\red19\green164\blue160;}" +
                                      @"{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\sl276\slmult1\lang2052\b\f0\fs" + strSize + " ";

            if (string.IsNullOrEmpty(_infoDesign.显示项目) == false)
            {
                foreach (string dItem in _infoDesign.显示项目.Split(','))
                {
                    if (string.IsNullOrEmpty(dItem))
                    {
                        continue;
                    }

                    if (_curBizData.ContainsKey(dItem))
                    {
                        string dataContext = SqlHelper.Nvl(_curBizData[dItem], "").Replace("\n", @" \par\cf0\fs" + strSize + " ");

                        strFormatContext = strFormatContext + @"\b\cf0\fs" + strSize + " " + dItem + ":" + @" \b0\cf0\fs" + strSize + " " + dataContext + @"\par";
                    }
                    else
                    {
                        strFormatContext = strFormatContext + @"\b\cf0\fs" + strSize + " " + dItem + ":" + @" \b0\cf0\fs" + strSize + " " + @"\par";
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <string, object> item in _curBizData)
                {
                    string dataContext = SqlHelper.Nvl(item.Value, "").Replace("\n", @" \par\cf0\fs" + strSize + " ");

                    strFormatContext = strFormatContext + @"\b\cf0\fs" + strSize + " " + item.Key + ":" + @" \b0\cf0\fs" + strSize + " " + dataContext + @"\par";
                }
            }


            richTextBox1.Rtf        = strFormatContext;
            richTextBox1.ZoomFactor = _ic.ZoomFactor;
        }