ÎļþÃû´Ó WinFrmUI/HStation.WinFrmUI.Assets.Core/10-exchanger/06-prop/EditExchangerPartPropDlg.cs ÐÞ¸Ä |
| | |
| | | namespace HStation.WinFrmUI.Assets |
| | | using HStation.WinFrmUI.Assets; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class EditExchangerPartPropDlg : DevExpress.XtraEditors.XtraForm |
| | | { |
| | |
| | | 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; |
| | |
| | | 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); |
| | | 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; |
| | |
| | | //产åå表èç¦æ¹å |
| | | private void ListBoxPart_SelectedIndexChanged() |
| | | { |
| | | var vm = this.ExchangerProductListBox1.GetCurrentVm(); |
| | | var vm = this.exchangerProductListBox1.GetCurrentVm(); |
| | | if (vm == null) |
| | | return; |
| | | SetPropSelectedValue(vm); |
| | |
| | | //确认ç¼è¾ |
| | | 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(); |
| | |
| | | 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) |
| | | { |
| | |
| | | } |
| | | 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 |
| | |
| | | } |
| | | |
| | | //左侧æ å³å»èåäºä»¶ |
| | | 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(); |
| | |
| | | _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 |
| | |
| | | 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 |
| | | { |
| | |
| | | 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); |
| | |
| | | // å°è¯æ¹åç¦ç¹ä»¥è§¦åæ§ä»¶æ´æ° |
| | | 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 |