From b53b7a16c8727c1c7c5752c5f69599b6a2aca20c Mon Sep 17 00:00:00 2001 From: DingJiaQi <3236352125@qq.com> Date: Mon, 11 Aug 2025 16:36:16 +0800 Subject: [PATCH] vault backup: 2025-08-11 16:36:16 --- .../相关操作/4.0-other/999.Delphi脚本记录.md | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md b/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md index c5c5ce8f..42ad1447 100644 --- a/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md +++ b/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md @@ -741,10 +741,53 @@ end. ## 整数判断 -想要达到的:物料 **启用库存周期复检** 时,**复检周期须不小于0** 且 **不小于提醒提前期** +举例:物料 **启用库存周期复检** 时,**复检周期须不小于0** 且 **不小于提醒提前期** ![](assets/Pasted%20image%2020250811162833.png) +脚本: +// 定义变量存储转换后的整数数值 +var StockCycle, LeadDay: Integer; +begin + // 注释:在下面添加您的脚本代码 + if cbxusr_FEnableCyclistQCSTK. checked = true then + begin + + try + // 将输入框文本转换为整数 + StockCycle := StrToInt(fedtusr_FStockCycle.Text); + LeadDay := StrToInt(fedtusr_FEWLeadDay.Text); + except + on E: EConvertError do + begin + ShowMessage('复检周期或提醒提前期输入格式错误,请输入有效的整数!'); + if Pos(fedtusr_FStockCycle.Text, E.Message) > 0 then + fedtusr_FStockCycle.SetFocus + else + fedtusr_FEWLeadDay.SetFocus; + Abort; + end; + end; + + // 检查复检周期是否大于提醒提前期,若不满足则提示错误 + if not (StockCycle > LeadDay) then + begin + ShowMessage('启用库存周期复检时,复检周期必须大于提醒提前期,请重新设置!'); + fedtusr_FStockCycle.SetFocus; // 将焦点定位到复检周期输入框 + Abort; // 终止后续操作,防止错误数据提交 + end; + + // 检查复检周期是否小于0 + if StockCycle < 0 then + begin + ShowMessage('启用库存周期复检时,复检周期不能小于0,请重新设置!'); + fedtusr_FStockCycle.SetFocus; + Abort; + end; + end; +end. + + 前置条件: // 定义变量存储转换后的整数数值