businessobj.pas

来自「Delphi面向对象编程思想附书源码 好用哦!」· PAS 代码 · 共 51 行

PAS
51
字号
unit BusinessObj;


{本单元是基于特定窗体及其数据模块的业务逻辑代码,用于处理相关查询}
interface
 uses dbtables, db, dbgrids, Graphics,variants,Classes;

type
  TBiz = class(TComponent)
  private
    { Private declarations }
  public
    Procedure LocateCorrectAddress(var vqryAddress: Tquery;
                               const cstrType: string);
    Procedure HighLightBank(var vcolCurrent: TColumn;
                        const cintColumn: integer);
    Procedure FindRightBank(var vqryOrder, vqryFinancial: tQuery);
  end;

implementation

Procedure TBiz.LocateCorrectAddress(var vqryAddress: Tquery;
                               const cstrType: string);
begin
 vqryAddress.Locate('CustomerNumber;AddressType',
                    VarArrayOf([vqryAddress['CustomerNumber'], cstrType]),
                    []);
end;

{为某些含有特殊字符的银行名称进行着色处理,突出显示效果}
Procedure TBiz.HighLightBank(var vcolCurrent: TColumn;const cintColumn: integer);
begin
  If cintColumn = 2 then
    If pos('中国', vcolCurrent.Field.asstring) > 0 then
       vcolCurrent.Color := clAqua
    else
    If pos('USA', vcolCurrent.Field.asstring) > 0 then
       vcolCurrent.Color := clRed;
end;

Procedure TBiz.FindRightBank(var vqryOrder, vqryFinancial: tQuery);
begin
 {根据帐户号定位银行}
 vqryFinancial.Locate('CustomerNumber;CreditCard',
                    VarArrayOf([vqryOrder['CustomerNumber'],
                                vqryOrder['CreditCard']]),
                    []);
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?