P
playvc
Unregistered / Unconfirmed
GUEST, unregistred user!
我的数据库服务是sql server 6.5,前台用的是BDE和ODBC连接。数据库别名是:hospital
我的程序代码如下:
procedure ShowPage(CurPage :integer;tag :integer);
procedure btnNextClick(Sender: TObject);
procedure btnPriorClick(Sender: TObject);
全局变量
var
frmYaoPing: TfrmYaoPing;
StateArray: TStateArray;
pagecount : integer = 0;
curpage : integer;
Const PageSize :integer = 50;
procedure TfrmYaoPing.ShowPage(CurPage, tag: integer);
var
sqlstr :string;
begin
// 显示收费标准查询的翻页查询
DM.qryYaoPing.Close;
DM.qryYaoPing.SQL.Clear;
DM.qryYaoPing.SQL.Add('select a.charge_name,');
DM.qryYaoPing.SQL.Add('a.specify,');
DM.qryYaoPing.SQL.Add('a.unit,');
DM.qryYaoPing.SQL.Add('a.sub_qty,');
DM.qryYaoPing.SQL.Add('a.sale_price,');
DM.qryYaoPing.SQL.Add('b.location_name,');
DM.qryYaoPing.SQL.Add('c.m_name,');
DM.qryYaoPing.SQL.Add('d.type_5 ');
DM.qryYaoPing.SQL.Add(' from yp_location a left outer join zd_location b on (a.location_no = b.location_no) ');
DM.qryYaoPing.SQL.Add(' left outer join yp_make c on a.menufacture = c.m_code ');
DM.qryYaoPing.SQL.Add(' left outer join yp_list d on (a.charge_id = d.charge_id and a.charge_name = d.charge_name) ');
DM.qryYaoPing.SQL.Add(' where (b.location_no like ''' + '02-001%'+ ''' or ');
DM.qryYaoPing.SQL.Add(' b.location_no like ''' + '02-002%'+ ''' or ');
DM.qryYaoPing.SQL.Add(' b.location_no like ''' + '02-003%'+ ''') ');
DM.qryYaoPing.SQL.Add(' and a.charge_name like ''' + '%'+edtCoding.Text+'%' + '''');
//Showmessage(DM.qryYaoPing.SQL.Text); // 显示输入的SQL语句
DM.qryYaoPing.Open;
// 显示门诊诊疗的翻页查询
DM.qryYaoPing1.Close;
DM.qryYaoPing1.SQL.Clear;
DM.qryYaoPing1.SQL.Add('select name,type1,amount,specify,office from zd_list');
DM.qryYaoPing1.SQL.Add(' where name like ''' + '%' + edtName.Text +'%' + '''');
DM.qryYaoPing1.SQL.Add(' and (specify <> '''') and (office <> '''') and (amount <> 0) ');
//Showmessage(DM.qryYaoPing1.SQL.Text); // 显示输入的SQL语句
DM.qryYaoPing1.Open;
// 显示住院诊疗的翻页查询
DM.qryYaoPing2.Close;
DM.qryYaoPing2.SQL.Clear;
DM.qryYaoPing2.SQL.Add('select order_name,order_gg,order_unit,price,ks_name,SUBSTRING(order_type,1,3) from yz_zd');
DM.qryYaoPing2.SQL.Add(' where order_name like ''' + '%'+edtName.Text+'%' + '''');
DM.qryYaoPing2.SQL.Add(' and (ks_name <> '''') and (order_gg <> '''') and (price <> 0) ');
//Showmessage(DM.qryYaoPing2.SQL.Text); // 显示输入的SQL语句
DM.qryYaoPing2.Open;
{计算页数}
pagecount := DM.qryYaoPing.RecordCount div pagesize;
if (DM.qryYaoPing.RecordCount / pagesize) <> 0 then
Inc(pageCount);
if (Curpage < 1) then
Curpage := 1;
if Curpage > pageCount then
curpage := pageCount;
{********************************************}
pagecount := DM.qryYaoPing1.RecordCount div pagesize;
if (DM.qryYaoPing1.RecordCount / pagesize) <> 0 then
Inc(pageCount);
if (Curpage < 1) then
Curpage := 1;
if Curpage > pageCount then
curpage := pageCount;
{********************************************}
pagecount := DM.qryYaoPing2.RecordCount div pagesize;
if (DM.qryYaoPing2.RecordCount / pagesize) <> 0 then
Inc(pageCount);
if (Curpage < 1) then
Curpage := 1;
if Curpage > pageCount then
curpage := pageCount;
{筛选当前页数据}
DM.qryYaoPing.Close;
DM.qryYaoPing.SQL.Clear;
// N确定开始的位置,M确定结束的位置。假如要去N=3,M=8的数据,可以直接这样写
DM.qryYaoPing.SQL.Add(' SELECT TOP M-N * FROM (SELECT * FROM Table WHERE NOT EXISTS(SELECT TOP N * FROM Table)) AS MY_TABLE
//DM.qryYaoPing.SQL.Add(' select * from Table where ID BETWEEN '+trim(inttostr((curpage-1)*pagesize))+' AND '+trim(inttostr(curpage*pagesize) );
//ShowMessage(DM.qryYaoPing.SQL.Text); // 显示SQL语句的内容
DM.qryYaoPing.Open;
{***********************************************************************}
DM.qryYaoPing1.Close;
DM.qryYaoPing1.SQL.Clear;
// N确定开始的位置,M确定结束的位置。假如要去N=3,M=8的数据,可以直接这样写
DM.qryYaoPing1.SQL.Add(' SELECT TOP M-N * FROM (SELECT * FROM Table WHERE NOT EXISTS(SELECT TOP N * FROM Table)) AS MY_TABLE
//DM.qryYaoPing1.SQL.Add(' select * from Table where ID BETWEEN '+trim(inttostr((curpage-1)*pagesize))+' AND '+trim(inttostr(curpage*pagesize) );
//ShowMessage(DM.qryYaoPing1.SQL.Text); // 显示SQL语句的内容
DM.qryYaoPing1.Open;
{***********************************************************************}
DM.qryYaoPing2.Close;
DM.qryYaoPing2.SQL.Clear;
// N确定开始的位置,M确定结束的位置。假如要去N=3,M=8的数据,可以直接这样写
DM.qryYaoPing2.SQL.Add(' SELECT TOP M-N * FROM (SELECT * FROM Table WHERE NOT EXISTS(SELECT TOP N * FROM Table)) AS MY_TABLE
//DM.qryYaoPing2.SQL.Add(' select * from Table where ID BETWEEN '+trim(inttostr((curpage-1)*pagesize))+' AND '+trim(inttostr(curpage*pagesize) );
//ShowMessage(DM.qryYaoPing2.SQL.Text); // 显示SQL语句的内容
DM.qryYaoPing2.Open;
end;
// 上翻页
procedure TfrmYaoPing.btnPriorClick(Sender: TObject);
begin
if curpage = 1 then
begin
//ShowMessage('已经到了第一页啦 (@_@)');
btnPrior.Enabled := false;
end
else
begin
btnNext.Enabled := true;
Dec(curpage);
self.ShowPage(curpage,0);
end
end;
// 下翻页
procedure TfrmYaoPing.btnNextClick(Sender: TObject);
begin
if curpage = pagecount then
begin
//ShowMessage('已经到了最后一页啦 (@_@)');
btnNext.Enabled := false;
btnPrior.Enabled := true;
end
else
begin
inc(curpage);
self.ShowPage(curpage,0);
end
end;
我的程序代码如下:
procedure ShowPage(CurPage :integer;tag :integer);
procedure btnNextClick(Sender: TObject);
procedure btnPriorClick(Sender: TObject);
全局变量
var
frmYaoPing: TfrmYaoPing;
StateArray: TStateArray;
pagecount : integer = 0;
curpage : integer;
Const PageSize :integer = 50;
procedure TfrmYaoPing.ShowPage(CurPage, tag: integer);
var
sqlstr :string;
begin
// 显示收费标准查询的翻页查询
DM.qryYaoPing.Close;
DM.qryYaoPing.SQL.Clear;
DM.qryYaoPing.SQL.Add('select a.charge_name,');
DM.qryYaoPing.SQL.Add('a.specify,');
DM.qryYaoPing.SQL.Add('a.unit,');
DM.qryYaoPing.SQL.Add('a.sub_qty,');
DM.qryYaoPing.SQL.Add('a.sale_price,');
DM.qryYaoPing.SQL.Add('b.location_name,');
DM.qryYaoPing.SQL.Add('c.m_name,');
DM.qryYaoPing.SQL.Add('d.type_5 ');
DM.qryYaoPing.SQL.Add(' from yp_location a left outer join zd_location b on (a.location_no = b.location_no) ');
DM.qryYaoPing.SQL.Add(' left outer join yp_make c on a.menufacture = c.m_code ');
DM.qryYaoPing.SQL.Add(' left outer join yp_list d on (a.charge_id = d.charge_id and a.charge_name = d.charge_name) ');
DM.qryYaoPing.SQL.Add(' where (b.location_no like ''' + '02-001%'+ ''' or ');
DM.qryYaoPing.SQL.Add(' b.location_no like ''' + '02-002%'+ ''' or ');
DM.qryYaoPing.SQL.Add(' b.location_no like ''' + '02-003%'+ ''') ');
DM.qryYaoPing.SQL.Add(' and a.charge_name like ''' + '%'+edtCoding.Text+'%' + '''');
//Showmessage(DM.qryYaoPing.SQL.Text); // 显示输入的SQL语句
DM.qryYaoPing.Open;
// 显示门诊诊疗的翻页查询
DM.qryYaoPing1.Close;
DM.qryYaoPing1.SQL.Clear;
DM.qryYaoPing1.SQL.Add('select name,type1,amount,specify,office from zd_list');
DM.qryYaoPing1.SQL.Add(' where name like ''' + '%' + edtName.Text +'%' + '''');
DM.qryYaoPing1.SQL.Add(' and (specify <> '''') and (office <> '''') and (amount <> 0) ');
//Showmessage(DM.qryYaoPing1.SQL.Text); // 显示输入的SQL语句
DM.qryYaoPing1.Open;
// 显示住院诊疗的翻页查询
DM.qryYaoPing2.Close;
DM.qryYaoPing2.SQL.Clear;
DM.qryYaoPing2.SQL.Add('select order_name,order_gg,order_unit,price,ks_name,SUBSTRING(order_type,1,3) from yz_zd');
DM.qryYaoPing2.SQL.Add(' where order_name like ''' + '%'+edtName.Text+'%' + '''');
DM.qryYaoPing2.SQL.Add(' and (ks_name <> '''') and (order_gg <> '''') and (price <> 0) ');
//Showmessage(DM.qryYaoPing2.SQL.Text); // 显示输入的SQL语句
DM.qryYaoPing2.Open;
{计算页数}
pagecount := DM.qryYaoPing.RecordCount div pagesize;
if (DM.qryYaoPing.RecordCount / pagesize) <> 0 then
Inc(pageCount);
if (Curpage < 1) then
Curpage := 1;
if Curpage > pageCount then
curpage := pageCount;
{********************************************}
pagecount := DM.qryYaoPing1.RecordCount div pagesize;
if (DM.qryYaoPing1.RecordCount / pagesize) <> 0 then
Inc(pageCount);
if (Curpage < 1) then
Curpage := 1;
if Curpage > pageCount then
curpage := pageCount;
{********************************************}
pagecount := DM.qryYaoPing2.RecordCount div pagesize;
if (DM.qryYaoPing2.RecordCount / pagesize) <> 0 then
Inc(pageCount);
if (Curpage < 1) then
Curpage := 1;
if Curpage > pageCount then
curpage := pageCount;
{筛选当前页数据}
DM.qryYaoPing.Close;
DM.qryYaoPing.SQL.Clear;
// N确定开始的位置,M确定结束的位置。假如要去N=3,M=8的数据,可以直接这样写
DM.qryYaoPing.SQL.Add(' SELECT TOP M-N * FROM (SELECT * FROM Table WHERE NOT EXISTS(SELECT TOP N * FROM Table)) AS MY_TABLE
//DM.qryYaoPing.SQL.Add(' select * from Table where ID BETWEEN '+trim(inttostr((curpage-1)*pagesize))+' AND '+trim(inttostr(curpage*pagesize) );
//ShowMessage(DM.qryYaoPing.SQL.Text); // 显示SQL语句的内容
DM.qryYaoPing.Open;
{***********************************************************************}
DM.qryYaoPing1.Close;
DM.qryYaoPing1.SQL.Clear;
// N确定开始的位置,M确定结束的位置。假如要去N=3,M=8的数据,可以直接这样写
DM.qryYaoPing1.SQL.Add(' SELECT TOP M-N * FROM (SELECT * FROM Table WHERE NOT EXISTS(SELECT TOP N * FROM Table)) AS MY_TABLE
//DM.qryYaoPing1.SQL.Add(' select * from Table where ID BETWEEN '+trim(inttostr((curpage-1)*pagesize))+' AND '+trim(inttostr(curpage*pagesize) );
//ShowMessage(DM.qryYaoPing1.SQL.Text); // 显示SQL语句的内容
DM.qryYaoPing1.Open;
{***********************************************************************}
DM.qryYaoPing2.Close;
DM.qryYaoPing2.SQL.Clear;
// N确定开始的位置,M确定结束的位置。假如要去N=3,M=8的数据,可以直接这样写
DM.qryYaoPing2.SQL.Add(' SELECT TOP M-N * FROM (SELECT * FROM Table WHERE NOT EXISTS(SELECT TOP N * FROM Table)) AS MY_TABLE
//DM.qryYaoPing2.SQL.Add(' select * from Table where ID BETWEEN '+trim(inttostr((curpage-1)*pagesize))+' AND '+trim(inttostr(curpage*pagesize) );
//ShowMessage(DM.qryYaoPing2.SQL.Text); // 显示SQL语句的内容
DM.qryYaoPing2.Open;
end;
// 上翻页
procedure TfrmYaoPing.btnPriorClick(Sender: TObject);
begin
if curpage = 1 then
begin
//ShowMessage('已经到了第一页啦 (@_@)');
btnPrior.Enabled := false;
end
else
begin
btnNext.Enabled := true;
Dec(curpage);
self.ShowPage(curpage,0);
end
end;
// 下翻页
procedure TfrmYaoPing.btnNextClick(Sender: TObject);
begin
if curpage = pagecount then
begin
//ShowMessage('已经到了最后一页啦 (@_@)');
btnNext.Enabled := false;
btnPrior.Enabled := true;
end
else
begin
inc(curpage);
self.ShowPage(curpage,0);
end
end;