| | |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraLayout.Utils; |
| | | |
| | | namespace HStation.WinFrmUI.Xhs |
| | | { |
| | |
| | | InitializeComponent(); |
| | | } |
| | | |
| | | private List<PumpMainChoieViewModel> _allBindingList = null; |
| | | private readonly PumpMainChoiceViewModel _vm = new(); |
| | | |
| | | private BLL.PumpSeries _seriesBll = new BLL.PumpSeries(); |
| | | private PumpMainChoiceManager _wizard; |
| | | |
| | | private BLL.PumpGroup _groupBll = new BLL.PumpGroup(); |
| | | |
| | | private BLL.PumpMain _pumpBll = new BLL.PumpMain(); |
| | | |
| | | private BLL.PumpGroupAndMainMap _groupMapBll = new BLL.PumpGroupAndMainMap(); |
| | | |
| | | //模糊查询文字输入 |
| | | private async void TextPopupPumpChoice_EditValueChanged(object sender, EventArgs e) |
| | | public void SetBindingData() |
| | | { |
| | | _wizard = new PumpMainChoiceManager(_vm); |
| | | _wizard.SelectedPageChangedEvent += _wizard_SelectedPageChangedEvent; |
| | | _wizard.SelectedPageStateChangedEvent += _wizard_SelectedPageStateChangedEvent; ; |
| | | _wizard.InitialManager(new IWizardPage<PumpMainChoiceViewModel>[] { |
| | | this.pumpMainChoicePage, |
| | | this.ValveChoicePage |
| | | }); |
| | | } |
| | | |
| | | //根据泵型号模糊查询 |
| | | private async void simpleLabelSearch_Click(object sender, EventArgs e) |
| | | //选择页面改变 |
| | | private void _wizard_SelectedPageChangedEvent(IWizardPage<PumpMainChoiceViewModel> page, int index) |
| | | { |
| | | _allBindingList = new List<PumpMainChoieViewModel>(); |
| | | var allSeries = await _seriesBll.GetAll(); |
| | | var allGroup = await _groupBll.GetAll(); |
| | | var allPumpMain = await _pumpBll.GetAll(); |
| | | var allGroupMap = await _groupMapBll.GetAll(); |
| | | if (TextPopupPumpChoice.EditValue == null) |
| | | this.navigationFrame1.SelectedPageIndex = index; |
| | | this.stepProgressBar1.SelectedItemIndex = index; |
| | | } |
| | | |
| | | //选择页面状态改变 |
| | | private void _wizard_SelectedPageStateChangedEvent(IWizardPage<PumpMainChoiceViewModel> page, int index) |
| | | { |
| | | this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never; |
| | | this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never; |
| | | this.itemForCancel.Visibility = page.AllowCancel ? LayoutVisibility.Always : LayoutVisibility.Never; |
| | | this.itemForComplete.Visibility = page.AllowComplete ? LayoutVisibility.Always : LayoutVisibility.Never; |
| | | } |
| | | |
| | | //上一步 |
| | | private void btnPrev_Click(object sender, EventArgs e) |
| | | { |
| | | if (_wizard != null) |
| | | { |
| | | return; |
| | | _wizard.Prev(); |
| | | } |
| | | //泵型号 |
| | | foreach (var item in allPumpMain) |
| | | } |
| | | |
| | | //下一步 |
| | | private void btnNext_Click(object sender, EventArgs e) |
| | | { |
| | | if (_wizard != null) |
| | | { |
| | | if (item.Name.Contains(this.TextPopupPumpChoice.Text.Trim())) |
| | | _wizard.Next(); |
| | | } |
| | | } |
| | | |
| | | //取消 |
| | | private void btnCancel_Click(object sender, EventArgs e) |
| | | { |
| | | if (_wizard != null) |
| | | { |
| | | var bol = _wizard.Cancel(); |
| | | if (bol) |
| | | { |
| | | 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.DialogResult = DialogResult.Cancel; |
| | | this.Close(); |
| | | } |
| | | } |
| | | this.treeList1.DataSource = _allBindingList; |
| | | TextPopupPumpChoice.ShowPopup(); |
| | | // TextPopupPumpChoice.Focus(); |
| | | } |
| | | |
| | | //选择项变换 |
| | | private async void treeList1_SelectionChanged(object sender, EventArgs e) |
| | | //完成 |
| | | private void btnComplete_Click(object sender, EventArgs e) |
| | | { |
| | | var vm = this.treeList1.GetCurrentViewModel(_allBindingList); |
| | | if (vm != null) |
| | | if (_wizard != null) |
| | | { |
| | | if (!vm.IsPump) |
| | | var bol = _wizard.Complete(); |
| | | if (bol) |
| | | { |
| | | return; |
| | | this.DialogResult = DialogResult.OK; |
| | | this.Close(); |
| | | } |
| | | 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(); |
| | | } |
| | | } |
| | | } |