If strtodatetime(chkon)>strtodatetime(timeon) then QRExpr6.caption := '遲到'; If strtodatetime(timeoff)>strtodatetime(chkoff) then QRExpr7.caption := '早退'; 这样就可以了当然也可以用计算字段拉
to : 007pro(等你说爱我) 如果按我的方法可以的話,是不是存在顯示一條紀錄要9个QRLabel控件,顯示第2條紀錄要18个QRLabel控件,作第3次循環要27个QRLabel控件.....像asp中一樣???你一般怎麼作啊?? 可以用计算字段,怎麼用來顯示數據庫表中沒有的字段呢??
这段代码没问题的 那么这样写在BeforePrint里应该也对吧procedure TForm1.Button1Click(Sender: TObject); VAR chkon,chkoff,timeoff,timeon,NOONTIME:STRING; begin timeoff:=DATETOSTR(DATE)+' '+'17:10' ; timeoff:=formatdatetime('hh:mm',strtodatetime(timeoff)); timeon:=DATETOSTR(DATE)+' '+'07:40' ; timeon:=formatdatetime('hh:mm',strtodatetime(timeon)); NOONTIME:=formatdatetime('12:00',strtodatetime(timeon)); chkon:= formatdatetime('hh:mm',NOW); chkoff:=formatdatetime('hh:mm',NOW); If (strtodatetime(chkon)>strtodatetime(timeon)) AND (strtodatetime(chkon)<strtodatetime(NOONTIME)) then EDIT1.Text := '遲到'; If (strtodatetime(timeoff)>strtodatetime(chkoff)) AND (strtodatetime(NOONTIME)<strtodatetime(chkoff)) then EDIT1.Text := '早退';end;
procedure Tpersonalrep.DetailBand1BeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); var sqlsect,timeon,timeoff,chkon,chkoff:string; i:integer; begin dataset:=dm.query1; sqlsect:='select chk_day ,chk_onduty, chk_offduty,chk_addonduty ,chk_addoffduty ,chk_note '; sqlsect:=sqlsect + 'from tab_chkduty where sta_id = ''p09000'' order by chk_day '; with dm.query1 do begin try Close; SQL.Clear; SQL.Add (sqlsect); open; except //showmessage('不能打開數據庫!'); end; end; QExpr1.caption := dm.query1.FieldByName ('chk_day').asstring; timeon:= dm.query1.FieldByName ('chk_day').asstring; timeoff:=timeon+' '+'17:10' ; timeoff:=formatdatetime('hh:mm',strtodatetime(timeoff)); timeon:=timeon+' '+'07:40' ; timeon:=formatdatetime('hh:mm',strtodatetime(timeon)); QRExpr2.caption := dm.query1.FieldByName ('chk_onduty').asstring; QRExpr3.caption := dm.query1.FieldByName ('chk_offduty').asstring; QRExpr4.caption := dm.query1.FieldByName ('chk_addonduty').asstring; QRExpr5.caption := dm.query1.FieldByName ('chk_addoffduty').asstring; chkon:=dm.query1.FieldByName ('chk_onduty').asstring; chkon:= formatdatetime('hh:mm',strtodatetime(chkon)); chkoff:=dm.query1.FieldByName ('chk_offduty').asstring; chkoff:=formatdatetime('hh:mm',strtodatetime(chkoff)); If strtodatetime(chkon)>strtodatetime(timeon) then QRExpr6.caption := '遲到'; If strtodatetime(timeoff)>strtodatetime(chkoff) then QRExpr7.caption := '早退'; QRExpr8.caption := '8:0'; QRExpr9.caption := dm.query1.FieldByName ('chk_note').asstring; end ;
不麻烦呀,就是打开Query1.sql.open,然后把9个字段赋给9个QRLabel控件,5秒
钟看完!
我用同样方法给qrlabel赋值取值的时候我没有用循环我看你用循环的话永远只会取倒最后一条纪录
我的程序為什麼一條紀錄都不顯示呀!
我想用sql語句來顯示Qreport是基本問題,大家一定經常碰到.用可視化的方法不靈活的.ASP上的熱心人很多,delphi上的热心人是越来越少了......
不用你那么麻烦
不要循环拉
我明白你的意思.
但我要顯示數據庫表中沒有的字段('上班是否遲到'),而'上班是否遲到'列 又與數據庫表中的'上班時間'有關.我只有在顯示每一條紀錄時作判斷. 怎麼辦???
chkon:= formatdatetime('hh:mm',strtodatetime(chkon));
chkoff:=dm.query1.FieldByName ('chk_offduty').asstring;
chkoff:=formatdatetime('hh:mm',strtodatetime(chkoff));
If strtodatetime(chkon)>strtodatetime(timeon) then
QRExpr6.caption := '遲到'; If strtodatetime(timeoff)>strtodatetime(chkoff) then
QRExpr7.caption := '早退';
这样就可以了当然也可以用计算字段拉
如果按我的方法可以的話,是不是存在顯示一條紀錄要9个QRLabel控件,顯示第2條紀錄要18个QRLabel控件,作第3次循環要27个QRLabel控件.....像asp中一樣???你一般怎麼作啊??
可以用计算字段,怎麼用來顯示數據庫表中沒有的字段呢??
那么这样写在BeforePrint里应该也对吧procedure TForm1.Button1Click(Sender: TObject);
VAR
chkon,chkoff,timeoff,timeon,NOONTIME:STRING;
begin
timeoff:=DATETOSTR(DATE)+' '+'17:10' ;
timeoff:=formatdatetime('hh:mm',strtodatetime(timeoff));
timeon:=DATETOSTR(DATE)+' '+'07:40' ;
timeon:=formatdatetime('hh:mm',strtodatetime(timeon));
NOONTIME:=formatdatetime('12:00',strtodatetime(timeon));
chkon:= formatdatetime('hh:mm',NOW);
chkoff:=formatdatetime('hh:mm',NOW);
If (strtodatetime(chkon)>strtodatetime(timeon))
AND (strtodatetime(chkon)<strtodatetime(NOONTIME)) then
EDIT1.Text := '遲到';
If (strtodatetime(timeoff)>strtodatetime(chkoff))
AND (strtodatetime(NOONTIME)<strtodatetime(chkoff)) then
EDIT1.Text := '早退';end;
var PrintBand: Boolean);
var
sqlsect,timeon,timeoff,chkon,chkoff:string;
i:integer;
begin
dataset:=dm.query1;
sqlsect:='select chk_day ,chk_onduty, chk_offduty,chk_addonduty ,chk_addoffduty ,chk_note ';
sqlsect:=sqlsect + 'from tab_chkduty where sta_id = ''p09000'' order by chk_day ';
with dm.query1 do
begin
try
Close;
SQL.Clear;
SQL.Add (sqlsect);
open;
except
//showmessage('不能打開數據庫!');
end;
end; QExpr1.caption := dm.query1.FieldByName ('chk_day').asstring;
timeon:= dm.query1.FieldByName ('chk_day').asstring;
timeoff:=timeon+' '+'17:10' ;
timeoff:=formatdatetime('hh:mm',strtodatetime(timeoff));
timeon:=timeon+' '+'07:40' ;
timeon:=formatdatetime('hh:mm',strtodatetime(timeon)); QRExpr2.caption := dm.query1.FieldByName ('chk_onduty').asstring;
QRExpr3.caption := dm.query1.FieldByName ('chk_offduty').asstring;
QRExpr4.caption := dm.query1.FieldByName ('chk_addonduty').asstring;
QRExpr5.caption := dm.query1.FieldByName ('chk_addoffduty').asstring;
chkon:=dm.query1.FieldByName ('chk_onduty').asstring;
chkon:= formatdatetime('hh:mm',strtodatetime(chkon));
chkoff:=dm.query1.FieldByName ('chk_offduty').asstring;
chkoff:=formatdatetime('hh:mm',strtodatetime(chkoff));
If strtodatetime(chkon)>strtodatetime(timeon) then
QRExpr6.caption := '遲到'; If strtodatetime(timeoff)>strtodatetime(chkoff) then
QRExpr7.caption := '早退'; QRExpr8.caption := '8:0';
QRExpr9.caption := dm.query1.FieldByName ('chk_note').asstring;
end ;
這麼做是不是存在顯示一條紀錄要9个QRLabel控件,顯示第2條紀錄要18个QRLabel控件,作第3次循環要27个QRLabel控件.....像asp中一樣的問題??? 我現在試試吧!可能我的方法不行!
你提到'计算字段',讓我想起數據庫表中沒有與column相應字段的用QRExpr控件,數據庫表中有與column相應字段的用QRLabel控件, 還是用可視化編程做.在QRExpr控件中的expression
窗口中不知能不能寫 if.. '遲到' else ..then '早退'.. ????
你是觉得浪费资源啊Quick Report datesouce只要指定就会复制recordcount个DetailBand实例
首先一点是不用手工建立的(我觉得你要手工创建QRLabel似的)
procedure Tpersonalrep.DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
用可視化編程做.在QRExpr控件中的Expression
窗口中不知能不能寫 if.. '遲到' else ..then '早退'.. ????
我剛學delphi的,你很牛為什麼不幫幫我?? (: