using DevExpress.Drawing;
|
using DevExpress.Utils.Svg;
|
using DevExpress.XtraEditors;
|
using HStation.Vmo;
|
using Yw;
|
using Yw.WinFrmUI.Page;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class AssetsCoolingMainMgrPage : DocumentPage
|
{
|
public AssetsCoolingMainMgrPage()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalView(30);
|
this.PageTitle.Caption = "冷却塔型号";
|
this.PageTitle.HeaderSvgImage = this.svgImg32[0];
|
this.PageTitle.SvgImageSize = new Size(24, 24);
|
}
|
|
private AssetsCoolingSeriesVmo _series = null;//系列
|
private List<AssetsCoolingMainMgrViewModel> _allBindingList = null;//数据绑定列表
|
private readonly object _locker = new();//锁定对象
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(AssetsCoolingSeriesVmo series)
|
{
|
if (series == null)
|
{
|
return;
|
}
|
_series = series;
|
InitialData();
|
}
|
|
/// <summary>
|
/// 初始化数据源
|
/// </summary>
|
public override void InitialDataSource()
|
{
|
base.InitialDataSource();
|
InitialData();
|
}
|
|
//初始化数据
|
private async void InitialData()
|
{
|
if (_series == null)
|
{
|
return;
|
}
|
var overlay = this.ShowOverlay();
|
var allBindingList = await BLLFactory<HStation.BLL.AssetsCoolingMain>.Instance.GetBySeriesID(_series.ID);
|
_allBindingList = new List<AssetsCoolingMainMgrViewModel>();
|
if (allBindingList != null && allBindingList.Count > 0)
|
{
|
foreach (var item in allBindingList)
|
{
|
var vm = new AssetsCoolingMainMgrViewModel(item);
|
_allBindingList.Add(vm);
|
}
|
}
|
this.assetsCoolingMainMgrViewModelBindingSource.DataSource = _allBindingList;
|
this.assetsCoolingMainMgrViewModelBindingSource.ResetBindings(false);
|
overlay.Close();
|
}
|
|
/// <summary>
|
/// 刷新数据
|
/// </summary>
|
public override void RefreshData()
|
{
|
base.RefreshData();
|
InitialData();
|
}
|
|
//添加
|
private void Add()
|
{
|
if (_series == null)
|
{
|
return;
|
}
|
if (_allBindingList == null)
|
{
|
TipFormHelper.ShowError("数据初始化失败!");
|
return;
|
}
|
var dlg = new AddAssetsCoolingMainDlg();
|
dlg.ReloadDataEvent += (rhs) =>
|
{
|
var vm = new AssetsCoolingMainMgrViewModel(rhs);
|
_allBindingList.Add(vm);
|
this.assetsCoolingMainMgrViewModelBindingSource.ResetBindings(false);
|
TipFormHelper.ShowSucceed("添加成功!");
|
};
|
dlg.SetBindingData(_series);
|
dlg.ShowDialog();
|
}
|
|
//编辑
|
private void Edit()
|
{
|
var vm = GetCurrentViewModel();
|
if (vm == null)
|
{
|
return;
|
}
|
var dlg = new EditAssetsCoolingMainDlg();
|
dlg.ReloadDataEvent += (rhs) =>
|
{
|
vm.Reset(rhs);
|
this.gridView1.RefreshRow(this.gridView1.FocusedRowHandle);
|
TipFormHelper.ShowSucceed("更新成功");
|
};
|
dlg.SetBindingData(vm.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.AssetsCoolingMain>.Instance.DeleteByID(vm.ID);
|
if (!bol)
|
{
|
TipFormHelper.ShowError("删除失败!");
|
return;
|
}
|
_allBindingList.Remove(vm);
|
this.assetsCoolingMainMgrViewModelBindingSource.ResetBindings(false);
|
TipFormHelper.ShowSucceed("删除成功!");
|
}
|
|
//查看
|
private void View()
|
{
|
var vm = GetCurrentViewModel();
|
if (vm == null)
|
{
|
return;
|
}
|
var dlg = new ViewAssetsCoolingMainDlg();
|
dlg.SetBindingData(vm.Vmo);
|
dlg.ShowDialog();
|
}
|
|
//上移
|
private void Up()
|
{
|
|
}
|
|
//下移
|
private void Down()
|
{
|
|
}
|
|
|
|
#region 当前
|
|
//获取当前
|
private AssetsCoolingMainMgrViewModel GetCurrentViewModel()
|
{
|
if (_allBindingList == null)
|
{
|
TipFormHelper.ShowError("数据初始化错误!");
|
return null;
|
}
|
if (_allBindingList.Count < 1)
|
{
|
TipFormHelper.ShowInfo("无数据!");
|
return null;
|
}
|
var vm = this.gridView1.GetCurrentViewModel(_allBindingList);
|
if (vm == null)
|
{
|
TipFormHelper.ShowWarn("请选择数据行!");
|
return null;
|
}
|
return vm;
|
}
|
|
#endregion
|
|
#region Ribbon
|
|
//添加
|
private void barBtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
Add();
|
}
|
|
//编辑
|
private void barBtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
Edit();
|
}
|
|
//删除
|
private void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
Delete();
|
}
|
|
//详细信息
|
private void barBtnInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
View();
|
}
|
|
//上移
|
private void barBtnUp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
|
}
|
|
//下移
|
private void barBtnDown_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
|
}
|
|
//查询
|
private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
this.gridView1.OptionsFind.AlwaysVisible = !this.gridView1.OptionsFind.AlwaysVisible;
|
}
|
|
//刷新
|
private void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
this.RefreshData();
|
}
|
|
#endregion
|
|
//系数
|
private void barBtnFactor_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
lock (_locker)
|
{
|
var guid = new PageGuid()
|
{
|
Modular = AssetsFunctionHelper.Modular,
|
MoudingType = eMoudingType.Tab,
|
Function = AssetsFunctionHelper.CoolingFactorMgr,
|
TagName = string.Empty
|
};
|
if (!IsExistPage(guid, true))
|
{
|
var page = new AssetsCoolingFactorMgrPage();
|
CreatePage(page, guid);
|
}
|
}
|
}
|
|
|
|
}
|
}
|