340 lines
8.3 KiB
ObjectPascal
340 lines
8.3 KiB
ObjectPascal
![]() |
unit U_JYMJIDPRINT;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, RM_Common, RM_Class, RM_e_Xls, RM_GridReport, RM_System,
|
|||
|
RM_Dataset, DBClient, DB, ADODB, StdCtrls, ExtCtrls, RM_E_llPDF;
|
|||
|
|
|||
|
type
|
|||
|
TfrmJYMJIDPRINT = class(TForm)
|
|||
|
ADOQueryTmp: TADOQuery;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
CDS_T: TClientDataSet;
|
|||
|
CDS_Z: TClientDataSet;
|
|||
|
CDS_E: TClientDataSet;
|
|||
|
RMDB_Main: TRMDBDataSet;
|
|||
|
RMDB_T: TRMDBDataSet;
|
|||
|
RMDB_Z: TRMDBDataSet;
|
|||
|
RMDB_E: TRMDBDataSet;
|
|||
|
RMGridReport1: TRMGridReport;
|
|||
|
Button1: TButton;
|
|||
|
RadioGroup1: TRadioGroup;
|
|||
|
Button2: TButton;
|
|||
|
// RMllPDFExport1: TRMllPDFExport;
|
|||
|
Button3: TButton;
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure Button1Click(Sender: TObject);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure Button2Click(Sender: TObject);
|
|||
|
procedure Button3Click(Sender: TObject);
|
|||
|
private
|
|||
|
Procedure Print1(flag1:integer);
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
fMJID:string;
|
|||
|
Fflag:integer;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmJYMJIDPRINT: TfrmJYMJIDPRINT;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_DataLink,U_Fun,U_JYOrderCDOne, U_CKProductBCPOutList;
|
|||
|
{$R *.dfm}
|
|||
|
Procedure TfrmJYMJIDPRINT.Print1(flag1:integer);
|
|||
|
var
|
|||
|
i,j:integer;
|
|||
|
fstr1,fPrintFile:string;
|
|||
|
Txt,fImagePath:string;
|
|||
|
Moudle: THandle;
|
|||
|
Makebar:TMakebar;
|
|||
|
Mixtext:TMixtext;
|
|||
|
begin
|
|||
|
|
|||
|
with ADOqueryTmp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('delete TBSubID where DName='''+Trim(DCode)+'''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
with ADOqueryTmp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * FROM TBSubID where DName='''+Trim(DCode)+'''');
|
|||
|
open;
|
|||
|
append;
|
|||
|
fieldbyname('SubId').Value:=Trim(fMJID);
|
|||
|
fieldbyname('Dname').Value:=Trim(DCode);
|
|||
|
post;
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
with ADOqueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' exec P_Get_JYMJID_Main ');
|
|||
|
sql.Add(' @MJID='+quotedstr(fMJID));
|
|||
|
if radiogroup1.ItemIndex>1 then
|
|||
|
sql.Add(',@flag=''1'' ')
|
|||
|
else
|
|||
|
sql.Add(',@flag=''0'' ');
|
|||
|
sql.Add(',@userID='+quotedstr(trim(DCode)));
|
|||
|
open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOqueryTmp,CDS_Main);
|
|||
|
SInitCDSData20(ADOqueryTmp,CDS_Main);
|
|||
|
|
|||
|
with ADOqueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' exec P_Get_JYMJID ');
|
|||
|
sql.Add(' @MJID='+quotedstr(fMJID));
|
|||
|
sql.Add(',@Flag='+quotedstr('0'));
|
|||
|
open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOqueryTmp,CDS_T);
|
|||
|
SCreateCDS20(ADOqueryTmp,CDS_Z);
|
|||
|
SCreateCDS20(ADOqueryTmp,CDS_E);
|
|||
|
// SInitCDSData20(ADOQueryMain,Order_Main);
|
|||
|
|
|||
|
|
|||
|
//<2F><>ֵ<EFBFBD><D6B5>ͷ<EFBFBD><CDB7>Ϣ
|
|||
|
with ADOqueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' exec P_Get_JYMJID ');
|
|||
|
sql.Add(' @MJID='+quotedstr(fMJID));
|
|||
|
if (radiogroup1.ItemIndex=1) or (radiogroup1.ItemIndex=3) then
|
|||
|
sql.Add(',@Flag='+quotedstr('2'))
|
|||
|
else
|
|||
|
sql.Add(',@Flag='+quotedstr('1'));
|
|||
|
open;
|
|||
|
end;
|
|||
|
with CDS_T do
|
|||
|
begin
|
|||
|
append;
|
|||
|
fieldbyname('N').Value:=1;
|
|||
|
post;
|
|||
|
while not ADOqueryTmp.eof do
|
|||
|
begin
|
|||
|
edit;
|
|||
|
fieldbyname('H'+inttostr(ADOqueryTmp.fieldbyname('keyNo').AsInteger)).Value:=ADOqueryTmp.fieldbyname('cdName').asstring;
|
|||
|
post;
|
|||
|
ADOqueryTmp.Next;
|
|||
|
i:=i+1;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
//<2F><>ֵ<EFBFBD>м<EFBFBD><D0BC>ε<EFBFBD><CEB5><EFBFBD>Ϣ
|
|||
|
with ADOqueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' exec P_Get_JYMJID ');
|
|||
|
sql.Add(' @MJID='+quotedstr(fMJID));
|
|||
|
sql.Add(',@Flag='+quotedstr('3'));
|
|||
|
open;
|
|||
|
end;
|
|||
|
i:=1;
|
|||
|
j:=1;
|
|||
|
with CDS_Z do
|
|||
|
begin
|
|||
|
for j:=1 to 150 do
|
|||
|
begin
|
|||
|
append;
|
|||
|
fieldbyname('N').Value:=j;
|
|||
|
post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
with CDS_Z do
|
|||
|
begin
|
|||
|
while not ADOqueryTmp.Eof do
|
|||
|
begin
|
|||
|
IF Locate('N',ADOqueryTmp.fieldbyname('H').AsInteger,[]) then
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
for i:=2 to 15 do
|
|||
|
begin
|
|||
|
Fields[i].Value:='----';
|
|||
|
end;
|
|||
|
fieldbyname('N1').Value:=ADOqueryTmp.fieldbyname('CDBeg').AsString;
|
|||
|
|
|||
|
IF ADOqueryTmp.FieldByName('KouFenQty').AsFloat>0 then
|
|||
|
begin
|
|||
|
fieldbyname('H'+inttostr(ADOqueryTmp.fieldbyname('keyNo').AsInteger)).Value:=inttostr(ADOqueryTmp.fieldbyname('KouFenQty').AsInteger)+'p';
|
|||
|
end;
|
|||
|
IF ADOqueryTmp.FieldByName('CDName').AsString='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
|||
|
begin
|
|||
|
fieldbyname('E1').Value:='----';
|
|||
|
fieldbyname('E2').Value:='----';
|
|||
|
fieldbyname('E3').Value:=ADOqueryTmp.fieldbyname('CDQty').AsString;
|
|||
|
end;
|
|||
|
post;
|
|||
|
|
|||
|
IF (ADOqueryTmp.FieldByName('koufenType').AsString='1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>覴<EFBFBD>')
|
|||
|
and (ADOqueryTmp.FieldByName('H1').AsInteger>ADOqueryTmp.FieldByName('H').AsInteger ) then
|
|||
|
begin
|
|||
|
for i:=ADOqueryTmp.FieldByName('H').AsInteger to ADOqueryTmp.FieldByName('H1').AsInteger do
|
|||
|
begin
|
|||
|
IF Locate('N',i,[]) then
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
fieldbyname('H'+inttostr(ADOqueryTmp.fieldbyname('keyNo').AsInteger)).Value:='=====';
|
|||
|
post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
ADOqueryTmp.Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
//<2F><>ֵ<EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD>Ϣ
|
|||
|
|
|||
|
with ADOqueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' exec P_Get_JYMJID ');
|
|||
|
sql.Add(' @MJID='+quotedstr(fMJID));
|
|||
|
sql.Add(',@Flag='+quotedstr('4'));
|
|||
|
open;
|
|||
|
end;
|
|||
|
i:=1;
|
|||
|
with CDS_E do
|
|||
|
begin
|
|||
|
append;
|
|||
|
fieldbyname('N').Value:=1;
|
|||
|
post;
|
|||
|
while not ADOqueryTmp.eof do
|
|||
|
begin
|
|||
|
edit;
|
|||
|
fieldbyname('H'+inttostr(ADOqueryTmp.fieldbyname('keyNo').AsInteger)).Value:=ADOqueryTmp.fieldbyname('num').asstring;
|
|||
|
post;
|
|||
|
ADOqueryTmp.Next;
|
|||
|
i:=i+1;
|
|||
|
end;
|
|||
|
end;
|
|||
|
if (radiogroup1.ItemIndex=0) or (radiogroup1.ItemIndex=2) then
|
|||
|
fPrintFile:=ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD>鵥<EFBFBD><E9B5A5><EFBFBD><EFBFBD>Ϣ.rmf';
|
|||
|
if (radiogroup1.ItemIndex=1) or (radiogroup1.ItemIndex=3) then
|
|||
|
fPrintFile:=ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD>鵥<EFBFBD><E9B5A5><EFBFBD><EFBFBD>Ϣ(Ӣ<><D3A2>).rmf';
|
|||
|
if NOT FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+trim(fPrintFile)),'<27><>ʾ',MB_ICONERROR);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
RMGridReport1.LoadFromFile(fPrintFile);
|
|||
|
if flag1=0 then
|
|||
|
RMGridReport1.ShowReport;
|
|||
|
If flag1=1 then
|
|||
|
begin
|
|||
|
|
|||
|
if not DirectoryExists(pchar('D:\pdf<64>ĵ<EFBFBD>')) then
|
|||
|
CreateDirectory(pchar('D:\pdf<64>ĵ<EFBFBD>'),nil);
|
|||
|
fstr1:='D:\pdf<64>ĵ<EFBFBD>\'+trim(CDS_Main.fieldbyname('ISHzEng').AsString)+'_'+trim(CDS_Main.fieldbyname('MJID').AsString)+'_'+trim(CDS_Main.fieldbyname('MJXH').AsString)+'.pdf';
|
|||
|
RMGridReport1.PrepareReport;
|
|||
|
// RMGridReport1.ExportTo(RMllPDFExport1,fstr1);
|
|||
|
end;
|
|||
|
// RMGridReport1.PrepareReport;
|
|||
|
// RMGridReport1.PrintReport10();
|
|||
|
// RMGridReport1.ExportTo(RMXLSExport1,'C:\111.excel');
|
|||
|
// RMGridReport1.ExportTo(RMllPDFExport1,'C:\111.pdf');
|
|||
|
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYMJIDPRINT.FormClose(Sender: TObject;
|
|||
|
var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action:=cafree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYMJIDPRINT.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmJYMJIDPRINT:=nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYMJIDPRINT.Button1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
Print1(0);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYMJIDPRINT.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
fMJID:='1504080304';
|
|||
|
Fflag:=0;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYMJIDPRINT.Button2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYMJIDPRINT.Button3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
IF Fflag=1 then
|
|||
|
begin
|
|||
|
if frmCKProductBCPOutList.CDS_Main.IsEmpty then Exit;
|
|||
|
if frmCKProductBCPOutList.CDS_Main.Locate('SSel',True,[])=False then
|
|||
|
begin
|
|||
|
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
frmCKProductBCPOutList.CDS_Main.DisableControls;
|
|||
|
with frmCKProductBCPOutList.CDS_Main do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
if FieldByName('SSel').AsBoolean then
|
|||
|
begin
|
|||
|
fMJID:=frmCKProductBCPOutList.CDS_Main.fieldbyname('MJID').AsString;
|
|||
|
Print1(1);
|
|||
|
end;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
frmCKProductBCPOutList.CDS_Main.EnableControls;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
if frmJYOrderCDOne.Order_Main.IsEmpty then Exit;
|
|||
|
if frmJYOrderCDOne.Order_Main.Locate('SSel',True,[])=False then
|
|||
|
begin
|
|||
|
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
frmJYOrderCDOne.Order_Main.DisableControls;
|
|||
|
with frmJYOrderCDOne.Order_Main do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
if FieldByName('SSel').AsBoolean then
|
|||
|
begin
|
|||
|
fMJID:=frmJYOrderCDOne.Order_Main.fieldbyname('MJID').AsString;
|
|||
|
Print1(1);
|
|||
|
end;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
frmJYOrderCDOne.Order_Main.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|