using DevExpress.XtraEditors.Controls;
|
|
namespace HStation.WinFrmUI.Xhs.PumpProduct
|
{
|
public partial class AddPumpProductSeriesDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public AddPumpProductSeriesDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Func<AddPumpSeriesDto, Task<bool>> ReloadDataEvent = null;
|
|
private Yw.BLL.SysCatalog _bll = null;
|
|
//数据验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(NameTextEdit.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(TextEditCatalogChoice.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.TextEditCatalogChoice, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//完成
|
private async void BtnOk_ClickAsync(object sender, EventArgs e)
|
{
|
var model = new AddPumpSeriesDto();
|
model.Name = NameTextEdit.Text.Trim();
|
model.TagName = TagNameTextEdit.Text.Trim();
|
model.MotorFrequency = MotorFrequencyTextEdit.Text.Trim();
|
if (long.TryParse(TextEditCatalogChoice.EditValue.ToString(), out long catalogID))
|
{
|
model.CatalogID = catalogID;
|
}
|
if (await this.ReloadDataEvent.Invoke(model))
|
{
|
MessageBoxHelper.ShowSuccess("添加成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("添加失败!");
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
//初始化
|
private async void AddPumpProductSeriesDlg_Load(object sender, EventArgs e)
|
{
|
_bll = new Yw.BLL.SysCatalog();
|
var alllist = await _bll.GetAll();
|
foreach (var item in alllist)
|
{
|
var imageItem = new ImageComboBoxItem(item.Name, item.ID);
|
TextEditCatalogChoice.Properties.Items.Add(imageItem);
|
}
|
}
|
}
|
}
|