ÎļþÃû´Ó WinFrmUI/HStation.WinFrmUI.Assets.Core/11-compressor/02-main/01-EditPumpPartProp/EditExchangerPartPropDlg.cs ÐÞ¸Ä |
| | |
| | | namespace HStation.WinFrmUI.Assets |
| | | using HStation.WinFrmUI.Assets; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class EditCompressorPartPropDlg : DevExpress.XtraEditors.XtraForm |
| | | { |
| | |
| | | this.CompressorProductListBox1.MouseUp += CompressorProductListBox1_MouseUp; |
| | | } |
| | | |
| | | private BLL.AssetsCompressorPartMain _bll = null; |
| | | private List<PropGroupChoiceViewModel> _proplist = null; |
| | | #region Private |
| | | |
| | | private List<CurrentPartMainViewModel> _allBindingList = new List<CurrentPartMainViewModel>(); |
| | | private BLL.AssetsCompressorPartMain _bll; |
| | | private List<HStation.WinFrmUI.Assets.CompressorPropChoiceViewModel> _propList; |
| | | |
| | | private Vmo.AssetsCompressorMainAndPartMapVmo _partmap = null; |
| | | private Vmo.AssetsCompressorMainAndPartMappingVmo _partMapping; |
| | | |
| | | private Vmo.AssetsCompressorPartMainVmo _CompressorPart = null; |
| | | private Vmo.AssetsCompressorMainVmo _CompressorMain; |
| | | |
| | | private Vmo.AssetsCompressorPartMainVmo _CompressorPart; |
| | | |
| | | private long _catalogID; //åç±»ID |
| | | |
| | | private long _seriesID; //ç³»åID |
| | | private Vmo.AssetsCompressorSeriesVmo _series; //ç³»åID |
| | | |
| | | private List<Vmo.AssetsCompressorPropContentVmo> _allPropList = null; |
| | | private List<Vmo.AssetsCompressorPropContentVmo> _allPropList; |
| | | |
| | | private Yw.BLL.SysPropMapping _sysPropMapping; |
| | | |
| | | #endregion Private |
| | | |
| | | //åè°äºä»¶ |
| | | public event Func<Vmo.AssetsCompressorPartMainVmo, List<Vmo.AssetsCompressorPropContentVmo>, Vmo.AssetsCompressorMainAndPartMapVmo, Task<bool>> ReloadEvent; |
| | | public event Func<Vmo.AssetsCompressorPartMainVmo, List<Vmo.AssetsCompressorPropContentVmo>, Vmo.AssetsCompressorMainAndPartMappingVmo, Task<bool>> ReloadEvent; |
| | | |
| | | //æ°æ®ç»å® |
| | | public async void SetBindingData(Vmo.AssetsCompressorMainVmo AssetsCompressorMain) |
| | | { |
| | | this.CompressorProductListBox1.SetBindingData(AssetsCompressorMain); |
| | | _CompressorMain = AssetsCompressorMain; |
| | | this.CompressorProductListBox1.SelectReloadEvent += () => |
| | | { |
| | | ListBoxPart_SelectedIndexChanged(); |
| | |
| | | { |
| | | BarBtnAddCompressorPart_ItemClick(); |
| | | }; |
| | | this.CompressorProductListBox1.DeleteReloadEvent += () => |
| | | { |
| | | BarBtnDeletePart_ItemClick(); |
| | | }; |
| | | _bll = new BLL.AssetsCompressorPartMain(); |
| | | var allpartlist = await _bll.GetByCompressorMainID(AssetsCompressorMain.ID); //è·åææäº§å |
| | | /* var series = await new BLL.AssetsCompressorSeries().GetByID(AssetsCompressorMain.CompressorSeriesID); //è·åç³»å |
| | | _CompressorPart = new Vmo.AssetsCompressorPartMainVmo(); |
| | | _series = series.ID; |
| | | _CompressorPart.SeriesID = _series; |
| | | _catalogID = series.CatalogID; |
| | | _propList = new List<PropGroupChoiceViewModel>(); |
| | | _partMapping = new Vmo.AssetsCompressorMainAndPartMapVmo(); |
| | | _partMapping.CompressorID = AssetsCompressorMain.ID; |
| | | _partMapping.SeriesID = _series;*/ |
| | | this.propGroupChoiceViewModelBindingSource.DataSource = _proplist; |
| | | this.propGroupChoiceViewModelBindingSource.ResetBindings(false); |
| | | var series = await new BLL.AssetsCompressorSeries().GetByID(AssetsCompressorMain.SeriesID); //è·åç³»å |
| | | _CompressorPart = new Vmo.AssetsCompressorPartMainVmo(); |
| | | _series = series; |
| | | _CompressorPart.SeriesID = _series.ID; |
| | | _catalogID = _series.CatalogID; |
| | | _propList = new List<HStation.WinFrmUI.Assets.CompressorPropChoiceViewModel>(); |
| | | _partMapping = new Vmo.AssetsCompressorMainAndPartMappingVmo(); |
| | | _partMapping.MainID = AssetsCompressorMain.ID; |
| | | _partMapping.SeriesID = _series.ID; |
| | | this.compressorPropChoiceViewModelBindingSource.DataSource = _propList; |
| | | this.compressorPropChoiceViewModelBindingSource.ResetBindings(false); |
| | | } |
| | | |
| | | //åç±»éæ©åæ¢ |
| | | //鿩忢 |
| | | private async void SetPropSelectedValue(CompressorPartViewModel partmain) |
| | | { |
| | | layoutControAddPart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | |
| | | 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) |
| | | { |
| | | this.propGroupChoiceViewModelBindingSource.ResetBindings(false); |
| | | this.compressorPropChoiceViewModelBindingSource.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 CompressorPropChoiceViewModel() |
| | | { |
| | | PropGroupName = item.Name, |
| | | PropName = prop.Name, |
| | | ID = prop.ID, |
| | | TagName = prop.Code |
| | | }); |
| | | } |
| | | } |
| | | var propbll = new BLL.AssetsCompressorPartPropContent(); |
| | | var alllist = await propbll.GetByCompressorPartID(model.ID); |
| | | _allPropList = alllist; |
| | | foreach (var item in alllist) |
| | | _allPropList = await propbll.GetByCompressorPartID(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; |
| | | } |
| | | } |
| | | this.propGroupChoiceViewModelBindingSource.ResetBindings(false); |
| | | this.compressorPropChoiceViewModelBindingSource.ResetBindings(false); |
| | | this.gridView1.ExpandAllGroups(); |
| | | } |
| | | |
| | |
| | | updatepart.Name = TextEditProductName.Text; |
| | | updatepart.NO = TextEditNo.Text; |
| | | updatepart.Code = TextEditProductCode.Text; |
| | | updatepart.SeriesID = _seriesID; |
| | | var updateproplist = new List<UpdateAssetsCompressorPropContentInput>(); |
| | | foreach (var item in _proplist) |
| | | updatepart.SeriesID = _series.ID; |
| | | foreach (var item in _propList) |
| | | { |
| | | if (_allPropList != null) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | _allPropList.Add(new Vmo.AssetsCompressorPropContentVmo() { SeriesID = _allPropList.First().SeriesID, PartID = _allPropList.First().PartID, PropID = item.ID, PropValue = item.Value }); |
| | | _allPropList.Add(new Vmo.AssetsCompressorPropContentVmo() |
| | | { |
| | | SeriesID = _allPropList.First().SeriesID, |
| | | PartID = _allPropList.First().PartID, |
| | | PropID = item.ID, |
| | | PropValue = item.Value, |
| | | TagName = item.TagName |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | var CompressorMainBll = new BLL.AssetsCompressorMain(); |
| | | await CompressorMainBll.Update(_CompressorMain); |
| | | if (await _bll.UpdateEx(updatepart, _allPropList)) |
| | | { |
| | | vm.Reset(updatepart); |
| | |
| | | //左侧æ å³å»èåäºä»¶ |
| | | private void CompressorProductListBox1_MouseUp(object sender, MouseEventArgs e) |
| | | { |
| | | /* if (e.Button == MouseButtons.Right) |
| | | { |
| | | Point screenPoint = Cursor.Position; |
| | | popupCompressorPartMenu.ShowPopup(screenPoint); |
| | | }*/ |
| | | if (e.Button == MouseButtons.Right) |
| | | { |
| | | Point screenPoint = Cursor.Position; |
| | | popupCompressorPartMenu.ShowPopup(screenPoint); |
| | | } |
| | | } |
| | | |
| | | //æ°æ®éªè¯ |
| | | private bool Vaild() |
| | | { |
| | | this.dxErrorProvider1.ClearErrors(); |
| | |
| | | _CompressorPart.NO = TextEditNo.Text; |
| | | _CompressorPart.Code = TextEditProductCode.Text; |
| | | var AssetsCompressorPropContent = new List<Vmo.AssetsCompressorPropContentVmo>(); |
| | | foreach (var item in _proplist) |
| | | foreach (var item in _propList) |
| | | { |
| | | AssetsCompressorPropContent.Add(new Vmo.AssetsCompressorPropContentVmo { PropID = item.ID, PropValue = item.Value, SeriesID = _CompressorPart.SeriesID }); |
| | | AssetsCompressorPropContent.Add(new Vmo.AssetsCompressorPropContentVmo |
| | | { |
| | | PropID = item.ID, |
| | | PropValue = item.Value, |
| | | SeriesID = _CompressorPart.SeriesID, |
| | | TagName = item.TagName |
| | | }); |
| | | } |
| | | var id = await _bll.InsertEx(_CompressorPart, AssetsCompressorPropContent, _partmap); |
| | | var id = await _bll.InsertEx(_CompressorPart, AssetsCompressorPropContent, _partMapping); |
| | | if (id > 0) |
| | | { |
| | | var Compressorpart = await _bll.GetByID(id); |
| | |
| | | private async void BarBtnAddCompressorPart_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 |
| | | { |
| | | var catlog = await bll.GetByCatalogID(_catalogID); |
| | | if (catlog == null) |
| | | { |
| | | this.propGroupChoiceViewModelBindingSource.ResetBindings(false); |
| | | this.compressorPropChoiceViewModelBindingSource.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 CompressorPropChoiceViewModel() |
| | | { |
| | | PropGroupName = item.Name, |
| | | PropName = prop.Name, |
| | | ID = prop.ID, |
| | | Value = prop.DefaultValue, |
| | | TagName = prop.Code |
| | | }); |
| | | } |
| | | } |
| | | this.propGroupChoiceViewModelBindingSource.ResetBindings(false); |
| | | this.compressorPropChoiceViewModelBindingSource.ResetBindings(false); |
| | | } |
| | | catch |
| | | { |
| | |
| | | // å°è¯æ¹åç¦ç¹ä»¥è§¦åæ§ä»¶æ´æ° |
| | | 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.CompressorProductListBox1.GetCurrentVm(); |
| | | if (vm == null) |
| | |
| | | { |
| | | this.CompressorProductListBox1._allBindingList.Remove(vm); |
| | | this.CompressorProductListBox1.Refresh(); |
| | | this._propList.Clear(); |
| | | this.compressorPropChoiceViewModelBindingSource.ResetBindings(false); |
| | | this.TextEditProductName.Text = string.Empty; |
| | | this.TextEditNo.Text = string.Empty; |
| | | this.TextEditProductCode.Text = string.Empty; |
| | | MessageBoxHelper.ShowSuccess("å 餿å!"); |
| | | } |
| | | else |