vault backup: 2025-05-08 20:01:04
This commit is contained in:
@ -189,6 +189,84 @@ begin
|
||||
end.
|
||||
```
|
||||
|
||||
## 批量校验控件并进行更新
|
||||
|
||||
```Delphi
|
||||
uses MyClass,Variables,BaseUtil,CommonFunc,DataConst,CFFrm,CFSimplePropFrm,Forms,StdCtrls,Variants,SysUtils,Classes,Controls,Dialogs,
|
||||
CHostIntf,ProductClas,DocClas,LoginClas,VirtualTrees,CEntClas,PathClas;
|
||||
|
||||
var
|
||||
ModifiedControls: TStringList;
|
||||
CurrentForm: TForm; // 添加窗体变量
|
||||
|
||||
procedure ProcessControls(EnablePrefix: string);
|
||||
var
|
||||
EnableCheckBox: TCheckBox;
|
||||
AffectCheckBox: TCheckBox;
|
||||
AffectNames: array[0..2] of string;
|
||||
AffectControlName: string;
|
||||
i: Integer;
|
||||
begin
|
||||
AffectNames[0] := 'FIsAffectPrice';
|
||||
AffectNames[1] := 'FIsAffectPlan';
|
||||
AffectNames[2] := 'FIsAffectCost';
|
||||
|
||||
// 通过当前窗体查找组件
|
||||
EnableCheckBox := TCheckBox(CurrentForm.FindComponent('cbxusr_' + EnablePrefix + '_FIsEnable'));
|
||||
if Assigned(EnableCheckBox) and not EnableCheckBox.Checked then
|
||||
begin
|
||||
for i := 0 to High(AffectNames) do
|
||||
begin
|
||||
AffectControlName := 'cbxusr_' + EnablePrefix + '_' + AffectNames[i];
|
||||
AffectCheckBox := TCheckBox(CurrentForm.FindComponent(AffectControlName));
|
||||
|
||||
if Assigned(AffectCheckBox) and AffectCheckBox.Checked then
|
||||
begin
|
||||
ModifiedControls.Add(AffectControlName);
|
||||
AffectCheckBox.Checked := False;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
ModifiedControls := TStringList.Create;
|
||||
try
|
||||
try
|
||||
// 获取当前活动窗体
|
||||
CurrentForm := Screen.ActiveForm;
|
||||
if not Assigned(CurrentForm) then
|
||||
begin
|
||||
ShowMessage('无法获取当前窗体');
|
||||
Exit;
|
||||
end;
|
||||
|
||||
ProcessControls('01');
|
||||
ProcessControls('02');
|
||||
ProcessControls('03');
|
||||
ProcessControls('04');
|
||||
ProcessControls('06');
|
||||
|
||||
if ModifiedControls.Count > 0 then
|
||||
begin
|
||||
ShowMessage(
|
||||
'以下控件的值已被自动修改为未选中状态:' + #13#10 +
|
||||
'--------------------------------' + #13#10 +
|
||||
ModifiedControls.Text + #13#10 +
|
||||
'--------------------------------' + #13#10 +
|
||||
'因为对应的Enable控件未选中'
|
||||
);
|
||||
end;
|
||||
except
|
||||
on E: Exception do
|
||||
ShowMessage('执行脚本时出错: ' + E.Message);
|
||||
end;
|
||||
finally
|
||||
ModifiedControls.Free;
|
||||
end;
|
||||
end.
|
||||
```
|
||||
|
||||
## 更新枚举选项
|
||||
|
||||
`cbxusr_444` 控件的值必须等于 `cbxusr_333` 控件的值(枚举选项用 `.Text` 可以直接获取,直接赋值,但是不能直接设置在控件上)
|
||||
|
Reference in New Issue
Block a user