From c4a3f8db90530a727ffab77c3bb5bb7d782792bf Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期一, 25 八月 2025 15:50:27 +0800
Subject: [PATCH] 上传代码;
---
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