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 | 54 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs
index 5c8091b..d2ecf37 100644
--- a/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs
+++ b/DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs
@@ -34,37 +34,77 @@
{
if (value < 0.0 || value > 1.0)
{
- MsgHelper.Warning("瓒呴噰鐜囧繀椤诲湪0鍒�1涔嬮棿锛�");
+ MsgHelper.ShowError("瓒呴噰鐜囧繀椤诲湪0鍒�1涔嬮棿锛�");
txt_lossPercent.Focus();
return false;
}
-
+
// 鏍煎紡鍖栨樉绀猴紝淇濈暀閫傚綋鐨勫皬鏁颁綅鏁�
txt_lossPercent.EditValue = Math.Round(value, 4);
return true;
}
else
{
- MsgHelper.Warning("璇疯緭鍏ユ湁鏁堢殑鏁板瓧锛�");
+ 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 (!ValidateLossPercent())
+ if (!string.IsNullOrEmpty(_percent) && !ValidateLossPercent())
{
return;
}
-
var _obj = new
{
guidList = this.guidList,
- bz10 = txt_day.Value,
- percent = txt_lossPercent.EditValue
+ bz10 = _bz10,//鎻愬墠鍒拌揣澶╂暟
+ percent = _percent,
+ bz09 = _bz09,//鍚庢潵鏀逛负iqc绉伴噸灞炴��1瑕佺О閲�0涓嶇О閲�
};
try
{
--
Gitblit v1.9.3