392 lines
9.5 KiB
ObjectPascal
392 lines
9.5 KiB
ObjectPascal
![]() |
unit U_CW_Money_LL;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
|||
|
cxEdit, DB, cxDBData, DBClient, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu,
|
|||
|
cxPC, StdCtrls, ComCtrls, ExtCtrls, cxGridLevel, cxGridCustomTableView,
|
|||
|
cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
|
|||
|
cxGrid, ToolWin, cxCalendar, cxCurrencyEdit, cxTextEdit, cxLookAndFeels,
|
|||
|
cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, dxSkinsCore,
|
|||
|
dxSkinsDefaultPainters, dxDateRanges, U_BaseList;
|
|||
|
|
|||
|
type
|
|||
|
TfrmMoney_LL = class(TfrmBaseList)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TINIT: TToolButton;
|
|||
|
TGLV: TToolButton;
|
|||
|
TADD: TToolButton;
|
|||
|
TUPDATE: TToolButton;
|
|||
|
TDEL: TToolButton;
|
|||
|
TSELECT: TToolButton;
|
|||
|
Texcel: TToolButton;
|
|||
|
TCLOSE: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
Label1: TLabel;
|
|||
|
Label4: TLabel;
|
|||
|
Label2: TLabel;
|
|||
|
CRType: TEdit;
|
|||
|
BegDate: TDateTimePicker;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
CRZY: TEdit;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
TV1: TcxGridDBTableView;
|
|||
|
V1CRTime: TcxGridDBColumn;
|
|||
|
V1CRType: TcxGridDBColumn;
|
|||
|
V1InMoney: TcxGridDBColumn;
|
|||
|
V1NOTE: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
DataSource1: TDataSource;
|
|||
|
AdoQueryTmp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
TZDY: TToolButton;
|
|||
|
cxTabControl1: TcxTabControl;
|
|||
|
V1CRZY: TcxGridDBColumn;
|
|||
|
V1OutMoney: TcxGridDBColumn;
|
|||
|
V1YEMoney: TcxGridDBColumn;
|
|||
|
Label3: TLabel;
|
|||
|
V1Column1: TcxGridDBColumn;
|
|||
|
TofactoryName: TEdit;
|
|||
|
Label5: TLabel;
|
|||
|
V1Column2: TcxGridDBColumn;
|
|||
|
V1Column3: TcxGridDBColumn;
|
|||
|
Label8: TLabel;
|
|||
|
BLID: TEdit;
|
|||
|
V1Column4: TcxGridDBColumn;
|
|||
|
V1Column5: TcxGridDBColumn;
|
|||
|
V1Column8: TcxGridDBColumn;
|
|||
|
V1Column9: TcxGridDBColumn;
|
|||
|
CDS_Bank: TClientDataSet;
|
|||
|
TV1Column1: TcxGridDBColumn;
|
|||
|
TV1Column3: TcxGridDBColumn;
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure TCLOSEClick(Sender: TObject);
|
|||
|
procedure TADDClick(Sender: TObject);
|
|||
|
procedure TINITClick(Sender: TObject);
|
|||
|
procedure TGLVClick(Sender: TObject);
|
|||
|
procedure TUPDATEClick(Sender: TObject);
|
|||
|
procedure TSELECTClick(Sender: TObject);
|
|||
|
procedure TexcelClick(Sender: TObject);
|
|||
|
procedure TDELClick(Sender: TObject);
|
|||
|
procedure TZDYClick(Sender: TObject);
|
|||
|
procedure CRTypeChange(Sender: TObject);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
private
|
|||
|
FBKID, FBKName: string;
|
|||
|
procedure initGrid();
|
|||
|
procedure SetTab();
|
|||
|
procedure GetCurTab();
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmMoney_LL: TfrmMoney_LL;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_CWLLInput, U_BankList;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
procedure TfrmMoney_LL.GetCurTab();
|
|||
|
begin
|
|||
|
CDS_Bank.Locate('BKName', Trim(cxTabControl1.Tabs.Strings[cxTabControl1.TabIndex]), []);
|
|||
|
FBKID := Trim(CDS_Bank.FieldByName('BKID').AsString);
|
|||
|
FBKName := Trim(CDS_Bank.FieldByName('BKName').AsString);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.SetTab();
|
|||
|
begin
|
|||
|
cxTabControl1.OnChange := nil;
|
|||
|
|
|||
|
cxTabControl1.Tabs.Clear;
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from CW_Bank order by BKXH ');
|
|||
|
open;
|
|||
|
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTmp, CDS_Bank);
|
|||
|
SInitCDSData(ADOQueryTmp, CDS_Bank);
|
|||
|
with CDS_Bank do
|
|||
|
begin
|
|||
|
if not CDS_Bank.isempty then
|
|||
|
begin
|
|||
|
while not eof do
|
|||
|
begin
|
|||
|
cxTabControl1.Tabs.Add(trim(fieldbyname('BKName').AsString));
|
|||
|
next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
if cxTabControl1.Tabs.Count < 1 then
|
|||
|
cxTabControl1.Tabs.Add('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>');
|
|||
|
// cxTabControl1.TabIndex:=0;
|
|||
|
cxTabControl1.OnChange := cxTabControl1Change;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.InitGrid();
|
|||
|
begin
|
|||
|
if Trim(cxTabControl1.Tabs.Strings[cxTabControl1.TabIndex]) = '' then
|
|||
|
Exit;
|
|||
|
|
|||
|
GetCurTab();
|
|||
|
with AdoQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select A.*,YEMoney=dbo.F_CWLS_Get_Ye(A.BLID,A.CRTime,A.BKID) ');
|
|||
|
sql.Add('from CW_Bank_LS A ');
|
|||
|
sql.Add('where CRTime>=''' + formatdateTime('yyyy-MM-dd', begdate.DateTime) + ''' ');
|
|||
|
sql.Add('and CRTime<''' + formatdateTime('yyyy-MM-dd', enddate.DateTime + 1) + ''' ');
|
|||
|
|
|||
|
sql.Add('and BKID=' + quotedstr(Trim(FBKID)));
|
|||
|
SQL.Add('order by A.CRTime,BLID');
|
|||
|
open;
|
|||
|
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTmp, CDS_Main);
|
|||
|
SInitCDSData(ADOQueryTmp, CDS_Main);
|
|||
|
CDS_Main.Last;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
cxgrid1.Align := alclient;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
ReadCxGrid(self.Caption + tv1.Name, Tv1);
|
|||
|
enddate.datetime := SGetServerDateTime(ADOQueryTmp);
|
|||
|
begdate.datetime := strtodate(formatdateTime('yyyy-MM', enddate.DateTime) + '-01');
|
|||
|
SetTab();
|
|||
|
cxTabControl1.Refresh;
|
|||
|
initGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
frmMoney_LL := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
writeCxGrid(self.Caption + tv1.Name, Tv1);
|
|||
|
Action := cafree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.TCLOSEClick(Sender: TObject);
|
|||
|
begin
|
|||
|
close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.TADDClick(Sender: TObject);
|
|||
|
begin
|
|||
|
GetCurTab();
|
|||
|
try
|
|||
|
frmCWLLInput := TfrmCWLLInput.Create(Application);
|
|||
|
with frmCWLLInput do
|
|||
|
begin
|
|||
|
BKName.TxtCode := FBKID;
|
|||
|
BKName.text := FBKName;
|
|||
|
Fkeyno := '';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmCWLLInput.free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.TINITClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.TGLVClick(Sender: TObject);
|
|||
|
begin
|
|||
|
SDofilter(AdoQueryTmp, SGetFilters(Panel1, 1, 0));
|
|||
|
SCreateCDS(AdoQueryTmp, CDS_Main);
|
|||
|
SInitCDSData(AdoQueryTmp, CDS_Main);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.TUPDATEClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
if Trim(CDS_Main.fieldbyname('Filler').AsString) <> Trim(DName) then
|
|||
|
begin
|
|||
|
application.messagebox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
if Trim(CDS_Main.fieldbyname('fromBLID').AsString) <> '' then
|
|||
|
begin
|
|||
|
application.messagebox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
if Trim(CDS_Main.fieldbyname('fromCWID').AsString) <> '' then
|
|||
|
begin
|
|||
|
application.messagebox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
try
|
|||
|
frmCWLLInput := TfrmCWLLInput.Create(Application);
|
|||
|
with frmCWLLInput do
|
|||
|
begin
|
|||
|
FStatus := '<27><EFBFBD>';
|
|||
|
Fkeyno := trim(Self.CDS_Main.fieldbyname('BLID').asstring);
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmCWLLInput.free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.TSELECTClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
try
|
|||
|
frmCWLLInput := TfrmCWLLInput.Create(Application);
|
|||
|
with frmCWLLInput do
|
|||
|
begin
|
|||
|
Fkeyno := trim(Self.CDS_Main.fieldbyname('BLID').asstring);
|
|||
|
TSave.Visible := False;
|
|||
|
panel1.Enabled := False;
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
// InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
;
|
|||
|
frmCWLLInput.free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.TexcelClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
TcxGridToExcel(Trim(cxTabControl1.Tabs.Strings[cxTabControl1.TabIndex]), cxGrid1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.TDELClick(Sender: TObject);
|
|||
|
var
|
|||
|
FBLID: string;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
exit;
|
|||
|
|
|||
|
FBLID := trim(CDS_Main.fieldbyname('BLID').AsString);
|
|||
|
if CDS_Main.fieldbyname('fromBLID').AsString <> '' then
|
|||
|
begin
|
|||
|
application.messagebox('<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>벻<EFBFBD><EBB2BB>ɾ<EFBFBD><C9BE>!', '<27><>ʾ', 0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
if Trim(CDS_Main.fieldbyname('Filler').AsString) <> Trim(DName) then
|
|||
|
begin
|
|||
|
application.messagebox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
if Trim(CDS_Main.fieldbyname('fromCWID').AsString) <> '' then
|
|||
|
begin
|
|||
|
application.messagebox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
if application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 1) = 2 then
|
|||
|
exit;
|
|||
|
try
|
|||
|
ADOQuerycmd.Connection.BeginTrans;
|
|||
|
with ADOQuerycmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('delete from CW_Bank_LS where BLID=''' + FBLID + '''');
|
|||
|
sql.Add('delete from CW_Bank_LS where fromBLID=''' + FBLID + '''');
|
|||
|
sql.Add('delete from CW_Money_CR where ISNULL(FromDataID1,''<27><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ɾ'')=''' + FBLID + '''');
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
ADOQuerycmd.Connection.CommitTrans;
|
|||
|
|
|||
|
with AdoQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select A.BLID from CW_Bank_LS A');
|
|||
|
sql.Add('where ISNULL(fromBLID,'''')<>'''' ');
|
|||
|
sql.Add('and not exists(select X.BLID from CW_Bank_LS X WHERE X.BLID=A.fromBLID)');
|
|||
|
open;
|
|||
|
|
|||
|
end;
|
|||
|
if AdoQueryTmp.IsEmpty = False then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
|
|||
|
initGrid();
|
|||
|
except
|
|||
|
ADOQuerycmd.connection.rollbackTrans;
|
|||
|
application.messagebox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD><CAA7>', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.TZDYClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmBankList := TfrmBankList.Create(self);
|
|||
|
with frmBankList do
|
|||
|
begin
|
|||
|
if showmodal = 1 then
|
|||
|
begin
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmBankList.Free;
|
|||
|
end;
|
|||
|
SetTab();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.CRTypeChange(Sender: TObject);
|
|||
|
begin
|
|||
|
SDofilter(AdoQueryTmp, SGetFilters(Panel1, 1, 0));
|
|||
|
SCreateCDS(AdoQueryTmp, CDS_Main);
|
|||
|
SInitCDSData(AdoQueryTmp, CDS_Main);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmMoney_LL.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
initGrid();
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|