From 5d0080eecc63a8ea1feac3f4f248549eb68d2c5e Mon Sep 17 00:00:00 2001
From: cdk <2441919651@qq.com>
Date: 星期四, 30 十月 2025 11:20:55 +0800
Subject: [PATCH] 增加验证

---
 DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs |   92 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 83 insertions(+), 9 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs
index 8bab744..d2ecf37 100644
--- a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs
+++ b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs
@@ -1,15 +1,9 @@
-锘縰sing DevExpress.XtraEditors;
+锘縰sing DevExpress.XtraRichEdit.Fields;
 using Gs.DevApp.ToolBox;
 using Newtonsoft.Json;
 using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows.Forms;
+using System.Text.RegularExpressions;
 
 namespace Gs.DevApp.DevFrm.BasicData
 {
@@ -25,12 +19,92 @@
             this.btnSave.Click += BtnSave_Click;
         }
 
+        /// <summary>
+        /// 楠岃瘉瓒呴噰鐜囪緭鍏ュ��
+        /// </summary>
+        private bool ValidateLossPercent()
+        {
+            if (txt_lossPercent.EditValue == null || string.IsNullOrWhiteSpace(txt_lossPercent.Text))
+            {
+                txt_lossPercent.EditValue = 0.0;
+                return true;
+            }
+
+            if (double.TryParse(txt_lossPercent.EditValue.ToString(), out double value))
+            {
+                if (value < 0.0 || value > 1.0)
+                {
+                    MsgHelper.ShowError("瓒呴噰鐜囧繀椤诲湪0鍒�1涔嬮棿锛�");
+                    txt_lossPercent.Focus();
+                    return false;
+                }
+
+                // 鏍煎紡鍖栨樉绀猴紝淇濈暀閫傚綋鐨勫皬鏁颁綅鏁�
+                txt_lossPercent.EditValue = Math.Round(value, 4);
+                return true;
+            }
+            else
+            {
+                MsgHelper.ShowError("璇疯緭鍏ユ湁鏁堢殑鏁板瓧锛�");
+                txt_lossPercent.EditValue = 0.0;
+                txt_lossPercent.Focus();
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 楠岃瘉鎻愬墠鍒拌揣澶╂暟蹇呴』涓哄ぇ浜�0鐨勬暣鏁�
+        /// </summary>
+        private bool ValidateDay()
+        {
+            var text = txt_day.Text?.Trim();
+            if (string.IsNullOrWhiteSpace(text))
+            {
+                // 鍏佽涓虹┖锛岃〃绀轰笉璁剧疆鎻愬墠澶╂暟
+                txt_day.EditValue = null;
+                return true;
+            }
+
+            if (int.TryParse(text, out int days))
+            {
+                if (days <= 0)
+                {
+                    MsgHelper.ShowError("鎻愬墠鍒拌揣澶╂暟蹇呴』涓哄ぇ浜�0鐨勬暣鏁般��");
+                    txt_day.Focus();
+                    return false;
+                }
+
+                // 瑙勮寖鍖栨樉绀轰负鏁存暟
+                txt_day.EditValue = days;
+                return true;
+            }
+            else
+            {
+                MsgHelper.ShowError("璇疯緭鍏ユ湁鏁堢殑鏁存暟澶╂暟銆�");
+                txt_day.Focus();
+                return false;
+            }
+        }
+
         private void BtnSave_Click(object sender, EventArgs e)
         {
+            if (!ValidateDay())
+                return;
+
+            string _bz10 = txt_day.Text;
+            string _percent = txt_lossPercent.Text;
+            string _bz09 = txt_bz09.Text;
+            // 淇濆瓨鍓嶉獙璇佽秴閲囩巼
+            if (!string.IsNullOrEmpty(_percent) && !ValidateLossPercent())
+            {
+                return;
+            }
             var _obj = new
             {
                 guidList = this.guidList,
-                bz10 = txt_day.Value,
+                bz10 = _bz10,//鎻愬墠鍒拌揣澶╂暟
+                percent = _percent,
+                bz09 = _bz09,//鍚庢潵鏀逛负iqc绉伴噸灞炴��1瑕佺О閲�0涓嶇О閲�
             };
             try
             {

--
Gitblit v1.9.3