360 lines
9.9 KiB
ObjectPascal
360 lines
9.9 KiB
ObjectPascal
unit U_WorkDeptList_DKCX;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, ComCtrls, ToolWin, cxStyles, cxCustomData, cxGraphics, cxFilter,
|
||
cxData, cxDataStorage, cxEdit, DB, cxDBData, cxTextEdit, cxCalendar,
|
||
cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
||
cxClasses, cxControls, cxGridCustomView, cxGrid, ADODB, DBClient,
|
||
cxButtonEdit, cxPC, StdCtrls, ExtCtrls, ExtDlgs, IdBaseComponent,
|
||
IdComponent, IdTCPConnection, IdTCPClient, IdFTP,jpeg, IniFiles,
|
||
DelphiTwain, Buttons, cxContainer, cxImage, cxDBEdit,strutils,ShellAPI,
|
||
RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport,
|
||
cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore,
|
||
dxSkinDarkRoom,
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
dxSkinOffice2013White,
|
||
dxSkinSharpPlus,
|
||
dxSkinSpringTime,
|
||
dxSkinsDefaultPainters,
|
||
dxSkinscxPCPainter,
|
||
cxNavigator;
|
||
|
||
type
|
||
TFrmWorkDeptList_DKCX = class(TForm)
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1DKDate: TcxGridDBColumn;
|
||
v1YGName: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
Order_Main: TClientDataSet;
|
||
ADOQueryMain: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
ADOQueryDel: TADOQuery;
|
||
Panel1: TPanel;
|
||
OpenPictureDialog1: TOpenPictureDialog;
|
||
IdFTP1: TIdFTP;
|
||
adoqueryImage: TADOQuery;
|
||
ADOQuery1: TADOQuery;
|
||
SaveDialog1: TSavePictureDialog;
|
||
ScrollBox1: TScrollBox;
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
TBExport: TToolButton;
|
||
Label3: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
Label1: TLabel;
|
||
YGName: TEdit;
|
||
Picture4: TcxDBImage;
|
||
DataSource2: TDataSource;
|
||
Panel2: TPanel;
|
||
v1SXBStatus: TcxGridDBColumn;
|
||
Label4: TLabel;
|
||
SXBStatus: TEdit;
|
||
TSBKQB: TToolButton;
|
||
TXBKQB: TToolButton;
|
||
Order_KQB: TClientDataSet;
|
||
Label2: TLabel;
|
||
EndDate: TDateTimePicker;
|
||
RM1: TRMGridReport;
|
||
RMDBMain: TRMDBDataSet;
|
||
procedure v1Column1PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure YGNameChange(Sender: TObject);
|
||
procedure Picture4DblClick(Sender: TObject);
|
||
procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView;
|
||
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
|
||
ANewItemRecordFocusingChanged: Boolean);
|
||
procedure TSBKQBClick(Sender: TObject);
|
||
private
|
||
hWndC : THandle;
|
||
CapturingAVI : bool;
|
||
{ Private declarations }
|
||
ClickPos: TPoint;
|
||
SelectedSource, PicLeft, PicTop, PicWidth, PicHeight: Integer;
|
||
procedure initGrid();
|
||
procedure SetStatus();
|
||
procedure LookImage(FileName:string);
|
||
{ Private declarations }
|
||
public
|
||
FilePath:string;
|
||
FileName:string;
|
||
FTFType:string;
|
||
pat1:string;
|
||
pic1:string;
|
||
fkeyNo:string;
|
||
fFlileFlag:string;
|
||
{ Public declarations }
|
||
MyJpeg: TJPEGImage;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
FrmWorkDeptList_DKCX: TFrmWorkDeptList_DKCX;
|
||
|
||
implementation
|
||
|
||
uses U_ZDYHelp,U_RTfun,U_DataLink;
|
||
const WM_CAP_START = WM_USER;
|
||
const WM_CAP_STOP = WM_CAP_START + 68;
|
||
const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
|
||
const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
|
||
const WM_CAP_SAVEDIB = WM_CAP_START + 25;
|
||
const WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
|
||
const WM_CAP_SEQUENCE = WM_CAP_START + 62;
|
||
const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;
|
||
const WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63 ;
|
||
const WM_CAP_SET_OVERLAY =WM_CAP_START+ 51 ;
|
||
const WM_CAP_SET_PREVIEW =WM_CAP_START+ 50 ;
|
||
const WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6;
|
||
const WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2;
|
||
const WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3;
|
||
const WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5;
|
||
const WM_CAP_SET_SCALE=WM_CAP_START+ 53 ;
|
||
const WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52 ;
|
||
function capCreateCaptureWindowA(lpszWindowName : PCHAR;
|
||
dwStyle : longint;
|
||
x : integer;
|
||
y : integer;
|
||
nWidth : integer;
|
||
nHeight : integer;
|
||
ParentWin : HWND;
|
||
nId : integer): HWND;
|
||
STDCALL EXTERNAL 'AVICAP32.DLL';
|
||
|
||
{$R *.dfm}
|
||
procedure TFrmWorkDeptList_DKCX.LookImage(FileName:string);
|
||
var
|
||
sFieldName:string;
|
||
begin
|
||
sFieldName:=leftbstr(ExtractFilePath(Application.ExeName),1)+':\ͼƬ<CDBC>鿴';
|
||
|
||
if not DirectoryExists(pchar(sFieldName)) then
|
||
CreateDirectory(pchar(sFieldName),nil);
|
||
|
||
sFieldName:=sFieldName+'\'+trim(fileName);
|
||
|
||
try
|
||
IdFTP1.Host := ReadINIFileStr('SYSTEMSET.INI','SERVER','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ','127.0.0.1');
|
||
IdFTP1.Username := 'three';
|
||
IdFTP1.Password := '641010';
|
||
IdFTP1.Connect();
|
||
except
|
||
;
|
||
end;
|
||
|
||
if IdFTP1.Connected then
|
||
begin
|
||
|
||
Panel2.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>Ե<EFBFBD>...';
|
||
Panel2.Visible:=true;
|
||
application.ProcessMessages;
|
||
try
|
||
IdFTP1.Get(fFlileFlag+'\'+ Trim(fileName), sFieldName,true, false);
|
||
except
|
||
Panel2.Visible:=false;
|
||
Application.MessageBox('<27>ͻ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
Panel2.Visible:=false;
|
||
Application.MessageBox('<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
Panel2.Visible:=false;
|
||
if IdFTP1.Connected then IdFTP1.Quit;
|
||
ShellExecute(Handle, 'open',PChar(sFieldName),'', '', SW_SHOWNORMAL);
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.SetStatus();
|
||
begin
|
||
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.initGrid();
|
||
begin
|
||
with ADOQueryMain do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from OA_YG_KQ ');
|
||
sql.add('where filltime>='''+trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
||
sql.add(' and filltime<'''+trim(FormatDateTime('yyyy-MM-dd',endDate.Date+1))+'''');
|
||
open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
SCreateCDS20(ADOQueryMain,Order_KQB);
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.v1Column1PropertiesButtonClick(
|
||
Sender: TObject; AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='PriceUnit';
|
||
flagname:='<27><><EFBFBD><EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
with Order_Main do
|
||
begin
|
||
edit;
|
||
fieldbyname('PriceUnit').AsString:=trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid('<27><><EFBFBD><EFBFBD>',Tv1,'<27><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
with ADOQueryMain do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from OA_YG_KQ ');
|
||
sql.Add('where convert(varchar(10),DKDate,120)=convert(varchar(10),getdate(),120)');
|
||
open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
fFlileFlag:='123YP';
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.FormDestroy(Sender: TObject);
|
||
begin
|
||
MyJpeg.Free;
|
||
FrmWorkDeptList_DKCX:=nil;
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.Image1MouseDown(Sender: TObject;
|
||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
begin
|
||
ClickPos.x := X;
|
||
ClickPos.y := Y;
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.FormCreate(Sender: TObject);
|
||
begin
|
||
MyJpeg := TJpegImage.Create;
|
||
EndDate.Date:=SGetServerDate(ADOQueryDel);
|
||
begdate.Date:=EndDate.Date;
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid('<27><><EFBFBD><EFBFBD>',Tv1,'<27><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
close;
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then Exit;
|
||
TcxGridToExcel('Ա<><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',cxGrid1);
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
initgrid();
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.YGNameChange(Sender: TObject);
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.Picture4DblClick(Sender: TObject);
|
||
var
|
||
sFieldName:string;
|
||
fileName:string;
|
||
begin
|
||
IF TcxDBImage(Sender).Picture.Height=0 then exit;
|
||
LookImage(ADOQueryImage.fieldbyname(TcxDBImage(Sender).Hint).asstring);
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.Tv1FocusedRecordChanged(
|
||
Sender: TcxCustomGridTableView; APrevFocusedRecord,
|
||
AFocusedRecord: TcxCustomGridRecord;
|
||
ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
if Order_Main.IsEmpty then exit;
|
||
with ADOQueryImage do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from TP_File A');
|
||
sql.Add('where WBID='+quotedstr(trim(Order_Main.fieldbyname('KQID').AsString)));
|
||
sql.Add('and TFType='+quotedstr(trim('Ա<><D4B1>')));
|
||
open;
|
||
end;
|
||
end;
|
||
|
||
procedure TFrmWorkDeptList_DKCX.TSBKQBClick(Sender: TObject);
|
||
var
|
||
fPrintFile:String;
|
||
Txt,fImagePath:string;
|
||
Moudle: THandle;
|
||
Makebar:TMakebar;
|
||
Mixtext:TMixtext;
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C>ϰ<CFB0>ڱ<EFBFBD>.rmf';
|
||
with ADOQuery1 do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select YGName');
|
||
sql.Add(' ,one=(select cast(''<27><>'' as varchar(10)) from OA_YG_KQ B where B.YGName=A.YGName and B.DKDate='''+trim(FormatDateTime('yyyy-MM',BegDate.Date))+'-01'+''')');
|
||
sql.Add(' ,TWO=(select cast(''<27><>'' as varchar(10)) from OA_YG_KQ B where B.YGName=A.YGName and B.DKDate='''+trim(FormatDateTime('yyyy-MM',BegDate.Date))+'-01'+''')');
|
||
sql.Add(' from OA_YG_DangAn A ');
|
||
// ShowMessage(sql.text);
|
||
open;
|
||
end;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.PrintReport;
|
||
end else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\Ա<><D4B1><EFBFBD><EFBFBD>.rmf'),'<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
end.
|