确实是在客户端计算完,再存回去的,但是让客户写 select 表达式 as f1 from 表名 这样的,比较难,你想想,工资项目每个公司都是不一样的,计算方法也不一样的,如果是给客户定制,项目包括计算方公是确定的,我都可以直接在后台sql处理,这样更快。
----------------------------------------------
专业提供人力资源软件、指纹考勤软件、POS进销存软件、酒店餐饮软件 http://www.winsoftcn.com
ArtFormula package contains two nonvisual Delphi component for symbolic expression parsing and evaluation. Provides runtime scripting engine for automating your programs. Also ArtFormula can symbolically evaluate derivatives of a function with basic simplification of a result.
TArtFormula description
Properties:
property Error : TFormulaError; - returns current error code.
property LocalStrings : TStrings; - if TArtFormula compiled with multilang support (see below), this property contains list of pairs "StringName=LocalValue". You can use Names and Values properties of LocalStings to obtain string names and local values.
Published properties:
property UnQuotedString : boolean; - if true, ArtFormula will consider unknown identifiers as string literals.
property TestUsedVars : boolean; - if true, ArtFormula will test whether all external variables, passed as vars parameter of Compile or Test procedure, are used in source expression.
property CaseSensitive : boolean; - if true, ArtFormula will distinguish case of characters in variables name. Note: functions names are always case insensitive.
property Step : boolean; - if true, you can stop computation, by setting Stop property to true. If false you can't stop computation until it ends.
property CaseSensitiveString : boolean; - if true, ArtFormula will distinguish case of string characters in comparison operations and in pos function.
property ExternGetVar : boolean; - if set, ArtFormula will use GetVarValue and GetVarsCount events to evaluate unspecified external variables.
property VarNameLiterals : string; - defines set of literals, allowed for variable names.
property NoLeadingZero : boolean; - if true, you can omit leadin zero before point in floationg point numbers (both .5 and 0.5 correct), if false - only notation with leading zero accepted (only 0.5, .5 - causes error).
property ZeroEmptyString : boolean; - if true, ArtFormula will treat empty string az 0 in arithmetic operations.
Methods:
procedure SetVar(name : string; value : PCalcItem); - sets value of variable, given by name parameter.
function GetVar(name : string) : PCalcItem; - returns value of variable.
function IncVar(name : string) : PCalcItem; - increments value of a variable.
function DecVar(name : string) : PCalcItem; - decrements value of a variable.
procedure AddUserConstant(name, value : string); - adds new constant.
function AddUserFunction(name : string; paramcount:integer; fun : pformulafunction; ismodule:boolean=false):PTableItem; - adds user function (see Section creating user functions and modules).
function AddModuleFunction(module: PTableItem; name : string; paramcount:integer; fun : pformulafunction; ismodule:boolean=false):PTableItem; - adds module function (see Section creating user functions and modules).
function Test(instr : string; num : byte = 0; vars : PStringArray = nil) : boolean; - tests syntax of source code represented by instr. External variable names are passed as vars parameter, num specifies number of external variables. Returns true if there are no errors.
function Compile(instr : string; num : byte = 0; vars : PStringArray = nil) : string; - compiles source string and returns compiled byte code. On error raises exception.
function ComputeN(num : byte = 0; vals : PCalcArray = nil) : double; - compute previously compiled program and returns result as numeric value. Values of extern variables are passed in vals parameter, the number of values is passed in num value.
function Compute(num : byte = 0; vals : PCalcArray = nil) : string; - compute previously compiled program and returns result as string value.
function ComputeStrN(instr : string; num : byte = 0; vars : PStringArray = nil; vals : PCalcArray = nil) : double; - compiles and computes source string. Returns result as numeric value.
function ComputeStr(instr : string; num : byte = 0; vars : PStringArray = nil; vals : PCalcArray = nil) : string; - compiles and computes source string. Returns result as string value.
procedure StartGetVars(n : integer); - starts new parameters evaluation for variable argument list function (see Section creating user functions and modules).
function GetNextVar(var x : TCalcItem) : boolean; - evaluates next variable argument list function parameter. Returns false for last value (see Section creating user functions and modules).
function GetLocalString(name : string; defvalue : string) : string; - if TArtFormula compiled with multilang support, this function returns local value from current loaded language for string name and if string not set or empty it returns defvalue.
procedure LoadLang(lngfile : string); - if TArtFormula compiled with multilang support, this procedure load local strings from lngfile.
Events:
property GetVarsCount : TArtFormulaGetVarsCountProc; TArtFormulaGetVarsCountProc = procedure(Vname:string; var count:integer; wantnumber:boolean=false) of object; If you set ExternGetVars all unknown identifiers will treated as external variables. To evaluate them you should implement GetVarsCount and GetVarValue event handlers. GetVarsCount should return in count parameter number of values associated with Vname variable. Value of wantnumber specifies whether ArtFormula expects numerical values. GetVarsCount is called by ArtFormula when you pass external variable as a parameter of variant argument list function.
property GetVarValue : TArtFormulaGetVarProc; TArtFormulaGetVarProc = procedure(Vname:string; n : integer; var Val:string; wantnumber:boolean=false) of object; GetVarValue should return in Val parameter n-th value associated with Vname variable. n will change from 0 to count-1 where count returned by GetVarsCount event. Value of wantnumber specifies whether ArtFormula expects numerical values.
Note. Using GetVarsCount and GetVarValue you can implement for example range calculation in spreadsheet application when one parameter is passed in variant argument list function associated with number of cells.
Note. For fixed argument list function and when external variables are used as operands of expression, ArtFormula don't calls GetVarsCount and evaluates only first value associated with variable.
property OnLoadLang : TArtFormulaLoadLangProc; TArtFormulaLoadLangProc = procedure of object; If TArtFormula compiled with multilang support, this event arises when new local strings loaded from lng file. You can use this event to change local strings for installed TArtFormula modules or user functions.
----------------------------------------------
-