From fe2aa4880d5c9fd88088ad0ed81ebaca05629f5f Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 17:59:45 +0800
Subject: [PATCH] feat: 集成CAN驱动/模拟器 + 仪器仪表注册/硬件调试模块

---
 HMI.MenuManage/Modal/RoleModal.xaml.cs |   83 ++++++++++++-----------------------------
 1 files changed, 25 insertions(+), 58 deletions(-)

diff --git a/HMI.MenuManage/Modal/RoleModal.xaml.cs b/HMI.MenuManage/Modal/RoleModal.xaml.cs
index 623a728..0b8f823 100644
--- a/HMI.MenuManage/Modal/RoleModal.xaml.cs
+++ b/HMI.MenuManage/Modal/RoleModal.xaml.cs
@@ -1,17 +1,12 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Reflection;
-using System.Windows;
-using Microsoft.Win32;
-using Panuon.WPF.UI;
-using HMI.Core.Annotation;
-using HMI.Core.Entity;
-using HMI.Core.Exceptions;
-using HMI.Core.Util;
+锘縰sing HMI.Core.Util;
 using HMI.MenuManage.Entity;
 using HMI.MenuManage.Util;
+using HMI.UI.DpUtil;
+using HMI.UI.Util;
+using Panuon.WPF.UI;
+using System;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
 
 namespace HMI.MenuManage
 {
@@ -65,7 +60,7 @@
                 }
                 catch (Exception ex)
                 {
-                    Panuon.WPF.UI.Toast.Show(this, "Error锛�", ToastPosition.Top);
+                    ToastHelper.Error(this, $"Error锛亄ex.Message}");
                     e.Cancel = true;
                     return;
                 }
@@ -78,58 +73,30 @@
             base.OnClosing(e);
         }
 
-        private bool ValidateForm()
+        private bool ValidateCode(object value, out string err)
         {
-            try
+            err = null;
+            string segment = string.IsNullOrEmpty(Data.Id) ? "" : $" AND id!='{Data.Id}'";
+            string sql = $"SELECT 1 FROM user WHERE username='{TbCode.Text}'{segment};";
+            if (sqliteHelper.HasData(sql))
             {
-                FormValidateException ex = new FormValidateException();
-                string segment = string.IsNullOrEmpty(Data.Id) ? "" : $" AND id!='{Data.Id}'";
-                string sql = $"SELECT 1 FROM user WHERE username='{TbCode.Text}'{segment};";
-                if (string.IsNullOrEmpty(TbCode.Text))
-                {
-                    ex.Result.Add(new FormGroupValidateResult("璇疯緭鍏ヨ鑹茬紪鍙�", FgCode));
-                }
-                else if (sqliteHelper.HasData(sql))
-                {
-                    ex.Result.Add(new FormGroupValidateResult("瑙掕壊缂栧彿涓嶈兘閲嶅", FgCode));
-                }
-                else
-                {
-                    FgCode.ValidateResult = ValidateResult.None;
-                    FgCode.Message = null;
-                }
-
-                if (string.IsNullOrEmpty(TbName.Text))
-                {
-                    ex.Result.Add(new FormGroupValidateResult("璇疯緭鍏ヨ鑹插悕绉�", FgName));
-                }
-                else
-                {
-                    FgName.ValidateResult = ValidateResult.None;
-                    FgName.Message = null;
-                }
-
-                if (!ex.Success)
-                {
-                    throw ex;
-                }
-            }
-            catch (FormValidateException ex)
-            {
-                foreach (var data in ex.Result)
-                {
-                    var fg = (FormGroup)data.Sender;
-                    fg.ValidateResult = ValidateResult.Error;
-                    fg.Message = data.Message;
-                }
+                err = this.lang("App.MustUnique", this.lang("HMI.Role.Code"));
                 return false;
             }
-
-            Data.Code = TbCode.Text;
-            Data.Name = TbName.Text;
             return true;
         }
 
+        private bool ValidateForm()
+        {
+            bool flag = FormGroupHelper.ValidateForm(formPanel);
+            if (flag)
+            {
+                Data.Code = TbCode.Text;
+                Data.Name = TbName.Text;
+            }
+            return flag;
+        }
+
         public bool? Open(RoleData data)
         {
             Data = data;

--
Gitblit v1.9.1