谁能帮我看看这些代码中的排序语句在哪里?(在线等待) (0分)

  • 主题发起人 主题发起人 lin2hu
  • 开始时间 开始时间
L

lin2hu

Unregistered / Unconfirmed
GUEST, unregistred user!
我在看一套程序,想改变它的排序,可是都不知道在哪里改,各位大虾帮我看看,谢谢了
unit ZSTJB;
procedure TfrmZSTJB.FormShow(Sender: TObject);
var Y,M:string;
begin
with ADOQuery2 do
begin
close;
sql.Clear;
sql.Add('select * from swzc_qyzt');
Open;
end;
ComboBox1.Items.Clear;
ComboBox1.Items.Add('全部');
while not ADOQuery2.Eof do
begin
ComboBox1.Items.Add(ADOQuery2.FieldValues['onr']);
ADOQuery2.Next;
end;
ComboBox1.ItemIndex:=1;
ADOQuery2.Close ;
TJLX:=' rtrim(ltrim(d.onr)) as onr '+
' from qyzl a , mima d, lpqk b '+
' where a.zgr=d.obh and a.nohm=b.nohm '+
' and b.kpsj>=:tem_kpsj and b.kpsj<=:end_kpsj and spzt=''02''';
DBGridEh2.Columns[1].Title.caption:=RadioButton1.Caption ;
SaveDialog1.FileName := '征收统计表('+RadioButton1.Caption+')';

Y:=inttostr(yearof(CurrDate));
M:=inttostr(monthof(CurrDate)-1);
if strtoint(M) <0 then begin Y:=inttostr(strtoint(Y)-1) ;M:='01'; end;
DateTime1.Date :=strtodate(Y+'-'+M+'-'+'26');
Y:=inttostr(yearof(CurrDate));
M:=inttostr(monthof(CurrDate));
DateTime2.Date :=strtodate(Y+'-'+M+'-'+'25');
sortField:='gg';
sortIsAsc:=false;
recno:=0;
XPMenu1.Active :=true;
end;

procedure TfrmZSTJB.RadioButton1Click(Sender: TObject);
begin
if RadioButton1.Checked then
begin
TJLX:=' rtrim(ltrim(d.onr)) as onr '+
' from qyzl a , mima d, lpqk b '+
' where a.zgr=d.obh and a.nohm=b.nohm '+
' and b.kpsj>=:tem_kpsj and b.kpsj<=:end_kpsj and spzt=''02''';
DBGridEh2.Columns[1].Title.caption:=RadioButton1.Caption ;
SaveDialog1.FileName := '征收统计表('+RadioButton1.Caption+')';
end;

end;

procedure TfrmZSTJB.RadioButton6Click(Sender: TObject);
begin
if RadioButton6.Checked then
begin
TJLX:=' d.onr as onr '+
' from qyzl a , swzc_jffs d,lpqk b '+
' where a.jffs=d.obh and a.nohm=b.nohm '+
' and b.kpsj>=:tem_kpsj and b.kpsj<=:end_kpsj and spzt=''02''';

DBGridEh2.Columns[1].Title.caption:=RadioButton6.Caption ;
SaveDialog1.FileName := '征收统计表('+RadioButton6.Caption+')';
end;

end;

procedure TfrmZSTJB.RadioButton3Click(Sender: TObject);
begin
if RadioButton3.Checked then
begin
TJLX:=' d.onr as onr'+
' from qyzl a , swzc_qyxz d,lpqk b '+
' where a.qyxz=d.obh and a.nohm=b.nohm '+
' and b.kpsj>=:tem_kpsj and b.kpsj<=:end_kpsj and spzt=''02''';

DBGridEh2.Columns[1].Title.caption:=RadioButton3.Caption ;
SaveDialog1.FileName := '征收统计表('+RadioButton3.Caption+')';
end;

end;

procedure TfrmZSTJB.RadioButton2Click(Sender: TObject);
begin
if RadioButton2.Checked then
begin
TJLX:=' d.onr onr '+
' from qyzl a , lpqk b , mima d'+
' where b.lpry=d.obh and a.nohm=b.nohm '+
' and b.kpsj>=:tem_kpsj and b.kpsj<=:end_kpsj and spzt=''02''';
DBGridEh2.Columns[1].Title.caption:=RadioButton2.Caption ;
SaveDialog1.FileName := '征收统计表('+RadioButton2.Caption+')';
end;

end;

procedure TfrmZSTJB.RadioButton5Click(Sender: TObject);
begin
if RadioButton5.Checked then
begin
TJLX:=' d.onr onr '+
' from qyzl a , swzc_qyzt d,lpqk b '+
' where a.qyzt=d.obh and a.nohm=b.nohm '+
' and b.kpsj>=:tem_kpsj and b.kpsj<=:end_kpsj and spzt=''02''';
DBGridEh2.Columns[1].Title.caption:=RadioButton5.Caption ;
SaveDialog1.FileName := '征收统计表('+RadioButton5.Caption+')';
end;

end;

procedure TfrmZSTJB.RadioButton4Click(Sender: TObject);
begin
if RadioButton4.Checked then
begin
TJLX:=' d.zgon as onr'+
' from qyzl a ,swzc_swzs d, lpqk b '+
' where a.swzs=d.zgbh and a.nohm=b.nohm '+
' and b.kpsj>=:tem_kpsj and b.kpsj<=:end_kpsj and spzt=''02''';
DBGridEh2.Columns[1].Title.caption:=RadioButton4.Caption ;
SaveDialog1.FileName := '征收统计表('+RadioButton4.Caption+')';
end;

end;

procedure TfrmZSTJB.RadioButton7Click(Sender: TObject);
begin
if RadioButton7.Checked then
begin
TJLX:=' d.onr as onr '+
' from qyzl a inner join tong c on a.nohm=c.nohm left join lpqk b on b.id=c.id'+
' inner join swzc_jjlx d'+
' on b.jjlx=d.obh '+
' and b.kpsj>=:tem_kpsj and b.kpsj<=:end_kpsj and spzt=''02''';

DBGridEh2.Columns[1].Title.caption:=RadioButton7.Caption ;
SaveDialog1.FileName := '征收统计表('+RadioButton7.Caption+')';
end;

end;

procedure TfrmZSTJB.dxButton4Click(Sender: TObject);
var ss:string;
begin
try
frmShowBar:=tfrmShowBar.Create(self);
frmShowBar.Show ;
frmShowBar.Label1.caption:='系统正在统计数据,估计用时1分钟,请稍候...' ;
frmShowBar.Label1.Update ;

ss:= ' select sum(isnull(b.bjssz1a,0)+isnull(b.bjssz2a,0)+isnull(b.bjssz3a,0)+ '+
' isnull(b.bjssz4a,0)+isnull(b.bjssz5a,0)+isnull(b.bjssz1b,0)+ ' +
' isnull(b.bjssz2b,0)+isnull(b.bjssz3b,0)+isnull(b.bjssz4b,0)+ ' +
' isnull(b.bjssz5b,0)+isnull(b.znj,0)) as 本期实收, ' +
' sum(isnull(b.znj,0)) as 其中滞纳金,';


ss:=ss+ TJLX;

adoquery1.Close ;
if RadioButton4.Checked then
begin
ss:=ss+' group by d.zgon';
SQLstr:=ss;

end else
begin
ss:=ss+' group by d.onr';
SQLstr:=ss;

DBGridEh2.Columns[1].FieldName :='onr'

end;



adoquery1.DisableControls ;
with adoquery1 do
begin
close;

sql.Text :=ss;
parameters.ParamByName('tem_kpsj').Value :=DateTime1.Date ;
parameters.ParamByName('end_kpsj').Value :=DateTime2.Date ;

RxMemoryData1.DisableControls ;
RxMemoryData1.Active:=false;
RxMemoryData1.EmptyTable ;
RxMemoryData1.LoadFromDataSet(adoquery1,0,lmAppend);
RxMemoryData1.Active :=true;

RxMemoryData1.SortOnFields(sortField,true,sortIsAsc) ;

RxMemoryData1.First ;
while not RxMemoryData1.Eof do
begin
RxMemoryData1.Edit ;
RxMemoryData1.FieldByName('xh').asInteger:=RxMemoryData1.RecNo ;
RxMemoryData1.next

end;


RxMemoryData1.EnableControls ;

end;
adoquery1.EnableControls ;
finally
frmShowBar.release;
end;
end;



procedure TfrmZSTJB.FormClose(Sender: TObject; var Action: TCloseAction);
begin
XPMenu1.Active :=false;
ADOQuery1.Close ;
end;

procedure TfrmZSTJB.ADOQuery1CalcFields(DataSet: TDataSet);
var sss:string;
begin

if RadioButton1.Checked then
begin
sss:='select sum(c.jssz1a+c.jssz2a+c.jssz3a+ ' +
' c.jssz4a+c.jssz5a+c.jssz1b+ ' +
' c.jssz2b+c.jssz3b+c.jssz4b+ ' +
' c.jssz5b) as 本期应收 from tong c,qyzl b,mima d where ' +
' c.nohm=b.nohm and c.xjsj>=:tem_bxjsj and c.xjsj<=:tem_exjsj '+
' and b.zgr=d.obh and d.onr=:tem_sw';
if ComboBox1.Text<>'全部' then
begin
sss:=sss+' and b.qyzt='+''''+GetCode('SWZC_QYZT','OBH','ONR',ComboBox1.Text)+'''';
end;
end;
if RadioButton4.Checked then
begin
sss:='select sum(c.jssz1a+c.jssz2a+c.jssz3a+ ' +
' c.jssz4a+c.jssz5a+c.jssz1b+ ' +
' c.jssz2b+c.jssz3b+c.jssz4b+ ' +
' c.jssz5b) as 本期应收 from tong c,qyzl b,swzc_swzs d where ' +
' c.nohm=b.nohm and c.xjsj>=:tem_bxjsj and c.xjsj<=:tem_exjsj '+
' and b.swzs=d.zgbh and d.zgon=:tem_sw';
if ComboBox1.Text<>'全部' then
begin
sss:=sss+' and b.qyzt='+''''+GetCode('SWZC_QYZT','OBH','ONR',ComboBox1.Text)+'''';
end;
end;
if RadioButton6.Checked then
begin
sss:='select sum(c.jssz1a+c.jssz2a+c.jssz3a+ ' +
' c.jssz4a+c.jssz5a+c.jssz1b+ ' +
' c.jssz2b+c.jssz3b+c.jssz4b+ ' +
' c.jssz5b) as 本期应收 from tong c,qyzl b,swzc_jffs d where ' +
' c.nohm=b.nohm and c.xjsj>=:tem_bxjsj and c.xjsj<=:tem_exjsj '+
' and b.jffs=d.obh and d.onr=:tem_sw';
if ComboBox1.Text<>'全部' then
begin
sss:=sss+' and b.qyzt='+''''+GetCode('SWZC_QYZT','OBH','ONR',ComboBox1.Text)+'''';
end;
end;
if RadioButton3.Checked then
begin
sss:='select sum(c.jssz1a+c.jssz2a+c.jssz3a+ ' +
' c.jssz4a+c.jssz5a+c.jssz1b+ ' +
' c.jssz2b+c.jssz3b+c.jssz4b+ ' +
' c.jssz5b) as 本期应收 from tong c,qyzl b,swzc_qyxz d where ' +
' c.nohm=b.nohm and c.xjsj>=:tem_bxjsj and c.xjsj<=:tem_exjsj '+
' and b.qyxz=d.obh and d.onr=:tem_sw';
if ComboBox1.Text<>'全部' then
begin
sss:=sss+' and b.qyzt='+''''+GetCode('SWZC_QYZT','OBH','ONR',ComboBox1.Text)+'''';
end;
end;

if RadioButton2.Checked then
begin
sss:='select sum(c.jssz1a+c.jssz2a+c.jssz3a+ ' +
' c.jssz4a+c.jssz5a+c.jssz1b+ ' +
' c.jssz2b+c.jssz3b+c.jssz4b+ ' +
' c.jssz5b) as 本期应收 from qyzl a,tong c,lpqk b,mima d where ' +
' a.nohm=b.nohm and a.nohm=c.nohm and c.xjsj>=:tem_bxjsj and c.xjsj<=:tem_exjsj '+
' and b.lpry=d.obh and d.onr=:tem_sw';
if ComboBox1.Text<>'全部' then
begin
sss:=sss+' and a.qyzt='+''''+GetCode('SWZC_QYZT','OBH','ONR',ComboBox1.Text)+'''';
end;
end;
if RadioButton5.Checked then
begin
sss:='select sum(c.jssz1a+c.jssz2a+c.jssz3a+ ' +
' c.jssz4a+c.jssz5a+c.jssz1b+ ' +
' c.jssz2b+c.jssz3b+c.jssz4b+ ' +
' c.jssz5b) as 本期应收 from tong c,qyzl b,swzc_qyzt d where ' +
' c.nohm=b.nohm and c.xjsj>=:tem_bxjsj and c.xjsj<=:tem_exjsj '+
' and b.qyzt=d.obh and d.onr=:tem_sw';

if ComboBox1.Text<>'全部' then
begin
sss:=sss+' and b.qyzt='+''''+GetCode('SWZC_QYZT','OBH','ONR',ComboBox1.Text)+'''';
end;
end;
with adoquery2 do
begin
close;
sql.Text :=sss;
parameters.ParamByName('tem_bxjsj').Value :=DateTime1.Date ;
parameters.ParamByName('tem_exjsj').Value :=DateTime2.Date ;
parameters.ParamByName('tem_sw').Value :=ADOQuery1.fieldbyname('onr').AsString ;
open;
ADOQuery1.fieldbyname('本期应收').AsCurrency := fields[0].AsCurrency ;
close;
end;
try
if (ADOQuery1.fieldbyname('本期应收').AsCurrency=null) or
(ADOQuery1.fieldbyname('本期应收').AsCurrency=0)then
ADOQuery1.FieldByName('gg').AsCurrency :=0 else
ADOQuery1.FieldByName('gg').AsCurrency :=
100*(ADOQuery1.fieldbyname('本期实收').AsCurrency-ADOQuery1.fieldbyname('其中滞纳金').AsCurrency)/ADOQuery1.fieldbyname('本期应收').AsCurrency ;
except
end;
end;

procedure TfrmZSTJB.DBGridEh2SortMarkingChanged(Sender: TObject);
var i :Integer;
s:String;
begin

end;

procedure TfrmZSTJB.DBGridEh2TitleBtnClick(Sender: TObject; ACol: Integer;
Column: TColumnEh);
begin

recno:=0;
sortField:=Column.FieldName;
if Column.Title.SortMarker = smUpEh then
sortIsAsc:=false
else
sortIsAsc:=true;
RxMemoryData1.SortOnFields(sortField,true,sortIsAsc) ;

RxMemoryData1.First ;
while not RxMemoryData1.Eof do
begin
RxMemoryData1.Edit ;
RxMemoryData1.FieldByName('xh').asInteger:=RxMemoryData1.RecNo ;
RxMemoryData1.next

end;
end;

procedure TfrmZSTJB.RxMemoryData1CalcFields(DataSet: TDataSet);
var i:integer;
begin


end;

procedure TfrmZSTJB.RxMemoryData1BeforePost(DataSet: TDataSet);
begin

end;

end.
 
你想改變哪裡的排序呀?排序的語句是這樣的了:
Select * from table where 條件 order by 排序.
清楚嗎?
 
怎么没有人回答呢?我都等了很久了,大家热心一点好吗?
 
帮我看看吧,我急死了
 
后退
顶部