259 lines
6.8 KiB
ObjectPascal
259 lines
6.8 KiB
ObjectPascal
unit U_JNPRT;
|
||
|
||
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, cxPC, cxCheckComboBox, cxDropDownEdit, Menus, RM_e_Xls, TeEngine,
|
||
Series, TeeProcs, Chart, DbChart, cxLookAndFeels, cxLookAndFeelPainters,
|
||
cxNavigator;
|
||
|
||
type
|
||
TfrmJNPRT = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
ToolButton2: TToolButton;
|
||
ADOQueryMain: TADOQuery;
|
||
RM1: TRMGridReport;
|
||
RMDB_Main: TRMDBDataSet;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
cxGridLevel1: TcxGridLevel;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
DS_HZ: TDataSource;
|
||
CDS_HZ: TClientDataSet;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
v2Column17: TcxGridDBColumn;
|
||
Panel1: TPanel;
|
||
RMXLSExport2: TRMXLSExport;
|
||
v2Column7: TcxGridDBColumn;
|
||
v2Column12: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
ToolButton3: TToolButton;
|
||
ADOQueryPrt: TADOQuery;
|
||
Tv2Column1: TcxGridDBColumn;
|
||
Label2: TLabel;
|
||
Label6: TLabel;
|
||
begdate: TDateTimePicker;
|
||
Enddate: TDateTimePicker;
|
||
Tv2Column2: TcxGridDBColumn;
|
||
Tv2Column3: TcxGridDBColumn;
|
||
Tv2Column4: TcxGridDBColumn;
|
||
Tv2Column5: TcxGridDBColumn;
|
||
Tv2Column6: TcxGridDBColumn;
|
||
Panel2: TPanel;
|
||
Label4: TLabel;
|
||
DYInt: TEdit;
|
||
JNCarNo1: TEdit;
|
||
Label1: TLabel;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
procedure PrintReport(FZDYNo, MJNCarNo: string);
|
||
procedure InitGrid();
|
||
public
|
||
fFlag: integer;
|
||
{ Public declarations }
|
||
RKFlag, FCYID, fmanage: string;
|
||
end;
|
||
|
||
var
|
||
frmJNPRT: TfrmJNPRT;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun, U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmJNPRT.PrintReport(FZDYNo, MJNCarNo: string);
|
||
var
|
||
fPrintFile, FFCYID: string;
|
||
i, j: Integer;
|
||
Txt, fImagePath: string;
|
||
Moudle: THandle;
|
||
Makebar: TMakebar;
|
||
Mixtext: TMixtext;
|
||
begin
|
||
if CDS_HZ.IsEmpty then
|
||
Exit;
|
||
|
||
ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ.rmf', ADOQueryTemp);
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ.rmf';
|
||
{with ADOQueryPrt do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' select * from Machine where MCNO=''' + Trim(FZDYNo) + '''');
|
||
open;
|
||
end;}
|
||
|
||
|
||
try
|
||
Moudle := LoadLibrary('MakeQRBarcode.dll');
|
||
@Makebar := GetProcAddress(Moudle, 'Make');
|
||
@Mixtext := GetProcAddress(Moudle, 'MixText');
|
||
Txt := Trim(FZDYNo);
|
||
fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
|
||
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
|
||
CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
|
||
if FileExists(fImagePath) then
|
||
DeleteFile(fImagePath);
|
||
Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
|
||
except
|
||
CDS_HZ.EnableControls;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
RMVariables['QRBARCODE'] := fImagePath;
|
||
RMVariables['JRId'] := FZDYNo;
|
||
RMVariables['JNCarNo'] := MJNCarNo;
|
||
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RM1.LoadFromFile(fPrintFile);
|
||
Rm1.DefaultCopies := 8;
|
||
RM1.PrintReport;
|
||
// RM1.ShowReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile + '!'), '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJNPRT.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select A.*,xiangQty=8 from JN_CR A ');
|
||
sql.Add('where A.Filltime>=''' + FormatDateTime('yyyy-MM-dd', begdate.DateTime) + ''' ');
|
||
sql.Add(' and A.Filltime<''' + FormatDateTime('yyyy-MM-dd', Enddate.DateTime + 1) + ''' ');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain, CDS_HZ);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
ToolButton2.Click;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJNPRT.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmJNPRT := nil;
|
||
end;
|
||
|
||
procedure TfrmJNPRT.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmJNPRT.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(Trim(Self.Caption), Tv2, '<27><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmJNPRT.FormShow(Sender: TObject);
|
||
begin
|
||
Enddate.DateTime := SGetServerDate(ADOQueryTemp);
|
||
begdate.DateTime := Enddate.DateTime - 30;
|
||
ReadCxGrid(Trim(Self.Caption), Tv2, '<27><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>');
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmJNPRT.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmJNPRT.ToolButton2Click(Sender: TObject);
|
||
var
|
||
sql: string;
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
sql := SGetFilters(Panel1, 1, 2);
|
||
SDofilter(ADOQueryMain, sql);
|
||
SCreateCDS20(ADOQueryMain, CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain, CDS_HZ);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJNPRT.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid;
|
||
end;
|
||
|
||
procedure TfrmJNPRT.ToolButton3Click(Sender: TObject);
|
||
var
|
||
maxId: string;
|
||
Fint: Integer;
|
||
begin
|
||
begdate.SetFocus;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* from JN_Car A where Valid=''Y'' ');
|
||
sql.Add('and JNCarNo= ' + quotedstr(JNCarNo1.Text));
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
Application.MessageBox('<27><>̨<EFBFBD><CCA8>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if TryStrToInt(DYInt.Text, Fint) = False then
|
||
begin
|
||
Application.MessageBox('<27><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
for Fint := 1 to StrToInt(DYInt.Text) do
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, maxId, 'JN', 'JN_CR', 4, 1) = False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('insert into JN_CR(JRId,PRTPerson,JNCarNo,PRTTime) values(' + quotedstr(Trim(maxId)) + ',' + quotedstr(Trim(dname)) + ',' + quotedstr(Trim(JNCarNo1.Text)) + ',getdate() )');
|
||
ExecSQL;
|
||
end;
|
||
PrintReport(Trim(maxId), JNCarNo1.Text);
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|