alielie
2025-03-11 2e54b439c64e0adbb7e010243c1f33aa5fc5f503
HMI.MenuManage/MenuManage.xaml.cs
@@ -1,15 +1,13 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using HMI.Base;
using HMI.Base;
using HMI.Core.Util;
using HMI.MenuManage.Entity;
using HMI.MenuManage.Model;
using HMI.UI.Util;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace HMI.MenuManage
{
@@ -29,11 +27,7 @@
            InitializeComponent();
        }
        #region 属性
        #endregion
        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var btn = ((Button)sender);
            if (btn.Name == "addBtn")
@@ -42,7 +36,7 @@
                {
                    MenuModal window = new MenuModal
                    {
                        Title = "新增菜单",
                        Title = $"{LangUtil.Get("HMI.Menu.Add")}",
                        sqliteHelper = Model.sqliteHelper,
                        Owner = Window.GetWindow(this)
                    };
@@ -55,7 +49,7 @@
                catch (Exception ex)
                {
                    log.Error("Add Menu Failed.", ex);
                    ToastHelper.Error(Window.GetWindow(this), $"新增失败!{ex.Message}");
                    ToastHelper.Error(Window.GetWindow(this), $"{LangUtil.Get("App.AddFailed")}: {ex.Message}");
                }
            }
            else if (btn.Name == "refreshBtn")
@@ -67,7 +61,7 @@
                catch (Exception ex)
                {
                    log.Error("Refresh Menu List Failed.", ex);
                    ToastHelper.Error(Window.GetWindow(this), $"刷新失败!{ex.Message}");
                    ToastHelper.Error(Window.GetWindow(this), $"{LangUtil.Get("App.RefreshFailed")}: {ex.Message}");
                }
            }
            else if (btn.Name == "deleteBatchBtn")
@@ -77,12 +71,12 @@
                    List<string> ids = Model.DataSource.Where(x => x.Selected).Select(x => x.Id).ToList();
                    if (ids == null || ids.Count <= 0)
                    {
                        ToastHelper.Warning(Window.GetWindow(this), "请选择要删除的菜单!");
                        ToastHelper.Warning(Window.GetWindow(this), LangUtil.Get("HMI.Menu.NoDeleteData"));
                        return;
                    }
                    var res = MsgBoxHelper.WarnMessage(Window.GetWindow(this),
                        $"确定删除选中的[{ids.Count}]条菜单吗?该操作不可逆!");
                        string.Format(LangUtil.Get("HMI.Menu.MakeSureDeletes"), ids.Count));
                    if (res == MessageBoxResult.OK)
                    {
                        Model.DeleteMenuByIds(ids);
@@ -92,7 +86,7 @@
                catch (Exception ex)
                {
                    log.Error("Delete Menu Batch Failed.", ex);
                    ToastHelper.Error(Window.GetWindow(this), $"删除失败!{ex.Message}");
                    ToastHelper.Error(Window.GetWindow(this), $"{LangUtil.Get("App.DeleteFailed")}: {ex.Message}");
                }
            }
            else if (btn.Name == "editBtn")
@@ -102,7 +96,7 @@
                    var data = (MenuData)btn.DataContext;
                    MenuModal window = new MenuModal
                    {
                        Title = "编辑菜单",
                        Title = $"{LangUtil.Get("HMI.Menu.Edit")}",
                        sqliteHelper = Model.sqliteHelper,
                        Owner = Window.GetWindow(this)
                    };
@@ -115,7 +109,7 @@
                catch (Exception ex)
                {
                    log.Error("Edit Menu Failed.", ex);
                    ToastHelper.Error(Window.GetWindow(this), $"编辑失败!{ex.Message}");
                    ToastHelper.Error(Window.GetWindow(this), $"{LangUtil.Get("HMI.EditFailed")}: {ex.Message}");
                }
            }
            else if (btn.Name == "delBtn")
@@ -124,7 +118,7 @@
                {
                    var data = (MenuData)((Button)sender).DataContext;
                    var res = MsgBoxHelper.WarnMessage(Window.GetWindow(this),
                        $"确定删除菜单[{data.Name}]吗?该操作不可逆!");
                        string.Format(LangUtil.Get("HMI.Menu.MakeSureDeleteSingle"), data.Name));
                    if (res == MessageBoxResult.OK)
                    {
                        Model.DeleteMenuById(data.Id);
@@ -134,7 +128,7 @@
                catch (Exception ex)
                {
                    log.Error("Delete Menu Failed.", ex);
                    ToastHelper.Error(Window.GetWindow(this), $"删除失败!{ex.Message}");
                    ToastHelper.Error(Window.GetWindow(this), $"{LangUtil.Get("HMI.DeleteFailed")}: {ex.Message}");
                }
            }
        }