| | |
| | | namespace HStation.WinFrmUI.PhartRelation |
| | | using DevExpress.XtraEditors; |
| | | using NetTaste; |
| | | using Yw.WinFrmUI.Phart; |
| | | |
| | | namespace HStation.WinFrmUI.PhartRelation |
| | | { |
| | | public partial class XhsValveMainPhartPanel : DocumentPage |
| | | { |
| | | public XhsValveMainPhartPanel() |
| | | { |
| | | InitializeComponent(); |
| | | this.PageTitle.Caption = "阀门型号曲线"; |
| | | this.PageTitle.Caption = "阀门损失系数曲线"; |
| | | |
| | | this.xhsValveMainPhartListCtrl1.FocusedChangedEvent += XhsValveMainPhartListCtrl1_FocusedChangedEvent; |
| | | } |
| | | |
| | | private long _valve_main_id; |
| | | private Vmo.XhsValveMainPhartMappingExtensions _xhs_phart_diagram_ex_std_dto = null; |
| | | private readonly BLL.XhsValveMainPhartMappingExtensions _bll_ex = new(); |
| | | private Vmo.AssetsValveCoefficientVmo _xhs_phart_diagram_ex_std_dto = null; |
| | | private readonly BLL.AssetsValveCoefficient _bll = new(); |
| | | |
| | | /// <summary> |
| | | /// 初始化数据 |
| | | /// </summary> |
| | | public void InitialDataSource(long valve_main_id) |
| | | public async void InitialDataSource(long valve_main_id) |
| | | { |
| | | _valve_main_id = valve_main_id; |
| | | if (_valve_main_id < 1) |
| | |
| | | this.xhsValveMainPhartListCtrl1.Clear(); |
| | | return; |
| | | } |
| | | this.xhsValveMainPhartListCtrl1.SetBindingData(valve_main_id); |
| | | //this.xhsValveMainPhartListCtrl1.SetBindingData(valve_main_id); |
| | | var chart = await new BLL.AssetsValveCoefficient().GetByMainID(valve_main_id); |
| | | if (chart.Count > 0) |
| | | { |
| | | _xhs_phart_diagram_ex_std_dto = chart.First(); |
| | | this.xtrPerform2dChart1.SetBindingData(_xhs_phart_diagram_ex_std_dto.MinorLossCurve); |
| | | } |
| | | this.xtrPerform2dChart1.SetAxisTitle("流量", "损失系数"); |
| | | } |
| | | |
| | | //选择曲线变换事件 |
| | | private void XhsValveMainPhartListCtrl1_FocusedChangedEvent(Vmo.XhsValveMainPhartMappingExtensions obj) |
| | | private void XhsValveMainPhartListCtrl1_FocusedChangedEvent(Vmo.AssetsValveCoefficientVmo obj) |
| | | { |
| | | _xhs_phart_diagram_ex_std_dto = obj; |
| | | InitChart(_xhs_phart_diagram_ex_std_dto); |
| | | this.xtrPerform2dChart1.SetBindingData(obj.MinorLossCurve); |
| | | // InitChart(_xhs_phart_diagram_ex_std_dto); |
| | | } |
| | | |
| | | |
| | | #region 图表 |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | var graph_ql = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.ValveQL); |
| | | var graph_ql = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.ValveOL); |
| | | if (graph_ql == null) |
| | | { |
| | | return; |
| | |
| | | List<Yw.Geometry.Point2d> points_ql = null; |
| | | points_ql = PhartPerformCurveHelper.GetFeatPointList(graph_ql.GraphType, graph_ql.GeometryInfo, 12, null); |
| | | |
| | | |
| | | var cubic_spline_ql = new Yw.Geometry.CubicSpline2d(points_ql); |
| | | |
| | | var disp_paras = diagram.DispParas; |
| | | var is_calc_disp_paras = string.IsNullOrWhiteSpace(disp_paras); |
| | | this.xtrPerform2dChart1.SetBindingData(cubic_spline_ql, disp_paras, is_calc_disp_paras); |
| | | this.xtrPerform2dChart1.SetBindingData(cubic_spline_ql.ToDbString(), disp_paras, is_calc_disp_paras); |
| | | } |
| | | |
| | | //清空图表数据 |
| | |
| | | //Excel 导入 |
| | | private void barBtnImportByExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | |
| | | var dlg = new Yw.WinFrmUI.Phart.ImportValvePerform2dByExcelDlg(); |
| | | dlg.ReloadDataEvent += async (other_name, ql) => |
| | | var dlg = new ImportValvePerform2dByExcelDlg(); |
| | | // dlg.SetBindingData("阀门开度", "压力损失系数"); |
| | | dlg.ReloadDataEvent += async (pt_list_json) => |
| | | { |
| | | var bol = await Import(other_name, ql); |
| | | var bol = await Import(pt_list_json); |
| | | return bol; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // 导入 |
| | | private async Task<bool> Import(string other_name, Yw.Geometry.CubicSpline2d ql) |
| | | private async Task<bool> Import(string pt_list_json) |
| | | { |
| | | if (_valve_main_id < 1) |
| | | { |
| | | XtraMessageBox.Show("ValveMain is null!"); |
| | | return false; |
| | | } |
| | | |
| | | var input = new Vmo.XhsValveMainPhartMappingExtensions(); |
| | | input.ValveMainID = _valve_main_id; |
| | | input.Importance = 0; |
| | | input.OtherName = other_name; |
| | | input.Diagram = new Vmo.PhartDiagramExGraphList() |
| | | { |
| | | DiagramType = HStation.PhartRelation.eDiagramType.Feat, |
| | | Name = other_name, |
| | | GraphList = new List<Vmo.PhartGraph>() |
| | | { |
| | | new () |
| | | { |
| | | Name = other_name, |
| | | GeometryStyle= HStation.PhartRelation.eGeometryStyle.FeatCurve, |
| | | GraphType= HStation.PhartRelation.eGraphType.ValveQL, |
| | | GeometryInfo=ql.ToDbString() |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | var mapping_id = await _bll_ex.Insert(input); |
| | | if (mapping_id < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var xhs_phart_diagram_ex_std_dto = await _bll_ex.GetByID(mapping_id); |
| | | this.xhsValveMainPhartListCtrl1.Add(xhs_phart_diagram_ex_std_dto); |
| | | return true; |
| | | var model = new Vmo.AssetsValveCoefficientVmo(); |
| | | model.MainID = _valve_main_id; |
| | | model.MinorLossCurve = pt_list_json; |
| | | this.xtrPerform2dChart1.SetBindingData(pt_list_json); |
| | | _xhs_phart_diagram_ex_std_dto = model; |
| | | return await _bll.Insert(model) > 0; |
| | | } |
| | | |
| | | #endregion 导入 |
| | | |
| | | |
| | | |
| | | #region 操作 |
| | | |
| | | //编辑 |
| | | private void barBtnEditChart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_xhs_phart_diagram_ex_std_dto == null) |
| | | { |
| | | return; |
| | | } |
| | | var diagram = _xhs_phart_diagram_ex_std_dto.Diagram; |
| | | if (diagram == null) |
| | | { |
| | | return; |
| | | } |
| | | var graph_list = diagram.GraphList; |
| | | if (graph_list == null || !graph_list.Any()) |
| | | { |
| | | return; |
| | | } |
| | | /* if (_xhs_phart_diagram_ex_std_dto == null) |
| | | { |
| | | return; |
| | | } |
| | | var diagram = _xhs_phart_diagram_ex_std_dto.Diagram; |
| | | if (diagram == null) |
| | | { |
| | | return; |
| | | } |
| | | var graph_list = diagram.GraphList; |
| | | if (graph_list == null || !graph_list.Any()) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var graph_ql = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.ValveQL); |
| | | var graph_ql = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.ValveOL); |
| | | |
| | | if (graph_ql == null) |
| | | { |
| | | return; |
| | | } |
| | | Yw.Geometry.CubicSpline2d ql = null; |
| | | List<Yw.Geometry.Point2d> points_ql = null; |
| | | points_ql = PhartPerformCurveHelper.GetFeatPointList(graph_ql.GraphType, graph_ql.GeometryInfo, 12, null); |
| | | ql = new Yw.Geometry.CubicSpline2d(points_ql); |
| | | if (graph_ql == null) |
| | | { |
| | | return; |
| | | } |
| | | Yw.Geometry.CubicSpline2d ql = null; |
| | | List<Yw.Geometry.Point2d> points_ql = null; |
| | | points_ql = PhartPerformCurveHelper.GetFeatPointList(graph_ql.GraphType, graph_ql.GeometryInfo, 12, null); |
| | | ql = new Yw.Geometry.CubicSpline2d(points_ql); |
| | | |
| | | |
| | | var dlg = new Yw.WinFrmUI.Phart.ValveEditDlg(); |
| | | dlg.SetBindingData(ql); |
| | | dlg.ReloadDataEvent += async (new_ql) => |
| | | { |
| | | graph_ql.GeometryInfo = new_ql.ToDbString(); |
| | | _xhs_phart_diagram_ex_std_dto.Diagram.GraphList = new List<Vmo.PhartGraph>() |
| | | { |
| | | graph_ql |
| | | }; |
| | | var bol = await _bll_ex.Update(_xhs_phart_diagram_ex_std_dto); |
| | | if (bol) |
| | | { |
| | | InitChart(_xhs_phart_diagram_ex_std_dto); |
| | | } |
| | | return bol; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | var dlg = new ValvePerform2dEditDlg(); |
| | | dlg.SetBindingData(ql); |
| | | dlg.SetAxisTile("阀门开度", "压力损失系数"); |
| | | dlg.ReloadDataEvent += async (new_ql) => |
| | | { |
| | | graph_ql.GeometryInfo = new_ql.ToDbString(); |
| | | _xhs_phart_diagram_ex_std_dto.Diagram.GraphList = new List<Vmo.PhartGraph>() |
| | | { |
| | | graph_ql |
| | | }; |
| | | var bol = await _bll.Update(_xhs_phart_diagram_ex_std_dto); |
| | | if (bol) |
| | | { |
| | | InitChart(_xhs_phart_diagram_ex_std_dto); |
| | | } |
| | | return bol; |
| | | }; |
| | | dlg.ShowDialog();*/ |
| | | } |
| | | |
| | | //别名 |
| | | private void barBtnOtherName_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (_xhs_phart_diagram_ex_std_dto == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new SetOtherNameDlg(); |
| | | dlg.SetBindingData(_xhs_phart_diagram_ex_std_dto.OtherName); |
| | | dlg.VerifyValueChanged += async (value) => |
| | | { |
| | | _xhs_phart_diagram_ex_std_dto.OtherName = value; |
| | | var bol = await _bll_ex.Update(_xhs_phart_diagram_ex_std_dto); |
| | | if (!bol) |
| | | { |
| | | XtraMessageBox.Show("更新失败!"); |
| | | return false; |
| | | } |
| | | this.xhsValveMainPhartListCtrl1.UpdateOtherName(_xhs_phart_diagram_ex_std_dto.ID, value); |
| | | XtraMessageBox.Show("更新成功!"); |
| | | return true; |
| | | }; |
| | | /* if (_xhs_phart_diagram_ex_std_dto == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new SetOtherNameDlg(); |
| | | dlg.SetBindingData(_xhs_phart_diagram_ex_std_dto.OtherName); |
| | | dlg.VerifyValueChanged += async (value) => |
| | | { |
| | | _xhs_phart_diagram_ex_std_dto.OtherName = value; |
| | | var bol = await _bll.Update(_xhs_phart_diagram_ex_std_dto); |
| | | if (!bol) |
| | | { |
| | | XtraMessageBox.Show("更新失败!"); |
| | | return false; |
| | | } |
| | | this.xhsValveMainPhartListCtrl1.UpdateOtherName(_xhs_phart_diagram_ex_std_dto.ID, value); |
| | | XtraMessageBox.Show("更新成功!"); |
| | | return true; |
| | | }; |
| | | |
| | | dlg.ShowDialog(); |
| | | dlg.ShowDialog();*/ |
| | | } |
| | | |
| | | //重要度 |
| | | private void barBtnUpdateimportance_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var dlg = new SetImportanceDlg(); |
| | | dlg.SetBindingData(_xhs_phart_diagram_ex_std_dto.Importance); |
| | | dlg.VerifyValueChanged += async (value) => |
| | | { |
| | | _xhs_phart_diagram_ex_std_dto.Importance = value; |
| | | var bol = await _bll_ex.Update(_xhs_phart_diagram_ex_std_dto); |
| | | if (!bol) |
| | | { |
| | | XtraMessageBox.Show("更新失败!"); |
| | | return false; |
| | | } |
| | | this.xhsValveMainPhartListCtrl1.UpdateImportance(_xhs_phart_diagram_ex_std_dto.ID, value); |
| | | XtraMessageBox.Show("更新成功!"); |
| | | return true; |
| | | }; |
| | | /* var dlg = new SetImportanceDlg(); |
| | | dlg.SetBindingData(_xhs_phart_diagram_ex_std_dto.Importance); |
| | | dlg.VerifyValueChanged += async (value) => |
| | | { |
| | | _xhs_phart_diagram_ex_std_dto.Importance = value; |
| | | var bol = await _bll.Update(_xhs_phart_diagram_ex_std_dto); |
| | | if (!bol) |
| | | { |
| | | XtraMessageBox.Show("更新失败!"); |
| | | return false; |
| | | } |
| | | this.xhsValveMainPhartListCtrl1.UpdateImportance(_xhs_phart_diagram_ex_std_dto.ID, value); |
| | | XtraMessageBox.Show("更新成功!"); |
| | | return true; |
| | | }; |
| | | |
| | | dlg.ShowDialog(); |
| | | dlg.ShowDialog();*/ |
| | | } |
| | | |
| | | #region 删除 |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var diagramId = _xhs_phart_diagram_ex_std_dto.Diagram.ID; |
| | | var bol = await _bll_ex.DeleteByDiagramID(diagramId); |
| | | var bol = await _bll.DeleteByID(_xhs_phart_diagram_ex_std_dto.ID); |
| | | if (!bol) |
| | | { |
| | | XtraMessageBox.Show("删除失败!"); |
| | |
| | | } |
| | | XtraMessageBox.Show("删除成功!"); |
| | | ClearChart(); |
| | | this.xhsValveMainPhartListCtrl1.Delete(_xhs_phart_diagram_ex_std_dto.ID); |
| | | |
| | | // this.xhsValveMainPhartListCtrl1.Delete(_xhs_phart_diagram_ex_std_dto.ID); |
| | | return true; |
| | | } |
| | | |
| | | #endregion 删除 |
| | | |
| | | #endregion 操作 |
| | | |
| | | } |
| | | } |