using HStation.WinFrmUI.PhartRelation;
|
using HStation.WinFrmUI.Xhs;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class CompressorSingleMatchingCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public CompressorSingleMatchingCtrl()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalView();
|
this.gridView3.SetNormalView();
|
}
|
|
public class PhartViewModel
|
{
|
public long ID { get; set; }
|
public string OtherName { get; set; }
|
public int Importance { get; set; }
|
public int SortCode { get; set; }
|
|
/// <summary>
|
/// 容积曲线
|
/// </summary>
|
public string MinorLossCurve { get; set; }
|
|
/// <summary>
|
/// 型号ID
|
/// </summary>
|
public long MainID { get; set; }
|
}
|
|
public class CurvieInfo
|
{
|
public long? Dbid { get; set; }
|
public long? Curveid { get; set; }
|
// public Vmo.XhsCompressorMainPhartMappingExtensions Curveinfo { get; set; }
|
}
|
|
private List<CompressorSingleMatchingViewModel> _allBindingList = null;
|
|
private BLL.AssetsCompressorMain _CompressorBll = null;
|
|
private List<PhartViewModel> _allPhartList = null;
|
private readonly Lazy<BLL.AssetsCompressorCoefficient> _bll_ex = new();
|
|
private HydroCompressorMatchingViewModel _pumpMatchingViewModel;
|
|
private List<HydroCurvePointViewModel> _currentCurvePoint;
|
|
public async void SetBindingData(HydroCompressorMatchingViewModel CompressorMatchingViewModel)
|
{
|
_pumpMatchingViewModel = CompressorMatchingViewModel;
|
_allBindingList = new List<CompressorSingleMatchingViewModel>();
|
_CompressorBll = new BLL.AssetsCompressorMain();
|
var allAssetsPumpMain = await _CompressorBll.GetAll();
|
if (allAssetsPumpMain != null)
|
{
|
foreach (var Main in allAssetsPumpMain)
|
{
|
_allBindingList.Add(new CompressorSingleMatchingViewModel(Main));
|
}
|
}
|
this.CompressorSingleMatchingViewModelBindingSource.DataSource = _allBindingList;
|
this.searchControl1.Text = _pumpMatchingViewModel.ModelType;
|
for (int i = 0; i < _allBindingList.Count; i++)
|
{
|
if (long.TryParse(CompressorMatchingViewModel.DbId, out long dbID))
|
{
|
if (_allBindingList[i].ID == dbID)
|
{
|
this.gridView3.FocusedRowHandle = i;
|
}
|
}
|
}
|
_currentCurvePoint = new List<HydroCurvePointViewModel>();
|
}
|
|
//阀门型号列表选择项切换事件
|
private async void gridView2_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
{
|
_allPhartList = new List<PhartViewModel>();
|
var vm = this.gridView3.GetCurrentViewModel(_allBindingList);
|
if (vm != null)
|
{
|
_pumpMatchingViewModel.MatchingDbId = vm.ID.ToString();
|
_pumpMatchingViewModel.MatchingModelType = vm.Name.ToString();
|
var list = await _bll_ex.Value.GetByMainID(vm.ID);
|
if (list != null && list.Any())
|
{
|
foreach (var item in list)
|
{
|
_allPhartList.Add(new PhartViewModel { ID = item.ID, MinorLossCurve = item.MinorLossCurve, MainID = item.MainID, OtherName = "默认曲线", Importance = 1 });
|
}
|
}
|
}
|
if (_pumpMatchingViewModel.MatchingCurveDbId != null)
|
{
|
for (int i = 0; i < _allPhartList.Count; i++)
|
{
|
if (_allBindingList[i].ID.ToString() == _pumpMatchingViewModel.MatchingCurveDbId)
|
{
|
gridView1.FocusedRowHandle = i;
|
}
|
}
|
}
|
this.gridControl1.DataSource = _allPhartList;
|
this.gridView1.FocusInvalidRow();
|
}
|
|
//查看曲线
|
private async void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
{
|
if (e.Column == this.ColShowChart)
|
{
|
var vm = this.gridView1.GetCurrentViewModel(_allPhartList);
|
|
var vmo = await _bll_ex.Value.GetByID(vm.ID);
|
if (vmo != null)
|
{
|
var dlg = new CompressorChartShowDlg();
|
dlg.InitChart(vmo.MinorLossCurve);
|
dlg.ShowDialog();
|
}
|
return;
|
}
|
}
|
|
private async void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
{
|
var vm = this.gridView1.GetCurrentViewModel(_allPhartList);
|
_currentCurvePoint.Clear();
|
if (vm == null)
|
return;
|
var vmo = await _bll_ex.Value.GetByID(vm.ID);
|
if (vmo != null)
|
{
|
_pumpMatchingViewModel.MatchingCurveDbId = vm.MainID.ToString();
|
var pt_list = Yw.JsonHelper.Json2Object<List<HydroCurvePointViewModel>>(vm.MinorLossCurve);
|
_pumpMatchingViewModel.MatchingCurveQL = pt_list;
|
}
|
}
|
}
|
}
|