| | |
| | | using DevExpress.XtraEditors; |
| | | using HStation.Vmo; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using Yw; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | |
| | | this.PageTitle.Caption = "水头损失曲线"; |
| | | this.PageTitle.HeaderSvgImage = AssetsMainSvgImageHelper.Curve; |
| | | this.PageTitle.SvgImageSize = new Size(24, 24); |
| | | this.phartDiagramRelationListCtrl1.SelectedChangedEvent += PhartDiagramRelationListCtrl1_SelectedChangedEvent; |
| | | } |
| | | |
| | | private AssetsExchangerMainVmo _vmo = null; |
| | | private List<PhartDiagramRelationVmo> _allBindingList = null; |
| | | private PhartDiagramRelationVmo _relation = null; |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// |
| | | /// </summary> |
| | | public void SetBindingData(AssetsExchangerMainVmo vmo) |
| | | public async void SetBindingData(AssetsExchangerMainVmo vmo) |
| | | { |
| | | if (vmo == null) |
| | | { |
| | |
| | | } |
| | | _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.ExchangerMain, vmo.ID); |
| | | allList?.ForEach(x => _allBindingList.Add(x)); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | } |
| | | |
| | | //excel |
| | | private void Excel() |
| | | { |
| | | if (_vmo == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new ImportAssetsExchangerCurveQLByExcelDlg(); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | _allBindingList.Add(rhs); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | }; |
| | | dlg.SetBindingData(_vmo); |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //图片 |
| | | private void Picture() |
| | | { |
| | | if (_vmo == null) |
| | | { |
| | | return; |
| | | } |
| | | var vm = GetCurrentViewModel(); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new ImportAssetsExchangerCurveQLByPictureDlg(); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | _allBindingList.Add(rhs); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | }; |
| | | dlg.SetBindingData(_vmo); |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //基本信息 |
| | | private void Info() |
| | | { |
| | | var vm = GetCurrentViewModel(); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new EditPhartDiagramRelationDlg(); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | var item = _allBindingList?.Find(x => x.ID == rhs.ID); |
| | | if (item == null) |
| | | { |
| | | return; |
| | | } |
| | | item.Reset(rhs); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | }; |
| | | dlg.SetBindingData(vm); |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //曲线 |
| | | private async void Curve() |
| | | { |
| | | var vm = GetCurrentViewModel(); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var vmo = await BLLFactory<Yw.BLL.PhartDiagramExtensions>.Instance.GetByID(vm.DiagramID); |
| | | var dlg = new EditAssetsExchangerCurveQLDlg(); |
| | | dlg.ReloadDataEvent += (rhs) => |
| | | { |
| | | this.universalChartViewCtrl1.SetBindingData(rhs); |
| | | }; |
| | | dlg.SetBindingData(vmo); |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //删除 |
| | | private async void Delete() |
| | | { |
| | | 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.universalChartViewCtrl1.ClearBindingData(); |
| | | this.phartDiagramRelationListCtrl1.SetBindingData(_allBindingList); |
| | | TipFormHelper.ShowSucceed("删除成功!"); |
| | | } |
| | | |
| | | #region 当前 |
| | | |
| | | //获取当前 |
| | | 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; |
| | | } |
| | | |
| | | #endregion 当前 |
| | | |
| | | //Excel导入 |
| | | private void barBtnImportByExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | Excel(); |
| | | } |
| | | |
| | | //图片导入 |
| | | private void barBtnImportByPicture_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | Picture(); |
| | | } |
| | | |
| | | //基本信息 |
| | | private void barBtnInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | Info(); |
| | | } |
| | | |
| | | //曲线 |
| | | private void barBtnCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | Curve(); |
| | | } |
| | | |
| | | //删除 |
| | | private void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | Delete(); |
| | | } |
| | | |
| | | //选择改变 |
| | | private void PhartDiagramRelationListCtrl1_SelectedChangedEvent(PhartDiagramRelationVmo obj) |
| | | { |
| | | _relation = obj; |
| | | LoadPhart(_relation); |
| | | } |
| | | |
| | | //加载图表 |
| | | private async void LoadPhart(PhartDiagramRelationVmo relation) |
| | | { |
| | | if (relation == null) |
| | | { |
| | | this.universalChartViewCtrl1.SetBindingData(null); |
| | | return; |
| | | } |
| | | var vmo = await BLLFactory<Yw.BLL.PhartDiagramExtensions>.Instance.GetByID(relation.DiagramID); |
| | | this.universalChartViewCtrl1.SetBindingData(vmo); |
| | | } |
| | | } |
| | | } |
| | | } |