//----------------- 主窗体调用代码 ---------------------
procedure TMainForm.Button1Click(Sender: TObject);
var
f: COMMONFORMS.TCommonSelectForm;
lResultStr: String;
begin
f := COMMONFORMS.TCommonSelectForm.Create(Context);
COMMONFORMS.TCommonSelectForm.IniFormObject(InfoBrokerYWXX1.Info,
dsWhere.DataSet,dsResult.DataSet,
'dsWhere', 'RESULT_G.FormDoc',
2,'ID');
if f.ShowModal = Business.Forms.Controls.mrOK then
begin
//字窗体定定义 Public static function ResultValue(): String;
lResultStr := COMMONFORMS.TCommonSelectForm.ResultValue();
Dialogs.ShowMessage(lResultStr);
end;
end;
//----------------- 子窗体调用接口过程代码 -------------------
static procedure TCommonSelectForm.IniFormObject(AInfo: TInfo;
AdsQueryWhere,AdsQueryResult: TDataSet;
AWhereDataSetID, AResultDodID: String;
AMode:Integer = 1; ADefaultKey: String='');
var
lForm: TCommonSelectForm;
begin
lForm:= TCommonSelectForm.Create(nil);
try
lForm.InfoBroker1.Info := AInfo;
lForm.dsQueryWhere.InfoBroker := lForm.InfoBroker1;
lForm.dsQueryWhere.DataSetID := AWhereDataSetID;
lForm.DocView1.DocClassID := AResultDodID;
AdsWhere := AdsQueryWhere;
AdsResult := AdsQueryResult;
AdsWhereDataSetID := AWhereDataSetID;
ASelectMode := AMode;
ADefaultKeyField := ADefaultKey;
AKeyFieldValue := '';
except
Dialogs.ShowMessage('传入参数错误');
end;
end;
//----------------- 子窗体 "确定" 按钮代码 ------------
procedure TCommonSelectForm.sbConfirmClick(Sender: TObject);
var
li: Integer;
begin
if AdsResult.IsEmpty then
begin
Self.ModalResult := Business.Forms.Controls.mrCancel
end else
Self.ModalResult := Business.Forms.Controls.mrOk;
end;
//----------------- 子窗体 "取消" 按钮代码 ------------
procedure TCommonSelectForm.sbExitClick(Sender: TObject);
begin
Self.ModalResult := Business.Forms.Controls.mrCancel;
Close;
end; |