自定程序
# PinToo 自定程序
# 1. TfxDm类程序
需引用ufxDm单元。
# 1.1. CopyStructure
procedure CopyStructure(ASourceDataSet, ATargetDataSet: TSQModuleDataSet);
1
说明: 复制数据集结构
- CopyStructure程序语法中各部分说明
部分 | 说明 |
---|---|
ASourceDataSet | 源数据集 |
ATargetDataSet | 目标数据集 |
# 1.2. DataExecSql
procedure DataExecSql(const ASql: string; ACds: TRFDataSet);
1
说明: 业务库数据操作
- 程序语法中各部分说明
部分 | 说明 |
---|---|
ASql | SQL语句 |
ACds | 数据集,数据集中的数据是通过执行SQL获得 |
begin
vDataSet:=TRFDataSet.Create;
try
vSQL := 'Select * from Basic_Whs';
fxDM.DataExecSql(vSQL,vDataSet);
finally
vDataSet.Free;
end;
end;
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 1.3. Edit_Plan_User_PassWord
Procedure Edit_Plan_User_PassWord(const AOldPW, ANewPW: string);
1
说明: 修改方案库中的用户密码
- Edit_Plan_User_PassWord程序语法中各部分说明
部分 | 说明 |
---|---|
AOldPW | 旧密码 |
ANewPW | 新密码 |
# 1.4. FillComboBox
procedure FillComboBox(var QControl: TfxComboBox; QSQL: string);
1
说明: 填充TComboBox下拉控件
- FillComboBox程序语法中各部分说明
部分 | 说明 |
---|---|
QControl | 指定一个需要填充数据的TComboBox对象 |
QSQL | 指定一个SQL字符串,用来获取填充数据 |
- 示列
Var
vSQL:String;
begin
vSQL:= 'Select FWhsName as FName from Basic_Whs';
fxDM.FillComboBox (fxComboBox1, vSQL);
end;
1
2
3
4
5
6
2
3
4
5
6
# 1.5. LoadDataFromDataSet
procedure LoadDataFromDataSet(ASource: TRFDataSet; ATarget: TRFDataSet;
ARecordCount: Integer = -1; ALoadDataType: TLoadDataType = ldtCopyData);
1
2
2
说明: 数据集传递
- LoadDataFromDataSet程序语法中各部分说明
部分 | 说明 |
---|---|
ASource | 源数据集 |
ATarget | 目标数据集 |
ARecordCount | 数据拷贝记录数 |
ALoadDataType | 数据拷贝类型(ldtCopyData, ldtCopyStruct, ldtStructAndData, ldtAppend); |
# 1.6. OpenSQL
procedure OpenSQL(ADataSet: TRFDataSet; ASQL: string; AConnectionDefName:
string = '');
1
2
2
说明: 打开SQL数据
- OpenSQL程序语法中各部分说明
部分 | 说明 |
---|---|
ADataSet | 需要打开数据的数据集 |
ASQL | 指定的SQL语句 |
AConnectionDefName | 帐套编号,默认为空,也可以指定帐套 |
- 示列
var
vDataSet:TRFDataSet;
vSQL:String;
begin
vDataSet:=TRFDataSet.Create;
try
vSQL := 'Select FWhsName as FName from Basic_Whs';
fxDM.OpenSQL(vDataSet,vSQL,’’);
//与以下两种方法效果相同
//方法1
vDataSet.SQL.Text := 'Select FWhsName as FName from Basic_Whs';
vDataSet.OpenData;
//方法2
vDataSet.OpenSQL(vSQL);
finally
vDataSet.Free;
end;
end;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 1.7. PlanExecSql
procedure PlanExecSql(const ASql: string; ACds: TRFDataSet);
1
说明: 方案库数据操作
- 程序语法中各部分说明
部分 | 说明 |
---|---|
ASql | SQL语句 |
ACds | 数据集,数据集中的数据是通过执行SQL获得 |
- 示列
begin
vDataSet:=TRFDataSet.Create;
try
vSQL := 'Select * from BaseUserInfo';
fxDM.PlanExecSql(vSQL,vDataSet);
finally
vDataSet.Free;
end;
end;
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 1.8. SetDataSetParam
procedure SetDataSetParam(QDataSet: TRFDataSet; QIndex: Integer; QValue: Variant);
1
说明: 设定指定数据集的参数信息。
- SetDataSetParam程序语法中各部分说明
部分 | 说明 |
---|---|
QDataSet | 需要设置参数的数据集 |
Qindex | 参数序号值,从0开始计数 |
QValue | 参数的取值 |
- 示例
begin
fxRFDataSet.SQL.Text := 'SELECT * FROM Sal_OrderEntry WHERE FInterID = :FInterID and FID = :FID';
//序号0对应的参数为:FInterID
FXDM.SetDataSetParam(fxRFDataSet,0,IntToStr(vInterID));
//序号1对应的参数为:FID
FXDM.SetDataSetParam(fxRFDataSet,1,IntToStr(vID));
fxRFDataSet.OpenData;
end.
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 1.9. SetStoredProcParam
procedure SetStoredProcParam(QStoredProc: TRFStoredProc; QIndex: Integer; QValue: Variant);
1
说明: 设置存储过程的参数
- SetStoredProcParam程序语法中各部分说明
部分 | 说明 |
---|---|
QStoredProc | 存储过程控件的名称 |
QIndex | 参数序号值,从0开始计数 |
QValue | 参数的取值 |
- 示例
var
vOption: String;
AStoredProc: TRFStoredProc;
vRAISEMSG,vMSG: String;
i, j: Integer;
Begin
if cbMore.ItemIndex = -1 Then
exit;
if cbMore.ItemIndex = 0 Then
vOption := 'Check';
if cbMore.ItemIndex = 1 Then
vOption := 'UnCheck';
if cbMore.ItemIndex = 2 Then
vOption := 'Revoke';
if cbMore.ItemIndex = 3 Then
vOption := 'Recover';
if cbMore.ItemIndex = 4 Then
vOption := 'Delete';
AStoredProc := TRFStoredProc.Create(nil);
AStoredProc.Connection := fxdm.DBConnection;
try
AStoredProc.StoredProcName := 'sp_Sal_Order';
AStoredProc.Prepare;
if AStoredProc.Prepared then
begin
//AStoredProc.ParamByName('FDataID').AsString := dts0.FieldByName('FInterID').AsString;
//AStoredProc.ParamByName('Flag').AsString := 'Delete';
//AStoredProc.ParamByName('FUserCode').AsString := self.GetMsgLang('admin');
fxdm.SetStoredProcParam(AStoredProc,0,vOption);
fxdm.SetStoredProcParam(AStoredProc,1,dts0.FieldByName('FInterID').AsString);
fxdm.SetStoredProcParam(AStoredProc,2,self.GetMsgLang('admin'));
try
AStoredProc.ExecProc;
Except
vRAISEMSG:= ErrorMsg;
i := Pos('SQMESSAGE', vRAISEMSG);
j := Pos('[SQL Server]', vRAISEMSG);
vMSG := Copy(vRAISEMSG, i, Length(vRAISEMSG) - i + 1);
// 非格式化消息提示
if i = 0 then
begin
ShowMessage(Copy(vRAISEMSG, j + 12, Length(vRAISEMSG) - j + 1));
Exit;
end;
end;
//btnQueryClick(sender);
end;
finally
AStoredProc.Free;
dts0.OpenData;
dts1.OpenData;
OpenSalOrder;
OpenSalOrderEntry;
cbMore.ItemIndex := -1;
end;
End;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 1.10. TransFieldValue
procedure TransFieldValue(ASource: TRFDataSet; ATarget: TRFDataSet;
ATransFieldList: String);
1
2
2
说明: 根据指定字段数据集记录拷贝
- TransFieldValue程序语法中各部分说明
部分 | 说明 |
---|---|
ASource | 源数据集 |
ATarget | 目标数据集 |
ATransFieldList | 需要拷贝的字段 |
- 示例
begin
//指定字段进行数据拷贝,将dts0拷贝到dts1
fxDM.TransFieldValue(dts0,dts1,'FInterID;FCustID;FCustName');
end;
1
2
3
4
2
3
4
# 1.11. TransSQLToDataSet
procedure TransSQLToDataSet(QSQLs: UnicodeString; QDataSets: TRFDataSet;
bTrans: Boolean = true);
1
2
2
说明: SQL通用数据传递
- TransSQLToDataSet程序语法中各部分说明
部分 | 说明 |
---|---|
QSQLs | SQL字符串,用来获取源数据 |
QDataSets | 目标数据集,需要接收数据的数据集对象 |
bTrans | 当目标字段不为空时,是否进行覆盖 |
- 示例
Var
vSQL:string;
Begin
vSQL:= 'select * from Basic_Process Order By FEntryID';
//将SQL语句执行结果传递到数据集dts1上
fxDM.TransSQLToDataSet(vSQL, dts1);
End;
1
2
3
4
5
6
7
2
3
4
5
6
7
# 2. TfxFun类函数
需引用ufxFuntions单元。
# 2.1. DownLoadFile
procedure DownLoadFile(const Url, FilePath: string);
1
说明: 指定网址下载文件
- DownLoadFile程序语法中各部分说明
部分 | 说明 |
---|---|
Url | 网络文件网址 |
FilePath | 指定一个文件存放目录 |
# 2.2. OpenFile
procedure OpenFile(const FilePath,FileName: string);
1
说明: 指定文件路径打开文件
- OpenFile程序语法中各部分说明
部分 | 说明 |
---|---|
FilePath | 文件目录 |
FileName | 文件名称 |
# 2.3. PrintHtml
procedure PrintHtml(const Url, JobName: string);
1
说明: 指定网址打印网页
- PrintHtml程序语法中各部分说明
部分 | 说明 |
---|---|
Url | 网址 |
JobName | 指定一个打印文件名称 |
# 2.4. PrintPdfFile
procedure PrintPdfFile(const PdfFileName, JobName: string);
1
说明: 指定PDF文件打印
- PrintPdfFile程序语法中各部分说明
部分 | 说明 |
---|---|
PdfFileName | 指定一个PDF文件 |
JobName | 指定一个打印文件名称 |