?? ppublic.pas
字號:
unit ppublic;
interface
uses Windows, Messages, Classes,SysUtils,Controls, Forms, Dialogs,db,dbtables;
function basci_search(sql:string;section:string;AOwner:TComponent):string;
function get_fielddata(sender:Tfield;l_sql,Err_msg:string):variant;
function emp_search(filt_str:string;AOwner:TComponent):string;
function bill_find(sql,detail_sql,master,detail:string;AOwner:TComponent;num:integer):string;
implementation
uses search,emp_find,gridmasterdetail;
function basci_search(sql:string;section:string;AOwner:TComponent):string;
var
tmpfind:Tsearchf;
begin
tmpfind:=Tsearchf.Create(AOwner);
try
tmpfind.Qu_find.Close;
tmpfind.Qu_find.sql.Text:=sql;
tmpfind.Qu_find.Open;
tmpfind.key_find.SearchField:=tmpfind.Qu_find.fields[0].FieldName;
tmpfind.WWdbGrid1.IniAttributes.FileName:=extractfilepath(application.ExeName)+'\ini\find.ini';
tmpfind.WWdbGrid1.IniAttributes.SectionName:=section;
tmpfind.WWdbGrid1.LoadFromIniFile;
tmpfind.ShowModal;
if tmpfind.ModalResult=mrOK then result:=tmpfind.search_str else result:='';
finally
tmpfind.Free;
tmpfind:=nil;
end;
end;
function get_fielddata(sender:Tfield;l_sql,Err_msg:string):variant;
var s_data:array of variant;
i:integer;
begin
if sender.Text<>'' then
with Tquery.Create(nil) do
begin
databasename:='train';
sql.Clear;
sql.Add(l_sql);
Params[0].value:=trim(sender.text);
open;
if isempty then
begin
sender.text:='';
showmessage(Err_msg);
abort;
end else
begin
setlength(s_data,fieldcount);
for i:=0 to fieldCount-1 do
s_data[i]:=fields[i].value;
result:=s_data;
end;
close;
end;
end;
function emp_search(filt_str:string;AOwner:TComponent):string;
var tmpfind :Temp_findf;
begin
tmpfind:=Temp_findf.Create(AOwner);
try
tmpfind.filter_sql:=filt_str;
if pos('dimission_flag=1',filt_str)>0 then
begin
tmpfind.design_flag_Radio.ItemIndex:=2;
tmpfind.design_flag_Radio.Enabled:=false;
end
else if pos('dimission_flag=0',filt_str)>0 then
begin
tmpfind.design_flag_Radio.ItemIndex:=1;
tmpfind.design_flag_Radio.Enabled:=false;
end;
tmpfind.Showmodal;
if (tmpfind.ModalResult =mrOK) and (tmpfind.find_emp<>'') then
result:=tmpfind.find_emp else result:='';
finally
tmpfind.Free;
tmpfind:=nil;
end;
end;
function bill_find(sql,detail_sql,master,detail:string;AOwner:TComponent;num:integer):string;
var tmpfind:TMasterDetailGrid;
i,j:integer;
bill_str:string;
begin
result:='';
tmpfind:=TMasterDetailGrid.Create(AOwner);
tmpfind.MasterGrid.IniAttributes.FileName:=extractfilepath(application.ExeName)+'\ini\search.ini';
tmpfind.DetailGrid.IniAttributes.FileName:=extractfilepath(application.ExeName)+'\ini\search.ini';
tmpfind.Qu_master.close;
tmpfind.Qu_master.Sql.Text:=sql;
tmpfind.Qu_master.open;
//detail_sql='' 表示只有主表沒有明細表
if detail_sql<>'' then
begin
tmpfind.Qu_detail.close;
tmpfind.Qu_detail.Sql.Text:=detail_sql;
tmpfind.Qu_detail.open;
end else begin
tmpfind.wwExpandButton1.Visible:=false;
tmpfind.wwExpandButton1.Grid:=nil;
tmpfind.DetailGrid.Visible:=false;
end;
tmpfind.findkey.SearchField:=tmpfind.MasterGrid.DataSource.DataSet.Fields[1].FieldName;
tmpfind.MasterGrid.ControlType.Text:='xh;CustomEdit;wwExpandButton1;F';
tmpfind.MasterGrid.IniAttributes.SectionName:=master;
tmpfind.DetailGrid.IniAttributes.SectionName:=Detail;
tmpfind.MasterGrid.LoadFromIniFile;
//detail空表示單有主表
if detail<>'' then
tmpfind.DetailGrid.loadfrominifile;
Try
tmpfind.showmodal;
if (tmpfind.ModalResult =mrOK) and (not tmpfind.Qu_master.IsEmpty) then
with tmpfind.MasterGrid,tmpfind.Qu_master do begin
bill_str:='';
if SelectedList.Count>50 then j:=49
else j:=SelectedList.Count-1;
for i:= 0 to j do begin
GotoBookmark(SelectedList.items[i]);
if num=1 then //返回兩個以上的key值;
bill_str:=bill_str+''''+GetFieldValue(1)+''','
else if num=2 then bill_str:=bill_str+''''+GetFieldValue(1)+GetFieldValue(2)+''','
else bill_str:=bill_str+''''+GetFieldValue(1)+GetFieldValue(2)+GetFieldValue(3)+''',';
Freebookmark(SelectedList.items[i]);
end;
SelectedList.clear;
if bill_str<>'' then result:='('+copy(bill_str,1,length(bill_str)-1)+')'
else result:='';
end;
tmpfind.MasterGrid.savetoIniFile;
finally
tmpfind.free;
tmpfind:=Nil;
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -