tangxu
2024-03-26 edd23f115dba31d764fdaf75a6207d888d0419d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms; 
using DevExpress.XtraCharts;
using DevExpress.XtraGrid.Views.Grid; 
 
namespace IStation.WinFrmUI.CalcErQu
{
    public partial class BlockTimeListDispCtrl : UserControl
    {
 
        public BlockTimeListDispCtrl()
        {
            InitializeComponent();
 
 
            this.gridView1.OptionsDetail.ShowDetailTabs = false;//不显示TAB名
            this.gridView1.OptionsView.ShowGroupPanel = false;//隐藏最上面的GroupPanel
            this.gridView1.OptionsSelection.MultiSelect = false;//单选
            //this.gridViewMain.OptionsBehavior.Editable = false;//只读 
            this.gridView1.IndicatorWidth = 4;
            this.gridView1.RowHeight = 30;
            this.gridView1.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(this.GridViewMain_RowClick);
            //this.gridViewMain.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.GridViewMain_CustomDrawRowIndicator);
            //this.gridViewMain.CustomUnboundColumnData += new DevExpress.XtraGrid.Views.Base.CustomColumnDataEventHandler(this.GridViewMain_CustomUnboundColumnData);
            //this.gridViewMain.DoubleClick += new System.EventHandler(this.GridViewMain_DoubleClick);
            //this.gridView1.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(this.GridViewMain_RowCellClick);
            //this.gridView1.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(this.gridViewMain_CellValueChanged);
        }
 
 
 
 
 
        /// <summary>
        /// 
        /// </summary> 
        /// <param name="anaPrj"></param>
        public void SetBindingData(IStation.CalcModel.AnaPrj anaPrj)
        {
            if (anaPrj == null)
                return;
            List<GridBlockTimeViewModel> gridBidings = new List<GridBlockTimeViewModel>();
 
            foreach (var item in anaPrj.BlockTimes)
            {
                //List<SpanTimeBlock> openTimeSpan = new List<SpanTimeBlock>();
                //List<SpanTimeBlock> closeTimeSpan = new List<SpanTimeBlock>();
 
 
                if (item.OpenPumpCount == 0)
                {
                    continue;
                    //pd.PumpName = "全关";
                }
                var pd = new GridBlockTimeViewModel();
                {
                    pd.PumpName = string.Format("{0}台泵", item.OpenPumpCount);
 
                    pd.SumFlow = item.SumFlow;
                    pd.SumPower = item.SumPower;
                    pd.SumMoney = item.SumMoney;
                }
 
                pd.StartTime = item.StartTime.ToString("HH:mm");
                pd.EndTime = item.EndTime.ToString("HH:mm");
                pd.SpanTime = Math.Round((item.EndTime - item.StartTime).TotalMinutes, 0);
 
                pd.Round();
 
                gridBidings.Add(pd);
            }
 
            this.bindingSourceGrid1.DataSource = gridBidings;
            this.bindingSourceGrid1.ResetBindings(false);
        }
 
 
        class GridBlockTimeViewModel
        {
            public string PumpName { get; set; }
 
            public double SumFlow { get; set; }//已经考虑时间段  (累计值)
            public double SumPower { get; set; }//已经考虑时间段 (累计值 度)
            public double SumMoney { get; set; }//已经考虑时间段 (累计值) 
            public double SpanTime { get; set; }
            public string StartTime { get; set; }
            public string EndTime { get; set; }
 
            public List<SubItem> SubItems { get; set; }
 
            public class SubItem
            {
                public string StartTime { get; set; }
                public string EndTime { get; set; }
                public double SpanTime { get; set; }
                public double SumFlow { get; set; }//已经考虑时间段  (累计值)
                public double SumPower { get; set; }//已经考虑时间段 (累计值 度)
                public double SumMoney { get; set; }//已经考虑时间段 (累计值) 
            }
 
            internal void Round()
            {
                this.SumFlow = Math.Round(this.SumFlow, 0);
                this.SumPower = Math.Round(this.SumPower, 0);
                this.SumMoney = Math.Round(this.SumMoney, 0);
            }
 
            //千吨水能耗
            public double QDSLN
            {
                get
                {
                    if (SumFlow == 0)
                        return 0;
                    return Math.Round(SumPower * 1000 / SumFlow, 1);
                }
            }
        }
 
        //class SpanTimeBlock
        //{
        //    public SpanTimeBlock(int pumpIndx, DateTime start, DateTime end)
        //    {
        //        this.PumpIndx = pumpIndx;
        //        this.Start = start;
        //        this.End = end;
        //    }
        //    public SpanTimeBlock(int pumpIndx, DateTime start, DateTime end, double flow, double power, double money)
        //    {
        //        this.PumpIndx = pumpIndx;
        //        this.Start = start;
        //        this.End = end;
        //        this.TotalFlow = flow;
        //        this.TotalPower = power;
        //        this.TotalMoney = money;
        //    }
        //    public int PumpIndx { get; set; }
        //    public DateTime Start { get; set; }
        //    public DateTime End { get; set; }
        //    public double TotalFlow { get; set; }
        //    public double TotalPower { get; set; }
        //    public double TotalMoney { get; set; }
        //}
 
 
 
  
        private void GridViewMain_RowClick(object sender, RowClickEventArgs e)
        {
            if (e.RowHandle < 0) return;
 
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //gridViewPrj = gridViewMain.GetRow(e.RowHandle) as AnaPrj;
                contextMenuGrid.Show(gridControl运行列表, e.Location);
            }
            else
            {
                //SetRibbonButtonDisp(SPump.WinFrmUI.SeriesTreeView.eNodeLevel.Pump);
            }
        }
 
        private void MenuItemGrid切换模式_Click(object sender, EventArgs e)
        {
            //if (MenuItemGrid切换模式.Text == "切换成时间段显示")
            //{
            //    _gridDispStyle = 1;
            //    MenuItemGrid切换模式.Text = "切换成泵分组显示";
            //    InitialGrid运行时间();
            //}
            //else
            //{
            //    _gridDispStyle = 0;
            //    MenuItemGrid切换模式.Text = "切换成时间段显示";
            //    InitialGrid运行时间();
            //}
        }
 
        private void MenuItem导出Grid_Click(object sender, EventArgs e)
        {
            ExportSpanGrid();
        }
        public void ExportSpanGrid()
        {
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Title = "导出信息列表";
            dlg.FileName = "信息列表.xls";
            dlg.Filter = "excel文件 (*.xls)|*.xls";
            if (dlg.ShowDialog() == DialogResult.OK)
                this.gridControl运行列表.ExportToXls(dlg.FileName);
        }
    }
}