2025-01-20 13:04:03 +08:00
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,
2025-10-21 13:50:21 +08:00
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,
dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee,
dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle,
dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary,
dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin,
dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins,
dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
dxSkinOffice2013LightGray, dxSkinPumpkin, dxSkinSeven,
dxSkinSevenClassic, dxSkinSharp, dxSkinSilver, dxSkinStardust,
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinValentine, dxSkinVS2010,
dxSkinWhiteprint, dxSkinXmas2008Blue;
2025-01-20 13:04:03 +08:00
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;
2025-10-21 13:50:21 +08:00
procedure v1Column1PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer ) ;
2025-01-20 13:04:03 +08:00
procedure FormShow( Sender: TObject) ;
procedure FormClose( Sender: TObject; var Action: TCloseAction) ;
procedure FormDestroy( Sender: TObject) ;
2025-10-21 13:50:21 +08:00
procedure Image1MouseDown( Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer ) ;
2025-01-20 13:04:03 +08:00
procedure FormCreate( Sender: TObject) ;
procedure TBCloseClick( Sender: TObject) ;
procedure TBExportClick( Sender: TObject) ;
procedure TBRafreshClick( Sender: TObject) ;
procedure YGNameChange( Sender: TObject) ;
procedure Picture4DblClick( Sender: TObject) ;
2025-10-21 13:50:21 +08:00
procedure Tv1FocusedRecordChanged( Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean ) ;
2025-01-20 13:04:03 +08:00
procedure TSBKQBClick( Sender: TObject) ;
private
2025-10-21 13:50:21 +08:00
hWndC: THandle;
CapturingAVI: bool;
2025-01-20 13:04:03 +08:00
{ Private declarations }
ClickPos: TPoint;
SelectedSource, PicLeft, PicTop, PicWidth, PicHeight: Integer ;
procedure initGrid( ) ;
procedure SetStatus( ) ;
2025-10-21 13:50:21 +08:00
procedure LookImage( FileName: string ) ;
2025-01-20 13:04:03 +08:00
{ Private declarations }
public
2025-10-21 13:50:21 +08:00
FilePath: string ;
FileName: string ;
FTFType: string ;
pat1: string ;
pic1: string ;
fkeyNo: string ;
fFlileFlag: string ;
2025-01-20 13:04:03 +08:00
{ Public declarations }
MyJpeg: TJPEGImage;
{ Public declarations }
end ;
var
FrmWorkDeptList_DKCX: TFrmWorkDeptList_DKCX;
implementation
2025-10-21 13:50:21 +08:00
uses
U_ZDYHelp, U_RTfun, U_DataLink;
const
WM_CAP_START = WM_USER;
const
WM_CAP_STOP = WM_CAP_START + 6 8 ;
const
WM_CAP_DRIVER_CONNECT = WM_CAP_START + 1 0 ;
const
WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 1 1 ;
const
WM_CAP_SAVEDIB = WM_CAP_START + 2 5 ;
const
WM_CAP_GRAB_FRAME = WM_CAP_START + 6 0 ;
const
WM_CAP_SEQUENCE = WM_CAP_START + 6 2 ;
const
WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 2 0 ;
const
WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 6 3 ;
const
WM_CAP_SET_OVERLAY = WM_CAP_START + 5 1 ;
const
WM_CAP_SET_PREVIEW = WM_CAP_START + 5 0 ;
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 + 5 3 ;
const
WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 5 2 ;
function capCreateCaptureWindowA( lpszWindowName: PCHAR ; dwStyle: longint ; x: integer ; y: integer ; nWidth: integer ; nHeight: integer ; ParentWin: HWND; nId: integer ) : HWND; stdcall external 'AVICAP32.DLL' ;
2025-01-20 13:04:03 +08:00
{$R *.dfm}
2025-10-21 13:50:21 +08:00
procedure TFrmWorkDeptList_DKCX. LookImage( FileName: string ) ;
2025-01-20 13:04:03 +08:00
var
2025-10-21 13:50:21 +08:00
sFieldName: string ;
2025-01-20 13:04:03 +08:00
begin
2025-10-21 13:50:21 +08:00
sFieldName : = leftbstr( ExtractFilePath( Application. ExeName) , 1 ) + ':\ͼƬ<CDBC> 鿴' ;
2025-01-20 13:04:03 +08:00
if not DirectoryExists( pchar( sFieldName) ) then
2025-10-21 13:50:21 +08:00
CreateDirectory( pchar( sFieldName) , nil ) ;
2025-01-20 13:04:03 +08:00
2025-10-21 13:50:21 +08:00
sFieldName : = sFieldName + '\' + trim( FileName) ;
2025-01-20 13:04:03 +08:00
try
2025-10-21 13:50:21 +08:00
IdFTP1. Host : = ReadINIFileStr( 'SYSTEMSET.INI' , 'SERVER' , '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ' , '127.0.0.1' ) ;
2025-01-20 13:04:03 +08:00
IdFTP1. Username : = 'three' ;
2025-10-21 13:50:21 +08:00
IdFTP1. Password : = '641010' ;
2025-01-20 13:04:03 +08:00
IdFTP1. Connect( ) ;
except
;
end ;
if IdFTP1. Connected then
begin
2025-10-21 13:50:21 +08:00
Panel2. Caption : = '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> <EFBFBD> <EFBFBD> Ե<EFBFBD> ...' ;
Panel2. Visible : = true ;
application. ProcessMessages;
2025-01-20 13:04:03 +08:00
try
2025-10-21 13:50:21 +08:00
IdFTP1. Get( fFlileFlag + '\' + Trim( FileName) , sFieldName, true , false ) ;
2025-01-20 13:04:03 +08:00
except
2025-10-21 13:50:21 +08:00
Panel2. Visible : = false ;
2025-01-20 13:04:03 +08:00
Application. MessageBox( '<27> ͻ<EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ' , '<27> <> ʾ ' , MB_ICONWARNING) ;
IdFTP1. Quit;
Exit;
end ;
end
else
begin
2025-10-21 13:50:21 +08:00
Panel2. Visible : = false ;
2025-01-20 13:04:03 +08:00
Application. MessageBox( '<27> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ' , '<27> <> ʾ ' , MB_ICONWARNING) ;
IdFTP1. Quit;
Exit;
end ;
2025-10-21 13:50:21 +08:00
Panel2. Visible : = false ;
if IdFTP1. Connected then
IdFTP1. Quit;
ShellExecute( Handle, 'open' , PChar( sFieldName) , '' , '' , SW_SHOWNORMAL) ;
2025-01-20 13:04:03 +08:00
end ;
procedure TFrmWorkDeptList_DKCX. SetStatus( ) ;
begin
2025-10-21 13:50:21 +08:00
2025-01-20 13:04:03 +08:00
end ;
procedure TFrmWorkDeptList_DKCX. initGrid( ) ;
begin
with ADOQueryMain do
begin
close;
sql. Clear;
sql. Add( 'select * from OA_YG_KQ ' ) ;
2025-10-21 13:50:21 +08:00
sql. add( 'where filltime>=' '' + trim( FormatDateTime( 'yyyy-MM-dd' , BegDate. Date) ) + '' '' ) ;
sql. add( ' and filltime<' '' + trim( FormatDateTime( 'yyyy-MM-dd' , endDate. Date + 1 ) ) + '' '' ) ;
2025-01-20 13:04:03 +08:00
open;
end ;
2025-10-21 13:50:21 +08:00
SCreateCDS20( ADOQueryMain, Order_Main) ;
SInitCDSData20( ADOQueryMain, Order_Main) ;
SCreateCDS20( ADOQueryMain, Order_KQB) ;
2025-01-20 13:04:03 +08:00
end ;
2025-10-21 13:50:21 +08:00
procedure TFrmWorkDeptList_DKCX. v1Column1PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer ) ;
2025-01-20 13:04:03 +08:00
begin
try
2025-10-21 13:50:21 +08:00
frmZDYHelp : = TfrmZDYHelp. Create( Application) ;
2025-01-20 13:04:03 +08:00
with frmZDYHelp do
begin
2025-10-21 13:50:21 +08:00
flag : = 'PriceUnit' ;
flagname : = '<27> <> <EFBFBD> <EFBFBD> ' ;
if ShowModal = 1 then
2025-01-20 13:04:03 +08:00
begin
with Order_Main do
begin
edit;
2025-10-21 13:50:21 +08:00
fieldbyname( 'PriceUnit' ) . AsString : = trim( ClientDataSet1. fieldbyname( 'ZDYName' ) . AsString) ;
2025-01-20 13:04:03 +08:00
end ;
end ;
end ;
finally
frmZDYHelp. Free;
end ;
end ;
procedure TFrmWorkDeptList_DKCX. FormShow( Sender: TObject) ;
begin
2025-10-21 13:50:21 +08:00
ReadCxGrid( '<27> <> <EFBFBD> <EFBFBD> ' , Tv1, '<27> <> <EFBFBD> ñ<EFBFBD> <C3B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ' ) ;
2025-01-20 13:04:03 +08:00
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 ;
2025-10-21 13:50:21 +08:00
SCreateCDS20( ADOQueryMain, Order_Main) ;
SInitCDSData20( ADOQueryMain, Order_Main) ;
fFlileFlag : = '123YP' ;
2025-01-20 13:04:03 +08:00
end ;
2025-10-21 13:50:21 +08:00
procedure TFrmWorkDeptList_DKCX. FormClose( Sender: TObject; var Action: TCloseAction) ;
2025-01-20 13:04:03 +08:00
begin
2025-10-21 13:50:21 +08:00
Action : = caFree;
2025-01-20 13:04:03 +08:00
end ;
procedure TFrmWorkDeptList_DKCX. FormDestroy( Sender: TObject) ;
begin
MyJpeg. Free;
2025-10-21 13:50:21 +08:00
FrmWorkDeptList_DKCX : = nil ;
2025-01-20 13:04:03 +08:00
end ;
2025-10-21 13:50:21 +08:00
procedure TFrmWorkDeptList_DKCX. Image1MouseDown( Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer ) ;
2025-01-20 13:04:03 +08:00
begin
ClickPos. x : = X;
ClickPos. y : = Y;
end ;
procedure TFrmWorkDeptList_DKCX. FormCreate( Sender: TObject) ;
begin
MyJpeg : = TJpegImage. Create;
2025-10-21 13:50:21 +08:00
EndDate. Date : = SGetServerDate( ADOQueryDel) ;
begdate. Date : = EndDate. Date;
2025-01-20 13:04:03 +08:00
end ;
procedure TFrmWorkDeptList_DKCX. TBCloseClick( Sender: TObject) ;
begin
2025-10-21 13:50:21 +08:00
WriteCxGrid( '<27> <> <EFBFBD> <EFBFBD> ' , Tv1, '<27> <> <EFBFBD> ñ<EFBFBD> <C3B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ' ) ;
2025-01-20 13:04:03 +08:00
close;
end ;
procedure TFrmWorkDeptList_DKCX. TBExportClick( Sender: TObject) ;
begin
2025-10-21 13:50:21 +08:00
if ADOQueryMain. IsEmpty then
Exit;
TcxGridToExcel( 'Ա<> <D4B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ' , cxGrid1) ;
2025-01-20 13:04:03 +08:00
end ;
procedure TFrmWorkDeptList_DKCX. TBRafreshClick( Sender: TObject) ;
begin
initgrid( ) ;
end ;
procedure TFrmWorkDeptList_DKCX. YGNameChange( Sender: TObject) ;
begin
2025-10-21 13:50:21 +08:00
SDofilter( ADOQueryMain, SGetFilters( Panel1, 1 , 2 ) ) ;
SCreateCDS20( ADOQueryMain, Order_Main) ;
SInitCDSData20( ADOQueryMain, Order_Main) ;
2025-01-20 13:04:03 +08:00
end ;
procedure TFrmWorkDeptList_DKCX. Picture4DblClick( Sender: TObject) ;
var
2025-10-21 13:50:21 +08:00
sFieldName: string ;
fileName: string ;
2025-01-20 13:04:03 +08:00
begin
2025-10-21 13:50:21 +08:00
if TcxDBImage( Sender) . Picture. Height = 0 then
exit;
2025-01-20 13:04:03 +08:00
LookImage( ADOQueryImage. fieldbyname( TcxDBImage( Sender) . Hint) . asstring) ;
end ;
2025-10-21 13:50:21 +08:00
procedure TFrmWorkDeptList_DKCX. Tv1FocusedRecordChanged( Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean ) ;
2025-01-20 13:04:03 +08:00
begin
2025-10-21 13:50:21 +08:00
if Order_Main. IsEmpty then
exit;
2025-01-20 13:04:03 +08:00
with ADOQueryImage do
begin
close;
sql. Clear;
sql. Add( 'select * from TP_File A' ) ;
2025-10-21 13:50:21 +08:00
sql. Add( 'where WBID=' + quotedstr( trim( Order_Main. fieldbyname( 'KQID' ) . AsString) ) ) ;
sql. Add( 'and TFType=' + quotedstr( trim( 'Ա<> <D4B1> ' ) ) ) ;
2025-01-20 13:04:03 +08:00
open;
end ;
end ;
procedure TFrmWorkDeptList_DKCX. TSBKQBClick( Sender: TObject) ;
var
2025-10-21 13:50:21 +08:00
fPrintFile: string ;
Txt, fImagePath: string ;
2025-01-20 13:04:03 +08:00
Moudle: THandle;
2025-10-21 13:50:21 +08:00
Makebar: TMakebar;
Mixtext: TMixtext;
2025-01-20 13:04:03 +08:00
begin
2025-10-21 13:50:21 +08:00
if Order_Main. IsEmpty then
Exit;
fPrintFile : = ExtractFilePath( Application. ExeName) + 'Report\<5C> ϰ<CFB0> ڱ<EFBFBD> .rmf' ;
2025-01-20 13:04:03 +08:00
with ADOQuery1 do
begin
close;
sql. Clear;
sql. Add( 'select YGName' ) ;
2025-10-21 13:50:21 +08:00
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' + '' ')' ) ;
2025-01-20 13:04:03 +08:00
sql. Add( ' from OA_YG_DangAn A ' ) ;
// ShowMessage(sql.text);
open;
end ;
if FileExists( fPrintFile) then
begin
RM1. LoadFromFile( fPrintFile) ;
RM1. PrintReport;
2025-10-21 13:50:21 +08:00
end
else
2025-01-20 13:04:03 +08:00
begin
2025-10-21 13:50:21 +08:00
Application. MessageBox( PChar( 'û<> <C3BB> <EFBFBD> <EFBFBD> ' + ExtractFilePath( Application. ExeName) + 'Report\Ա<> <D4B1> <EFBFBD> <EFBFBD> .rmf' ) , '<27> <> ʾ ' , 0 ) ;
2025-01-20 13:04:03 +08:00
Exit;
end ;
end ;
end .
2025-10-21 13:50:21 +08:00