From 26917739c47252ecdc3b8f43eca6ebaf9cba6ac4 Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期二, 10 十二月 2024 15:17:04 +0800 Subject: [PATCH] 提交报告修改 --- WinFrmUI/HStation.WinFrmUI.Assets.Core/10-exchanger/06-prop/EditPackagePartPropDlg.cs | 162 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 103 insertions(+), 59 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Assets.Core/10-exchanger/06-prop/EditExchangerPartPropDlg.cs b/WinFrmUI/HStation.WinFrmUI.Assets.Core/10-exchanger/06-prop/EditPackagePartPropDlg.cs similarity index 60% rename from WinFrmUI/HStation.WinFrmUI.Assets.Core/10-exchanger/06-prop/EditExchangerPartPropDlg.cs rename to WinFrmUI/HStation.WinFrmUI.Assets.Core/10-exchanger/06-prop/EditPackagePartPropDlg.cs index f5788b9..30f8f3c 100644 --- a/WinFrmUI/HStation.WinFrmUI.Assets.Core/10-exchanger/06-prop/EditExchangerPartPropDlg.cs +++ b/WinFrmUI/HStation.WinFrmUI.Assets.Core/10-exchanger/06-prop/EditPackagePartPropDlg.cs @@ -1,4 +1,6 @@ -锘縩amespace HStation.WinFrmUI.Assets +锘縰sing HStation.WinFrmUI.Assets; + +namespace HStation.WinFrmUI { public partial class EditExchangerPartPropDlg : DevExpress.XtraEditors.XtraForm { @@ -7,55 +9,66 @@ InitializeComponent(); this.gridView1.Columns["PropGroupName"].Group(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; - this.ExchangerProductListBox1.MouseUp += ExchangerProductListBox1_MouseUp; + this.exchangerProductListBox1.MouseUp += exchangerProductListBox1_MouseUp; } - private BLL.AssetsExchangerPartMain _bll = null; - private List<PropGroupChoiceViewModel> _proplist = null; + #region Private - private List<CurrentPartMainViewModel> _allBindingList = new List<CurrentPartMainViewModel>(); + private BLL.AssetsExchangerPartMain _bll; + private List<HStation.WinFrmUI.Assets.ExchangerPropChoiceViewModel> _propList; - private Vmo.AssetsExchangerMainAndPartMapVmo _partmap = null; + private Vmo.AssetsExchangerMainAndPartMappingVmo _partMapping; - private Vmo.AssetsExchangerPartMainVmo _ExchangerPart = null; + private Vmo.AssetsExchangerMainVmo _ExchangerMain; + + private Vmo.AssetsExchangerPartMainVmo _ExchangerPart; private long _catalogID; //鍒嗙被ID - private long _seriesID; //绯诲垪ID + private Vmo.AssetsExchangerSeriesVmo _series; //绯诲垪ID - private List<Vmo.AssetsExchangerPropContentVmo> _allPropList = null; + private List<Vmo.AssetsExchangerPropContentVmo> _allPropList; + + private Yw.BLL.SysPropMapping _sysPropMapping; + + #endregion Private //鍥炶皟浜嬩欢 - public event Func<Vmo.AssetsExchangerPartMainVmo, List<Vmo.AssetsExchangerPropContentVmo>, Vmo.AssetsExchangerMainAndPartMapVmo, Task<bool>> ReloadEvent; + public event Func<Vmo.AssetsExchangerPartMainVmo, List<Vmo.AssetsExchangerPropContentVmo>, Vmo.AssetsExchangerMainAndPartMappingVmo, Task<bool>> ReloadEvent; //鏁版嵁缁戝畾 public async void SetBindingData(Vmo.AssetsExchangerMainVmo AssetsExchangerMain) { - this.ExchangerProductListBox1.SetBindingData(AssetsExchangerMain); - this.ExchangerProductListBox1.SelectReloadEvent += () => + this.exchangerProductListBox1.SetBindingData(AssetsExchangerMain); + _ExchangerMain = AssetsExchangerMain; + this.exchangerProductListBox1.SelectReloadEvent += () => { ListBoxPart_SelectedIndexChanged(); }; - this.ExchangerProductListBox1.AddReloadEvent += () => + this.exchangerProductListBox1.AddReloadEvent += () => { BarBtnAddExchangerPart_ItemClick(); }; + this.exchangerProductListBox1.DeleteReloadEvent += () => + { + BarBtnDeletePart_ItemClick(); + }; _bll = new BLL.AssetsExchangerPartMain(); var allpartlist = await _bll.GetByExchangerMainID(AssetsExchangerMain.ID); //鑾峰彇鎵�鏈変骇鍝� - /* var series = await new BLL.AssetsExchangerSeries().GetByID(AssetsExchangerMain.ExchangerSeriesID); //鑾峰彇绯诲垪 - _ExchangerPart = new Vmo.AssetsExchangerPartMainVmo(); - _series = series.ID; - _ExchangerPart.SeriesID = _series; - _catalogID = series.CatalogID; - _propList = new List<PropGroupChoiceViewModel>(); - _partMapping = new Vmo.AssetsExchangerMainAndPartMapVmo(); - _partMapping.ExchangerID = AssetsExchangerMain.ID; - _partMapping.SeriesID = _series;*/ - this.propGroupChoiceViewModelBindingSource.DataSource = _proplist; + var series = await new BLL.AssetsExchangerSeries().GetByID(AssetsExchangerMain.SeriesID); //鑾峰彇绯诲垪 + _ExchangerPart = new Vmo.AssetsExchangerPartMainVmo(); + _series = series; + _ExchangerPart.SeriesID = _series.ID; + _catalogID = _series.CatalogID; + _propList = new List<HStation.WinFrmUI.Assets.ExchangerPropChoiceViewModel>(); + _partMapping = new Vmo.AssetsExchangerMainAndPartMappingVmo(); + _partMapping.MainID = AssetsExchangerMain.ID; + _partMapping.SeriesID = _series.ID; + this.propGroupChoiceViewModelBindingSource.DataSource = _propList; this.propGroupChoiceViewModelBindingSource.ResetBindings(false); } - //鍒嗙被閫夋嫨鍙樻崲 + //閫夋嫨鍙樻崲 private async void SetPropSelectedValue(ExchangerPartViewModel partmain) { layoutControAddPart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; @@ -64,7 +77,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) @@ -72,20 +85,25 @@ 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 }); + _propList.Add(new ExchangerPropChoiceViewModel() + { + PropGroupName = item.Name, + PropName = prop.Name, + ID = prop.ID, + TagName = prop.Code + }); } } var propbll = new BLL.AssetsExchangerPartPropContent(); - var alllist = await propbll.GetByExchangerPartID(model.ID); - _allPropList = alllist; - foreach (var item in alllist) + _allPropList = await propbll.GetByExchangerPartID(model.ID); + foreach (var item in _allPropList) { - var selectProp = _proplist.Find(x => x.ID == item.PropID); + var selectProp = _propList.Find(x => x.ID == item.PropID); if (selectProp != null) { selectProp.Value = item.PropValue; @@ -98,7 +116,7 @@ //浜у搧鍒楄〃鑱氱劍鏀瑰彉 private void ListBoxPart_SelectedIndexChanged() { - var vm = this.ExchangerProductListBox1.GetCurrentVm(); + var vm = this.exchangerProductListBox1.GetCurrentVm(); if (vm == null) return; SetPropSelectedValue(vm); @@ -107,7 +125,7 @@ //纭缂栬緫 private async void BtnOk_Click(object sender, EventArgs e) { - var vm = this.ExchangerProductListBox1.GetCurrentVm(); + var vm = this.exchangerProductListBox1.GetCurrentVm(); if (vm == null) return; var updatepart = new Vmo.AssetsExchangerPartMainVmo(); @@ -115,9 +133,8 @@ updatepart.Name = TextEditProductName.Text; updatepart.NO = TextEditNo.Text; updatepart.Code = TextEditProductCode.Text; - updatepart.SeriesID = _seriesID; - var updateproplist = new List<UpdateAssetsExchangerPropContentInput>(); - foreach (var item in _proplist) + updatepart.SeriesID = _series.ID; + foreach (var item in _propList) { if (_allPropList != null) { @@ -130,14 +147,23 @@ } else { - _allPropList.Add(new Vmo.AssetsExchangerPropContentVmo() { SeriesID = _allPropList.First().SeriesID, PartID = _allPropList.First().PartID, PropID = item.ID, PropValue = item.Value }); + _allPropList.Add(new Vmo.AssetsExchangerPropContentVmo() + { + SeriesID = _allPropList.First().SeriesID, + PartID = _allPropList.First().PartID, + PropID = item.ID, + PropValue = item.Value, + TagName = item.TagName + }); } } } + var ExchangerMainBll = new BLL.AssetsExchangerMain(); + await ExchangerMainBll.Update(_ExchangerMain); if (await _bll.UpdateEx(updatepart, _allPropList)) { vm.Reset(updatepart); - this.ExchangerProductListBox1.Refresh(); + this.exchangerProductListBox1.Refresh(); TipFormHelper.ShowSucceed("淇敼鎴愬姛!"); } else @@ -149,15 +175,16 @@ } //宸︿晶鏍戝彸鍑昏彍鍗曚簨浠� - private void ExchangerProductListBox1_MouseUp(object sender, MouseEventArgs e) + private void exchangerProductListBox1_MouseUp(object sender, MouseEventArgs e) { - /* if (e.Button == MouseButtons.Right) - { - Point screenPoint = Cursor.Position; - popupExchangerPartMenu.ShowPopup(screenPoint); - }*/ + if (e.Button == MouseButtons.Right) + { + Point screenPoint = Cursor.Position; + popupExchangerPartMenu.ShowPopup(screenPoint); + } } + //鏁版嵁楠岃瘉 private bool Vaild() { this.dxErrorProvider1.ClearErrors(); @@ -178,16 +205,22 @@ _ExchangerPart.NO = TextEditNo.Text; _ExchangerPart.Code = TextEditProductCode.Text; var AssetsExchangerPropContent = new List<Vmo.AssetsExchangerPropContentVmo>(); - foreach (var item in _proplist) + foreach (var item in _propList) { - AssetsExchangerPropContent.Add(new Vmo.AssetsExchangerPropContentVmo { PropID = item.ID, PropValue = item.Value, SeriesID = _ExchangerPart.SeriesID }); + AssetsExchangerPropContent.Add(new Vmo.AssetsExchangerPropContentVmo + { + PropID = item.ID, + PropValue = item.Value, + SeriesID = _ExchangerPart.SeriesID, + TagName = item.TagName + }); } - var id = await _bll.InsertEx(_ExchangerPart, AssetsExchangerPropContent, _partmap); + var id = await _bll.InsertEx(_ExchangerPart, AssetsExchangerPropContent, _partMapping); if (id > 0) { var Exchangerpart = await _bll.GetByID(id); - this.ExchangerProductListBox1._allBindingList.Add(new ExchangerPartViewModel(Exchangerpart)); - this.ExchangerProductListBox1.Refresh(); + this.exchangerProductListBox1._allBindingList.Add(new ExchangerPartViewModel(Exchangerpart)); + this.exchangerProductListBox1.Refresh(); TipFormHelper.ShowSucceed("娣诲姞鎴愬姛!"); } else @@ -204,9 +237,9 @@ private async void BarBtnAddExchangerPart_ItemClick() { layoutControAddPart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; - TextEditProductName.Text = string.Empty; - TextEditNo.Text = string.Empty; - TextEditProductCode.Text = string.Empty; + this.TextEditProductName.Text = string.Empty; + this.TextEditNo.Text = string.Empty; + this.TextEditProductCode.Text = string.Empty; var bll = new Yw.BLL.SysPropStruct(); try { @@ -216,12 +249,19 @@ 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 ExchangerPropChoiceViewModel() + { + PropGroupName = item.Name, + PropName = prop.Name, + ID = prop.ID, + Value = prop.DefaultValue, + TagName = prop.Code + }); } } this.propGroupChoiceViewModelBindingSource.ResetBindings(false); @@ -233,23 +273,27 @@ // 灏濊瘯鏀瑰彉鐒︾偣浠ヨЕ鍙戞帶浠舵洿鏂� this.TextEditProductName.Focus(); // this.TextEditProductName.SelectAll(); - this.TextEditNo.Properties.NullText = "鍦ㄦ杈撳叆浜у搧缂栧彿"; this.TextEditProductCode.Properties.NullText = "鍦ㄦ杈撳叆浜у搧鍥惧彿"; } // 鍒犻櫎浜у搧 - private async void BarBtnDeletePart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + private async void BarBtnDeletePart_ItemClick() { - var vm = this.ExchangerProductListBox1.GetCurrentVm(); + var vm = this.exchangerProductListBox1.GetCurrentVm(); if (vm == null) return; if (!MessageBoxHelper.IsClickOk("纭畾鍒犻櫎鏁版嵁琛�")) { if (await _bll.DeleteEx(vm.ID)) { - this.ExchangerProductListBox1._allBindingList.Remove(vm); - this.ExchangerProductListBox1.Refresh(); + this.exchangerProductListBox1._allBindingList.Remove(vm); + this.exchangerProductListBox1.Refresh(); + this._propList.Clear(); + this.propGroupChoiceViewModelBindingSource.ResetBindings(false); + this.TextEditProductName.Text = string.Empty; + this.TextEditNo.Text = string.Empty; + this.TextEditProductCode.Text = string.Empty; MessageBoxHelper.ShowSuccess("鍒犻櫎鎴愬姛!"); } else -- Gitblit v1.9.3