//设置汇总显示的信息
        public void SetGroupSummary(DevExpress.XtraGrid.Views.Grid.GridView gridView, Dictionary<string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys) {
            ArrayList list = new ArrayList();

            foreach (DevExpress.XtraGrid.Columns.GridColumn dc in gridView.Columns) {
                int num;
                string name = string.Empty;
                if (!string.IsNullOrEmpty(colPropertys.Keys.FirstOrDefault(o => string.Compare(o, dc.FieldName, true) == 0))) {
                    name = dc.FieldName;
                }
                else {
                    name = interceptRightNumber(dc.FieldName, out num);
                }
                MB.WinBase.Common.ColumnPropertyInfo info = null;
                if (colPropertys.ContainsKey(name))
                    info = colPropertys[name];
                if (info != null && info.SummaryItem) {
                    //设置Total 汇总的信息
                    dc.SummaryItem.SummaryType = (DevExpress.Data.SummaryItemType)Enum.Parse(typeof(DevExpress.Data.SummaryItemType), info.SummaryItemType.ToString());
                    dc.SummaryItem.DisplayFormat = getSummmaryDisplayCaption(dc.SummaryItem.SummaryType) + "={0}";
                    //为了设置小计的显示而存储
                    list.Add(dc);
                }
                // 处理动态创建的列.
                if (info == null && dc.Tag != null) {
                    switch (dc.Tag.ToString()) {
                        case "System.Int32":
                        case "System.Decimal":
                            dc.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
                            dc.SummaryItem.DisplayFormat = getSummmaryDisplayCaption(dc.SummaryItem.SummaryType) + "={0}";
                            list.Add(dc);
                            break;
                        default:
                            break;
                    }
                }
            }
            if (list.Count > 0) {
                List<DevExpress.XtraGrid.GridSummaryItem> summaryItems = new List<GridSummaryItem>();
                for (int i = 0; i < list.Count; i++) {
                    DevExpress.XtraGrid.Columns.GridColumn dc = list[i] as DevExpress.XtraGrid.Columns.GridColumn;
                    if (dc != null) {
                        var sumItem = new DevExpress.XtraGrid.GridGroupSummaryItem(dc.SummaryItem.SummaryType, dc.FieldName, dc, getSummmaryDisplayCaption(dc.SummaryItem.SummaryType) + "={0}");
                        var gsumItem = new DevExpress.XtraGrid.GridGroupSummaryItem(dc.SummaryItem.SummaryType, dc.FieldName, null, getSummmaryDisplayCaption(dc.SummaryItem.SummaryType) + "={0}");
                        summaryItems.Add(sumItem);
                        summaryItems.Add(gsumItem);
                    }
                }
                gridView.GroupSummary.AddRange(summaryItems.ToArray());
            }
        }
Beispiel #2
0
        static public void gridviewGroupSummaryAdd(DevExpress.XtraGrid.Views.Grid.GridView _view, String _fild_name, DevExpress.Data.SummaryItemType _summary_item_type, String _display_format)
        {
            if (null != _view)
            {
                DevExpress.XtraGrid.Columns.GridColumn des_column = _view.Columns[_fild_name];
                if (null != des_column)
                {
                    DevExpress.XtraGrid.GridGroupSummaryItem item = new DevExpress.XtraGrid.GridGroupSummaryItem();
                    if (null != item)
                    {
                        item.FieldName   = _fild_name;
                        item.SummaryType = _summary_item_type;
                        if (null != _display_format && 0 < _display_format.Length)
                        {
                            item.DisplayFormat = _display_format;
                        }
                        item.ShowInGroupColumnFooter = des_column;

                        _view.GroupSummary.Add(item);
                    }
                }
            }
        }
Beispiel #3
0
        void ucContractList_EventDataChanged()
        {
//a.ContractNo, a.ContractType, ct.name as ContractTypeName, a.CustNo, c.FirstName, c.LastName,
//c.CorporateName, a.ValidStartDate, a.ValidStartTime, a.ValidEndDate, a.ValidEndTime,
//a.Amount, a.Balance, a.CurCode, a.PersonCount, a.DepFreq,
//a.DepAmount, a.Status, decode(a.Status, 0, 'Идэвхгүй', 1, 'Идэвхтэй') as StatusName

            ucContractList.FieldLinkSetColumnCaption(0, "Гэрээний ID");
            ucContractList.FieldLinkSetColumnCaption(1, "Гэрээний төрөл");
            ucContractList.FieldLinkSetColumnCaption(2, "Гэрээний төрлийн нэр");
            ucContractList.FieldLinkSetColumnCaption(3, "Харилцагчийн дугаар");
            ucContractList.FieldLinkSetColumnCaption(4, "Харилцагчийн эцэг эхийн нэр");
            ucContractList.FieldLinkSetColumnCaption(5, "Харилцагчийн нэр");
            ucContractList.FieldLinkSetColumnCaption(6, "Компаний нэр");
            ucContractList.FieldLinkSetColumnCaption(7, "Эхлэх огноо");

            ucContractList.FieldLinkSetColumnCaption(8, "Эхлэх цаг");
            ucContractList.FieldLinkSetColumnCaption(9, "Дуусах огноо");
            ucContractList.FieldLinkSetColumnCaption(10, "Дуусах цаг");

            ucContractList.FieldLinkSetColumnCaption(11, "Гэрээний үнийн дүн");
            ucContractList.gridView1.Columns[11].DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Custom;
            ucContractList.gridView1.Columns[11].DisplayFormat.FormatString = "{0:n2}";

            ucContractList.FieldLinkSetColumnCaption(12, "Гэрээний үлдэгдэл үнэ");
            ucContractList.gridView1.Columns[12].DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Custom;
            ucContractList.gridView1.Columns[12].DisplayFormat.FormatString = "{0:n2}";

            ucContractList.FieldLinkSetColumnCaption(13, "Валют");
            ucContractList.FieldLinkSetColumnCaption(14, "Гэрээнд хамрагдах үйчлүүлэгчийн тоо");
            ucContractList.FieldLinkSetColumnCaption(15, "Гэрээний дүнг элэгдүүлэх давтамж");

            ucContractList.FieldLinkSetColumnCaption(16, "Гэрээний дүнг элэгдүүлэх дүн");
            ucContractList.gridView1.Columns[16].DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Custom;
            ucContractList.gridView1.Columns[16].DisplayFormat.FormatString = "{0:n2}";

            ucContractList.FieldLinkSetColumnCaption(17, "Гэрээний төлөв");
            ucContractList.FieldLinkSetColumnCaption(18, "Гэрээний төлөв");

            ucContractList.FieldLinkSetColumnCaption(19, "Үүсэгсэн огноо");
            ucContractList.FieldLinkSetColumnCaption(20, "Үүсэгсэн огноо цаг");
            ucContractList.FieldLinkSetColumnCaption(21, "Үүсэгсэн хэрэглэгч");
            ucContractList.FieldLinkSetColumnCaption(22, "Хариуцсан хэрэглэгч");

            ucContractList.gridView1.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways;

            // Customize the total summary.

            ucContractList.gridView1.Columns[0].SummaryItem.SummaryType   = DevExpress.Data.SummaryItemType.Count;
            ucContractList.gridView1.Columns[0].SummaryItem.DisplayFormat = "Нийт гэрээний тоо :{0:C2}";
            ucContractList.gridView1.Columns[0].SummaryItem.Tag           = 1;
            (ucContractList.gridView1.Columns[0].View as GridView).OptionsView.ShowFooter = true;

            ucContractList.gridView1.OptionsView.ShowGroupPanel = false;
            ucContractList.gridView1.ExpandAllGroups();

            ucContractList.gridView1.Columns[11].SummaryItem.SummaryType   = DevExpress.Data.SummaryItemType.Sum;
            ucContractList.gridView1.Columns[11].SummaryItem.DisplayFormat = "Нийт:{0:C2}";
            ucContractList.gridView1.Columns[11].SummaryItem.Tag           = 1;
            (ucContractList.gridView1.Columns[11].View as GridView).OptionsView.ShowFooter = true;

            ucContractList.gridView1.OptionsView.ShowGroupPanel = true;
            ucContractList.gridView1.ExpandAllGroups();


            ucContractList.gridView1.Columns[12].SummaryItem.SummaryType   = DevExpress.Data.SummaryItemType.Sum;
            ucContractList.gridView1.Columns[12].SummaryItem.DisplayFormat = "Нийт:{0:C2}";
            ucContractList.gridView1.Columns[12].SummaryItem.Tag           = 1;
            (ucContractList.gridView1.Columns[12].View as GridView).OptionsView.ShowFooter = true;


            // Create and setup the first summary item.
            GridGroupSummaryItem item = new GridGroupSummaryItem();

            item.FieldName   = "ContractNo";
            item.SummaryType = DevExpress.Data.SummaryItemType.Count;
            ucContractList.gridView1.GroupSummary.Add(item);


            DevExpress.XtraGrid.GridGroupSummaryItem item1 = new DevExpress.XtraGrid.GridGroupSummaryItem();
            item1.FieldName = "Amount";

            item1.SummaryType             = DevExpress.Data.SummaryItemType.Sum;
            item1.DisplayFormat           = "Нийт б/хураамж {0:c2}";
            item1.Tag                     = 1;
            item1.ShowInGroupColumnFooter = ucContractList.gridView1.Columns["Amount"];

            ucContractList.gridView1.GroupSummary.Add(item1);


            DevExpress.XtraGrid.GridGroupSummaryItem item2 = new DevExpress.XtraGrid.GridGroupSummaryItem();
            item2.FieldName = "Balance";

            item2.SummaryType             = DevExpress.Data.SummaryItemType.Sum;
            item2.DisplayFormat           = "Нийт б/үнэлгээ {0:c2}";
            item2.Tag                     = 1;
            item2.ShowInGroupColumnFooter = ucContractList.gridView1.Columns["Balance"];

            ucContractList.gridView1.GroupSummary.Add(item2);

            FormUtility.RestoreStateGrid(appname, formname, ref ucContractList.gridView1);
            FormUtility.RestoreStateVGrid(appname, formname, ref ucContractList.ucParameterPanel1.vGridControl1, ref ucContractList.groupControl1);
        }