请教一个关于progress bar的问题,不知为什么TIMER1事件不执行(50分)

  • 主题发起人 主题发起人 mwp316
  • 开始时间 开始时间
M

mwp316

Unregistered / Unconfirmed
GUEST, unregistred user!
查询过程
procedure TPOGenInfForm.btn_QueryClick(Sender: TObject);
var
i,count_all,count_delay,count_more:integer;
amount_all,sysu_all:real;
begin
inherited;
//查询
Timer1.Enabled:=true;
rzprogressbar1.Visible:=true;
rzprogressbar1.Percent :=0;
condition:='';
if trim(edt_PO.Text)<>'' then
begin
condition:=' and ODNO='+''''+trim(edt_PO.Text)+'''';
end;
if trim(cbx_COP_G_NO.Text)<>'' then
begin
condition:=condition+' and ZBAN='+''''+cbx_COP_G_NO.Text+'''';
end;
if trim(cbx_VENDOR.Text)<>'' then
begin
condition:=condition+' and SAKI='+''''+cbx_VENDOR.EditValue+'''';
end;
if trim(cbx_DEPT.Text)<>'' then
begin
condition:=condition+' and JGYO='+''''+trim(cbx_DEPT.Text)+'''';
end;
if trim(edt_MODEL.Text)<>'' then
begin
condition:=condition+' and SSCD='+''''+trim(edt_MODEL.Text)+'''';
end;
case cbx_ZX_STATE.ItemIndex of
0:condition:=condition+' and 1=1';
1:condition:=condition+' and STATE1=1';
2:condition:=condition+' and STATE1=2';
3:condition:=condition+' and STATE1=3';
end;
case cbx_YQ_STATE.ItemIndex of
0:condition:=condition+' and 1=1';
1:condition:=condition+' and STATE2=1';
2:condition:=condition+' and STATE2=2';
3:condition:=condition+' and STATE2=3';
end;
if (edt_START_HTDT.IsDateInput) and (edt_END_HTDT.IsDateInput) then
begin
if edt_START_HTDT.Date>edt_END_HTDT.Date then
begin
ShowMessage('开始日期不能大于结束日期!');
exit;
end
else
begin
condition:=condition+' and HTDT between '+''''+DateToStr(edt_START_HTDT.Date)+''''+' and '+''''+DateToStr(edt_END_HTDT.Date)+'''';
end;
end;
if (edt_START_NOKI.IsDateInput) and (edt_END_NOKI.IsDateInput) then
begin
if edt_START_NOKI.Date>edt_END_NOKI.Date then
begin
ShowMessage('开始日期不能大于结束日期');
exit;
end
else
begin
condition:=condition+' and NOKI between '+''''+DateToStr(edt_START_NOKI.Date)+''''+' and '+''''+DateToStr(edt_END_NOKI.Date)+'''';
end;
end;
condition:=copy(condition,6,length(condition)-5);
sqlstr:='SELECT ZBAN,ODNO,SYSU,TANK,SYSU*TANK as AMOUNT,JGYO,HTDT,NOKI,HZAN,SSCD,SAKI,TUKA,STATE1,STATE2,';
sqlstr:=sqlstr+' T_CTE_ITEMMST.G_ENG_NAME,T_ITEMNO.G_CHN_NAME,T_CTE_VENDOR.VENDOR_NAME,T_CTE_CURR.NAME_CN ';
sqlstr:=sqlstr+' FROM PO_INFO LEFT OUTER JOIN T_CTE_ITEMMST ON PO_INFO.ZBAN=T_CTE_ITEMMST.COP_G_NO ';
sqlstr:=sqlstr+' LEFT OUTER JOIN T_ITEMNO ON T_CTE_ITEMMST.ITEM_NO=T_ITEMNO.ITEM_NO ';
sqlstr:=sqlstr+' LEFT OUTER JOIN T_CTE_VENDOR ON PO_INFO.SAKI=T_CTE_VENDOR.VENDOR_NO ';
sqlstr:=sqlstr+' LEFT OUTER JOIN (SELECT CODE,NAME_CN FROM T_CTE_CODE WHERE CODE_TYPE='+''''+'CURR'+'''';
sqlstr:=sqlstr+' and ISVALID=1) T_CTE_CURR ON PO_INFO.TUKA=T_CTE_CURR.CODE WHERE ';
sqlstr:=sqlstr+condition;
//ShowMessage(sqlstr);
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text:=sqlstr;
ADOQuery1.Open;
count_all:=0;
sysu_all:=0;
amount_all:=0;
ADOQuery1.First;
while not ADOQuery1.Eofdo
begin
count_all:=count_all+1;
//计算总行数
sysu_all:=sysu_all+ADOQuery1.fieldbyname('SYSU').Value;
amount_all:=amount_all+ADOQuery1.fieldbyname('AMOUNT').Value;
ADOQuery1.Next;
end;
//延期到货数
dm_public.qry_Public.Close;
dm_public.qry_Public.SQL.Clear;
dm_public.qry_Public.SQL.Text:='select count(*) from po_info where '+condition+' and state1=3 and state2=1';
//showmessage(dm_public.qry_Public.SQL.Text);
dm_public.qry_Public.open;
count_delay:=dm_public.qry_Public.Fields[0].Value;
//多到货记录数
dm_public.qry_Public.Close;
dm_public.qry_Public.SQL.Clear;
dm_public.qry_Public.SQL.Text:='select count(*) from po_info where '+condition+' and state1=3 and state2=3';
dm_public.qry_Public.open;
count_more:=dm_public.qry_Public.Fields[0].Value;
RzStatusPane1.Caption:='合计发注数量:'+floattostr(sysu_all);
RzStatusPane2.Caption:='合计发注金额:'+floattostr(amount_all);
RzStatusPane3.Caption:='当前记录总数:'+IntToStr(count_all);
RzStatusPane4.Caption:='延期所占百分比:'+copy(FloatToStr(count_delay/count_all*100),1,4)+'%';
RzStatusPane5.Caption:='多到所占百分比:'+copy(FloatToStr(count_more/count_all*100),1,4)+'%';
RzProgressBar1.Visible:=false;
timer1.Enabled:=false;
end;
//timer事件
procedure TPOGenInfForm.Timer1Timer(Sender: TObject);
begin
inherited;
if RzProgressBar1.Percent=100 then
begin
RzProgressBar1.Percent:=0;
end
else
begin
RzProgressBar1.Percent:=RzProgressBar1.Percent+1;
end;
end;
 
在单线程里,当cpu忙碌的时候根本不可能去执行ontimer事件,因此,如果你要这么做,把进度条放在线程里试试
 
接受答案了.
 
后退
顶部