| | |
| | | namespace HStation.WinFrmUI |
| | | using DevExpress.XtraEditors; |
| | | using HStation.Vmo; |
| | | using Yw; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class PumpChartMainPage : DocumentPage |
| | | { |
| | | public PumpChartMainPage() |
| | | { |
| | | InitializeComponent(); |
| | | this.phartDiagramRelationListCtrl1.SelectedChangedEvent += PhartDiagramRelationListCtrl1_SelectedChangedEvent; |
| | | } |
| | | |
| | | private AssetsPumpMainVmo _vmo; |
| | | |
| | | private List<PhartDiagramRelationVmo> _allBindingList; |
| | | private PhartDiagramRelationVmo _relation = null; |
| | | |
| | | public async void SetBindingData(AssetsPumpMainVmo vmo) |
| | | { |
| | | if (vmo == null) |
| | | { |
| | | return; |
| | | } |
| | | _vmo = vmo; |
| | | this.PageTitle.Caption = $"{vmo.Name}\r\n损失曲线"; |
| | | _allBindingList = new List<PhartDiagramRelationVmo>(); |
| | | var allList = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance |
| | | .GetByObjectTypeAndObjectID(HStation.Assets.DataType.PumpMain, vmo.ID); |
| | | allList?.ForEach(x => _allBindingList.Add(x)); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | } |
| | | |
| | | private async Task<bool> PumpChartViewCtrl1_DataChangedEvent(Yw.Vmo.PhartDiagramExGraphListVmo vmo) |
| | | { |
| | | var bol = await BLLFactory<Yw.BLL.PhartDiagramExtensions>.Instance.Update(vmo); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowError("更新失败!"); |
| | | } |
| | | else |
| | | { |
| | | TipFormHelper.ShowSucceed("更新成功!"); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | //选择改变 |
| | | private void PhartDiagramRelationListCtrl1_SelectedChangedEvent(PhartDiagramRelationVmo obj) |
| | | { |
| | | _relation = obj; |
| | | LoadPhart(_relation); |
| | | } |
| | | |
| | | //加载图表 |
| | | private async void LoadPhart(PhartDiagramRelationVmo relation) |
| | | { |
| | | if (relation == null) |
| | | { |
| | | this.pumpChartViewCtrl1.SetBindingData(null, default); |
| | | return; |
| | | } |
| | | var vmo = await BLLFactory<Yw.BLL.PhartDiagramExtensions>.Instance.GetByID(relation.DiagramID); |
| | | this.pumpChartViewCtrl1.SetBindingData(vmo, _vmo.RatedSpeed); |
| | | } |
| | | |
| | | //表格 |
| | | private void barBtnImportByExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var dlg = new ImportPumpPerform2dByExcelDlg(); |
| | | dlg.SetBindingData(); |
| | | dlg.ReloadDataEvent += async (rhs) => |
| | | dlg.SetBindingData(_vmo); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | _allBindingList.Add(rhs); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //图片 |
| | | private void barBtnImportByPicture_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var dlg = new ImportPumpPerform2dByImageDlg(); |
| | | dlg.SetBindingData(_vmo); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | var bll = new BLL.PhartDiagramRelation(); |
| | | var id = await bll.InsertEx(rhs); |
| | | if (id > 0) |
| | | { |
| | | return true; |
| | | } |
| | | return true; |
| | | _allBindingList.Add(rhs); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //单点 |
| | | private void barBtnImportByPoint_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var dlg = new ImportPumpChartPoint(); |
| | | dlg.SetBindingData(_vmo); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | _allBindingList.Add(rhs); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //编辑 |
| | | private void barBtnEditChart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | private async void barBtnEditChart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var vm = GetCurrentViewModel(); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var diagram = await BLLFactory<Yw.BLL.PhartDiagramExtensions>.Instance.GetByID(vm.DiagramID); |
| | | var dlg = new EditAssetsPumpPerform2dDlg(); |
| | | dlg.SetBindingData(diagram, _vmo); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | this.pumpChartViewCtrl1.SetBindingData(rhs, _vmo.RatedSpeed); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //别名 |
| | | private void barBtnOtherName_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_relation == null) |
| | | return; |
| | | var dlg = new SetPumpOtherNameDlg(); |
| | | dlg.SetBindingData(_relation.OtherName); |
| | | dlg.VerifyValueChanged += async (name) => |
| | | { |
| | | _relation.OtherName = name; |
| | | var bol = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance.Update(_relation); |
| | | if (bol) |
| | | { |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | return true; |
| | | } |
| | | return false; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //重要度 |
| | | private void barBtnUpdateimportance_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_relation == null) |
| | | return; |
| | | var dlg = new SetPumpImportanceDlg(); |
| | | dlg.SetBindingData(_relation.Importance); |
| | | dlg.VerifyValueChanged += async (Importance) => |
| | | { |
| | | _relation.Importance = Importance; |
| | | var bol = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance.Update(_relation); |
| | | if (bol) |
| | | { |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | return true; |
| | | } |
| | | return false; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //删除 |
| | | private void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | private async void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var vm = GetCurrentViewModel(); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var result = XtraMessageBox.Show("请问确认删除当前数据吗?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes; |
| | | if (!result) |
| | | { |
| | | return; |
| | | } |
| | | var bol = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance.DeleteByID(vm.ID); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowError("删除失败!"); |
| | | return; |
| | | } |
| | | _allBindingList.Remove(vm); |
| | | this.pumpChartViewCtrl1.ClearBindingData(); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | TipFormHelper.ShowSucceed("删除成功!"); |
| | | } |
| | | |
| | | //获取当前 |
| | | private PhartDiagramRelationVmo GetCurrentViewModel() |
| | | { |
| | | if (_allBindingList == null) |
| | | { |
| | | TipFormHelper.ShowError("数据初始化错误!"); |
| | | return null; |
| | | } |
| | | if (_allBindingList.Count < 1) |
| | | { |
| | | TipFormHelper.ShowInfo("无数据!"); |
| | | return null; |
| | | } |
| | | if (_relation == null) |
| | | { |
| | | TipFormHelper.ShowWarn("请选择数据行!"); |
| | | return null; |
| | | } |
| | | return _relation; |
| | | } |
| | | } |
| | | } |