| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 751 人关注过本帖
标题:DBGridEh数据显示转换???
只看楼主 加入收藏
青鸟初飞
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-12-18
收藏
 问题点数:0 回复次数:0 
DBGridEh数据显示转换???
说明:DBGridEh显示ttmp_obj_dl(电缆段表)表中字段数据,那么其中“所属电缆”的字段值是数字。库中有张ttmp_obj_de(电缆表),电缆段与电缆的连接关系是由电缆表字段的att_id和电缆段表字段的PCABLEID做对应关系。让电缆段表的所属电缆(PCABLEID)字段在DBGridEh表格显示成电缆表中的dev_code字段值。

如:ttmp_obj_dl(电缆段表) ttmp_obj_de(电缆表)
PCABLEID     ATT_ID DEV_CODE
1236456  1236456 CCD.522/01
124545   124545 CCD.522/02
45456   45456 CCD.522/03

要将查ttmp_obj_dl表的PCABLEID时,显示所对应的电缆表的DEV_CODE值


代码部分:(目前PCABLEID字段显示的值是没有转换的值),如何实现这种转换?
procedure TForm1.Button24Click(Sender: TObject);
var ed19,ed20,ed21,Box83,Box84,Box85,Box86,Box87,Box88,box89,Box90,Box91,Box92,Box93,Box94,Box95,Box96,Box97,che:string;
begin
//判断并赋值//
//1
if trim(COMBOBOX16.text)<>'' then
ed19:='dept_id like ' + '''' + '%' +trim(COMBOBOX16.text)+ '%' + ''''
else
ed19:='1=1';
//2
if trim(COMBOBOX17.text)<>'' then
ed20:='bure_no like ' + '''' + '%' +trim(COMBOBOX17.text)+ '%' + ''''
else
ed20:='1=1';
//4
if trim(edit9.text)<>'' then
ed21:='dev_code like ' + '''' + '%' +trim(edit9.text)+ '%' + ''''
else
ed21:='1=1';
//判断查询字段并赋值
//box1
if CheckBox83.checked=true then
box83:='dev_code AS 电缆段编码,'
else
box83:='';
//box2
if checkbox84.checked=true then
box84:='dept_id AS 区域,'
else
box84:='';
//box3
if checkbox85.checked=true then
box85:='bure_no AS 所属局,'
else
box85:='';
//box4
if checkbox86.checked=true then
box86:='PCABLEID AS 所属电缆,'
else
box86:='';
//box5
if checkbox87.checked=true then
box87:='DL_LENGTH AS 电缆段长度,'
else
box87:='';
//box6
if checkbox88.checked=true then
box88:='DL_NUMPR AS 电缆段对数,'
else
box88:='';
//box7
if checkbox89.checked=true then
box89:='ST_TYPE AS 起始设施类型,'
else
box89:='';
//box8
if checkbox90.checked=true then
box90:='ST_ID AS 起始设施编码,'
else
box90:='';
//box9
if checkbox91.checked=true then
box91:='ED_TYPE AS 终止设施类型,'
else
box91:='';
//box10
if checkbox92.checked=true then
box92:='ED_ID AS 终止设备编码,'
else
box92:='';
//box11
if checkbox93.checked=true then
box93:='ST_SEQS AS 起始线序,'
else
box93:='';
//box12
if checkbox94.checked=true then
box94:='ED_SEQS AS 终止线序,'
else
box94:='';
//box13
if checkbox95.Checked=true then
box95:='OPER_DATE AS 投产日期,'
else
box95:='';
//box14
if checkbox96.checked=true then
box96:='LH_TYPE AS 规格型号,'
else
box96:='';
//box15
if checkbox97.checked=true then
box97:='R_LEN AS 线径,'
else
box97:='';
begin
with ADOQuery3 do
begin
close;
SQL.Clear;
IF (combobox16.text<>'') THEN
SQL.Add('select '+box84+''+box85+''+box83+''+box86+''+box87+''+box88+''+box89+''+box90+''+box91+''+box92+''+box93+''+box94+''+box95+''+box96+''+box97+'COMM_D AS 备注 from ttmp_obj_dl where '+ed19+' and '+ed20+' and '+ed21+'')
ELSE
begin
showmessage('请选择统计字段和查询条件!');
exit;
end;
open;
StatusBar1.PANELS[1].TEXT := '共查询到 [' + inttostr(ADOQuery3.RecordCount) + '] 条记录';
end;
end;
end;

[此贴子已经被作者于2006-12-28 14:41:50编辑过]

搜索更多相关主题的帖子: 数据显示 
2006-12-28 14:40
快速回复:DBGridEh数据显示转换???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011279 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved