这里是我当时实现的源码,因为我没用中文做字段名,所以处理得比较复杂。
===================================
unit Pur_Selection;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CheckLst, QuickRpt, ExtCtrls, Buttons, ComCtrls,
QRCtrls, QRExport;
type
TForm12 = class(TForm)
QRTextFilter1: TQRTextFilter;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Panel3: TPanel;
Label11: TLabel;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
Bevel4: TBevel;
Label12: TLabel;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
Label13: TLabel;
Bevel5: TBevel;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton15: TSpeedButton;
Label7: TLabel;
ListBox1: TListBox;
ListBox2: TListBox;
CheckListBox1: TCheckListBox;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
Edit1: TEdit;
TabSheet3: TTabSheet;
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
PageFooterBand1: TQRBand;
QRShape2: TQRShape;
QRExpr1: TQRExpr;
QRBand1: TQRBand;
QRShape3: TQRShape;
QRShape1: TQRShape;
QRImage1: TQRImage;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRExpr2: TQRExpr;
QRLabel4: TQRLabel;
QRLabel3: TQRExpr;
SummaryBand1: TQRBand;
QRExpr3: TQRExpr;
QRShape4: TQRShape;
procedure ListBox1DblClick(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure SpeedButton7Click(Sender: TObject);
procedure SpeedButton8Click(Sender: TObject);
procedure TabSheet1Show(Sender: TObject);
procedure FlashData;
procedure FormCreate(Sender: TObject);
procedure ComboBox4DropDown(Sender: TObject);
procedure ComboBox5DropDown(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton15Click(Sender: TObject);
procedure SpeedButton9Click(Sender: TObject);
procedure SpeedButton10Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure CreateReport;
procedure FormShow(Sender: TObject);
procedure QRBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
procedure SummaryBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
private
procedure ReFresh;
{ Private declarations }
public
{ Public declarations }
end;
var
Form12: TForm12;
Store:array of String;
List:array of String;
DField:Array of String;
DyList:Array of String;
PRList:array of String;
MOList:Array of String;
TermList:Array of String;
Term:Array of String;
s:String;
Flag:Array[0..7] of Integer;
FList:Array of String;
a:boolean;
OrderList:Array of String;
implementation
uses Pur_DataModule, Pur_Report, Pur_Login;
{$R *.dfm}
procedure TForm12.ListBox1DblClick(Sender: TObject);
begin
if Copy(ListBox1.Items[ListBox1.ItemIndex],5,4)='µ¥' then
ShowMessage('Êý¾ÝÀà±ð²»¿ÉÒÔ±»Ñ¡Ôñ£¡')
else
begin
s:= ListBox1.Items[ListBox1.ItemIndex];
ListBox2.Items.Add(ListBox1.Items[ListBox1.ItemIndex]);
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;
ReFresh;
end;
procedure TForm12.SpeedButton6Click(Sender: TObject);
begin
Close;
end;
procedure TForm12.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TForm12.SpeedButton7Click(Sender: TObject);
begin
if Copy(ListBox1.Items[ListBox1.ItemIndex],5,4)='µ¥' then
ShowMessage('Êý¾ÝÀà±ð²»¿ÉÒÔ±»Ñ¡Ôñ£¡')
else
begin
s:=ListBox1.Items[ListBox1.ItemIndex];
ListBox2.Items.Add(ListBox1.Items[ListBox1.ItemIndex]);
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;
ReFresh;
end;
procedure TForm12.SpeedButton8Click(Sender: TObject);
begin
if ListBox2.ItemIndex<0 then
ShowMessage('&Auml;&atilde;&Atilde;&raquo;&Oacute;&ETH;&Ntilde;&iexcl;&Ocirc;&ntilde;&Egrave;&Icirc;&ordm;&Icirc;×&Ecirc;&Aacute;&Iuml;&pound;&iexcl;')
else
begin
ListBox1.Items.Add(ListBox2.Items[ListBox2.ItemIndex]);
ListBox2.Items.Delete(ListBox2.ItemIndex);
end;
FlashData;
ReFresh;
end;
procedure TForm12.TabSheet1Show(Sender: TObject);
var
i:Integer;
begin
SetLength(Store,ListBox1.Count);
for i:=0 to ListBox1.Count-1 do
Store:=ListBox1.Items.Strings;
end;
procedure TForm12.FlashData;
var
i,j:Integer;
begin
SetLength(List,0);
for i:=0 to Length(Store)-1 do
begin
for j:=0 to ListBox1.Count-1 do
begin
if ListBox1.Items[j]=Store then
begin
SetLength(List,Length(List)+1);
List[Length(List)-1]:=ListBox1.Items[j];
end;
end;
end;
ListBox1.Clear;
for i:=0 to Length(List)-1 do
ListBox1.Items.Add(List);
end;
procedure TForm12.FormCreate(Sender: TObject);
begin
SetLength(DField,42);
DField[0]:='PUR_PRFORM A';
DField[1]:='A.PR_NO';
DField[2]:='A.DEPT_NO';
DField[3]:='A.MATE_ITEM';
DField[4]:='A.MATE_CODE';
DField[5]:='A.QTY';
DField[6]:='A.DATE_ORDER';
DField[7]:='A.DATE_SUPP';
DField[8]:='A.SUPP_CODE';
DField[9]:='A.BUDGETED';
DField[10]:='PUR_POFORM B';
DField[11]:='B.PO_NO';
DField[12]:='B.SUPP_CODE';
DField[13]:='B.PO_DATE';
DField[14]:='B.PR_NO';
DField[15]:='B.MATE_CODE';
DField[16]:='B.UNIT_PRICE';
DField[17]:='B.QTY';
DField[18]:='B.DELI_DATE';
DField[19]:='PUR_QAFORM C';
DField[20]:='C.PR_NO';
DField[21]:='C.PO_NO';
DField[22]:='C.QA_DATE';
DField[23]:='C.MATE_CODE';
DField[24]:='C.REC_QTY';
DField[25]:='C.REF_QTY';
DField[26]:='C.MEMO';
DField[27]:='PUR_RECFORM D';
DField[28]:='D.PR_NO';
DField[29]:='D.PO_NO';
DField[30]:='D.REC_DATE';
DField[31]:='D.MATE_CODE';
DField[32]:='D.REC_QTY';
DField[33]:='D.PRESENT';
DField[34]:='PUR_INVOICE E';
DField[35]:='E.IN_NO';
DField[36]:='E.IN_DATE';
DField[37]:='E.PO_NO';
DField[38]:='E.MATE_CODE';
DField[39]:='E.QTY';
DField[40]:='E.UNIT_PRICE';
DField[41]:='E.SUPP_CODE';
SetLength(FList,42);
FList[0]:='PUR_PRFORM A';
FList[1]:='&Ccedil;&euml;&sup1;&ordm;&micro;&yen;&ordm;&Aring;';
FList[2]:='&sup3;&Eacute;±&frac34;&Ouml;&ETH;&ETH;&Auml;';
FList[3]:='&sup2;&Auml;&Aacute;&Iuml;&Agrave;à±&eth;';
FList[4]:='&sup2;&Auml;&Aacute;&Iuml;&acute;ú&ordm;&Aring;';
FList[5]:='&Ccedil;&euml;&sup1;&ordm;&Ecirc;&yacute;&Aacute;&iquest;';
FList[6]:='&Ccedil;&euml;&sup1;&ordm;&Egrave;&Otilde;&AElig;&Uacute;';
FList[7]:='&ETH;è&Ccedil;ó&AElig;&Uacute;&Iuml;&THORN;';
FList[8]:='&sup1;&copy;&Oacute;&brvbar;&Eacute;&Igrave;';
FList[9]:='&Ocirc;¤&Euml;&atilde;';
FList[10]:='PUR_POFORM B';
FList[11]:='&para;&copy;&sup1;&ordm;&micro;&yen;&ordm;&Aring;';
FList[12]:='&sup1;&copy;&Oacute;&brvbar;&Eacute;&Igrave;';
FList[13]:='&para;&copy;&sup1;&ordm;&Egrave;&Otilde;&AElig;&Uacute;';
FList[14]:='&Ccedil;&euml;&sup1;&ordm;&micro;&yen;&ordm;&Aring;';
FList[15]:='&sup2;&Auml;&Aacute;&Iuml;&acute;ú&ordm;&Aring;';
FList[16]:='&micro;&yen;&frac14;&Ucirc;';
FList[17]:='&para;&copy;&sup1;&ordm;&Ecirc;&yacute;&Aacute;&iquest;';
FList[18]:='&frac12;&raquo;&raquo;&otilde;&AElig;&Uacute;&Iuml;&THORN;';
FList[19]:='PUR_QAFORM C';
FList[20]:='&Ccedil;&euml;&sup1;&ordm;&micro;&yen;&ordm;&Aring;';
FList[21]:='&para;&copy;&sup1;&ordm;&micro;&yen;&ordm;&Aring;';
FList[22]:='&frac14;ì&Ntilde;é&Egrave;&Otilde;&AElig;&Uacute;';
FList[23]:='&sup2;&Auml;&Aacute;&Iuml;&acute;ú&ordm;&Aring;';
FList[24]:='&Ntilde;é&Ecirc;&Otilde;&Ecirc;&yacute;';
FList[25]:='&frac34;&Uuml;&Ecirc;&Otilde;&Ecirc;&yacute;';
FList[26]:='&frac34;&Uuml;&Ecirc;&Otilde;&Ocirc;&shy;&Ograve;ò';
FList[27]:='PUR_RECFORM D';
FList[28]:='&Ccedil;&euml;&sup1;&ordm;&micro;&yen;&ordm;&Aring;';
FList[29]:='&para;&copy;&sup1;&ordm;&micro;&yen;&ordm;&Aring;';
FList[30]:='&Ntilde;é&Ecirc;&Otilde;&Egrave;&Otilde;&AElig;&Uacute;';
FList[31]:='&sup2;&Auml;&Aacute;&Iuml;&acute;ú&ordm;&Aring;';
FList[32]:='&Ntilde;é&Ecirc;&Otilde;&Ecirc;&yacute;&Aacute;&iquest;';
Flist[33]:='&Ocirc;ù&Euml;&Iacute;&Ecirc;&yacute;&Aacute;&iquest;';
FList[34]:='PUR_INVOICE E';
FList[35]:='·&cent;&AElig;±&ordm;&Aring;&Acirc;&euml;';
FList[36]:='·&cent;&AElig;±&Egrave;&Otilde;&AElig;&Uacute;';
FList[37]:='&para;&copy;&sup1;&ordm;&micro;&yen;&ordm;&Aring;';
FList[38]:='&sup2;&Auml;&Aacute;&Iuml;&acute;ú&ordm;&Aring;';
FList[39]:='&Ecirc;&yacute;&Aacute;&iquest;';
FList[40]:='&micro;&yen;&frac14;&Ucirc;';
FList[41]:='&sup1;&copy;&Oacute;&brvbar;&Eacute;&Igrave;';
end;
procedure TForm12.ComboBox4DropDown(Sender: TObject);
var
i:Integer;
XSQL:String;
Str:String;
begin
SetLength(Term,CheckListBox1.Count+1);
XSQL:='SELECT';
if ListBox2.ItemIndex<0 then
ShowMessage('&Ccedil;&euml;&Ntilde;&iexcl;&Ocirc;&ntilde;&Ograve;&ordf;&sup2;é&Ntilde;&macr;&micro;&Auml;&Agrave;&cedil;&Icirc;&raquo;!')
else
begin
for i:=0 to Length(Store) -1 do
begin
if ListBox2.Items[ListBox2.ItemIndex]=Store then
begin
Str:=Copy(DField,3,Length(DField)-2);
Term[Length(Term)-1]:=DField;
XSQL:=XSQL+' '+DField;
if i<10 then
XSQL:=XSQL+' '+'FROM '+' '+Dfield[0]
else if (i<19) and (i>10) then
XSQL:=XSQL+' '+'FROM ' + ' ' +Dfield[10]
else if (i<27) and (i>19) then
XSQL:=XSQL+' '+'FROM '+' '+Dfield[19]
else if (i<34) and (i>27) then
XSQL:=XSQL+' '+'FROM '+' '+Dfield[27]
else if (i>34) then
XSQL:=XSQL+' '+'FROM '+' '+DField[3];
end;
end;
XSQL:=XSQL+' GROUP BY '+Str;
Pur_DM1.Pur_ADS1.Close;
Pur_DM1.Pur_ADS1.CommandText:=XSQL;
Pur_DM1.Pur_ADS1.Open;
Combobox4.Clear;
Pur_DM1.Pur_ADS1.First;
while not Pur_DM1.Pur_ADS1.Eof do
begin
ComboBox4.Items.Add(Pur_DM1.Pur_ADS1.FieldByName(Str).AsString);
Pur_DM1.Pur_ADS1.Next;
end;
end;
end;
procedure TForm12.ComboBox5DropDown(Sender: TObject);
begin
ComboBox5.Items:=ComboBox4.Items;
end;
procedure TForm12.SpeedButton1Click(Sender: TObject);
var
i:Integer;
j:Integer;
begin
if (ComboBox4.Text<>'') and (ComboBox5.Text<>'') then
begin
SetLength(TermList,CheckListBox1.Count+1);
SetLength(OrderList,CheckListBox1.Count+1);
CheckListBox1.Items.Add(Trim(ListBox2.Items[ListBox2.ItemIndex])+' From'+' '+Trim(ComboBox4.Text)+' '+'To'+' '+Trim(ComboBox5.Text));
for i:=0 to Length(TermList)-1 do
begin
TermList[Length(TermList)-1]:=Term+'>='+''''+Trim(ComboBox4.Text)+''''+' AND '+Term+'<='+''''+Trim(ComboBox5.Text)+'''';
OrderList[Length(OrderList)-1]:=Term;
end;
if CheckListBox1.Count>1 then
begin
TermList[Length(TermList)-1]:='AND '+TermList[Length(TermList)-1];
OrderList[Length(OrderList)-1]:=OrderList[Length(OrderList)-1];
end;
end
else
begin
ShowMessage('&Ccedil;&euml;&Ntilde;&iexcl;&Ocirc;&ntilde;&Ecirc;&yacute;&frac34;&Yacute;·&para;&Icirc;§');
ComboBox4.SetFocus;
end;
end;
procedure TForm12.SpeedButton15Click(Sender: TObject);
begin
if CheckListBox1.ItemIndex>-1 then
begin
TermList[CheckListBox1.ItemIndex]:='';
Term[CheckListBox1.ItemIndex]:='';
CheckListBox1.Items.Delete(CheckListBox1.ItemIndex);
end
else
ShowMessage('&Auml;&atilde;&Atilde;&raquo;&Oacute;&ETH;&Ntilde;&iexcl;&Ocirc;&ntilde;&Egrave;&Icirc;&ordm;&Icirc;&Ecirc;&yacute;&frac34;&Yacute;!');
end;
procedure TForm12.SpeedButton9Click(Sender: TObject);
var
i:Integer;
begin
SetLength(MOList,Length(PRList));
for i:=0 to Length(PRList)-1 do
MOList:=PRList;
if ListBox2.ItemIndex>0 then
begin
for i:=0 to Length(PRList)-1 do
begin
if Trim(ListBox2.Items[ListBox2.ItemIndex])=Trim(PRList) then
begin
MOList:=PRlist[i-1];
MOList[i-1]:=PRList;
s:=MOList[i-1];
end;
end;
ListBox2.Clear;
for i:=0 to Length(MOList)-1 do
ListBox2.Items.Add(MOList);
end
else if ListBox2.ItemIndex=0 then
ShowMessage(ListBox2.Items[ListBox2.ItemIndex]+'&Ograve;&Ntilde;&Icirc;&raquo;&Oacute;&Uacute;&micro;&Uacute;&Ograve;&raquo;&Icirc;&raquo;!')
else if ListBox2.ItemIndex<0 then
ShowMessage('&Auml;&atilde;&Atilde;&raquo;&Oacute;&ETH;&Ntilde;&iexcl;&Ocirc;&ntilde;&Egrave;&Icirc;&ordm;&Icirc;×&Ecirc;&Aacute;&Iuml;!');
ReFresh;
end;
procedure TForm12.ReFresh;
var
i:Integer;
begin
SetLength(PRList,ListBox2.Count);
for i:=0 to ListBox2.Count-1 do
begin
PrList:=ListBox2.Items.Strings;
end;
for i:=0 to ListBox2.Count-1 do
begin
if s=ListBox2.Items.Strings then
begin
ListBox2.Selected:=True;
end;
end;
end;
procedure TForm12.SpeedButton10Click(Sender: TObject);
var
i:Integer;
begin
SetLength(MOList,Length(PRList));
for i:=0 to Length(PRList)-1 do
MOList:=PRList;
if ListBox2.ItemIndex<ListBox2.Count-1 then
begin
for i:=0 to Length(PRList)-1 do
begin
if Trim(ListBox2.Items[ListBox2.ItemIndex])=Trim(PRList) then
begin
MOList:=PRlist[i+1];
MOList[i+1]:=PRList;
s:=MOList[i+1];
end;
end;
ListBox2.Clear;
for i:=0 to Length(MOList)-1 do
ListBox2.Items.Add(MOList);
end
else if ListBox2.ItemIndex=ListBox2.Count-1 then
ShowMessage(ListBox2.Items[ListBox2.ItemIndex]+'&Ograve;&Ntilde;&Icirc;&raquo;&Oacute;&Uacute;×&icirc;&ordm;ó&Ograve;&raquo;&Icirc;&raquo;!')
else if ListBox2.ItemIndex<0 then
ShowMessage('&Auml;&atilde;&Atilde;&raquo;&Oacute;&ETH;&Ntilde;&iexcl;&Ocirc;&ntilde;&Egrave;&Icirc;&ordm;&Icirc;×&Ecirc;&Aacute;&Iuml;!');
ReFresh;
end;
procedure TForm12.SpeedButton5Click(Sender: TObject);
var
XSQL:String;
i:Integer;
j:Integer;
str:String;
begin
QRExpr1.Expression:='';
for i:=0 to 7 do
Flag:=0;
XSQL:='';
if ListBox2.Count<>0 then
begin
for j:=0 to Length(PRList)-1 do
begin
for i:=0 to Length(Store)-1 do
begin
if PRList[j]=Store then
begin
if XSQL='' then
XSQL:='SELECT '+DField+' '+FList+' '
else
XSQL:=XSQL+','+DField+' '+FList+' ';
if i=2 then
XSQL:=XSQL+',F.DEPT_NAME &ETH;è&Ccedil;ó&sup2;&iquest;&Atilde;&Aring; ';
if i in [4,15,23,31,38] then
XSQL:=XSQL+',G.MATE_NAME &sup2;&Auml;&Aacute;&Iuml;&Atilde;&ucirc;&sup3;&AElig; ,G.MATE_UNIT &micro;&yen;&Icirc;&raquo; ';
if i in [12,41] then
XSQL:=XSQL+',H.SUPP_NAME &sup1;&copy;&Oacute;&brvbar;&Eacute;&Igrave;&Atilde;&ucirc;&sup3;&AElig; ';
end;
end;
end;
XSQL:=XSQL+'FROM ';
for i:=0 to Length(Store)-1 do
begin
for j:=0 to ListBox2.Count-1 do
begin
if PRList[j]=Store then
begin
if (i<10) and (Flag[0]=0) and (Flag[1]+Flag[2]+Flag[3]+Flag[4]+Flag[5]+Flag[6]+Flag[7]=0) then
begin
XSQL:=XSQL+DField[0]+' ';
Flag[0]:=1;
end
else if (i<10) and (Flag[0]=0) and (Flag[1]+Flag[2]+Flag[3]+Flag[4]+Flag[5]+Flag[6]+Flag[7]>0) then
begin
XSQL:=XSQL+','+DField[0]+' ';
Flag[0]:=1;
end;
if (i<19) and (i>10) and (Flag[1]=0) and (Flag[0]+Flag[2]+Flag[3]+Flag[4]+Flag[5]+Flag[6]+Flag[7]=0) then
begin
XSQL:=XSQL+DField[10]+' ';
Flag[1]:=1;
end
else if (i<19) and (i>10) and (Flag[1]=0) and (Flag[0]+Flag[2]+Flag[3]+Flag[4]+Flag[5]+Flag[6]+Flag[7]>0) then
begin
XSQL:=XSQL+','+DField[10]+' ';
Flag[1]:=1;
end;
if (i<27) and (i>19) and (Flag[2]=0) and (Flag[0]+Flag[1]+Flag[3]+Flag[4]+Flag[5]+Flag[6]+Flag[7]=0) then
begin
XSQL:=XSQL+Dfield[19]+' ';
Flag[2]:=1;
end
else if (i<27) and (i>19) and (Flag[2]=0) and (Flag[0]+Flag[1]+Flag[3]+Flag[4]+Flag[5]+Flag[6]+Flag[7]>0) then
begin
XSQL:=XSQL+','+Dfield[19]+' ';
Flag[2]:=1;
end;
if (i<34) and (i>27) and (Flag[3]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[4]+Flag[5]+Flag[6]+Flag[7]=0) then
begin
XSQL:=XSQL+DField[27]+' ';
Flag[3]:=1;
end
else if (i<34) and (i>27) and (Flag[3]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[4]+Flag[5]+Flag[6]+Flag[7]>0) then
begin
XSQL:=XSQL+','+DField[27]+' ';
Flag[3]:=1;
end;
if (i>34) and (Flag[4]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[3]+Flag[5]+Flag[6]+Flag[7]=0) then
begin
XSQL:=XSQL+DField[34]+' ';
Flag[4]:=1;
end
else if (i>34) and (Flag[4]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[3]+Flag[5]+Flag[6]+Flag[7]>0) then
begin
XSQL:=XSQL+','+DField[34]+' ';
Flag[4]:=1;
end;
if (i=2) and (Flag[5]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[3]+Flag[4]+Flag[6]+Flag[7]=0) then
begin
XSQL:=XSQL+' PUR_DEPT F ';
Flag[5]:=1;
end
else if (i=2) and (Flag[5]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[3]+Flag[4]+Flag[6]+Flag[7]>0) then
begin
XSQL:=XSQL+' , PUR_DEPT F ';
Flag[5]:=1;
end;
if (i in [4,15,23,31,38]) and (Flag[6]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[3]+Flag[4]+Flag[5]+Flag[7]=0) then
begin
XSQL:=XSQL+' PUR_MATERIAL G ';
Flag[6]:=1;
end
else if (i in [4,15,23,31,38]) and (Flag[6]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[3]+Flag[4]+Flag[5]+Flag[7]>0) then
begin
XSQL:=XSQL+' , PUR_MATERIAL G ';
Flag[6]:=1;
end;
if (i in [12,40]) and (Flag[7]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[3]+Flag[4]+Flag[5]+Flag[6]=0) then
begin
XSQL:=XSQL+' PUR_SUPPLIER H ';
Flag[7]:=1;
end
else if (i in [12,41]) and (Flag[7]=0) and (Flag[0]+Flag[1]+Flag[2]+Flag[3]+Flag[4]+Flag[5]+Flag[6]>0) then
begin
XSQL:=XSQL+' , PUR_SUPPLIER H ';
Flag[7]:=1;
end;
end;
end;
end;
if (Flag[1]>0) and (Flag[0]>0) then
STR:=STR+' AND '+DField[14]+'='+DField[1]+' AND '+ DField[15]+'='+DField[4];
if (Flag[2]>0) and (Flag[0]>0) then
STR:=STR+' AND '+DField[20]+'='+DField[1]+' AND '+ DField[23]+'='+DField[4];
if (Flag[3]>0) and (Flag[0]>0) then
STR:=STR+' AND '+DField[28]+'='+DField[1]+' AND '+ DField[31]+'='+DField[4];
if (Flag[2]>0) and (Flag[1]>0) then
STR:=STR+' AND '+DField[20]+'='+DField[14]+' AND '+ DField[21]+'='+DField[11]+' AND '+ DField[23]+'='+DField[15];
if (Flag[3]>0) and (Flag[1]>0) then
STR:=STR+' AND '+DField[28]+'='+DField[14]+' AND '+ DField[29]+'='+DField[11]+' AND '+ DField[31]+'='+DField[15];
if (Flag[3]>0) and (Flag[2]>0) then
STR:=STR+' AND '+DField[28]+'='+DField[20]+' AND '+ DField[29]+'='+DField[21]+' AND '+ DField[31]+'='+DField[23];
if (Flag[4]>0) and (Flag[1]>0) then
STR:=STR+' AND '+DField[36]+'='+DField[11]+' AND '+ DField[38]+'='+DField[14];
if (Flag[4]>0) and (Flag[2]>0) then
STR:=STR+' AND '+DField[36]+'='+DField[21]+' AND '+ DField[38]+'='+DField[23];
if (Flag[4]>0) and (Flag[3]>0) then
STR:=STR+' AND '+DField[36]+'='+DField[29]+' AND '+ DField[38]+'='+DField[31];
if Flag[5]>0 then
STR:=STR+' AND F.DEPT_NO=A.DEPT_NO ';
if (Flag[6]>0) and (Flag[0]>0) then
STR:=STR+' AND G.MATE_CODE=A.MATE_CODE ';
if (Flag[6]>0) and (Flag[1]>0) then
STR:=STR+' AND G.MATE_CODE=B.MATE_CODE ';
if (Flag[6]>0) and (Flag[2]>0) then
STR:=STR+' AND G.MATE_CODE=C.MATE_CODE ';
if (Flag[6]>0) and (Flag[3]>0) then
STR:=STR+' AND G.MATE_CODE=D.MATE_CODE ';
if (Flag[6]>0) and (Flag[4]>0) then
STR:=STR+' AND G.MATE_CODE=E.MATE_CODE ';
if (Flag[7]>0) and (Flag[1]>0) then
STR:=STR+' AND H.SUPP_CODE=B.SUPP_CODE ';
if (Flag[7]>0) and (Flag[4]>0) then
STR:=STR+' AND H.SUPP_CODE=E.SUPP_CODE ';
if (CheckListBox1.Count>0) or (STR>'') then
XSQL:=XSQL+' WHERE ';
for j:=0 to CheckListBox1.Count-1 do
XSQL:=XSQL+' '+TermList[j];
if STR>'' then
begin
if Trim(Copy(XSQL,Length(XSQL)-6,8))<>'WHERE' then
XSQL:=XSQL+' '+STR
else
XSQL:=XSQL+' '+Copy(STR,5,Length(STR));
end;
XSQL:=XSQL+' GROUP BY ';
for j:=0 to Length(PRList)-1 do
begin
for i:=0 to Length(Store)-1 do
begin
if PRList[j]=Store then
begin
if Trim(Copy(XSQL,Length(XSQL)-3,4))='BY' then
XSQL:=XSQL+DField
else
XSQL:=XSQL+','+DField;
if i=2 then
XSQL:=XSQL+',F.DEPT_NAME ';
if i in [4,15,23,31,38] then
XSQL:=XSQL+',G.MATE_NAME ,G.MATE_UNIT ';
if i in [12,41] then
XSQL:=XSQL+',H.SUPP_NAME ';
end;
end;
end;
for i:=0 to CheckListBox1.Count-1 do
begin
if CheckListBox1.Checked then
begin
if Trim(Copy(XSQL,Length(XSQL)-2,2))<>'BY' then
XSQL:=XSQL+' ORDER BY ';
end;
end;
for i:=0 to CheckListBox1.Count-1 do
begin
if CheckListBox1.Checked then
begin
if Trim(Copy(XSQL,Length(XSQL)-2,2))='BY' then
XSQL:=XSQL+' '+OrderList
else
XSQL:=XSQL+','+OrderList;
end;
end;
if Edit1.Text='' then
begin
if Edit1.Text<>'' then
QuickRep1.ReportTitle:=Edit1.Text
else
QuickRep1.ReportTitle:=' &sup2;é &Ntilde;&macr; &frac12;á &sup1;&ucirc; ';
if MessageDlg('&Auml;&atilde;&Ouml;&raquo;&Ecirc;&Ccedil;&Ograve;&ordf;&frac12;&oslash;&ETH;&ETH;&sup2;é&Ntilde;&macr;&para;&oslash;&sup2;&raquo;&acute;ò&Oacute;&iexcl;&Acirc;&eth;?&Egrave;&ccedil;&sup1;&ucirc;&Auml;&atilde;&Ograve;&ordf;&acute;ò&Oacute;&iexcl;,&Ccedil;&euml;&Ecirc;&auml;&Egrave;&euml;±¨±í&Atilde;&ucirc;&sup3;&AElig;!', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
// ComboBox4.Text:=XSQL;
Pur_DM1.Pur_ADS2.Close;
Pur_DM1.Pur_ADS2.CommandText:=XSQL;
Pur_DM1.Pur_ADS2.Open;
if Pur_DM1.Pur_ADS2.RecordCount>0 then
begin
with TForm12.Create(Application) do
try
CreateReport;
finally
Release;
end;
end
else
ShowMessage('&Atilde;&raquo;&Oacute;&ETH;&Egrave;&Icirc;&ordm;&Icirc;&Auml;&atilde;&Ograve;&ordf;&sup2;é&Ntilde;&macr;&Iacute;&sup3;&frac14;&AElig;&micro;&Auml;×&Ecirc;&Aacute;&Iuml;!');
end;
end
else
begin
// ComboBox4.Text:=XSQL;
Pur_DM1.Pur_ADS2.Close;
Pur_DM1.Pur_ADS2.CommandText:=XSQL;
Pur_DM1.Pur_ADS2.Open;
if Pur_DM1.Pur_ADS2.RecordCount>0 then
begin
with TForm12.Create(Application) do
try
CreateReport;
finally
Release;
end;
end
else
ShowMessage('&Atilde;&raquo;&Oacute;&ETH;&Egrave;&Icirc;&ordm;&Icirc;&Auml;&atilde;&Ograve;&ordf;&sup2;é&Ntilde;&macr;&Iacute;&sup3;&frac14;&AElig;&micro;&Auml;×&Ecirc;&Aacute;&Iuml;!');
end;
end
else
ShowMessage('&Auml;&atilde;&Atilde;&raquo;&Oacute;&ETH;&Ntilde;&iexcl;&Ocirc;&ntilde;&Ograve;&ordf;&sup2;é&Ntilde;&macr;&micro;&Auml;&Egrave;&Icirc;&ordm;&Icirc;×&Ecirc;&Aacute;&Iuml;!');
end;
procedure TForm12.CreateReport;
var
QRLalist:Array of TQRLabel;
QRTeList:Array of TQRDBText;
Count:Integer;
i,k:Integer;
begin
Count:=Pur_DM1.Pur_ADS2.FieldCount;
SetLength(QRLaList,Count);
SetLength(QRTeList,Count);
for i:=0 to high(QRTeList) do
begin
k:=0;
QRLaList:=TQRLabel.Create(self);
if i=0 then
QRLaList.Left:=38
else
QRLaList.Left:=QRLaList[i-1].Left+QRLaList[i-1].Width+12;
QRLaList.Parent:=QuickRep1;
QRLaList.AutoSize:=False;
Pur_DM1.Pur_ADS2.First;
while not Pur_DM1.Pur_ADS2.Eof do
begin
if Pur_DM1.Pur_ADS2.Fields.DataSize>k then
k:=Pur_DM1.Pur_ADS2.Fields.DataSize;
Pur_DM1.Pur_ADS2.Next;
end;
QRLaList.Caption:=Pur_DM1.Pur_ADS2.Recordset.Fields.Name;
QRLaList.Top:=130;
if Pur_DM1.Pur_ADS2.FieldCount>12 then
begin
QRLaList.Font.Size:=7;
QRLaList.Width:=K*2+20;
end
else
begin
QRLaList.Font.Size:=8;
QRLaList.Width:=K*3+20;
end;
QRTeList:=TQRDBText.Create(self);
QRTeList.Parent:=DetailBand1;
QRTeList.DataSet:=Pur_DM1.Pur_ADS2;
QRTeList.DataField:=Pur_DM1.Pur_ADS2.Recordset.Fields.Name;
QRTeList.AutoSize:=True;
QRTeList.Font.Size:=QRLaList.Font.Size;
QRTeList.Top:=10;
QRTeList.Left:=QRLaList.Left-38;
end;
if Pur_DM1.Pur_ADS2.RecordCount/24<>Pur_DM1.Pur_ADS2.RecordCount div 24 then
QRExpr1.Expression:='''Page ''+'+'PAGENUMBER'+'+'' of ''+'+''''+FloatToStr(Pur_DM1.Pur_ADS2.RecordCount/24-(Pur_DM1.Pur_ADS2.RecordCount / 24-Pur_DM1.Pur_ADS2.RecordCount div 24)+1)+''''
else
QRExpr1.Expression:='''Page ''+'+'PAGENUMBER'+'+'' of ''+'+''''+IntToStr(Pur_DM1.Pur_ADS2.RecordCount div 24)+'''';
QuickRep1.Preview;
end;
procedure TForm12.FormShow(Sender: TObject);
begin
TabSheet3.TabVisible:=False;
end;
procedure TForm12.QRBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
var
XSQL:String;
begin
XSQL:='SELECT USER_CNAME FROM PUR_PURVIEW WHERE USER_NAME='+''''+Form2.Edit1.Text+'''';
Pur_DM1.Pur_ADS1.Close;
Pur_DM1.Pur_ADS1.CommandText:=XSQL;
Pur_DM1.Pur_ADS1.Open;
QRLabel4.Caption:='&Ouml;&AElig;±í : '+Pur_DM1.Pur_ADS1.FieldByName('USER_CNAME').AsString;
QRLabel3.Left:=(Screen.Width) div 2;
end;
procedure TForm12.SummaryBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
if QRExpr3.Value.strResult='' then
QRShape4.Pen.Color:=clWhite;
end;
end.