ศึกษาจากกระทู้นี้ครับ
http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=21592.0ส่วน script ที่ผมใช้งานก็ตามนี้ครับ
var
fvn,fcomputername,fdepartment,fhn : string;
fdate_1,fdate_2,fdate_3 : string;
tc : TClientDataset;
dTDate, sdTDate : date;
begin
//showmessage('TEST Script');
fvn:= GetGlobalValue('VN');
fcomputername := GetGlobalValue('CURRENT_COMPUTER');
fdepartment := GetGlobalValue('CURRENT_DEPCODE');
fhn:=getsqldata('select hn from ovst where vn = "'+fvn+'"');
// showmessage('Current VN = '+fvn+' , Computer Name = '+fcomputername+' , Department Code = '+fdepartment);
{==================== check TT ====================}
if getsqldata('select depcode from kskdepartment where depcode in ("011","044","008") and depcode="'+fdepartment+'"')=''+fdepartment+'' then
begin
fhn:=getsqldata('select hn from ovst where vn = "'+fvn+'"');
dTDate:=getsqldata('select o.vstdate from er_regist_oper e '+
'left outer join vn_stat o on o.vn=e.vn '+
'where o.hn = "'+fhn+'" and e.er_oper_code in ("148","266") order by o.vstdate desc limit 1 ');
if getsqldata('select count(*) as cc from er_regist_oper e '+
'left outer join vn_stat o on o.vn=e.vn '+
'where o.hn = "'+fhn+'" and e.er_oper_code in ("148","266") ')>0 then
begin
sdTDate:=FormatDatetime('dd/mmm/eeee',dTDate);
showmessage('[ ¼Ùé»èÇÂà¤Â©Õ´ÇѤ«Õ¹ Tetanus toxoid ËÃ×Í DIPHTHERIA-TETANUS à¢çÁ·Õè 3 ÁÒáÅéÇàÁ×èÍÇѹ·Õè '+sdTDate+' ]');
end;
end;
end;