From 3a8ca9cfb9312444b7cbe9c1988829432c4ba80d Mon Sep 17 00:00:00 2001 From: Shuxia Ning <NingShuxia0927@outlook.com> Date: 星期三, 11 十二月 2024 17:13:46 +0800 Subject: [PATCH] ExportToImage --- WinFrmUI/HStation.WinFrmUI.Assets.Core/01-pump/01-EditPumpPartProp/EditPumpPartPropDlg.cs | 164 +++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 129 insertions(+), 35 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Assets.Core/01-pump/01-EditPumpPartProp/EditPumpPartPropDlg.cs b/WinFrmUI/HStation.WinFrmUI.Assets.Core/01-pump/01-EditPumpPartProp/EditPumpPartPropDlg.cs index 865b3eb..14114fe 100644 --- a/WinFrmUI/HStation.WinFrmUI.Assets.Core/01-pump/01-EditPumpPartProp/EditPumpPartPropDlg.cs +++ b/WinFrmUI/HStation.WinFrmUI.Assets.Core/01-pump/01-EditPumpPartProp/EditPumpPartPropDlg.cs @@ -9,22 +9,31 @@ InitializeComponent(); this.gridView1.Columns["PropGroupName"].Group(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; + this.pumpProductListBox1.MouseUp += PumpProductListBox1_MouseUp; } - private BLL.AssetsPumpPartMain _bll = null; - private List<PropGroupChoiceViewModel> _proplist = null; + #region Private + + private BLL.AssetsPumpPartMain _bll; + private List<PropGroupChoiceViewModel> _propList; private List<CurrentPartMainViewModel> _allBindingList = new List<CurrentPartMainViewModel>(); - private Vmo.AssetsPumpMainAndPartMapVmo _partmap = null; + private Vmo.AssetsPumpMainAndPartMapVmo _partMapping; - private Vmo.AssetsPumpPartMainVmo _pumpPart = null; + private Vmo.AssetsPumpMainVmo _pumpMain; + + private Vmo.AssetsPumpPartMainVmo _pumpPart; private long _catalogID; //鍒嗙被ID - private long _seriesID; //绯诲垪ID + private Vmo.AssetsPumpSeriesVmo _series; //绯诲垪ID - private List<Vmo.AssetsPumpPropContentVmo> _allPropList = null; + private List<Vmo.AssetsPumpPropContentVmo> _allPropList; + + private Yw.BLL.SysPropMapping _sysPropMapping; + + #endregion Private //鍥炶皟浜嬩欢 public event Func<Vmo.AssetsPumpPartMainVmo, List<Vmo.AssetsPumpPropContentVmo>, Vmo.AssetsPumpMainAndPartMapVmo, Task<bool>> ReloadEvent; @@ -33,6 +42,7 @@ public async void SetBindingData(Vmo.AssetsPumpMainVmo AssetsPumpMain) { this.pumpProductListBox1.SetBindingData(AssetsPumpMain); + _pumpMain = AssetsPumpMain; this.pumpProductListBox1.SelectReloadEvent += () => { ListBoxPart_SelectedIndexChanged(); @@ -43,19 +53,16 @@ }; _bll = new BLL.AssetsPumpPartMain(); var allpartlist = await _bll.GetByPumpMainID(AssetsPumpMain.ID); //鑾峰彇鎵�鏈変骇鍝� - var series = await new BLL.AssetsPumpSeries().GetByID(AssetsPumpMain.PumpSeriesID); //鑾峰彇绯诲垪 + var series = await new BLL.AssetsPumpSeries().GetByID(AssetsPumpMain.SeriesID); //鑾峰彇绯诲垪 _pumpPart = new Vmo.AssetsPumpPartMainVmo(); - _seriesID = series.ID; - _pumpPart.SeriesID = _seriesID; + _series = series; + _pumpPart.SeriesID = _series.ID; _catalogID = series.CatalogID; - _proplist = new List<PropGroupChoiceViewModel>(); - _partmap = new Vmo.AssetsPumpMainAndPartMapVmo(); - _partmap.PumpID = AssetsPumpMain.ID; - _partmap.SeriesID = _seriesID; - - // this.ListBoxPart.DataSource = _allBindingList; - // this.ListBoxPart.Refresh(); - this.propGroupChoiceViewModelBindingSource.DataSource = _proplist; + _propList = new List<PropGroupChoiceViewModel>(); + _partMapping = new Vmo.AssetsPumpMainAndPartMapVmo(); + _partMapping.MainID = AssetsPumpMain.ID; + _partMapping.SeriesID = _series.ID; + this.propGroupChoiceViewModelBindingSource.DataSource = _propList; this.propGroupChoiceViewModelBindingSource.ResetBindings(false); } @@ -68,7 +75,7 @@ this.TextEditNo.Text = partmain.NO.Trim(); this.TextEditProductCode.Text = partmain.Code.Trim(); this.TextEditProductName.Text = partmain.Name.Trim(); - _proplist.Clear(); + _propList.Clear(); var bll = new Yw.BLL.SysPropStruct(); var catlog = await bll.GetByCatalogID(_catalogID); if (catlog == null) @@ -76,12 +83,16 @@ this.propGroupChoiceViewModelBindingSource.ResetBindings(false); return; } - _proplist.Clear(); + _propList.Clear(); + _propList.Add(new PropGroupChoiceViewModel() { PropGroupName = "閾墝鍙傛暟", PropName = "娴侀噺", Value = _pumpMain.RatedFlow.ToString(), KeyWorldType = "Basic_Flow" }); + _propList.Add(new PropGroupChoiceViewModel() { PropGroupName = "閾墝鍙傛暟", PropName = "鎵▼", Value = _pumpMain.RatedHead.ToString(), KeyWorldType = "Basic_Head" }); + _propList.Add(new PropGroupChoiceViewModel() { PropGroupName = "閾墝鍙傛暟", PropName = "鍔熺巼", Value = _pumpMain.RatedPower.ToString(), KeyWorldType = "Basic_Power" }); + _propList.Add(new PropGroupChoiceViewModel() { PropGroupName = "閾墝鍙傛暟", PropName = "杞��", Value = _pumpMain.RatedSpeed.ToString(), KeyWorldType = "Basic_Speed" }); foreach (var item in catlog) { foreach (var prop in item.PropList) { - _proplist.Add(new PropGroupChoiceViewModel() { PropGroupName = item.Name, PropName = prop.Name, ID = prop.ID }); + _propList.Add(new PropGroupChoiceViewModel() { PropGroupName = item.Name, PropName = prop.Name, ID = prop.ID, KeyWorldType = "Prop" }); } } var propbll = new BLL.PumpPartPropContent(); @@ -89,7 +100,11 @@ _allPropList = alllist; foreach (var item in alllist) { - _proplist.Find(x => x.ID == item.PropID).Value = item.PropValue; + var selectProp = _propList.Find(x => x.ID == item.PropID); + if (selectProp != null) + { + selectProp.Value = item.PropValue; + } } this.propGroupChoiceViewModelBindingSource.ResetBindings(false); this.gridView1.ExpandAllGroups(); @@ -115,30 +130,63 @@ updatepart.Name = TextEditProductName.Text; updatepart.NO = TextEditNo.Text; updatepart.Code = TextEditProductCode.Text; - updatepart.SeriesID = _seriesID; - var updateproplist = new List<UpdateAssetsPumpPropContentInput>(); - // var update = _allPropList.Select(x => x.Adapt<AssetsPumpPropContentDto, UpdateAssetsPumpPropContentInput>()).ToList(); - foreach (var item in _proplist) + updatepart.SeriesID = _series.ID; + var propList = _propList.Where(x => x.KeyWorldType == "Prop").ToList(); //鎵惧埌鎵�鏈夌殑棰濆灞炴�� + foreach (var item in propList) { if (_allPropList != null) { - _allPropList.Find(x => x.PropID == item.ID).PropValue = item.Value; + // 鏌ユ壘 _allPropList 涓槸鍚﹀瓨鍦ㄤ笌 item.ID 鍖归厤鐨勯」 + var prop = _allPropList.FirstOrDefault(x => x.PropID == item.ID); + // 濡傛灉鎵惧埌鍖归厤鐨勯」锛屽垯鏇存柊鍏� PropValue + if (prop != null) + { + prop.PropValue = item.Value; + } + else + { + _allPropList.Add(new Vmo.AssetsPumpPropContentVmo() { SeriesID = _allPropList.First().SeriesID, PartID = _allPropList.First().PartID, PropID = item.ID, PropValue = item.Value }); + } } } + var basicFlow = _propList.Find(x => x.KeyWorldType == "Basic_Flow"); + var basicHead = _propList.Find(x => x.KeyWorldType == "Basic_Head"); + var basicSpeed = _propList.Find(x => x.KeyWorldType == "Basic_Speed"); + var basicPower = _propList.Find(x => x.KeyWorldType == "Basic_Power"); + if (double.TryParse(basicFlow.Value, out double flow)) + { + _pumpMain.RatedFlow = flow; + } + if (double.TryParse(basicHead.Value, out double head)) + { + _pumpMain.RatedHead = head; + } + if (double.TryParse(basicSpeed.Value, out double speed)) + { + _pumpMain.RatedSpeed = speed; + } + if (double.TryParse(basicPower.Value, out double power)) + { + _pumpMain.RatedPower = power; + } + var pumpMainBll = new BLL.AssetsPumpMain(); + await pumpMainBll.Update(_pumpMain); if (await _bll.UpdateEx(updatepart, _allPropList)) { vm.Reset(updatepart); this.pumpProductListBox1.Refresh(); - MessageBoxHelper.ShowSuccess("淇敼鎴愬姛!"); + TipFormHelper.ShowSucceed("淇敼鎴愬姛!"); } else { - MessageBoxHelper.ShowError("淇敼澶辫触!"); + TipFormHelper.ShowError("淇敼澶辫触!"); } + this.DialogResult = DialogResult.OK; + this.Close(); } //宸︿晶鏍戝彸鍑昏彍鍗曚簨浠� - private void ListBoxPart_MouseUp(object sender, MouseEventArgs e) + private void PumpProductListBox1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { @@ -167,22 +215,24 @@ _pumpPart.NO = TextEditNo.Text; _pumpPart.Code = TextEditProductCode.Text; var AssetsPumpPropContent = new List<Vmo.AssetsPumpPropContentVmo>(); - foreach (var item in _proplist) + foreach (var item in _propList) { AssetsPumpPropContent.Add(new Vmo.AssetsPumpPropContentVmo { PropID = item.ID, PropValue = item.Value, SeriesID = _pumpPart.SeriesID }); } - var id = await _bll.InsertEx(_pumpPart, AssetsPumpPropContent, _partmap); + var id = await _bll.InsertEx(_pumpPart, AssetsPumpPropContent, _partMapping); if (id > 0) { var pumppart = await _bll.GetByID(id); this.pumpProductListBox1._allBindingList.Add(new CurrentPartMainViewModel(pumppart)); this.pumpProductListBox1.Refresh(); - MessageBoxHelper.ShowSuccess("娣诲姞鎴愬姛!"); + TipFormHelper.ShowSucceed("娣诲姞鎴愬姛!"); } else { - MessageBoxHelper.ShowError("娣诲姞澶辫触!"); + TipFormHelper.ShowError("娣诲姞澶辫触!"); } + this.DialogResult = DialogResult.OK; + this.Close(); } #region 鑿滃崟鍔熻兘 @@ -203,12 +253,12 @@ this.propGroupChoiceViewModelBindingSource.ResetBindings(false); return; } - _proplist.Clear(); + _propList.Clear(); foreach (var item in catlog) { foreach (var prop in item.PropList) { - _proplist.Add(new PropGroupChoiceViewModel() { PropGroupName = item.Name, PropName = prop.Name, ID = prop.ID, Value = prop.DefaultValue }); + _propList.Add(new PropGroupChoiceViewModel() { PropGroupName = item.Name, PropName = prop.Name, ID = prop.ID, Value = prop.DefaultValue }); } } this.propGroupChoiceViewModelBindingSource.ResetBindings(false); @@ -247,5 +297,49 @@ } #endregion 鑿滃崟鍔熻兘 + + //澧炲姞灞炴�� + private void simpleLabelItemAddProp_Click(object sender, EventArgs e) + { + var dlg = new AddPumpPropDlg(); + dlg.SetBindingData(_series.CatalogID); + dlg.ReloadDataEvent += async (rhs, groupName, propValue) => + { + var bll = new Yw.BLL.SysProp(); + var id = await bll.Insert(rhs); + if (id > 0) + { + _sysPropMapping = new Yw.BLL.SysPropMapping(); + var allList = await _sysPropMapping.GetHaveListByCatalogID(_series.CatalogID); + var list = new List<Yw.Vmo.SysPropMappingSetterVmo>(); + foreach (var item in allList) + { + foreach (var prop in item.PropList) + { + if (prop.Have) + { + list.Add(new Yw.Vmo.SysPropMappingSetterVmo + { + PropID = prop.ID, + UnitName = prop.UnitName, + IsNull = prop.IsNull, + DefaultValue = prop.DefaultValue, + ChoiceIds = prop.ChoiceList.Select(x => x.ID).ToList(), + }); + } + } + } + list.Add(new Yw.Vmo.SysPropMappingSetterVmo { PropID = id, UnitName = rhs.UnitName, IsNull = rhs.IsNull }); + await _sysPropMapping.SetByCatalogID(_series.CatalogID, list); + var model = await bll.GetByID(id); + var partMain = new PropGroupChoiceViewModel() { PropGroupName = groupName, PropName = model.Name, ID = model.ID, Value = propValue, KeyWorldType = "Prop" }; + _propList.Add(partMain); + this.propGroupChoiceViewModelBindingSource.ResetBindings(false); + return true; + } + return false; + }; + dlg.ShowDialog(); + } } } \ No newline at end of file -- Gitblit v1.9.3