namespace HStation.WinFrmUI
|
{
|
public partial class DeleteEqualEDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public DeleteEqualEDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
this.layoutControl1.SetupLayoutControl();
|
this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
|
this.gridView2.SetNormalView();
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public event Func<List<double>, bool> ReloadDataEvent;
|
|
private class CurrentViewModel
|
{
|
public double Eff { get; set; }
|
}
|
|
private List<CurrentViewModel> _eff_list = null;
|
private List<double> _delete_id_list = null;
|
|
/// <summary>
|
///
|
/// </summary>
|
public void SetBindingData(List<double> list)
|
{
|
_eff_list = new List<CurrentViewModel>();
|
_delete_id_list = new();
|
if (list == null || !list.Any())
|
return;
|
_eff_list = list.OrderByDescending(x => x).Select(x => new CurrentViewModel()
|
{
|
Eff = x
|
}).ToList();
|
|
this.gridControl2.DataSource = _eff_list;
|
this.gridControl2.RefreshDataSource();
|
}
|
|
//删除
|
private void gridView2_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
{
|
if (_eff_list == null || _eff_list.Count < 1)
|
return;
|
if (e.Column == this.colDelete)
|
{
|
var item = _eff_list.ElementAt(e.RowHandle);
|
_delete_id_list.Add(item.Eff);
|
_eff_list.RemoveAt(e.RowHandle);
|
this.gridControl2.RefreshDataSource();
|
}
|
|
}
|
|
//验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
|
return true;
|
}
|
|
//确定
|
private void GeneralOkAndCancelCtrl1_OkEvent()
|
{
|
if (_delete_id_list == null || !_delete_id_list.Any())
|
{
|
return;
|
}
|
|
if (!Valid())
|
{
|
return;
|
}
|
|
if (this.ReloadDataEvent == null)
|
return;
|
|
var bol = this.ReloadDataEvent.Invoke(_delete_id_list);
|
if (!bol)
|
{
|
return;
|
}
|
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
|
}
|
|
}
|
}
|