duheng
2024-12-24 ea882c1741812b0783b2924548cb9e8c638a1be9
WinFrmUI/HStation.WinFrmUI.Assets.Core/05-elbow/02-main/AddAssetsElbowMainDlg.cs
ÎļþÃû´Ó WinFrmUI/HStation.WinFrmUI.Assets.Core/05-elbow/02-main/AddAssetsCoolingMainDlg.cs ÐÞ¸Ä
@@ -1,5 +1,6 @@
using DevExpress.XtraEditors;
using DevExpress.XtraScheduler.Outlook.Interop;
using HStation.Assets;
using HStation.Service.Assets;
using HStation.Vmo;
using System;
@@ -15,9 +16,9 @@
namespace HStation.WinFrmUI
{
    public partial class AddAssetsCoolingMainDlg : DevExpress.XtraEditors.XtraForm
    public partial class AddAssetsElbowMainDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddAssetsCoolingMainDlg()
        public AddAssetsElbowMainDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
@@ -25,29 +26,29 @@
            this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
        }
        private static AssetsCoolingMainVmo _last = null;
        private static AssetsElbowMainVmo _last = null;
        /// <summary>
        /// è¿”回数据事件
        /// </summary>
        public event Action<HStation.Vmo.AssetsCoolingMainVmo> ReloadDataEvent;
        public event Action<HStation.Vmo.AssetsElbowMainVmo> ReloadDataEvent;
        private HStation.Vmo.AssetsCoolingSeriesVmo _series = null;
        private HStation.Vmo.AssetsCoolingMainVmo _vmo = null;
        private HStation.Vmo.AssetsElbowSeriesVmo _series = null;
        private HStation.Vmo.AssetsElbowMainVmo _vmo = null;
        /// <summary>
        /// ç»‘定数据
        /// </summary>
        public async void SetBindingData(HStation.Vmo.AssetsCoolingSeriesVmo series)
        public async void SetBindingData(HStation.Vmo.AssetsElbowSeriesVmo series)
        {
            if (series == null)
            {
                return;
            }
            _series = series;
            _vmo = new Vmo.AssetsCoolingMainVmo();
            _vmo = new Vmo.AssetsElbowMainVmo();
            _vmo.SeriesID = series.ID;
            var flags = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(HStation.Assets.DataType.CoolingMain);
            var flags = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(HStation.Assets.DataType.ElbowMain);
            this.setFlagsEditCtrl1.SetBindingData(flags?.Select(x => x.Name).ToList(), null);
            if (_last != null)
            {
@@ -55,12 +56,13 @@
                this.txtMaterial.EditValue = _last.Material;
                this.txtKeyWord.EditValue = KeyWordHelper.ToString(_last.KeyWords);
                this.txtCaliber.EditValue = _last.Caliber;
                this.txtCoefficient.EditValue = _last.Coefficient;
                this.txtLowerLimit.EditValue = _last.LowerLimit;
                this.txtCoefficient.EditValue = _last.MinorLoss;
                this.setFlagsEditCtrl1.SetBindingData(flags?.Select(x => x.Name).ToList(), _last.Flags);
                this.txtTagName.EditValue = _last.TagName;
                this.txtDescription.EditValue = _last.Description;
            }
            this.imageComboBoxEditConnectlenght.Properties.AddEnum(typeof(eElbowType));
            this.imageComboBoxEditConnectlenght.SelectedIndex = 1;
        }
        //验证
@@ -82,15 +84,10 @@
                this.dxErrorProvider1.SetError(this.txtCoefficient, "必填项");
                return false;
            }
            if (string.IsNullOrEmpty(this.txtLowerLimit.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtLowerLimit, "必填项");
                return false;
            }
            var tagname = this.txtTagName.Text.Trim();
            if (!string.IsNullOrEmpty(tagname))
            {
                if (await BLLFactory<HStation.BLL.AssetsCoolingMain>.Instance.IsExistTagName(tagname))
                if (await BLLFactory<HStation.BLL.AssetsElbowMain>.Instance.IsExistTagName(tagname))
                {
                    this.dxErrorProvider1.SetError(this.txtTagName, "重复");
                    return false;
@@ -117,20 +114,20 @@
            _vmo.Name = this.txtName.Text.Trim();
            _vmo.Material = this.txtMaterial.Text.Trim();
            _vmo.Caliber = this.txtCaliber.EditValue == null ? null : double.Parse(this.txtCaliber.EditValue?.ToString());
            _vmo.Coefficient = double.Parse(this.txtCoefficient.EditValue?.ToString());
            _vmo.LowerLimit = double.Parse(this.txtLowerLimit.EditValue?.ToString());
            _vmo.MinorLoss = double.Parse(this.txtCoefficient.EditValue?.ToString());
            _vmo.KeyWords = HStation.Service.Assets.KeyWordHelper.ToList(this.txtKeyWord.Text.Trim());
            _vmo.Flags = this.setFlagsEditCtrl1.SelectedFlagList;
            _vmo.TagName = this.txtTagName.Text.Trim();
            _vmo.Description = this.txtDescription.Text.Trim();
            var id = await BLLFactory<HStation.BLL.AssetsCoolingMain>.Instance.Insert(_vmo);
            _vmo.ElbowType = (eElbowType)this.imageComboBoxEditConnectlenght.EditValue;
            _vmo.Angle = int.Parse(this.txtAngle.EditValue?.ToString());
            var id = await BLLFactory<HStation.BLL.AssetsElbowMain>.Instance.Insert(_vmo);
            if (id < 1)
            {
                TipFormHelper.ShowError("添加失败!");
                return;
            }
            var vmo = await BLLFactory<HStation.BLL.AssetsCoolingMain>.Instance.GetByID(id);
            var vmo = await BLLFactory<HStation.BLL.AssetsElbowMain>.Instance.GetByID(id);
            _last = vmo;
            this.ReloadDataEvent?.Invoke(vmo);
            this.DialogResult = DialogResult.OK;
@@ -138,24 +135,25 @@
        }
        //获取所有系数列表
        private async Task<List<AssetsCoolingFactorVmo>> GetAllFactorList()
        private async Task<List<AssetsElbowFactorVmo>> GetAllFactorList()
        {
            if (_allFactorList == null)
            {
                _allFactorList = await BLLFactory<HStation.BLL.AssetsCoolingFactor>.Instance.GetAll();
                _allFactorList = await BLLFactory<HStation.BLL.AssetsElbowFactor>.Instance.GetAll();
                if (_allFactorList == null)
                {
                    _allFactorList = new List<AssetsCoolingFactorVmo>();
                    _allFactorList = new List<AssetsElbowFactorVmo>();
                }
            }
            return _allFactorList;
        }
        private List<AssetsCoolingFactorVmo> _allFactorList = null;
        private List<AssetsElbowFactorVmo> _allFactorList = null;
        //匹配系数
        private async void MatchingFactor()
        {
            if (this.txtCoefficient.EditValue == null && this.txtLowerLimit.EditValue == null)
            if (this.txtCoefficient.EditValue == null)
            {
                var allFactorList = await GetAllFactorList();
                if (allFactorList != null && allFactorList.Count > 0)
@@ -174,8 +172,7 @@
                    var factor = factorList.FirstOrDefault();
                    if (factor != null)
                    {
                        this.txtCoefficient.EditValue = factor.Coefficient;
                        this.txtLowerLimit.EditValue = factor.LowerLimit;
                        this.txtCoefficient.EditValue = factor.MinorLoss;
                    }
                }
            }
@@ -190,7 +187,5 @@
        {
            MatchingFactor();
        }
    }
}