306 lines
8.2 KiB
ObjectPascal
306 lines
8.2 KiB
ObjectPascal
![]() |
unit U_ZdyAttachmentBJ;
|
|||
|
|
|||
|
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, RM_e_Xls, RM_E_llPDF, cxLookAndFeels,
|
|||
|
cxLookAndFeelPainters, cxNavigator, cxContainer, cxImage, cxDBEdit;
|
|||
|
|
|||
|
type
|
|||
|
TfrmZdyAttachmentCB = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBDel: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
Panel1: TPanel;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
Label3: TLabel;
|
|||
|
custNo: TEdit;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
Tv2: TcxGridDBTableView;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
DS_Main: TDataSource;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v2Column1: TcxGridDBColumn;
|
|||
|
v2Column2: TcxGridDBColumn;
|
|||
|
v2Column3: TcxGridDBColumn;
|
|||
|
v2Column5: TcxGridDBColumn;
|
|||
|
v2Column7: TcxGridDBColumn;
|
|||
|
v2Column8: TcxGridDBColumn;
|
|||
|
v2Column9: TcxGridDBColumn;
|
|||
|
v2Column10: TcxGridDBColumn;
|
|||
|
ToolButton4: TToolButton;
|
|||
|
v2Column11: TcxGridDBColumn;
|
|||
|
v2DEFStr7: TcxGridDBColumn;
|
|||
|
v2Column12: TcxGridDBColumn;
|
|||
|
v2Column13: TcxGridDBColumn;
|
|||
|
v2Column14: TcxGridDBColumn;
|
|||
|
v2Column16: TcxGridDBColumn;
|
|||
|
Label5: TLabel;
|
|||
|
begdate: TDateTimePicker;
|
|||
|
Label6: TLabel;
|
|||
|
enddate: TDateTimePicker;
|
|||
|
v2Column4: TcxGridDBColumn;
|
|||
|
custName: TEdit;
|
|||
|
Label2: TLabel;
|
|||
|
v2Column15: TcxGridDBColumn;
|
|||
|
v2Column17: TcxGridDBColumn;
|
|||
|
ToolButton5: TToolButton;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
RM1: TRMGridReport;
|
|||
|
// RMllPDFExport1: TRMllPDFExport;
|
|||
|
RMXLSExport1: TRMXLSExport;
|
|||
|
RMDBDataSet1: TRMDBDataSet;
|
|||
|
Tv2Column1: TcxGridDBColumn;
|
|||
|
Tv2Column2: TcxGridDBColumn;
|
|||
|
Tv2Column3: TcxGridDBColumn;
|
|||
|
GroupBox1: TGroupBox;
|
|||
|
Picture4: TcxDBImage;
|
|||
|
ADOQueryImage: TADOQuery;
|
|||
|
DSImage: TDataSource;
|
|||
|
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 ToolButton2Click(Sender: TObject);
|
|||
|
procedure custNoChange(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure ToolButton4Click(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure ToolButton5Click(Sender: TObject);
|
|||
|
procedure Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
private
|
|||
|
canshu1: string;
|
|||
|
{ Private declarations }
|
|||
|
procedure InitGrid();
|
|||
|
procedure InitImage(fwbid: string);
|
|||
|
|
|||
|
public
|
|||
|
fkhType: string;
|
|||
|
Fmanage: string;
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmZdyAttachmentCB: TfrmZdyAttachmentCB;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_Fun, U_ZDYHelp, U_ZdyAttInput, U_ZdyInput,
|
|||
|
U_ZdyAttachmentBJ_Edit;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
|
|||
|
Close;
|
|||
|
Filtered := False;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' select * from KH_CP_BJ ');
|
|||
|
sql.Add(' where CRTime>=''' + formatdateTime('yyyy-MM-dd', begdate.DateTime) + '''');
|
|||
|
sql.Add(' and CRTime<''' + formatdateTime('yyyy-MM-dd', enddate.DateTime + 1) + '''');
|
|||
|
if trim(canshu1) <> '<27><>Ȩ<EFBFBD><C8A8>' then
|
|||
|
sql.Add(' and Filler=' + quotedstr(trim(DName)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain, CDS_Main);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmZdyAttachmentCB := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(self.Caption, Tv2, '<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.TBDelClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('delete KH_CP_BJ where BJNO=''' + Trim(CDS_Main.fieldbyname('BJNO').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
CDS_Main.Delete;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
ReadCxGrid(self.Caption, Tv2, '<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
|||
|
GroupBox1.Left := Self.Width - 461;
|
|||
|
GroupBox1.top := Self.Height - 327;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
SCreateCDS20(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain, CDS_Main);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.custNoChange(Sender: TObject);
|
|||
|
begin
|
|||
|
ToolButton2.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then
|
|||
|
Exit;
|
|||
|
TcxGridToExcel(self.Caption, cxgrid2);
|
|||
|
// SelExportData(Tv2,ADOQueryMain,'<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.ToolButton4Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_main.IsEmpty then
|
|||
|
exit;
|
|||
|
try
|
|||
|
frmZdyAttachmentBJ_Edit := TfrmZdyAttachmentBJ_Edit.Create(Application);
|
|||
|
with frmZdyAttachmentBJ_Edit do
|
|||
|
begin
|
|||
|
fkeyNo := self.cds_main.fieldbyname('BJNO').asstring;
|
|||
|
fType := 1;
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
TBRafresh.Click;
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZdyAttachmentBJ_Edit.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.ToolButton3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZdyAttachmentBJ_Edit := TfrmZdyAttachmentBJ_Edit.Create(Application);
|
|||
|
with frmZdyAttachmentBJ_Edit do
|
|||
|
begin
|
|||
|
fkeyNO := '';
|
|||
|
fType := 0;
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
TBRafresh.Click;
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZdyAttachmentBJ_Edit.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
enddate.Date := date();
|
|||
|
begdate.Date := strtodate(formatdateTime('yyyy-MM', enddate.Date) + '-01');
|
|||
|
canshu1 := trim(DParameters1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.ToolButton5Click(Sender: TObject);
|
|||
|
var
|
|||
|
fPrintFile: string;
|
|||
|
Porderno: string;
|
|||
|
i, j: Integer;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>.rmf';
|
|||
|
with ADOQueryPrint do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select A.*, ');
|
|||
|
sql.Add('PrtImage=(select Top 1 FilesOther from TP_File X where X.WBID=A.P_Code) ');
|
|||
|
sql.Add(' from KH_CP_BJ A ');
|
|||
|
sql.Add(' Where A.BJNO=''' + Trim(CDS_Main.fieldbyname('BJNO').AsString) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
RM1.ShowReport;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + trim(fPrintFile)), '<27><>ʾ', 0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
begin
|
|||
|
initImage(CDS_Main.fieldbyname('HXPic').AsString);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentCB.InitImage(fwbid: string);
|
|||
|
begin
|
|||
|
ADOQueryImage.close;
|
|||
|
if fwbid = '' then
|
|||
|
exit;
|
|||
|
with ADOQueryImage do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from TP_File A');
|
|||
|
sql.Add('where WBID=' + quotedstr(trim(fwbid)));
|
|||
|
// ShowMessage(sql.Text);
|
|||
|
open;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|