duheng
2025-02-19 ad8f813f5eddd66740b4e09801e4ea02ddf70a4a
WinFrmUI/HStation.WinFrmUI.Auth.Core/01-menu/AddMenuDlg.cs
@@ -1,7 +1,9 @@
using DevExpress.XtraEditors;
using DevExpress.DocumentServices.ServiceModel.DataContracts;
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;
using Yw.WinFrmUI;
using static HStation.WinFrmUI.MenuViewModel;
namespace HStation.WinFrmUI
{
@@ -15,19 +17,20 @@
            InitializeComponent();
        }
        public event Func<Yw.Vmo.ProjectMenu, Task<bool>> ReloadDataEvent;
        public event Func<Yw.Vmo.AddProjectMenuExVmo, Task<bool>> ReloadDataEvent;
        private Yw.Vmo.ProjectMenu _model = null;
        private Yw.Vmo.ProjectMenuVmo _model = null;
        /// <summary>
        /// 添加
        /// </summary>
        public async void SetBindingData()
        public async void SetBindingData(long parentId)
        {
            _model = new Yw.Vmo.ProjectMenu();
            var allList = await new Yw.BLL.ProjectMenu().GetByProjectID(1);
            var allList = await new Yw.BLL.ProjectMenu().GetByProjectID(GlobalParas._GlobalParas.ProjectID);
            this.treeListLookUpEdit1TreeList.DataSource = allList;
            _model.ProjectID = 1;
            this.imageComboBoxMenuType.Properties.AddEnum(typeof(eMenuType));
            this.imageComboBoxMenuType.SelectedIndex = 0;
            this.ComboBoxEditParentsChoice.EditValue = parentId;
        }
        //验证
@@ -39,9 +42,9 @@
                this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项");
                return false;
            }
            if (string.IsNullOrEmpty(this.CodeTextEdit.Text.Trim()))
            if (string.IsNullOrEmpty(this.TxtEditPermission.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.CodeTextEdit, "必填项");
                this.dxErrorProvider1.SetError(this.TxtEditPermission, "必填项");
                return false;
            }
            return true;
@@ -52,10 +55,15 @@
        {
            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))
            var AddProject = new Yw.Vmo.AddProjectMenuExVmo();
            AddProject.Name = this.NameTextEdit.Text.Trim();
            AddProject.Description = this.DescriptionMemoEdit.Text.Trim();
            AddProject.ParentID = this.ComboBoxEditParentsChoice.EditValue == null ? 0 : Convert.ToInt64(this.ComboBoxEditParentsChoice.EditValue);
            AddProject.Type = (int)(eMenuType)this.imageComboBoxMenuType.EditValue;
            AddProject.Permission = this.TxtEditPermission.Text.Trim();
            AddProject.ProjectID = GlobalParas._GlobalParas.ProjectID;
            AddProject.SoftwareIds = new List<long> { GlobalParas._GlobalParas.SoftwareID };
            if (await this.ReloadDataEvent.Invoke(AddProject))
            {
                TipFormHelper.ShowSucceed("添加成功!!");
            }
@@ -66,5 +74,10 @@
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        private void simpleLabelDelete_Click(object sender, EventArgs e)
        {
            this.ComboBoxEditParentsChoice.EditValue = null;
        }
    }
}