我想设计个DBGrid显示从数据库中查找的数据,其DBGrid中的标头分别是:流水号,卡标签,姓名,持卡人类别,设备描述,使用时间,消费金额,卡余额,使用次数。
其中,流水号和卡余额,在数据库中是找不到的。流水号是查找到的数据的自动(递增)编号,而卡余额是要通过t5.zvaluechanged-t5.zcurrentamount的差。
主要牵涉到五个数据表:From zcardlist t1,zotheruserlist t2,zidlookup t3,zdevicelist t4,zcardvaluelog t5 
查找的是:Select t1.zcardlabel(卡标签),t2.zname(姓名),t3.ztypename(持卡人类别),t4.zdevdesc(设备描述),t5.ztranstime(使用时间),t5.zvaluechanged(消费金额),t5.zcurrentamount(当前金额),t5.ztotalusetimes(使用次数)
。救命啊!!~~!!
各位大虾,没有做过这方面的实例,给小的举例举例
谢谢~~~!!!!

解决方案 »

  1.   

    你查询语句写好点就行了!例如:
    select count(...) as 流水号,(t5.zvaluechanged-t5.zcurrentamount) as 卡余额,...
    就行啦!!
      

  2.   

    递增编号用 一个计算字段=query.RecNo
      

  3.   

    在DBGrid1DrawColumnCell写:if (query.Active) and (query.RecordCount>0) then
      if column.Field.FieldName='id' then  //在dbgrid增加一个ID字段
      begin
       DBGrid1.Canvas.FillRect(Rect);
       DBGrid1.Canvas.TextOut(Rect.left+1,Rect.top+1,inttostr(query.recno));
      end;