我想查询2个时间段中间的所有数据,
现在有人家的代码,因为刚学,我不太会写,(这段代码是我张贴过来的)
有个地方我看不 明白,我想问下代码中的 ctv1  是 什么?
代码如下:procedure TForm1.sbtnSearchClick(Sender: TObject);
var
  I: INteger;
  sBM,sFBM: string;
  sStr: string;
begin
  sBM:='';
  sFBM:='';  for i:=0 to ctv1.Items.Count -1 do
  begin
    if ctv1.ItemState[i]=csunchecked then continue;    if (ctv1.Items[i].Level=1) and
       (ctv1.ItemState[(ctv1.Items[i].Parent).AbsoluteIndex]=csChecked) then Continue;    if ctv1.ItemState[i]=cschecked then
    begin
      if ctv1.Items[i].Level=0 then
      begin
        sBM := Copy(ctv1.Items[i].Text,pos('[',ctv1.Items[i].Text)+1,2);
        if sStr = '' then
          sStr := '(DOC.BM='''+sBM+''')'
        else
          sStr := sStr+ ' or (DOC.BM='''+sBM+''')';
      end
      else
      begin
        sBM := Copy((ctv1.Items[i].Parent).Text,pos('[',(ctv1.Items[i].Parent).Text)+1,2);
        sFBM := Copy((ctv1.Items[i]).Text,pos('[',(ctv1.Items[i]).Text)+1,2);
        if sStr = '' then
          sStr := '(DOC.BM='''+sBM+''' and DOC.FB='''+sFBM+''')'
        else
          sStr :=  sStr+ ' or (DOC.BM='''+sBM+''' and DOC.FB='''+sFBM+''')';
      end;
    end;
  end;
  with qryCX do
  begin
    if Active then Close;
    SQL.Clear;
    SQL.Add('select   DOC.BH,bumen_temp.BMS,fenbu_temp.fbs,DOC.XM,count(*) as CS,');
    SQL.Add('case when isnull(fenbu_temp.jg,0)=0 then bumen_temp.jg else fenbu_temp.jg end as jg from DOC');
    SQL.Add('left join bumen_temp on bumen_temp.BM=DOC.BM');
    SQL.Add('left join fenbu_temp on fenbu_temp.BM=DOC.BM and fenbu_temp.fb=DOC.FB');
    SQL.Add('left join SFDATA on SFDATA.BH=DOC.BH and SFDATA.lb=''2''');
    SQL.Add('where 1=1');
    SQL.Add('and rq >='+formatdateTime('YYYYMMDD',s_date.date)+' and rq <='+formatdateTime('YYYYMMDD',e_date.date));
    if sStr <> '' then
      SQL.Add('and ('+sStr+')');
    SQL.Add('group by DOC.BH,bumen_temp.BMS,DOC.XM,fenbu_temp.fbs,fenbu_temp.jg,bumen_temp.jg');
    SQL.Add('order by bumen_temp.BMS,fenbu_temp.fbs,DOC.BH');
    Open;
  end;  
end;
报错如下:
[Warning] Unit1.pas(8): Unit 'FileCtrl' is specific to a platform
[Error] Unit1.pas(118): Undeclared identifier: 'ctv1'
[Error] Unit1.pas(120): 'THEN' expected but identifier 'ItemState' found
[Error] Unit1.pas(122): ')' expected but identifier 'Items' found
[Error] Unit1.pas(125): 'THEN' expected but identifier 'ItemState' found
[Error] Unit1.pas(125): 'THEN' expected but identifier 'ItemState' found
[Error] Unit1.pas(127): 'THEN' expected but identifier 'Items' found
[Error] Unit1.pas(129): Incompatible types
[Error] Unit1.pas(129): Incompatible types
[Error] Unit1.pas(129): Incompatible types
[Error] Unit1.pas(129): 'END' expected but ')' found
[Error] Unit1.pas(130): Missing operator or semicolon
[Error] Unit1.pas(137): ')' expected but identifier 'Items' found
[Error] Unit1.pas(137): Incompatible types
[Error] Unit1.pas(139): Missing operator or semicolon
[Error] Unit1.pas(145): '.' expected but ';' found
[Error] Unit1.pas(148): Undeclared identifier: 'Active'
[Error] Unit1.pas(148): '(' expected but ';' found
[Error] Unit1.pas(149): Undeclared identifier: 'SQL'
[Error] Unit1.pas(150): Missing operator or semicolon
[Error] Unit1.pas(151): Missing operator or semicolon
。。
[Warning] Unit1.pas(157): Text after final 'END.' - ignored by compiler
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

解决方案 »

  1.   

    看这个属性AbsoluteIndex,好像是dx控件的,有可能是dxtreelist
      

  2.   

    我用的 DELPHI7   ,我 没找到那个dxtreelist 控件,好像不是treeview
      

  3.   

    treeview?我要查询2个时间(选择2个时间按查询)段的数据,要用到treeview???我 是刚学的 ,不是很明白,能说 清楚点吗 ?
      

  4.   

    放一个Treeview控件,命名为ctv1
    然后编译试试看。