From 49d80c1cc3d2d76956f7f6acd6babad2f1e03d28 Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期一, 23 十二月 2024 14:58:41 +0800 Subject: [PATCH] 新增报告程序集 --- WinFrmUI/HStation.WinFrmUI.Assets.Core/07-fourLink/02-main/AddFourLinkMainDlg.cs | 78 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 77 insertions(+), 1 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Assets.Core/07-fourLink/02-main/AddFourLinkMainDlg.cs b/WinFrmUI/HStation.WinFrmUI.Assets.Core/07-fourLink/02-main/AddFourLinkMainDlg.cs index b0d4000..f4607f8 100644 --- a/WinFrmUI/HStation.WinFrmUI.Assets.Core/07-fourLink/02-main/AddFourLinkMainDlg.cs +++ b/WinFrmUI/HStation.WinFrmUI.Assets.Core/07-fourLink/02-main/AddFourLinkMainDlg.cs @@ -1,4 +1,5 @@ 锘縰sing DevExpress.XtraEditors.Controls; +using HStation.Vmo; namespace HStation.WinFrmUI.Assets { @@ -7,13 +8,19 @@ public AddAssetsFourlinkMainDlg() { InitializeComponent(); + this.treeList1.InitialMultiColSettings(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; } private Vmo.AssetsFourlinkMainVmo _FourLinkVmo = null; + private List<Vmo.AssetsFourlinkCoefficientVmo> _AssetsFourlinkCoefficient; + public async void SetBindingData(long SeriesID) { + var bll = new BLL.AssetsFourlinkCoefficient(); + _AssetsFourlinkCoefficient = await bll.GetAll(); + this.fourlinkCoefficientViewModelBindingSource.DataSource = _AssetsFourlinkCoefficient; _FourLinkVmo = new Vmo.AssetsFourlinkMainVmo(); _FourLinkVmo.SeriesID = SeriesID; var allCaliber = await new Yw.BLL.SysDictData().GetByTypeCode("1"); @@ -36,6 +43,7 @@ } TextEditCaliber.SelectedIndex = 0; TextEditMaterial.SelectedIndex = 0; + this.selectFlagsPopupCtrl1.SetBindingData<AssetsFlags>(); } public event Func<Vmo.AssetsFourlinkMainVmo, Task<bool>> ReloadDataEvent = null; @@ -54,8 +62,67 @@ this.dxErrorProvider1.SetError(this.TextEditCoefficient, "蹇呭~椤�"); return false; } - return true; + } + + //鏉愭枡閫夋嫨鍙樺寲浜嬩欢 + private void TextEditMaterial_SelectedIndexChanged(object sender, EventArgs e) + { + if (_AssetsFourlinkCoefficient == null) + return; + var select = GetCoefficientByMaterial(TextEditMaterial.Text); + if (select == null) + { + this.TextEditCoefficient.Text = string.Empty; + return; + } + this.TextEditCoefficient.Text = select.MinorLoss.ToString(); + } + + //鍙e緞閫夋嫨鍙樺寲浜嬩欢 + private void TextEditCaliber_SelectedIndexChanged(object sender, EventArgs e) + { + if (_AssetsFourlinkCoefficient == null) + return; + + if (double.TryParse(TextEditCaliber.Text, out double caliber)) + { + foreach (var item in _AssetsFourlinkCoefficient) + { + if (item.Caliber.HasValue) + { + if (Math.Abs(Convert.ToDouble(item.Caliber) - caliber) < 10) + { + this.TextEditCoefficient.Text = item.MinorLoss.ToString(); + return; + } + } + } + } + } + + //鎵惧埌鏈�鐩歌繎鐨勬潗鏂� + private AssetsFourlinkCoefficientVmo GetCoefficientByMaterial(string name) + { + AssetsFourlinkCoefficientVmo select = null; + int maxMatchedChars = 0; + foreach (var item in _AssetsFourlinkCoefficient) + { + int matchedChars = GetIntersect(item.Material, name); + if (matchedChars > maxMatchedChars) + { + maxMatchedChars = matchedChars; + select = item; + return select; + } + } + return select; + } + + private int GetIntersect(string str1, string str2) + { + if (str1 == null || str2 == null) return 0; + return string.Join("", str1.Intersect(str2)).Count(); } //瀹屾垚 @@ -78,6 +145,7 @@ { _FourLinkVmo.MinorLoss = Coefficient; } + _FourLinkVmo.Flags = this.selectFlagsPopupCtrl1.SelectedFlags; if (await this.ReloadDataEvent.Invoke(_FourLinkVmo)) { TipFormHelper.ShowSucceed("娣诲姞鎴愬姛!"); @@ -89,5 +157,13 @@ this.DialogResult = DialogResult.OK; this.Close(); } + + private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) + { + var vm = this.treeList1.GetCurrentViewModel(_AssetsFourlinkCoefficient); + if (vm == null) + return; + this.TextEditCoefficient.Text = vm.MinorLoss.ToString(); + } } } \ No newline at end of file -- Gitblit v1.9.3