通用查询控件或代码,400分.

jyqkr 2003-01-06 01:29:55
通用查询控件或代码,象金蝶中的那种的也不错。
...全文
105 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
beata88 2003-04-11
  • 打赏
  • 举报
回复
up
小豆好好 2003-04-11
  • 打赏
  • 举报
回复
关注,以后就要用到了!
智商无下限 2003-04-11
  • 打赏
  • 举报
回复
我也想要一份!
bee2518 2003-04-10
  • 打赏
  • 举报
回复
关注
ideage 2003-04-10
  • 打赏
  • 举报
回复
帮忙@,谢谢
jyqkr 2003-01-27
  • 打赏
  • 举报
回复
象金蝶那样的
悟空师傅来了 2003-01-24
  • 打赏
  • 举报
回复
帮你up
yczyk 2003-01-24
  • 打赏
  • 举报
回复
你想做怎么样的呢?我不是很清楚呢!
xirumin 2003-01-06
  • 打赏
  • 举报
回复
金蝶软件的速度太慢了, 我用PB写过通用查询, 还可动态分三级以下的分组。
我也一直在找Delphi的通用查询
找到了, 好东西大家分享!!!
jyqkr 2003-01-06
  • 打赏
  • 举报
回复
lxmlhh(143143),有什么更好的?
lxmlhh 2003-01-06
  • 打赏
  • 举报
回复
金碾那太简单了,
我有更好的。
sexalpha 2003-01-06
  • 打赏
  • 举报
回复
我做查詢是用dll做的
提供數據庫名稱
讓dll中的form生成查詢語句
然後返回給應用程序
——————————————————————————
library FindDll;

{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }

uses
ShareMem,
SysUtils,
Classes,
UtFind in 'UtFind.pas' {FindFrm};

{$R *.res}
exports
FindShow;
begin
end.

unit UtFind;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, DB, DBTables, ADODB, Buttons;

type
TFindFrm = class(TForm)
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RichEdit1: TRichEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Query1: TADOQuery;
ADOConnection1: TADOConnection;
ListBox1: TListBox;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
ListBox2: TListBox;
Label1: TLabel;
RichEdit2: TRichEdit;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure ListBox2DblClick(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private declarations }
TBname:string; //數據庫名稱
FindSqlString:string; //返回的查詢字符串
public
{ Public declarations }
end;

//定義出口函數
function FindShow(H:THandle;TName:string):string;stdcall;

implementation

{$R *.dfm}

function FindShow(H:THandle;TName:string):string;
var
FindFrm: TFindFrm;
begin
application.Handle:=H;
FindFrm:=TFindFrm.Create(application);
try
FindFrm.Query1.SQL.Clear;
FindFrm.Query1.SQL.Add(TName);
FindFrm.ShowModal;
Result:=FindFrm.FindSqlString;
finally
FindFrm.Free;
end;
end;

procedure TFindFrm.Button1Click(Sender: TObject);
var aa,bb :string;
var c:integer;
begin
if RichEdit1.Lines.Text='' then
aa:=''
else
begin
if RadioButton1.Checked=True then
aa:='AND'
else
aa:='OR';
end;
c:=Pos(' ',ComboBox1.Text);
RichEdit2.Text:=RichEdit2.Text+' '+aa+' '+'('+copy(ComboBox1.Text,1,c-1)+' '+ComboBox2.Text+' '+''''+Edit1.Text+''')';
RichEdit1.Text:=RichEdit1.Text+' '+aa+' '+'('+copy(ComboBox1.Text,c+1,Length(ComboBox1.Text)-c-1)+' '+ComboBox2.Text+' '+''''+Edit1.Text+''')';
end;
procedure TFindFrm.Button3Click(Sender: TObject);
var i,n:integer;
var OrderStr,ListStr:string;
begin
//把生成的sql語句添加到FindSqlString中
if RichEdit1.Lines.Text<>'' then
FindSqlString:='SELECT * FROM '+trim(TBname)+' WHERE '+trim(RichEdit2.Text)
else
FindSqlString:='SELECT * FROM '+trim(TBname);
//加orderby
if ListBox2.Items.Text<>'' then
for i:=0 to ListBox2.Items.Count-1 do
begin
n:=Pos(' ',ListBox2.Items.Strings[i]);
ListStr:=copy(ListBox2.Items.Strings[i],1,n-1);
if i=0 then
OrderStr:=ListStr
else
OrderStr:=OrderStr+','+ListStr;
end;
//加dsc
if OrderStr<>'' then
begin
if RadioButton3.Checked=True then
OrderStr:=' ORDER BY '+OrderStr+' ASC'
else
OrderStr:=' ORDER BY '+OrderStr+' DESC';
end;
FindSqlString:=FindSqlString+OrderStr;
self.Close;
end;

procedure TFindFrm.Button4Click(Sender: TObject);
begin
FindSqlString:='';
self.Close;
end;

procedure TFindFrm.FormShow(Sender: TObject);
var i:integer;
var a:Tobject;
begin
TBname:=Query1.SQL.Text;
Query1.SQL.Clear;
Query1.SQL.Add('SELECT MA003,MA004 FROM XADMA WHERE MA001='''+Trim(TBname)+'''');
RichEdit1.Lines.Text:='';
if Query1.Active=False then Query1.Open;
while not Query1.Eof do
begin
ComboBox1.AddItem(trim(Query1.FieldValues['MA003'])+' '+Query1.FieldValues['MA004'],a);
ListBox1.AddItem(trim(Query1.FieldValues['MA003'])+' '+Query1.FieldValues['MA004'],a);
Query1.Next;
end;
Query1.Close;
ComboBox1.ItemIndex:=0;
end;

procedure TFindFrm.Button2Click(Sender: TObject);
begin
RichEdit2.Text:='';
RichEdit1.Text:='';
end;

procedure TFindFrm.ListBox1DblClick(Sender: TObject);
var a:Tobject;
begin
if ListBox1.ItemIndex<>-1 then
begin
ListBox2.AddItem(ListBox1.Items.Strings[ListBox1.ItemIndex],a);
ListBox1.DeleteSelected;
end;
end;

procedure TFindFrm.ListBox2DblClick(Sender: TObject);
var a:Tobject;
begin
if ListBox2.ItemIndex<>-1 then
begin
ListBox1.AddItem(ListBox1.Items.Strings[ListBox2.ItemIndex],a);
ListBox2.DeleteSelected;
end;
end;

procedure TFindFrm.SpeedButton1Click(Sender: TObject);
begin
ListBox1DblClick(Sender);
end;

procedure TFindFrm.SpeedButton2Click(Sender: TObject);
begin
ListBox2DblClick(Sender);
end;

end.

調用時的代碼
Fstr:=FindShow(application.Handle,TableName);
smilelhh 2003-01-06
  • 打赏
  • 举报
回复
关注

5,930

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧