duheng
2025-01-08 21067008153a810c72e8b86faaeca577290ff265
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;
using Yw.WinFrmUI;
 
namespace HStation.WinFrmUI.Organize
{
    /// <summary>
    /// 添加菜单
    /// </summary>
    public partial class AddMenuDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddMenuDlg()
        {
            InitializeComponent();
        }
 
        public event Func<Yw.Vmo.ProjectMenu, Task<bool>> ReloadDataEvent;
 
        private Yw.Vmo.ProjectMenu _model = null;
 
        /// <summary>
        /// 添加
        /// </summary>
        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();
        }
    }
}