Example #1
0
        /// <summary>
        /// 列标题添加
        /// </summary>
        /// <param name="itemChild">子项</param>
        /// <param name="itemProperty">内部名称</param>
        /// <param name="addXiaoJi">是否开始添加小计</param>
        /// <param name="isRowFinish">是否完成</param>
        void ColumnTittleInit(TJGridView datagrrd, TongJiItemChild itemChild, string itemProperty, bool addXiaoJi, bool isColumnFinish)
        {
            try
            {
                //去除小计
                if (itemChild.PropertyList.Contains("小计"))
                {
                    itemChild.PropertyList.Remove("小计");
                }

                if (itemChild.DicPropertyCaml != null && columnItemTagList.Contains(itemChild.ParentPropertyName))
                {
                    //标题内容
                    List <string> titleSum = new List <string>();

                    //映射数
                    itemChild.IntIndenttitys.Clear();

                    //遍历进行行标题的添加
                    for (int p = 0; p < itemChild.DicPropertyCaml.Count; p++)
                    {
                        if (itemChild.DicPropertyCaml.Values.ElementAt(p).Contains("小计"))
                        {
                            itemChild.DicPropertyCaml.Values.ElementAt(p).Remove("小计");
                        }
                        //加一个映射点
                        itemChild.IntIndenttitys.Add(itemChild.DicPropertyCaml.Values.ElementAt(p).Count);

                        if (addXiaoJi && _IsNeedXiaoJi)
                        {
                            itemChild.DicPropertyCaml.Values.ElementAt(p).Add("小计");
                            itemChild.IntIndenttitys[p]++;
                        }
                        //添加标题
                        titleSum.AddRange(itemChild.DicPropertyCaml.Values.ElementAt(p));
                    }
                    //通过列表名称获取其标题内容
                    datagrrd._ColumnHeaderAdd(titleSum, itemChild.IntIndenttitys, isColumnFinish);
                }
                else
                {
                    if (addXiaoJi && _IsNeedXiaoJi)
                    {
                        itemChild.PropertyList.Add("小计");
                    }
                    datagrrd._ColumnHeaderAdd(itemChild.PropertyList, isColumnFinish);
                }
                columnItemTagList.Add(itemProperty);
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "TongJi", ex.ToString(), itemChild, itemProperty, addXiaoJi, isColumnFinish);
            }
        }
Example #2
0
        /// <summary>
        /// 通过指定条件获取单元格数据
        /// </summary>
        /// <param name="striTittleList"></param>
        /// <returns></returns>
        public object[] GetData(TJGridView dataGridd, Dictionary <int, object[]> dicData)
        {
            object[] data = new object[dataGridd.dataGrid.Columns.Count];
            try
            {
                for (int i = 0; i < dicData[0].Count(); i++)
                {
                    int count1 = 0;
                    int count2 = 0;

                    int.TryParse(Convert.ToString(dicData[0][i]), out count1);

                    int.TryParse(Convert.ToString(dicData[1][i]), out count2);

                    data[i] = count2 - count1;
                }
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "TongJi", ex.ToString(), dicData);
            }
            return(data);
        }
Example #3
0
        /// <summary>
        /// 显示加载提示(开始生成表格)
        /// </summary>
        void TitleInit(TJGridView dataGrid, StackPanel stack1, StackPanel stack2, ComSearch comSearch)
        {
            try
            {
                _comSearch = comSearch;

                rowItemTagList.Clear();
                columnItemTagList.Clear();

                //单元格数据
                List <int> intlist = new List <int>();

                DataTable dt = null;
                if (dt == null && _comSearch != null)
                //获取指定时间的数据
                {
                    //高级查询条件
                    var ss = _comSearch.GetHuanBiShuJu();

                    //已完成
                    ss.Add("IsFinish", "是,#Text#Eq");

                    //获取Dtatable
                    dt = DataOperation.ClientGetDic(Proxy.ListName, ss, ref _dicList);
                }

                #region 生成行标题

                //是否结束
                bool isRowFinish = false;
                //是否开始添加小计
                bool rowaddXiaoJi = false;

                int stackPanelRowCount = 0;

                stackPanelRowCount = stack1.Children.Count;

                //生成行标题
                for (int i = 0; i < stackPanelRowCount; i++)
                {
                    //获取item对象
                    var item = stack1.Children[i] as TongJiItem;

                    //执行最后一次标记完成
                    if (i == stackPanelRowCount - 1)
                    {
                        isRowFinish = true;
                    }
                    //是否开始添加小计
                    if (i == stackPanelRowCount - 1 && stackPanelRowCount > 1)
                    {
                        rowaddXiaoJi = true;
                    }

                    //月份统计
                    if (item.Tittle.Equals("月份"))
                    {
                        this.MonthDealWidth(item);
                        RowTittleInit(dataGrid, item.ItemChild, item.StrProperty, false, false);

                        //是否开始添加小计
                        if (i == stackPanelRowCount - 1 && stackPanelRowCount > 0)
                        {
                            rowaddXiaoJi = true;
                        }

                        RowTittleInit(dataGrid, item.ItemChild2, item.StrProperty, rowaddXiaoJi, isRowFinish);

                        continue;
                    }
                    RowTittleInit(dataGrid, item.ItemChild, item.StrProperty, rowaddXiaoJi, isRowFinish);
                }

                #endregion

                #region 去掉年份

                this.scv.tongjiR.gridMain.ColumnDefinitions[0].Width = new GridLength(0);

                this.scv.tongjiR.Width = this.scv.tongjiR.gridMain.ColumnDefinitions[1].Width.Value;

                this.scv.tongjiR.txtSum.Text = "增量";

                #endregion

                #region 生成列标题

                //是否生成列标题最后一层
                bool isColumnFinish = false;
                //是否开始添加小计
                bool addXiaoJi = false;

                int stackPanleCollumnCount = stack2.Children.Count;

                //生成列标题
                for (int i = 0; i < stackPanleCollumnCount; i++)
                {
                    //获取item对象
                    var item = stack2.Children[i] as TongJiItem;

                    //通过列表名称获取其标题内容(加载最后一行标题标注为完成)
                    if (i == stackPanleCollumnCount - 1)
                    {
                        isColumnFinish = true;
                    }
                    //是否开始添加小计
                    if (stackPanleCollumnCount > 1 && i == stackPanleCollumnCount - 1)
                    {
                        addXiaoJi = true;
                    }

                    //月份处理
                    if (item.Tittle.Equals("月份"))
                    {
                        this.MonthDealWidth(item);
                        //列标题添加
                        ColumnTittleInit(dataGrid, item.ItemChild, item.StrProperty, false, false);

                        //是否开始添加小计
                        if (i == stackPanleCollumnCount - 1 && stackPanleCollumnCount > 0)
                        {
                            addXiaoJi = true;
                        }
                        //列标题添加
                        ColumnTittleInit(dataGrid, item.ItemChild2, item.StrProperty, addXiaoJi, isColumnFinish);

                        continue;
                    }
                    //列标题添加
                    this.ColumnTittleInit(dataGrid, item.ItemChild, item.StrProperty, addXiaoJi, isColumnFinish);
                }

                #endregion

                #region 生成数据

                //数据表格
                System.Data.DataTable table = new System.Data.DataTable();
                //指定有多少列
                for (int i = 0; i < dataGrid.dataGrid.Columns.Count - 1; i++)
                {
                    table.Columns.Add(Convert.ToString(i));
                }

                table.Columns.Add("总计");

                Dictionary <int, object[]> dicData = new Dictionary <int, object[]>();

                if (dt.Columns.Count < 1 || dt.Rows.Count < 1)
                {
                    //给每一行添加数据
                    for (int i = 0; i < dataGrid.tongjiR._LeftCount + 1; i++)
                    {
                        object[] list = new object[dataGrid.dataGrid.Columns.Count];
                        for (int y = 0; y < dataGrid.dataGrid.Columns.Count; y++)
                        {
                            list[y] = 0;
                        }
                        table.Rows.Add(list);
                    }
                }
                else
                {
                    //给每一行添加数据
                    for (int i = 0; i < dataGrid.tongjiR._LeftCount; i++)
                    {
                        var ps = GetData(dataGrid, dt, dataGrid.tongjiR.GetRangeTittle(i), i);
                        table.Rows.Add(ps);
                        dicData.Add(i, ps);
                    }
                    var ds = GetData(dataGrid, dicData);

                    table.Rows.Add(ds);
                }

                //绑定数据源
                dataGrid.dataGrid.ItemsSource = table.DefaultView;

                #endregion

                #region 清理垃圾,释放内存


                #endregion
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "TitleInit", ex.ToString(), dataGrid);
            }
        }