몇 일 째 고생하고 있습니다.
해결이 안되는 군요...
지금 구현하려고 하는 내용을 잠시 설명하자면..
우선..
TClientSocket 을 통해..
서버와 데이터를 주고 받습니다.
그리곤..
서버에서 전송받은 값을 파싱해서
가지고 있죠...
서버에선 전송받은 값은..
메모 컴포넌트에도 넣어보고..
텍스트파일에도..
넣어봤습니다.
그 후에
퀵리포트의 NeedData 이벤트가 먼저 발생시키는 것이죠..
그런데...
NeedData 이벤트는 발생이 되어 지는데...
퀵리포트에는 아무런 값도 보여지지 않습니다.
퀵 리포트의 NeedData 이벤트가 TClientSocket의 OnRead 이벤트보다
먼저 발생하는 줄 알았는데..
그런거 같지은 않네요~~
좋은 해결 방법이 없는지요??
선배 고수님들의 시원한 답변 기다립니다.
ㅠ.ㅠ
unit and_rep1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, QRCtrls, QuickRpt, ExtCtrls, ADODB, ScktComp,
Grids, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
qrpt: TQuickRep;
QRBand1: TQRBand;
QRShape1: TQRShape;
QRShape3: TQRShape;
QRShape2: TQRShape;
QRShape4: TQRShape;
titlex: TQRLabel;
Man1: TQRLabel;
Man2: TQRLabel;
Man3: TQRLabel;
SpoolDate: TQRLabel;
Team: TQRLabel;
QRBand2: TQRBand;
solgonet: TQRLabel;
Corp: TQRLabel;
CurDate: TQRLabel;
QRShape5: TQRShape;
QRShape8: TQRShape;
QRShape9: TQRShape;
QRShape10: TQRShape;
QRShape11: TQRShape;
QRShape12: TQRShape;
QRShape13: TQRShape;
QRShape14: TQRShape;
QRShape16: TQRShape;
QRShape18: TQRShape;
QRShape19: TQRShape;
QRShape21: TQRShape;
QRShape22: TQRShape;
QRShape23: TQRShape;
QRShape20: TQRShape;
QRShape24: TQRShape;
QRShape25: TQRShape;
QRShape26: TQRShape;
QRShape27: TQRShape;
QRShape28: TQRShape;
QRShape29: TQRShape;
QRShape31: TQRShape;
QRShape32: TQRShape;
QRShape33: TQRShape;
QRShape34: TQRShape;
QRShape7: TQRShape;
category: TQRLabel;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
.
.
.
QRLabel362: TQRLabel;
QRLabel363: TQRLabel;
QRLabel364: TQRLabel;
ClientSocket1: TClientSocket;
Man4: TQRLabel;
Memo1: TMemo;
procedure qrptStartPage(Sender: TCustomQuickRep);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer);
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
procedure FormCreate(Sender: TObject);
procedure qrptNeedData(Sender: TObject; var MoreData: Boolean);
private
{ Private declarations }
procedure divResult(str_result:String);//row단위로 데이터 자름
procedure createArray(str_rowdata:String);//cell단위로 데이터 분리후 배열에 저장
public
{ Public declarations }
Cat1: array[0..11] of TQRLabel;
Cat2: array[0..24] of TQRLabel;
Dat1: array[0..11,0..24] of TQRLabel;
SpoolDate_,Team_,Corp_: string;
Man1_,Man2_,Man3_, Man4_, option_: string;
end;
var
Form1: TForm1;
data:array[0..100,0..4] of String;//StringGrid1에 사용될 배열
int_f,int_l:integer;
count:integer;
implementation
{$R *.dfm}
uses expression;
const
AlignmentTypes: Array[0..2] of TAlignment = (taLeftJustify, taRightJustify, taCenter);
BiDiModeTypes: Array[0..3] of TBiDiMode = (bdLeftToRight, bdRightToLeft, bdRightToLeftNoAlign, bdRightToLeftReadingOnly);
FileName = 'C:\QuckReport.txt';
procedure TForm1.FormCreate(Sender: TObject);
begin
count := 0;
ClientSocket1.Active := True;
end;
procedure TForm1.qrptStartPage(Sender: TCustomQuickRep);
var
i,j,k:integer;
yyyy,mm,dd: Word;
CurDate_ : String;
ValueX: array[0..11,0..24] of real;
Cat1_ttl: array[0..11] of string;
Cat2_ttl: array[0..24] of string;
str_sql : String;
field_count:integer;
begin
category.Caption := '구분';
titlex.Caption := '현황';
SpoolDate.caption := 'Dec-20-2004';
Team.caption := '운영팀';
Corp.caption := '(주)XX닷컴';
Man1.caption := '담 당';
Man2.caption := '과 장';
Man3.caption := '팀 장';
Man4.caption := '중 역';
SpoolDate.caption := SpoolDate_;
Team.caption := Team_;
Corp.caption := Corp_;
Man1.caption := Man1_;
Man2.caption := Man2_;
Man3.caption := Man3_;
Man4.caption := Man4_;
Curdate.Caption := DateToStr(Date);
for i:=0 to 11 do begin
Cat1[i] := TQRLabel(FindComponent('QRLabel'+IntToStr(i+2)));
Cat1[i].caption := '';
end;
for i:=0 to 24 do begin
Cat2[i] := TQRLabel(FindComponent('QRLabel'+IntToStr(i+15)));
Cat2[i].caption := '';
end;
for i:=0 to 324 do begin
j := i mod 13;
k := i div 13;
Dat1[j][k] := TQRLabel(FindComponent('QRLabel'+IntToStr(i+40)));
Dat1[j][k].caption := '';
end;
category.Caption := '구분';
Cat1_ttl[0] := '설계';
Cat1_ttl[1] := '구매';
Cat1_ttl[2] := '자재';
Cat1_ttl[3] := '생산1';
Cat1_ttl[4] := '생산2';
Cat1_ttl[5] := '전산';
Cat1_ttl[6] := '통관';
Cat1_ttl[7] := '외주';
Cat1_ttl[8] := '영업';
Cat1_ttl[9] := '계약';
Cat1_ttl[10] := '기타';
Cat1_ttl[11] := '합계';
if Form1.option_ = '1' then
begin
titlex.Caption := '현황';
for i:=0 to 23 do Cat2_ttl[i] := inttostr(i);
Cat2_ttl[24] := '평균';
for i:=0 to 24 do begin
Cat2[i].Alignment := AlignmentTypes[0];
Cat2[i].BiDiMode := BiDiModeTypes[0];
end;
end;
for i:=0 to 12 do begin
Cat1[i].caption := Cat1_ttl[i];
end;
end;
procedure TForm1.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
var
strsend:String;
begin
strsend := '';
strsend := ' select b.descr, a.serno,a.ekcode,a.ecode,a.status,a.ofkinds,a.ofserno,a.owner, ';
strsend := strsend+' a.reason,a.mcomp,a.scomp,a.mtime,a.price,a.mngr ';
strsend := strsend+' from tb_fa_equipmst a, tb_fa_equipcode b ';
strsend := strsend+' where a.ekcode=b.ekcode(+) and a.ecode=b.ecode(+) ';
ClientSocket1.Socket.SendText('$s$04$'+strsend+#9);
end;
procedure TForm1.ClientSocket1Error(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
case ErrorCode of
10061 : ShowMessage('서버 데이터베이스에 연결할수 없습니다.');
end;
ErrorCode := 0;
Socket.Close;
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
strreceive:String;
f1 : textfile;
begin
strreceive := trim(Socket.ReceiveText);
AssignFile(f1, FileName);
Rewrite(f1);
WriteLn(f1, strreceive);
CloseFile(f1);
divResult(strreceive); //받은 데이터 분리작업
end;
procedure TForm1.divResult(str_result: String);
var
int_s,int_e : integer;
int_gubun:integer;
str_data : String;
str_end:String;
str_rowdata : String;
begin
if str_result = '###empty###' then begin
ClientSocket1.Active := false; //소켓닫음
ClientSocket1.Close;
end else begin
int_s := pos('$s$',str_result); //사작구분자위치
int_e := pos('$e$',str_result); //종료구분자위치
str_data := copy(str_result,int_s+3,int_e-4); //실제데이터부분리
str_end := trim(copy(str_result,length(str_result)-8,length(str_result)));//마지막인지 확인
if str_data <> '' then begin
int_gubun := pos('@#@', str_data); //row 구분자 위치
while (int_gubun <> 0) do begin //row구분자가 있는 만큼
str_rowdata := copy(str_data,0,int_gubun-1); //row만큼 분리
if str_rowdata <> '' then begin
createArray(str_rowdata); //배열에 데이터 담기위한 메소드 호출
inc(int_f);//row값 증가
end else
break;
str_data := copy(str_data,int_gubun+3,int_e-4);
int_gubun := pos('@#@', str_data);
end;
end;
if str_end = '###end###' then begin
ClientSocket1.Active := false; //소켓닫음
ClientSocket1.Close;
end;
if ClientSocket1.Active = false then
end;
end;
procedure TForm1.createArray(str_rowdata: String);
var
int_s,int_t:integer;
str_celldata:string;
str_divdata:string;
i:integer;
Buf : TStringList;
f1 : textfile;
begin
Buf := TStringList.Create;
str_divdata := str_rowdata;
int_s := pos('%|%',str_divdata);
int_t := length(str_divdata);
int_l := 0;
AssignFile(f1, FileName);
while int_s <> 0 do begin
str_celldata := copy(str_divdata,0,int_s-1);
data[int_f][int_l] := str_celldata;
Buf.Add(str_celldata);
Append(f1);
for i := 0 to Buf.Count -1 do begin
WriteLn(f1, Buf.Strings[i]);
end;
CloseFile(f1);
AssignFile(f1, FileName);
Rewrite(f1);
WriteLn(f1, str_celldata);
CloseFile(f1);
inc(int_l);
str_divdata := copy(str_divdata, int_s+3,int_t);
int_s := pos('%|%',str_divdata);
end;
qrpt.Prepare ;
end;
procedure TForm1.qrptNeedData(Sender: TObject; var MoreData: Boolean);
var
i, j, k, l:integer;
ValueX: array[0..12,0..24] of real;
F : TextFile;
S : String;
count : Integer;
begin
AssignFile(F, FileName);
Reset(F);
try
count := 0;
While not Eof(F) do begin
MoreData := true;
ReadLn(F, S);
for i := 1 to Length(S) do begin//행의 길이만큼 반복
for j := 0 to 12 do
for k := 0 to 24 do begin
Dat1[j][k].Caption := S[i];
end;
count := count + 1;
end; {for end}
end; { While end}
MoreData := false;
finally
end; {try end}
CloseFile(F);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
end.
===============================================================
위 소스론..
레포트 출력이 안됩니다.
제발~~
ㅠ.ㅠ