399 lines
11 KiB
ObjectPascal
399 lines
11 KiB
ObjectPascal
![]() |
unit U_TradeLabelPrint;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
|
|||
|
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
|
|||
|
cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
|
|||
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
|
|||
|
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
|
|||
|
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
|
|||
|
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
|
|||
|
IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
|
|||
|
cxTextEdit, cxDBLookupComboBox, ComObj, cxLookAndFeels, cxLookAndFeelPainters,
|
|||
|
cxNavigator, U_BaseList, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges,
|
|||
|
dxBarBuiltInMenu, dxScrollbarAnnotations;
|
|||
|
|
|||
|
type
|
|||
|
TfrmTradeLabelPrint = class(TfrmBaseList)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
GPM_1: TcxGridPopupMenu;
|
|||
|
DS_1: TDataSource;
|
|||
|
CDS_1: TClientDataSet;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v2Column2: TcxGridDBColumn;
|
|||
|
v2Column10: TcxGridDBColumn;
|
|||
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
Panel1: TPanel;
|
|||
|
Label1: TLabel;
|
|||
|
edtScan: TEdit;
|
|||
|
btnFind: TToolButton;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
Label2: TLabel;
|
|||
|
ComboBox1: TComboBox;
|
|||
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
Tv1Column5: TcxGridDBColumn;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
RMDB_1: TRMDBDataSet;
|
|||
|
RM1: TRMGridReport;
|
|||
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
cxStyle1: TcxStyle;
|
|||
|
Button3: TButton;
|
|||
|
CDS_Print: TClientDataSet;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
Tv2: TcxGridDBTableView;
|
|||
|
cxgrdbclmn1: TcxGridDBColumn;
|
|||
|
cxgrdbclmn2: TcxGridDBColumn;
|
|||
|
cxgrdbclmn3: TcxGridDBColumn;
|
|||
|
cxgrdbclmn4: TcxGridDBColumn;
|
|||
|
cxgrdbclmn5: TcxGridDBColumn;
|
|||
|
cxgrdbclmn6: TcxGridDBColumn;
|
|||
|
cxgrdbclmn7: TcxGridDBColumn;
|
|||
|
cxgrdbclmn8: TcxGridDBColumn;
|
|||
|
cxGridLevel2: TcxGridLevel;
|
|||
|
btn1: TButton;
|
|||
|
DS_2: TDataSource;
|
|||
|
CDS_2: TClientDataSet;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure TBDelClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure btnFindClick(Sender: TObject);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
procedure ToolButton5Click(Sender: TObject);
|
|||
|
procedure edtScanKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure Button3Click(Sender: TObject);
|
|||
|
procedure btn1Click(Sender: TObject);
|
|||
|
private
|
|||
|
fFlileFlag: string;
|
|||
|
{ Private declarations }
|
|||
|
procedure InitGrid();
|
|||
|
public
|
|||
|
FAuthority, FCIID: string;
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmTradeLabelPrint: TfrmTradeLabelPrint;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp, U_AttachmentUpload;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Filtered := False;
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('select top 500 * from Trade_Cloth_Inspect A INNER JOIN Trade_LabelPrint B on A.CIID=B.CIID');
|
|||
|
sql.Add('where B.Filler =''' + trim(DName) + '''');
|
|||
|
sql.Add('order by B.Filltime desc');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Filtered := False;
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('SELECT * FROM Trade_Cloth_Inspect a WHERE a.Filltime > ''2024-12-16'' and NOT EXISTS(SELECT DISTINCT Ciid FROM Trade_LabelPrint b WHERE a.CIID = b.CIID)');
|
|||
|
sql.Add('order by Filltime desc');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDS_2);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_2);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
CDS_1.First;
|
|||
|
CDS_2.first;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
frmTradeLabelPrint := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.Button3Click(Sender: TObject);
|
|||
|
var
|
|||
|
fPrintFile, FLabVolume: string;
|
|||
|
begin
|
|||
|
with ADOQueryPrint do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' EXEC P_Trade_Insp_Prt_Lab ');
|
|||
|
SQL.Add(' @CIID=''' + Trim(CDS_1.fieldbyname('CIID').AsString) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryPrint, CDS_Print);
|
|||
|
SInitCDSData(ADOQueryPrint, CDS_Print);
|
|||
|
if ADOQueryPrint.IsEmpty then
|
|||
|
begin
|
|||
|
application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
if Trim(ADOQueryPrint.fieldbyname('Grade').AsString) = '<27><>Ʒ' then
|
|||
|
FLabVolume := Trim(ADOQueryPrint.fieldbyname('LabVolume').AsString)
|
|||
|
else
|
|||
|
FLabVolume := '<27><>Ʒ<EFBFBD><C6B7>ǩ';
|
|||
|
|
|||
|
ExportFtErpFile(FLabVolume + '.rmf', ADOQueryTemp);
|
|||
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + FLabVolume + '.rmf';
|
|||
|
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
Rm1.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1);
|
|||
|
RM1.PrintReport;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
edtScan.SetFocus;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.edtScanKeyPress(Sender: TObject; var Key: Char);
|
|||
|
var
|
|||
|
fPrintFile, FLabVolume, FCIID: string;
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
if trim(edtScan.Text) = '' then
|
|||
|
exit;
|
|||
|
|
|||
|
FCIID := trim(edtScan.Text);
|
|||
|
edtScan.text := '';
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' select * from Trade_Cloth_Inspect A');
|
|||
|
SQL.Add(' where CIID=''' + trim(FCIID) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryTemp.IsEmpty then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>и<EFBFBD><D0B8><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('insert into Trade_LabelPrint(CIID,Filltime,Filler) values( ');
|
|||
|
sql.Add(quotedstr(Trim(FCIID)));
|
|||
|
sql.Add(',getdate() ');
|
|||
|
sql.Add(', ' + quotedstr(trim(DName)));
|
|||
|
sql.Add(')');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
with ADOQueryPrint do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' EXEC P_Trade_Insp_Prt_Lab ');
|
|||
|
SQL.Add(' @CIID=''' + Trim(FCIID) + '''');
|
|||
|
// ShowMessage(sql.text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryPrint, CDS_Print);
|
|||
|
SInitCDSData(ADOQueryPrint, CDS_Print);
|
|||
|
if ADOQueryPrint.IsEmpty then
|
|||
|
begin
|
|||
|
application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
if Trim(ADOQueryPrint.fieldbyname('Grade').AsString) = '<27><>Ʒ' then
|
|||
|
FLabVolume := Trim(ADOQueryPrint.fieldbyname('LabVolume').AsString)
|
|||
|
else
|
|||
|
FLabVolume := '<27><>Ʒ<EFBFBD><C6B7>ǩ';
|
|||
|
ExportFtErpFile(FLabVolume + '.rmf', ADOQueryTemp);
|
|||
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + FLabVolume + '.rmf';
|
|||
|
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
Rm1.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1);
|
|||
|
RM1.PrintReport;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
InitGrid();
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.TBDelClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_1.IsEmpty then
|
|||
|
Exit;
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
|
|||
|
if Trim(CDS_1.fieldbyname('COID').AsString) <> '' then
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('update BS_Company set Valid=''N'' where COID=''' + Trim(CDS_1.fieldbyname('COID').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end;
|
|||
|
CDS_1.Delete;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
ReadCxGrid(trim(self.Caption), Tv1, '<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
edtScan.SetFocus;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.ToolButton5Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_1.IsEmpty then
|
|||
|
Exit;
|
|||
|
try
|
|||
|
frmAttachmentUpload := TfrmAttachmentUpload.Create(Application);
|
|||
|
with frmAttachmentUpload do
|
|||
|
begin
|
|||
|
// FEditAuthority := True;
|
|||
|
if (Trim(FAuthority) = '¼<><C2BC>') or (Trim(FAuthority) = '<27><><EFBFBD><EFBFBD>') then
|
|||
|
FEditAuthority := True;
|
|||
|
fkeyNO := Trim(Self.CDS_1.fieldbyname('Coid').AsString);
|
|||
|
fType := '<27>ͻ<EFBFBD>';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmAttachmentUpload.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.btn1Click(Sender: TObject);
|
|||
|
var
|
|||
|
fPrintFile, FLabVolume: string;
|
|||
|
begin
|
|||
|
if CDS_2.IsEmpty then
|
|||
|
begin
|
|||
|
application.MessageBox('<27><>ѡ<EFBFBD><D1A1>Ҫ<EFBFBD><D2AA>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('insert into Trade_LabelPrint(CIID,Filltime,Filler) values('''+Trim(CDS_2.FieldByName('CIID').AsString)+'''');
|
|||
|
sql.Add(',getdate() ');
|
|||
|
sql.Add(', ' + quotedstr(trim(DName)));
|
|||
|
sql.Add(')');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
with ADOQueryPrint do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' EXEC P_Trade_Insp_Prt_Lab ');
|
|||
|
SQL.Add(' @CIID=''' + Trim(CDS_2.fieldbyname('CIID').AsString) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryPrint, CDS_Print);
|
|||
|
SInitCDSData(ADOQueryPrint, CDS_Print);
|
|||
|
if ADOQueryPrint.IsEmpty then
|
|||
|
begin
|
|||
|
application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
if Trim(ADOQueryPrint.fieldbyname('Grade').AsString) = '<27><>Ʒ' then
|
|||
|
FLabVolume := Trim(ADOQueryPrint.fieldbyname('LabVolume').AsString)
|
|||
|
else
|
|||
|
FLabVolume := '<27><>Ʒ<EFBFBD><C6B7>ǩ';
|
|||
|
|
|||
|
ExportFtErpFile(FLabVolume + '.rmf', ADOQueryTemp);
|
|||
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + FLabVolume + '.rmf';
|
|||
|
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
Rm1.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1);
|
|||
|
RM1.PrintReport;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
edtScan.SetFocus;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.btnFindClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeLabelPrint.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(trim(self.caption), Tv1, '<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|