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, FrameDateSel, cxButtons, cxCurrencyEdit; 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); procedure FormCreate(Sender: TObject); private { Private declarations } FAuthority, canshu4: string; procedure InitGrid(); public fmanage, FZKType: string; { Public declarations } RKFlag, FCYID: string; end; implementation uses U_DataLink, U_RtFun, U_RPFun, U_ZDYHelp, U_SingleCustStatement, U_LabelPrint; {$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; end; if FAuthority = '低权限' then sql.Add(' ,@DCode=' + QuotedStr(Trim(DCode))); 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; procedure TfrmCustStatement.FormCreate(Sender: TObject); begin inherited; FAuthority := Trim(Self.fParameters1); canshu4 := Trim(Self.fParameters4); end; 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 ToolBar1.SetFocus(); 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 begdate.Date := self.frmFrameDateSel1.begdate.Date; enddate.Date := self.frmFrameDateSel1.Enddate.Date; 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 MFiltration: string; MPrintJson: string; begin if CDS_HZ.IsEmpty then exit; MFiltration := ' @begdate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.begdate.Date))); MFiltration := MFiltration + ' ,@Enddate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.Enddate.Date + 1))); case cxTabControl1.TabIndex of 0: begin MFiltration := MFiltration + ' ,@Currency=''USD'' '; end; 1: begin MFiltration := MFiltration + ' ,@Currency=''CNY'' '; end; 2: begin MFiltration := MFiltration + ' ,@Currency=''EUR'' '; end; end; 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)); end; procedure TfrmCustStatement.ToolButton5Click(Sender: TObject); var MFiltration: string; MPrintJson: string; begin if CDS_HZ.IsEmpty then exit; 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)); case cxTabControl1.TabIndex of 0: begin MFiltration := MFiltration + ' ,@Currency=''USD'' '; end; 1: begin MFiltration := MFiltration + ' ,@Currency=''CNY'' '; end; 2: begin MFiltration := MFiltration + ' ,@Currency=''EUR'' '; end; end; 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)); 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.