begin
Sql_Open(Format('select distinct wxxm_no,wxxm_mc from sm_tongji_xm where GongSiNo = ''%S'' ', [GongSiNo]), Dm_Main.ADOQuery_Temp);
with DBGridEh_temp do
begin
for i := 0 to Columns.Count - 1 do
begin
if Dm_Main.ADOQuery_Temp.Locate('wxxm_no', Columns[i].Field.DisplayLabel, []) then
Columns[i].Field.DisplayLabel := Dm_Main.ADOQuery_Temp.FieldByName('wxxm_mc').AsString
else if LowerCase(Columns[i].FieldName) = 'reco_no' then
begin
Columns[i].Field.DisplayLabel := '序号';
Columns[i].Visible := False;
end
else if LowerCase(Columns[i].FieldName) = 'flag_bs' then
begin
Columns[i].Field.DisplayLabel := '内部标识';
Columns[i].Visible := False;
end
else if LowerCase(Columns[i].FieldName) = 'xche_jsrq' then
begin
Columns[i].Field.DisplayLabel := '结算日期';
Columns[i].HideDuplicates := True;
end
else if LowerCase(Columns[i].FieldName) = 'work_no' then
begin
Columns[i].Field.DisplayLabel := '维修单号';
Columns[i].HideDuplicates := True;
end
else if LowerCase(Columns[i].FieldName) = 'che_no' then
begin
Columns[i].Field.DisplayLabel := '车牌号码';
Columns[i].HideDuplicates := True;
end
else if LowerCase(Columns[i].FieldName) = 'kehu_mc' then
begin
Columns[i].Field.DisplayLabel := '客户名称';
Columns[i].HideDuplicates := True;
end
else if LowerCase(Columns[i].FieldName) = 'xche_bz' then
begin
Columns[i].Field.DisplayLabel := '说明';
end
else if LowerCase(Columns[i].FieldName) = 'xche_heji' then
begin
Columns[i].Field.DisplayLabel := '合计';
Columns[i].Footer.ValueType := fvtSum;
//打印时0不显示
if Columns[i].Field is TBCDField then
Columns[i].Field.OnGetText := HideZeroGetText;
//标题居中
Columns[i].Title.Alignment := taCenter;
if Columns[i].Field is TStringField then
Columns[i].Width := 100
else
Columns[i].Width := 80;
end;
end;
end;
//ADOQuery中,TFloatField设置DisplayFormat
with ADOQuery do
begin
for I := 0 to Fields.Count - 1 do
begin
if LowerCase(fields[I].Classname) = 'tfloatfield' then
begin
with Fields[I] as TFloatField do
begin
DisplayFormat := '0.00';
end;
end;
end;
end;
-------------------
procedure HideZeroGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
begin
if Sender is TBCDField then
begin
if Sender.AsFloat = 0 then
Text :=''
else
Text := Sender.AsString;
end;
end;