lg
2024-09-14 895c38a3e682df58469ae5346a70408b2bdbca57
DevApp/Gs.DevApp/DevFrm/User/SysMenu.cs
@@ -1,10 +1,13 @@
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
using Gs.DevApp.Models;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Windows.Forms;
namespace Gs.DevApp.DevFrm.User
{
@@ -19,7 +22,7 @@
            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
            this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
            // txt_category.TextChanged += Txt_category_TextChanged;
            txt_category.TextChanged += Txt_category_TextChanged;
            tlMenu.MouseDoubleClick += TlMenu_MouseDoubleClick;
            getTree();
            getDownList();
@@ -33,7 +36,7 @@
        /// <param name="e"></param>
        private void Txt_category_TextChanged(object sender, EventArgs e)
        {
            if (txt_category.SelectedIndex == 1)
            if (txt_category.SelectedIndex ==1)
            {
                this.txt_formPath.Enabled = true;
                this.txt_icon.Enabled = true;
@@ -44,8 +47,6 @@
                this.txt_icon.Enabled = false;
                this.txt_formPath.Text = "";
                this.txt_icon.Text = "";
                MsgHelper.ShowError(txt_formPath.Enabled.ToString());
                MsgHelper.ShowError(txt_icon.Enabled.ToString());
            }
        }
        /// <summary>
@@ -134,6 +135,16 @@
                return;
            }
            getModel(rowGuid, true, 1);
            if (txt_category.SelectedIndex == 1)
            {
                this.txt_formPath.Enabled = true;
                this.txt_icon.Enabled = true;
            }
            else
            {
                this.txt_formPath.Enabled = false;
                this.txt_icon.Enabled = false;
            }
        }
        /// <summary>
        /// 新增事件
@@ -166,17 +177,17 @@
                txt_name.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_status.Text.Trim()) || txt_status.SelectedIndex == 0)
            if (string.IsNullOrEmpty(txt_isStatus.Text.Trim()) || txt_isStatus.SelectedIndex == 0)
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("菜单状态不能为空!");
                txt_status.Focus();
                txt_isStatus.Focus();
                return;
            }
            string _upGuid = txt_upGuid.EditValue.ToString();
            if (txt_category.SelectedIndex == 2 && string.IsNullOrEmpty(_upGuid))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("按钮类型必须选择父级菜单!");
                txt_status.Focus();
                txt_isStatus.Focus();
                return;
            }
            var _obj = new
@@ -185,7 +196,7 @@
                upGuid = _upGuid,//上级的主建
                name = txt_name.Text.Trim(),//名称
                icon = txt_icon.Text,//菜单图标
                status = txt_status.SelectedIndex,//状态
                isStatus = txt_isStatus.SelectedIndex,//状态
                formPath = txt_formPath.Text.Trim(),//窗体路径
                idx = int.Parse(txt_idx.Value.ToString()),//排序
                category = txt_category.SelectedIndex,//类型
@@ -208,9 +219,12 @@
            }
        }
        /// <summary>
        /// 读取列表
        /// </summary>
        private void getTree()
        {
            Models.PageQueryModel pgq = new Models.PageQueryModel(1, 999999, "idx", "asc", "", "");
            PageQueryModel pgq = new PageQueryModel(1, 999999, "idx", "asc", "", "");
            string json = JsonConvert.SerializeObject(pgq);
            try
            {
@@ -262,10 +276,12 @@
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 读取上级树
        /// </summary>
        private void getDownList()
        {
            Models.PageQueryModel pgq = new Models.PageQueryModel(1, 999999, "idx", "asc", "", " and category=1");
            PageQueryModel pgq = new PageQueryModel(1, 999999, "idx", "asc", "", " and category=1");
            string json = JsonConvert.SerializeObject(pgq);
            try
            {
@@ -285,7 +301,18 @@
        }
        private void getActionList()
        {
            List<string> lst = new List<string>();
            lst = toolBarMenu1.actions;
            txt_name.Properties.Items.AddRange(toolBarMenu1.actions);
            Assembly assembly = Assembly.GetExecutingAssembly();
            Type[] types = assembly.GetTypes();
            foreach (Type type in types)
            {
                if (type.IsSubclassOf(typeof(Form)))
                {
                    txt_formPath.Properties.Items.Add(type.FullName);
                }
            }
        }
    }
}