using DevExpress.XtraEditors; using System; using System.Windows.Forms; using Yw.WinFrmUI; namespace HStation.WinFrmUI.Organize { /// /// 添加菜单 /// public partial class AddMenuDlg : DevExpress.XtraEditors.XtraForm { public AddMenuDlg() { InitializeComponent(); } public event Func> ReloadDataEvent; private Yw.Vmo.ProjectMenu _model = null; /// /// 添加 /// public async void SetBindingData() { _model = new Yw.Vmo.ProjectMenu(); var allList = await new Yw.BLL.ProjectMenu().GetByProjectID(1); this.treeListLookUpEdit1TreeList.DataSource = allList; _model.ProjectID = 1; } //验证 private bool Valid() { this.dxErrorProvider1.ClearErrors(); if (string.IsNullOrEmpty(this.NameTextEdit.Text.Trim())) { this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项"); return false; } if (string.IsNullOrEmpty(this.CodeTextEdit.Text.Trim())) { this.dxErrorProvider1.SetError(this.CodeTextEdit, "必填项"); return false; } return true; } //确定 private async void btnOk_Click(object sender, EventArgs e) { if (!Valid()) return; _model.Name = this.NameTextEdit.Text.Trim(); _model.Description = this.DescriptionMemoEdit.Text.Trim(); _model.ParentID = this.ComboBoxEditParentsChoice.EditValue == null ? 0 : Convert.ToInt64(this.ComboBoxEditParentsChoice.EditValue); if (await this.ReloadDataEvent.Invoke(_model)) { TipFormHelper.ShowSucceed("添加成功!!"); } else { MessageBoxHelper.ShowError("添加失败!"); } this.DialogResult = DialogResult.OK; this.Close(); } } }