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)
|
{
|
}
|
}
|
}
|