using Yw.WinFrmUI;
|
|
namespace HStation.WinFrmUI.WE
|
{
|
public partial class EditCatalogueDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public EditCatalogueDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
}
|
|
public event Func<Vmo.WE.CatalogueVmo, object, Task<bool>> ReloadDataEvent = null;
|
|
private Vmo.WE.CatalogueVmo _CatalogueDlg = null;
|
private List<CatalogueViewModel> _CatalogueDlgViews;
|
|
public async void SetBindingData(Vmo.WE.CatalogueVmo seriesVmo)
|
{
|
_CatalogueDlgViews = new List<CatalogueViewModel>();
|
_CatalogueDlg = seriesVmo;
|
this.NameTextEdit.Text = _CatalogueDlg.Name;
|
this.DescriptionTextEdit.Text = _CatalogueDlg.Description;
|
this.TagNameTextEdit.Text = _CatalogueDlg.TagName;
|
var allList = await new BLL.WE.Catalogue().GetAll();
|
foreach (var item in allList)
|
{
|
_CatalogueDlgViews.Add(new CatalogueViewModel(item));
|
}
|
treeListLookUpEdit1TreeList.DataSource = _CatalogueDlgViews;
|
if (_CatalogueDlg.ParentIds.Count > 0)
|
{
|
this.textEditParentList.EditValue = _CatalogueDlg.ParentIds.Last();
|
}
|
}
|
|
//数据验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(NameTextEdit.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//完成
|
private async void BtnOk_ClickAsync(object sender, EventArgs e)
|
{
|
if (!Valid())
|
return;
|
_CatalogueDlg.Name = NameTextEdit.Text;
|
_CatalogueDlg.TagName = TagNameTextEdit.Text;
|
_CatalogueDlg.Description = DescriptionTextEdit.Text;
|
if (await this.ReloadDataEvent.Invoke(_CatalogueDlg, this.textEditParentList.EditValue))
|
{
|
TipFormHelper.ShowSucceed("修改成功!");
|
}
|
else
|
{
|
TipFormHelper.ShowError("修改失败!");
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|