lixiaojun
2024-12-05 84820e6296602b263633ff9a960bfd15cf0618de
WinFrmUI/HStation.WinFrmUI.Assets.Core/03-valve/04-chart-edit/XhsValveMainPhartMinorLossPanel.cs
@@ -15,7 +15,7 @@
        private long _valve_main_id;
        private Vmo.AssetsValveCoefficientVmo _xhs_phart_diagram_ex_std_dto = null;
        private readonly BLL.XhsValveMainPhartMappingExtensions _bll_ex = new();
        private readonly BLL.AssetsValveCoefficient _bll = new();
        /// <summary>
        /// 初始化数据
@@ -34,7 +34,7 @@
            {
                _xhs_phart_diagram_ex_std_dto = chart.First();
                this.xtrPerform2dChart1.SetBindingData(_xhs_phart_diagram_ex_std_dto.MinorLossCurve);
             }
            }
            this.xtrPerform2dChart1.SetAxisTitle("阀门开度", "损失系数");
        }
@@ -43,7 +43,6 @@
        {
            _xhs_phart_diagram_ex_std_dto = obj;
            this.xtrPerform2dChart1.SetBindingData(obj.MinorLossCurve);
            //  InitChart(_xhs_phart_diagram_ex_std_dto);
        }
@@ -107,18 +106,19 @@
        }
        // 导入
        private async Task<bool> Import( string pt_list_json)
        private async Task<bool> Import(string pt_list_json)
        {
            if (_valve_main_id < 1)
            {
                XtraMessageBox.Show("ValveMain is null!");
                return false;
            }
            var bll = new BLL.AssetsValveCoefficient();
            var model = new Vmo.AssetsValveCoefficientVmo();
            model.MainID = _valve_main_id;
            model.MinorLossCurve = pt_list_json;
            return await bll.Insert(model) > 0;
            this.xtrPerform2dChart1.SetBindingData(pt_list_json);
            _xhs_phart_diagram_ex_std_dto = model;
            return await _bll.Insert(model) > 0;
        }
        #endregion 导入
@@ -128,50 +128,50 @@
        //编辑
        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.ValveOL);
               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 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_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();*/
        }
        //别名
@@ -186,7 +186,7 @@
               dlg.VerifyValueChanged += async (value) =>
               {
                   _xhs_phart_diagram_ex_std_dto.OtherName = value;
                   var bol = await _bll_ex.Update(_xhs_phart_diagram_ex_std_dto);
                   var bol = await _bll.Update(_xhs_phart_diagram_ex_std_dto);
                   if (!bol)
                   {
                       XtraMessageBox.Show("更新失败!");
@@ -208,7 +208,7 @@
               dlg.VerifyValueChanged += async (value) =>
               {
                   _xhs_phart_diagram_ex_std_dto.Importance = value;
                   var bol = await _bll_ex.Update(_xhs_phart_diagram_ex_std_dto);
                   var bol = await _bll.Update(_xhs_phart_diagram_ex_std_dto);
                   if (!bol)
                   {
                       XtraMessageBox.Show("更新失败!");
@@ -227,29 +227,27 @@
        //删除
        private async void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //    await Delete();
            await Delete();
        }
        /*       //删除
               private async Task<bool> Delete()
               {
              *//*     if (_xhs_phart_diagram_ex_std_dto == null)
                   {
                       return false;
                   }
                   var diagramId = _xhs_phart_diagram_ex_std_dto.Diagram.ID;
                   var bol = await _bll_ex.DeleteByDiagramID(diagramId);
                   if (!bol)
                   {
                       XtraMessageBox.Show("删除失败!");
                       return false;
                   }
                   XtraMessageBox.Show("删除成功!");
                   ClearChart();
                   this.xhsValveMainPhartListCtrl1.Delete(_xhs_phart_diagram_ex_std_dto.ID);
                   return true;*//*
               }*/
        //删除
        private async Task<bool> Delete()
        {
            if (_xhs_phart_diagram_ex_std_dto == null)
            {
                return false;
            }
            var bol = await _bll.DeleteByID(_xhs_phart_diagram_ex_std_dto.ID);
            if (!bol)
            {
                XtraMessageBox.Show("删除失败!");
                return false;
            }
            XtraMessageBox.Show("删除成功!");
            ClearChart();
            //   this.xhsValveMainPhartListCtrl1.Delete(_xhs_phart_diagram_ex_std_dto.ID);
            return true;
        }
        #endregion 删除