tx
8 天以前 e0b138b3e057de6f57021e6c8963868f5c5acc5a
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
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using TProduct.Common;
 
namespace TProduct.WinFrmUI.TPump
{
    public partial class ResultJudgeForm : XtraForm
    {
        public ResultJudgeForm()
        {
            InitializeComponent();
 
            this.btnJudge.SetCommButtonColor();
            this.gridViewMain.OptionsDetail.ShowDetailTabs = false;//不显示TAB名
            this.gridViewMain.OptionsView.ShowGroupPanel = false;//隐藏最上面的GroupPanel
            this.gridViewMain.OptionsSelection.MultiSelect = false;//单选
            //this.gridViewMain.OptionsBehavior.Editable = false;//只读
            this.gridViewMain.BestFitColumns();
            this.gridViewMain.IndicatorWidth = 2;
            this.gridViewMain.RowHeight = 38;
        }
        private TProduct.Model.TestProjectItemView _featTestItem = null;//只针对性能测试
        private TProduct.Model.ProductMainExPump _currentPump = null;
        private TProduct.Model.RatedParas4Pump _ratedParas = null;
        private TProduct.Model.TestStandard _testStandard = null;
        private TProduct.Model.TestGrade _testGrade = null;
        private List<Model.TestGradeJudgeItem> _testJudgeItems = null;
        private List<TProduct.Model.TestJudgeItemResultViewModel> _testJudgeResults = null;
        public void SetRatedParas(TProduct.Model.ProductMainExPump currentPump, TProduct.Model.RatedParas4Pump ratedParas)
        {
            this._currentPump = currentPump;
            this._ratedParas = ratedParas;
        }
        private List<TProduct.Model.PumpFeatTestRecordViewModel> _allRecords = null;
        public void SetRecordPoints(List<TProduct.Model.PumpFeatTestRecordViewModel> allRecords)
        {
            this._allRecords = allRecords;
        }
        public void SetBindingData(
            TProduct.Model.TestProjectItemView featTestItem,// 对性能测试
            TProduct.Model.TestStandard testStandard,
            TProduct.Model.TestGrade testGrade,
            List<Model.TestGradeJudgeItem> testJudgeItems,
            List<TProduct.Model.TestJudgeItemResultViewModel> testJudgeResults)
        {
            this._testStandard = testStandard;
            this._testGrade = testGrade;
            this._testJudgeItems = testJudgeItems;
            this._testJudgeResults = testJudgeResults;
            this._featTestItem = featTestItem;
 
            this.imageComboTestStandard.Properties.Items.Clear();
            TestStandardHelper.Instance.GetStandardList(
                TProduct.Model.eProductType.Pump,
                 Model.eTestType.FeatTest).ForEach(x => this.imageComboTestStandard.Properties.Items.Add(x.Name, x.ID, -1));
            this.imageComboTestStandard.EditValue = testStandard.ID;
            this.imageComboTestGrade.EditValue = testGrade.ID;
            this.bindingSource1.DataSource = testJudgeResults;
        }
 
        private void imageComboTestStandard_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (imageComboTestStandard.SelectedIndex < 0)
                return;
            var standard_id = this.imageComboTestStandard.EditValue.ToString();
            string defaultGradeId = null;
            var grades = TestStandardHelper.Instance.GetGradeList(TProduct.Model.eProductType.Pump, standard_id, out defaultGradeId);
 
            this.imageComboTestGrade.Properties.Items.Clear();
            grades.ForEach(x => this.imageComboTestGrade.Properties.Items.Add(x.Name, x.ID, -1));
            this.imageComboTestGrade.EditValue = defaultGradeId;
        }
 
        public Action<string, string, List<Model.TestGradeJudgeItem>> OnSaveGrade = null;
        public Action<Model.eTestJudgeResult, List<TProduct.Model.TestJudgeItemResultViewModel>> OnSaveResult = null;
        private void btnJudge_Click(object sender, EventArgs e)
        {
            if (imageComboTestStandard.SelectedIndex < 0)
                return;
            if (imageComboTestGrade.SelectedIndex < 0)
                return;
            var standard_id = this.imageComboTestStandard.EditValue.ToString();
            var grade_id = this.imageComboTestGrade.EditValue.ToString();
            if (this._testGrade.ID != grade_id)
            {
                this._testStandard = TestStandardHelper.Instance.GetStandard(TProduct.Model.eProductType.Pump, standard_id);
                this._testGrade = TestStandardHelper.Instance.GetGrade(TProduct.Model.eProductType.Pump, standard_id, grade_id);
 
                this._testJudgeItems = TProduct.Common.TestStandardHelper.Instance.GetJudgeItems(TProduct.Model.eProductType.Pump, _testStandard.ID, _testGrade.ID);
                if (OnSaveGrade != null)
                    OnSaveGrade(standard_id, grade_id, this._testJudgeItems);
            }
 
            if (this._allRecords == null || this._allRecords.Count() < 4)
            {
                MessageBox.Show("点数量过少,暂时无法判断");
                return;
            }
 
            TProduct.Common.PumpTestJudgeHelper helper = new TProduct.Common.PumpTestJudgeHelper();
            helper.SetRatedParas(this._currentPump, this._ratedParas);
            helper.SetStandard(this._testStandard, this._testGrade, this._testJudgeItems);
            if (this._featTestItem.ItemParas != null &&
            this._featTestItem.ItemParas.ExtendPointQ != null)
            {
                helper.SetCurveMaxFlow(this._featTestItem.ItemParas.ExtendPointQ.Value);
            }
            var isOk = helper.Judge(this._allRecords, out _testJudgeResults);
            OnSaveResult(isOk, _testJudgeResults);
            this.bindingSource1.DataSource = _testJudgeResults;
            this.bindingSource1.ResetBindings(false);
        }
 
        private void ResultJudgeForm_Load(object sender, EventArgs e)
        {
 
        }
    }
}