using DevExpress.XtraRichEdit.API.Native; namespace HStation.WinFrmUI.Xhs { public partial class PumpMainChoicePage : DevExpress.XtraEditors.XtraUserControl, IWizardPage { public PumpMainChoicePage() { InitializeComponent(); } private BLL.PumpSeries _seriesBll = null; private BLL.PumpGroup _groupBll = null; private BLL.PumpMain _pumpBll = null; private BLL.PumpGroupAndMainMap _groupMapBll = null; /// /// 初始化 /// public async void InitialPage(PumpMainChoiceViewModel t) { _seriesBll = new BLL.PumpSeries(); _groupBll = new BLL.PumpGroup(); _pumpBll = new BLL.PumpMain(); _groupMapBll = new BLL.PumpGroupAndMainMap(); PageStateChangedEvent.Invoke(); } /// /// 允许上一步 /// public bool AllowPrev { get { return false; } } /// /// 允许下一步 /// public bool AllowNext { get { return true; } } /// /// 允许取消 /// public bool AllowCancel { get { return true; } } /// /// 允许完成 /// public bool AllowComplete { get { return false; } } public event Action PageStateChangedEvent; public bool CanCancel() { return true; } public bool CanComplete() { return false; } public bool CanNext() { return true; } public bool CanPrev() { return false; } private List _allBindingList = null; //根据泵型号模糊查询(树显示) private async void simpleLabelSearch_Click(object sender, EventArgs e) { TextPopupPumpChoice.Properties.PopupControl = popupContainerControl1; _allBindingList = new List(); var allSeries = await _seriesBll.GetAll(); var allGroup = await _groupBll.GetAll(); var allPumpMain = await _pumpBll.GetAll(); var allGroupMap = await _groupMapBll.GetAll(); if (TextPopupPumpChoice.EditValue == null) { return; } //泵型号 foreach (var item in allPumpMain) { if (item.Name.Contains(this.TextPopupPumpChoice.Text.Trim())) { var groupMap = allGroupMap.Find(x => x.PumpMainID == item.ID); if (groupMap != null) { var group = allGroup.Find(x => x.ID == groupMap.PumpGroupID); if (group != null) { var series = allSeries.Find(x => x.ID == group.PumpSeriesID); if (series != null) { if (_allBindingList.Find(x => x.ID == series.ID) == null) { _allBindingList.Add(new PumpMainChoieViewModel(series)); } if (_allBindingList.Find(x => x.ID == group.ID) == null) { _allBindingList.Add(new PumpMainChoieViewModel(item, group.ID)); } _allBindingList.Add(new PumpMainChoieViewModel(group)); } } } else { var series = allSeries.Find(x => x.ID == item.PumpSeriesID); if (series != null) { if (_allBindingList.Find(x => x.ID == series.ID) == null) { _allBindingList.Add(new PumpMainChoieViewModel(series)); } _allBindingList.Add(new PumpMainChoieViewModel(item)); } } } } this.treeList1.DataSource = _allBindingList; TextPopupPumpChoice.ShowPopup(); } //模糊查询(表格显示) private void simpleLabelItemVagueSearch_Click(object sender, EventArgs e) { TextPopupPumpChoice.Properties.PopupControl = popupContainerControl2; TextPopupPumpChoice.ShowPopup(); } //选择项变换 private async void treeList1_SelectionChanged(object sender, EventArgs e) { var vm = this.treeList1.GetCurrentViewModel(_allBindingList); if (vm != null) { if (!vm.IsPump) { return; } var model = await _pumpBll.GetByID(vm.ID); if (model == null) return; pumpMainForm1.SetBindingData(model); } //treeList1.CloseEditForm(); } private void BtnAddPumpMain_Click(object sender, EventArgs e) { var dlg = new AddPumpMainDlg(); dlg.ShowDialog(); } } }