lu
昨天 2caa1d97437e4089a7d6547c2efb87c7990b3b16
DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesItemsShow.cs
@@ -1,7 +1,9 @@
using Gs.DevApp.ToolBox;
using DevExpress.XtraRichEdit.Fields;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using System;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace Gs.DevApp.DevFrm.BasicData
{
@@ -17,12 +19,52 @@
            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.Warning("超采率必须在0到1之间!");
                    txt_lossPercent.Focus();
                    return false;
                }
                // 格式化显示,保留适当的小数位数
                txt_lossPercent.EditValue = Math.Round(value, 4);
                return true;
            }
            else
            {
                MsgHelper.Warning("请输入有效的数字!");
                txt_lossPercent.EditValue = 0.0;
                txt_lossPercent.Focus();
                return false;
            }
        }
        private void BtnSave_Click(object sender, EventArgs e)
        {
            // 保存前验证超采率
            if (!ValidateLossPercent())
            {
                return;
            }
            var _obj = new
            {
                guidList = this.guidList,
                bz10 = txt_day.Value,
                percent = txt_lossPercent.EditValue
            };
            try
            {