tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
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
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using TProduct.Model;
 
namespace TProduct.WinFrmUI.Data4Factory
{
    public partial class MotorImportDlg : BaseForm
    {
        public MotorImportDlg()
        {
            InitializeComponent();
            this.gridView1.SetNormalView();
            this.gridView1.SetGridMianViewColor();
        }
 
        public class CurrentViewModel : Model.ProductMainExMotor
        {
            public CurrentViewModel() { }
            public CurrentViewModel(Model.ProductMainExMotor rhs) : base(rhs)
            {
                this.RatedPower = rhs.RatedPower < 0 ? null : rhs.RatedPower;
                this.PowerFactor = rhs.PowerFactor < 0 ? null : rhs.PowerFactor;
                this.RatedI = rhs.RatedI < 0 ? null : rhs.RatedI;
                this.RatedU = rhs.RatedU < 0 ? null : rhs.RatedU;
                this.Ratedn = rhs.Ratedn < 0 ? null : rhs.Ratedn;
                this.PhaseNum = rhs.PhaseNum;
                var paras = RatedParas4Motor.ToModel(rhs.RatedParas);
                this.E_Self = paras?.E_Self < 0 ? null : paras?.E_Self;
                this.E_PLC = paras?.E_PLC < 0 ? null : paras?.E_PLC;
                this.IsFrequency = paras?.IsFrequency;
            }
 
            public double? E_Self { get; set; }
            public double? E_PLC { get; set; }
            public bool? IsFrequency { get; set; }
        }
        private List<CurrentViewModel> _bindList;
        public void SetBindData(List<Model.ProductMainExMotor> list)
        {
            _bindList = new List<CurrentViewModel>();
            if (list == null)
                return;
            list.ForEach(x => _bindList.Add(new CurrentViewModel(x)));
            this.bindingSource1.DataSource = _bindList;
            this.bindingSource1.ResetBindings(false);
        }
 
        private void simpleBtnOK_Click(object sender, EventArgs e)
        {
            if (_bindList == null)
                return;
            var list = new List<Model.ProductMainExMotor>();
            _bindList.ForEach(x => list.Add(x));
            if (list == null)
                return;
            var bll = new BLL.ProductMotor();
            if (!bll.InsertsEx(list))
            {
                XtraMessageBox.Show("Error:70,导入失败!");
                return;
            }
            this.Close();
        }
 
        private void simpleBtnCancel_Click(object sender, EventArgs e)
        {
        }
    }
}