ÎļþÃû´Ó WinFrmUI/HStation.WinFrmUI.Assets.Core/05-elbow/02-main/AddAssetsCoolingMainDlg.cs ÐÞ¸Ä |
| | |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraScheduler.Outlook.Interop; |
| | | using HStation.Assets; |
| | | using HStation.Service.Assets; |
| | | using HStation.Vmo; |
| | | using System; |
| | |
| | | |
| | | 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; |
| | |
| | | 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) |
| | | { |
| | |
| | | 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; |
| | | } |
| | | |
| | | //éªè¯ |
| | |
| | | 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; |
| | |
| | | _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; |
| | |
| | | } |
| | | |
| | | //è·åææç³»æ°å表 |
| | | 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) |
| | |
| | | var factor = factorList.FirstOrDefault(); |
| | | if (factor != null) |
| | | { |
| | | this.txtCoefficient.EditValue = factor.Coefficient; |
| | | this.txtLowerLimit.EditValue = factor.LowerLimit; |
| | | this.txtCoefficient.EditValue = factor.MinorLoss; |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | MatchingFactor(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |