D10xhGemei/A09财务通用管理/U_CustStatement.pas

310 lines
9.3 KiB
ObjectPascal
Raw Normal View History

2024-12-14 17:23:12 +08:00
unit U_CustStatement;
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, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
dxBarBuiltInMenu, cxPC, dxDateRanges, U_BaseList, Vcl.Menus, Vcl.Clipbrd,
DateUtils, cxContainer, dxCore, cxDateUtils, cxDropDownEdit,
dxScrollbarAnnotations, dxSkinsCore, dxSkinsDefaultPainters, cxProgressBar,
2025-07-17 14:27:41 +08:00
FrameDateSel, cxButtons, cxCurrencyEdit;
2024-12-14 17:23:12 +08:00
type
TfrmCustStatement = class(TfrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
Panel1: TPanel;
ToolButton2: TToolButton;
ADOQueryMain: TADOQuery;
Label3: TLabel;
OppCoName: TcxTextEdit;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
cxGridLevel1: TcxGridLevel;
GPM_2: TcxGridPopupMenu;
DS_HZ: TDataSource;
CDS_HZ: TClientDataSet;
v2Column5: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
v2Column2: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ADOQueryPrint: TADOQuery;
cxTabControl1: TcxTabControl;
ToolButton1: TToolButton;
Tv2Column1: TcxGridDBColumn;
Tv2Column2: TcxGridDBColumn;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
frmFrameDateSel1: TfrmFrameDateSel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure OppCoNameChange(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
2025-07-17 14:27:41 +08:00
procedure FormCreate(Sender: TObject);
2024-12-14 17:23:12 +08:00
private
{ Private declarations }
2025-07-21 17:21:17 +08:00
FAuthority, canshu4: string;
2024-12-14 17:23:12 +08:00
procedure InitGrid();
public
fmanage, FZKType: string;
{ Public declarations }
RKFlag, FCYID: string;
end;
implementation
uses
2025-07-17 14:27:41 +08:00
U_DataLink, U_RtFun, U_RPFun, U_ZDYHelp, U_SingleCustStatement, U_LabelPrint;
2024-12-14 17:23:12 +08:00
{$R *.dfm}
procedure TfrmCustStatement.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
SQL.Clear;
sql.Add(' exec P_Fin_CustStatement ');
sql.Add(' @begdate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.begdate.Date))));
sql.Add(' ,@Enddate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.Enddate.Date + 1))));
case cxTabControl1.TabIndex of
0:
begin
sql.Add(' ,@Currency=''USD'' ');
end;
1:
begin
sql.Add(' ,@Currency=''CNY'' ');
end;
2:
begin
sql.Add(' ,@Currency=''EUR'' ');
end;
2025-07-17 14:27:41 +08:00
2024-12-14 17:23:12 +08:00
end;
2025-07-17 14:27:41 +08:00
if FAuthority = '低权限' then
sql.Add(' ,@DCode=' + QuotedStr(Trim(DCode)));
2024-12-14 17:23:12 +08:00
Open;
end;
SCreateCDS(ADOQueryMain, CDS_HZ);
SInitCDSData(ADOQueryMain, CDS_HZ);
finally
ADOQueryMain.EnableControls;
TV2.DataController.Filter.Clear;
end;
ToolButton2.Click;
end;
procedure TfrmCustStatement.N1Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(CDS_HZ.fieldbyname(TV2.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmCustStatement.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
2025-07-17 14:27:41 +08:00
procedure TfrmCustStatement.FormCreate(Sender: TObject);
begin
inherited;
FAuthority := Trim(Self.fParameters1);
2025-07-21 17:21:17 +08:00
canshu4 := Trim(Self.fParameters4);
2025-07-17 14:27:41 +08:00
end;
2024-12-14 17:23:12 +08:00
procedure TfrmCustStatement.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmCustStatement.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid(trim(self.Caption), Tv2, '财务管理');
frmFrameDateSel1.Enddate.Date := SGetServerDate(ADOQueryTemp);
frmFrameDateSel1.begdate.Date := StartOfTheMonth(frmFrameDateSel1.Enddate.Date);
InitGrid();
end;
procedure TfrmCustStatement.TBRafreshClick(Sender: TObject);
begin
2025-07-17 14:27:41 +08:00
ToolBar1.SetFocus();
2024-12-14 17:23:12 +08:00
InitGrid();
end;
procedure TfrmCustStatement.ToolButton1Click(Sender: TObject);
begin
WriteCxGrid(trim(self.Caption), Tv2, '财务管理');
end;
procedure TfrmCustStatement.ToolButton2Click(Sender: TObject);
var
fsj: string;
begin
if ADOQueryMain.Active = False then
Exit;
SDofilter(ADOQueryMain, Trim(SGetFilters(Panel1, 1, 2)));
SCreateCDS(ADOQueryMain, CDS_HZ);
SInitCDSData(ADOQueryMain, CDS_HZ);
end;
procedure TfrmCustStatement.OppCoNameChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmCustStatement.ToolButton3Click(Sender: TObject);
begin
if CDS_HZ.IsEmpty then
exit;
frmSingleCustStatement := TfrmSingleCustStatement.Create(self);
with frmSingleCustStatement do
begin
2025-07-17 14:27:41 +08:00
begdate.Date := self.frmFrameDateSel1.begdate.Date;
enddate.Date := self.frmFrameDateSel1.Enddate.Date;
2024-12-14 17:23:12 +08:00
OppCoName.Text := self.CDS_HZ.fieldbyname('OppCoName').AsString;
FOppCoNo := self.CDS_HZ.fieldbyname('OppCoNo').AsString;
FZKType := Self.FZKType;
case cxTabControl1.TabIndex of
0:
begin
FCurrency := 'USD';
end;
1:
begin
FCurrency := 'CNY';
end;
2:
begin
FCurrency := 'EUR';
end;
end;
show;
end;
end;
procedure TfrmCustStatement.ToolButton4Click(Sender: TObject);
var
2025-07-17 14:27:41 +08:00
MFiltration: string;
MPrintJson: string;
2024-12-14 17:23:12 +08:00
begin
if CDS_HZ.IsEmpty then
exit;
2025-07-17 14:27:41 +08:00
MFiltration := ' @begdate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.begdate.Date)));
MFiltration := MFiltration + ' ,@Enddate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.Enddate.Date + 1)));
2024-12-14 17:23:12 +08:00
case cxTabControl1.TabIndex of
0:
begin
2025-07-17 14:27:41 +08:00
MFiltration := MFiltration + ' ,@Currency=''USD'' ';
2024-12-14 17:23:12 +08:00
end;
1:
begin
2025-07-17 14:27:41 +08:00
MFiltration := MFiltration + ' ,@Currency=''CNY'' ';
2024-12-14 17:23:12 +08:00
end;
2:
begin
2025-07-17 14:27:41 +08:00
MFiltration := MFiltration + ' ,@Currency=''EUR'' ';
2024-12-14 17:23:12 +08:00
end;
end;
2025-07-17 14:27:41 +08:00
MPrintJson := ' {"LMType": "CustStatement" ';
MPrintJson := MPrintJson + ' ,"PreviewPrint": true ';
MPrintJson := MPrintJson + ' ,"PrtArgs": [ { "IsSql": true, "Filtration":" ' + MFiltration + '" }, ';
MPrintJson := MPrintJson + ' { "IsSql": true, "Filtration":" ' + MFiltration + '" }, ';
MPrintJson := MPrintJson + ' { "IsSql": true, "Filtration":" ' + MFiltration + '" }, ';
MPrintJson := MPrintJson + ' { "IsSql": true, "Filtration":" ' + MFiltration + '" }, ';
MPrintJson := MPrintJson + ' { "IsSql": true, "Filtration":" ' + MFiltration + '" } ] } ';
FromPrintFr3(Application, PChar(DConString), PChar(MPrintJson));
2024-12-14 17:23:12 +08:00
end;
procedure TfrmCustStatement.ToolButton5Click(Sender: TObject);
var
2025-07-17 14:27:41 +08:00
MFiltration: string;
MPrintJson: string;
2024-12-14 17:23:12 +08:00
begin
if CDS_HZ.IsEmpty then
exit;
2025-07-17 14:27:41 +08:00
MFiltration := ' @begdate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.begdate.Date)));
MFiltration := MFiltration + ' ,@Enddate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.Enddate.Date + 1)));
MFiltration := MFiltration + ' ,@OppCoNo=' + QuotedStr(Trim(self.CDS_HZ.fieldbyname('OppCoNo').AsString));
2024-12-14 17:23:12 +08:00
case cxTabControl1.TabIndex of
0:
begin
2025-07-17 14:27:41 +08:00
MFiltration := MFiltration + ' ,@Currency=''USD'' ';
2024-12-14 17:23:12 +08:00
end;
1:
begin
2025-07-17 14:27:41 +08:00
MFiltration := MFiltration + ' ,@Currency=''CNY'' ';
2024-12-14 17:23:12 +08:00
end;
2:
begin
2025-07-17 14:27:41 +08:00
MFiltration := MFiltration + ' ,@Currency=''EUR'' ';
2024-12-14 17:23:12 +08:00
end;
end;
2025-07-17 14:27:41 +08:00
MPrintJson := ' {"LMType": "SingleCustStatement" ';
MPrintJson := MPrintJson + ' ,"PreviewPrint": true ';
MPrintJson := MPrintJson + ' ,"PrtArgs": [ { "IsSql": true, "Filtration":" ' + MFiltration + '" }, ';
MPrintJson := MPrintJson + ' { "IsSql": true, "Filtration":" ' + MFiltration + '" }, ';
MPrintJson := MPrintJson + ' { "IsSql": true, "Filtration":" ' + MFiltration + '" }, ';
MPrintJson := MPrintJson + ' { "IsSql": true, "Filtration":" ' + MFiltration + '" }, ';
MPrintJson := MPrintJson + ' { "IsSql": true, "Filtration":" ' + MFiltration + '" } ] } ';
FromPrintFr3(Application, PChar(DConString), PChar(MPrintJson));
2024-12-14 17:23:12 +08:00
end;
procedure TfrmCustStatement.ToolButton6Click(Sender: TObject);
begin
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Fin_Up_All ');
Open;
end;
end;
procedure TfrmCustStatement.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
end;
end.