194 lines
4.8 KiB
ObjectPascal
194 lines
4.8 KiB
ObjectPascal
![]() |
unit U_LabelPrint;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, DB, ADODB, RM_e_Graphic, RM_e_bmp, RM_BarCode, RM_System,
|
|||
|
RM_Common, RM_Class, RM_GridReport, RM_e_Xls, RM_Dataset, StdCtrls,
|
|||
|
ExtCtrls;
|
|||
|
|
|||
|
type
|
|||
|
TfrmLabelPrint = class(TForm)
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOConnection1: TADOConnection;
|
|||
|
RMXLSExport1: TRMXLSExport;
|
|||
|
RMGridReport1: TRMGridReport;
|
|||
|
RMBarCodeObject1: TRMBarCodeObject;
|
|||
|
RMBMPExport1: TRMBMPExport;
|
|||
|
RMDS_Main: TRMDBDataSet;
|
|||
|
ADOQueryTmp: TADOQuery;
|
|||
|
Button1: TButton;
|
|||
|
ADOQueryCust: TADOQuery;
|
|||
|
Panel1: TPanel;
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure Button1Click(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
private
|
|||
|
procedure InitDataSetDictionary();
|
|||
|
procedure InitVarDictionary();
|
|||
|
procedure OpenLabel();
|
|||
|
public
|
|||
|
fLabelId:string; //<2F><>ǩ<EFBFBD><C7A9>¼Id;
|
|||
|
fKeyNo:string; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>
|
|||
|
fCustomNo:string; //<2F>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
fLabelCopys:integer; //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
|||
|
fplanNO:string;
|
|||
|
fIsPreviewPrint:Boolean;
|
|||
|
procedure DoPrintLabel();
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmLabelPrint: TfrmLabelPrint;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_global;
|
|||
|
{$R *.dfm}
|
|||
|
////////////////////////////////////////////////////////////////////
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>
|
|||
|
////////////////////////////////////////////////////////////////////
|
|||
|
procedure TfrmLabelPrint.DoPrintLabel();
|
|||
|
begin
|
|||
|
InitDataSetDictionary();
|
|||
|
OpenLabel();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelPrint.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
with ADOConnection1 do
|
|||
|
begin
|
|||
|
Connected:=false;
|
|||
|
ConnectionString:=gConString;
|
|||
|
Connected:=true;
|
|||
|
end;
|
|||
|
Except
|
|||
|
application.MessageBox('<27><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><><EFBFBD><EFBFBD>',mb_Ok+ MB_ICONERROR);
|
|||
|
end;
|
|||
|
end;
|
|||
|
/////////////////////////////////////////////////
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>ر<EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>
|
|||
|
/////////////////////////////////////////////////
|
|||
|
procedure TfrmLabelPrint.InitDataSetDictionary();
|
|||
|
begin
|
|||
|
try
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear ;
|
|||
|
sql.Add('exec P_Label_ClothPrintData');
|
|||
|
sql.Add(quotedStr(fKeyNo));
|
|||
|
sql.Add(','+quotedStr(fPlanNO));
|
|||
|
//sql.Add(','+quotedStr(''));
|
|||
|
//sql.Add(','+quotedStr(''));
|
|||
|
//sql.Add(','+quotedStr(''));
|
|||
|
OPen;
|
|||
|
end;
|
|||
|
with RMGridReport1 do
|
|||
|
begin
|
|||
|
Dictionary.FieldAliases.Clear;
|
|||
|
Dictionary.FieldAliases['RMDS_Main']:= '<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>';
|
|||
|
Dictionary.FieldAliases['RMDS_Main."BarCodeNo"']:='<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>';
|
|||
|
end;
|
|||
|
except
|
|||
|
application.MessageBox('<27><><EFBFBD>ر<EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
////////////////////////////////////////////////////////////
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ֵ
|
|||
|
////////////////////////////////////////////////////////////
|
|||
|
procedure TfrmLabelPrint.InitVarDictionary();
|
|||
|
var
|
|||
|
mName:string;
|
|||
|
i:integer;
|
|||
|
begin
|
|||
|
try
|
|||
|
with ADOQueryCust do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear ;
|
|||
|
sql.Add('exec P_Label_CustPrintData');
|
|||
|
sql.Add(quotedStr(fCustomNo));
|
|||
|
Open;
|
|||
|
|
|||
|
if isEmpty then exit;
|
|||
|
end;
|
|||
|
with RMGridReport1 do
|
|||
|
begin
|
|||
|
for i:=0 to Dictionary.Variables.Count-1 do
|
|||
|
begin
|
|||
|
mName:=Dictionary.Variables.Name[i];
|
|||
|
if (trim(mName)<>'<27>ͻ<EFBFBD><CDBB><EFBFBD>λ<EFBFBD><CEBB>Ϣ') and (trim(mName)<>'<27><>λ<EFBFBD><CEBB>Ϣ') then
|
|||
|
Dictionary.Variables.AsString[mName]:=trim(ADOQueryCust.fieldByName(mName).AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
except
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
////////////////////////////////////////////////////////
|
|||
|
procedure TfrmLabelPrint.OpenLabel();
|
|||
|
begin
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear ;
|
|||
|
sql.Add('select labelfile from jd_label_plan A');
|
|||
|
sql.Add('where planNo='+quotedStr(fPlanNO));
|
|||
|
sql.Add('and labelId='+quotedStr(fLabelId));
|
|||
|
Open;
|
|||
|
if fieldbyname('labelFile').IsNull then
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear ;
|
|||
|
sql.Add('select labelfile from jd_label_sub A');
|
|||
|
sql.Add('where labelId='''+fLabelId+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if fieldbyname('labelFile').IsNull then
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear ;
|
|||
|
sql.Add('select labelfile from jd_label_plan A');
|
|||
|
sql.Add('where planNo='''+fPlanNO+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if fieldbyname('labelFile').IsNull then
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear ;
|
|||
|
sql.Add('select labelfile from jd_label_sub A');
|
|||
|
sql.Add('where customNo=''<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>ñ<EFBFBD>ǩ''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if fieldbyname('labelFile').IsNull then
|
|||
|
begin
|
|||
|
application.MessageBox('δ<>ҵ<EFBFBD>Ҫ<EFBFBD><D2AA>ӡ<EFBFBD>ı<EFBFBD>ǩ<EFBFBD><C7A9>Ϣ<EFBFBD><CFA2>¼!','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
|||
|
self.Close ;
|
|||
|
exit;
|
|||
|
end;
|
|||
|
RMGridReport1.LoadFromBlobField(tblobfield(fieldbyname('labelFile')));
|
|||
|
InitVarDictionary();
|
|||
|
//fIsPreviewPrint:=true;
|
|||
|
if fIsPreviewPrint then
|
|||
|
RMGridReport1.ShowReport
|
|||
|
else
|
|||
|
RMGridReport1.PrintReport ;
|
|||
|
close;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
procedure TfrmLabelPrint.Button1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
DoPrintLabel();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelPrint.FormClose(Sender: TObject;
|
|||
|
var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action:=caFree;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|