using DevExpress.XtraEditors;
|
|
namespace HStation.WinFrmUI
|
{
|
/// <summary>
|
/// 设置使用状态
|
/// </summary>
|
public partial class SetUseStatusDlg : XtraForm
|
{
|
public SetUseStatusDlg()
|
{
|
InitializeComponent();
|
}
|
|
/// <summary>
|
/// 回调函数
|
/// </summary>
|
public event Func<Yw.Model.eUseStatus, Task<bool>> ReloadDataEvent;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Model.eUseStatus UseStatus)
|
{
|
switch (UseStatus)
|
{
|
case Yw.Model.eUseStatus.Enable: this.radioGroup1.SelectedIndex = 1; break;
|
case Yw.Model.eUseStatus.Disable: this.radioGroup1.SelectedIndex = 0; break;
|
default: break;
|
}
|
}
|
|
//确定
|
|
private async void btnOk_Click(object sender, EventArgs e)
|
{
|
var status = Yw.Model.eUseStatus.Enable;
|
if (this.radioGroup1.SelectedIndex == 0)
|
status = Yw.Model.eUseStatus.Disable;
|
else if (this.radioGroup1.SelectedIndex == 1)
|
status = Yw.Model.eUseStatus.Enable;
|
|
if (this.ReloadDataEvent != null)
|
{
|
var result = await this.ReloadDataEvent.Invoke(status);
|
if (result)
|
{
|
MessageBoxHelper.ShowSuccess("更新成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("更新失败!");
|
return;
|
}
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|