namespace HStation.WinFrmUI.Assets { public partial class AddAssetsExchangerSeriesDlg : DevExpress.XtraEditors.XtraForm { public AddAssetsExchangerSeriesDlg() { InitializeComponent(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; this.Load += AddAssetsExchangerSeriesDlg_Load; } public event Func> ReloadDataEvent = null; private List _assetsExchangerSeriesViews; //初始化 private async void AddAssetsExchangerSeriesDlg_Load(object sender, EventArgs e) { _assetsExchangerSeriesViews = new List(); var allList = await new BLL.AssetsExchangerSeries().GetAll(); if (allList != null) { foreach (var item in allList) { _assetsExchangerSeriesViews.Add(new AssetsExchangerSeriesViewModel(item)); } } treeListLookUpEdit1TreeList.DataSource = _assetsExchangerSeriesViews; } //数据验证 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; var model = new Vmo.AssetsExchangerSeriesVmo(); model.Name = NameTextEdit.Text; model.TagName = TagNameTextEdit.Text; model.Description = DescriptionTextEdit.Text; if (await this.ReloadDataEvent.Invoke(model, this.textEditParentList.EditValue)) { TipFormHelper.ShowSucceed("添加成功!"); } else { TipFormHelper.ShowError("添加失败!"); } this.DialogResult = DialogResult.OK; this.Close(); } } }