D10djxinbiao/项目代码/djdxinbiao/A00通用窗体/U_MdPrint.pas
DESKTOP-E401PHE\Administrator 6c85a6e5ec 欣标~
2026-02-06 14:24:15 +08:00

327 lines
8.6 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_MdPrint;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, ToolWin, ComCtrls, U_BaseHelp, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls,
cxGridCustomView, cxGrid, DBClient, ADODB, ImgList, StdCtrls, ExtCtrls,
cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels,
cxNavigator, dxDateRanges, dxBarBuiltInMenu, System.ImageList, U_BaseInput,
RM_Common, RM_Class, RM_GridReport, RM_Dataset, Vcl.Buttons, RM_E_llPDF,
RM_BarCode, RM_e_Graphic, RM_e_Jpeg, RM_e_Xls, cxContainer, cxMaskEdit,
cxDropDownEdit, cxMRUEdit, cxLookAndFeelPainters;
type
TfrmMdPrint = class(TfrmBaseHelp)
ADOQueryTemp: TADOQuery;
ADOConnection1: TADOConnection;
Panel1: TPanel;
ImageList1: TImageList;
RMDB_1: TRMDBDataSet;
RM1: TRMGridReport;
RMDB_2: TRMDBDataSet;
CDS_Label: TClientDataSet;
ADO_1: TADOQuery;
btnPrint: TSpeedButton;
btnShow: TSpeedButton;
ADO_2: TADOQuery;
RMDB_3: TRMDBDataSet;
ADO_3: TADOQuery;
RMXLSExport1: TRMXLSExport;
RMJPEGExport1: TRMJPEGExport;
RMBarCodeObject1: TRMBarCodeObject;
RMllPDFExport1: TRMllPDFExport;
CheckBox1: TCheckBox;
Label1: TLabel;
CheckBox2: TCheckBox;
ComboBox1: TcxComboBox;
cbbLab: TcxMRUEdit;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure TV1DblClick(Sender: TObject);
procedure btnPrintClick(Sender: TObject);
procedure btnShowClick(Sender: TObject);
procedure cbbLabPropertiesButtonClick(Sender: TObject);
procedure RM1PrintReportEvent(Sender: TObject);
private
procedure InitGrid();
procedure PrintLabel(MIsShow: Boolean);
{ Private declarations }
public
FPreviewPrint, IsSql1: Boolean;
FLMType: string; //<2F><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>
FFiltration1, FFiltration2, FFiltration3: string;
{ Public declarations }
end;
var
frmMdPrint: TfrmMdPrint;
implementation
uses
U_DataLink, U_RTFun, U_globalVar, U_BillPrintList;
{$R *.dfm}
procedure TfrmMdPrint.PrintLabel(MIsShow: Boolean);
var
fPrintFile, fPrintFile10, FMainID, LBName: string;
begin
if CDS_Label.IsEmpty then
begin
Application.MessageBox(PChar('<27><><EFBFBD><EFBFBD>' + FLMType + <><C3BB><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD>ǩ!'), '<27><>ʾ', 0);
Exit;
end;
RMllPDFExport1.ShowDialog := CheckBox2.Checked;
RMJPEGExport1.ShowDialog := CheckBox2.Checked;
RMXLSExport1.ShowDialog := CheckBox2.Checked;
RM1.ShowPrintDialog := CheckBox1.Checked;
LBName := cbbLab.text;
ExportFtErpFile(LBName + '.rmf', ADOQueryTemp);
if CDS_Label.Locate('billName', LBName, []) then
begin
if IsSql1 then
begin
with ADO_1 do
begin
Close;
sql.Clear;
sql.add('exec ' + trim(CDS_Label.fieldbyname('procedureName').AsString));
sql.add(FFiltration1);
Open;
end;
end
else
begin
if trim(CDS_Label.fieldbyname('procedureName').AsString) <> '' then
begin
with ADO_1 do
begin
Close;
sql.Clear;
sql.add('exec ' + trim(CDS_Label.fieldbyname('procedureName').AsString) + ' @Filtration=' + quotedstr(Trim(FFiltration1)));
sql.Add(',@billName=' + QuotedStr(cbbLab.Text));
Open;
end;
end;
if trim(CDS_Label.fieldbyname('procedureName2').AsString) <> '' then
begin
with ADO_2 do
begin
Close;
sql.Clear;
sql.add('exec ' + trim(CDS_Label.fieldbyname('procedureName2').AsString) + ' @Filtration=' + quotedstr(Trim(FFiltration2)));
sql.Add(',@billName=' + QuotedStr(cbbLab.Text));
Open;
end;
end;
if trim(CDS_Label.fieldbyname('procedureName3').AsString) <> '' then
begin
with ADO_3 do
begin
Close;
sql.Clear;
sql.add('exec ' + trim(CDS_Label.fieldbyname('procedureName3').AsString) + ' @Filtration=' + quotedstr(Trim(FFiltration3)));
Open;
end;
end;
end;
end;
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + LBName + '.rmf';
if FileExists(fPrintFile) then
begin
RM1.LoadFromFile(fPrintFile);
RM1.DefaultCopies := StrToIntDef(ComboBox1.Text, 1);
RMVariables['LBPrtCode'] := dcode;
RMVariables['LBPrtName'] := dname;
if MIsShow then
RM1.ShowReport
else
RM1.PrintReport;
end
else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
end;
end;
procedure TfrmMdPrint.RM1PrintReportEvent(Sender: TObject);
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
SQL.Add('update Print_Num set Printnum=Printnum+1,Printtime=convert(char(10),GETDATE(),120) ');
execsql;
end;
end;
procedure TfrmMdPrint.FormCreate(Sender: TObject);
begin
inherited;
FPreviewPrint := True;
try
with ADOConnection1 do
begin
Connected := false;
ConnectionString := DConString;
Connected := true;
end;
ADOQueryBaseCmd.Connection := ADOConnection1;
ADOQueryBaseTemp.Connection := ADOConnection1;
except
{if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>,<2C>Ƿ<EFBFBD>Ҫ<EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>?','<27><>ʾ',32+4)=IDYES then
begin
try
with ADOConnection1 do
begin
Connected:=false;
ConnectionString:=DConString;
//ConnectionString:='23242';
Connected:=true;
end;
except
end;
end; }
end;
end;
procedure TfrmMdPrint.btnPrintClick(Sender: TObject);
begin
if Trim(cbbLab.Text) = '' then
begin
application.MessageBox(<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5>ӡ<EFBFBD><D3A1>ʽ!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
exit;
end;
PrintLabel(False);
ModalResult := 1;
end;
procedure TfrmMdPrint.btnShowClick(Sender: TObject);
begin
if Trim(cbbLab.Text) = '' then
begin
application.MessageBox(<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5>ӡ<EFBFBD><D3A1>ʽ!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
exit;
end;
PrintLabel(true);
end;
procedure TfrmMdPrint.cbbLabPropertiesButtonClick(Sender: TObject);
begin
if not gIsCanDesign then
exit;
try
frmBillPrintList := TfrmBillPrintList.Create(Application);
with frmBillPrintList do
begin
IsSql1 := self.IsSql1;
FFiltration1 := self.FFiltration1;
FFiltration2 := self.FFiltration2;
FFiltration3 := self.FFiltration3;
FLMType := self.FLMType;
if ShowModal = 1 then
begin
Self.InitGrid();
end;
end;
finally
frmBillPrintList.Free;
end;
end;
procedure TfrmMdPrint.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := cahide;
end;
procedure TfrmMdPrint.InitGrid();
begin
with ADOQueryTemp do
begin
close;
sql.Clear;
sql.Add('select recid, billname from SD_BillPrint');
sql.Add('where billtype=' + QuotedStr(TRIM(FLMType)));
sql.Add('and billGroup=''<27>뵥'' and valid=1');
sql.Add('and isnull(billname,'''')<>''''');
sql.Add(' order by orderno ');
Open;
if isEmpty then
begin
exit;
end;
cbbLab.Properties.LookupItems.Clear;
while not Eof do
begin
// cbbLab.Properties.items.AddObject()
// cbbLab.Properties.items.AddPair(Trim(fieldByName('billname').AsString),Trim(fieldByName('recid').AsString)) ;
cbbLab.Properties.items.Add(Trim(fieldByName('billname').AsString));
// cbbLab.Properties.LookupItems.Add(Trim(fieldByName('recid').AsString));
Next;
end;
cbbLab.ItemIndex := 0;
end;
with ADOQueryTemp do
begin
Filtered := False;
Close;
sql.Clear;
Sql.Add('select * from SD_BillPrint where billtype=' + QuotedStr(TRIM(FLMType)));
sql.Add('and billGroup=''<27>뵥'' and valid=1');
Open;
end;
SCreateCDS(ADOQueryTemp, CDS_Label);
SInitCDSData(ADOQueryTemp, CDS_Label);
if CDS_Label.IsEmpty then
begin
Application.MessageBox(PChar('<27><><EFBFBD><EFBFBD>' + FLMType + <><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>!'), '<27><>ʾ', 0);
Exit;
end;
end;
procedure TfrmMdPrint.FormShow(Sender: TObject);
begin
inherited;
if FPreviewPrint then
RM1.PreviewButtons := [rmpbZoom, rmpbLoad, rmpbSave, rmpbPrint, rmpbFind, rmpbPageSetup, rmpbExit, rmpbSaveToXLS, rmpbExport, rmpbNavigator]
else
RM1.PreviewButtons := [rmpbZoom, rmpbLoad, rmpbSave, rmpbFind, rmpbPageSetup, rmpbExit, rmpbSaveToXLS, rmpbExport, rmpbNavigator];
if Trim(FFiltration2) = '' then
FFiltration2 := FFiltration1;
if Trim(FFiltration3) = '' then
FFiltration3 := FFiltration1;
InitGrid();
end;
procedure TfrmMdPrint.TV1DblClick(Sender: TObject);
begin
ModalResult := 1;
end;
procedure TfrmMdPrint.FormDestroy(Sender: TObject);
begin
inherited;
frmMdPrint := nil;
end;
end.