ลองทดสอบดูนะครับ
procedure GlobalOnCreate;
begin
GetDateRangeDialog(date1, date2);
bdate := Formatdatetime('yyyy-mm-dd',date1);
edate := Formatdatetime('yyyy-mm-dd',date2);
sp :=GetPickupList('select "·Ø¡â»Ãá¡ÃÁ" union select name from lansaka_risk_program_head ');
if sp<>'·Ø¡â»Ãá¡ÃÁ' then
begin
sp1:=GetSQLStringData('select id from lansaka_risk_program_head where name="'+sp+'" ');
end;
if sp='·Ø¡â»Ãá¡ÃÁ' then
begin
ChangeReportSQL('select risk_sum_dep,risk_id,risk_date,risk_time,risk_event,risk_level,login_name,risk_safety,risk_program_head,risk_program_detail '+
' from lansaka_risk_head '+
' where risk_date between "'+bdate+'" and "'+edate+'" '+
' and risk_level in ("1","2","3","4","A","B","C","D","E","F","G","H","I") '+
' order by risk_level desc ');
end;
if sp<>'·Ø¡â»Ãá¡ÃÁ' then
begin
ChangeReportSQL('select risk_sum_dep,risk_id,risk_date,risk_time,risk_event,risk_level,login_name,risk_safety,risk_program_head,risk_program_detail '+
' from lansaka_risk_head '+
' where risk_date between "'+bdate+'" and "'+edate+'" '+
' and risk_level in ("1","2","3","4","A","B","C","D","E","F","G","H","I") '+
' and risk_program_head="'+sp1+'" '+
' order by risk_level desc ');
end;
end;