📄 csh800_01.pas.svn-base
字号:
var
AType,AParent,ANo:Integer;
AAmount,AIncome,APayment,ABalance:Double;
ACurNm,AName:string;
begin
AIncome:=0;
APayment:=0;
//按客户、收入支出类型分组求和
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select C.G100_003 as FCurNm, D.O150_001 as FNo, D.O150_003 as FName, A.C510A_005 as FType, 0 as FParent, sum(A.C510A_009) as FAmount from CSH510A A, CSH550 B, GLD100 C,');
SYSDM.qryQuery.SQL.Add('(select O150_001, O150_003, 0 as FCustType from ORD150');
SYSDM.qryQuery.SQL.Add('union');
SYSDM.qryQuery.SQL.Add('select H150_001 as O150_001, H150_003 as O150_003, 1 as FCustType from HRM150) as D');
SYSDM.qryQuery.SQL.Add('where A.C510A_003=B.C550_001 and B.C550_005=C.G100_001 and A.C510A_008=D.O150_001 and A.C510A_007=D.FCustType and A.C510A_004 not in (0,3) and A.C510A_010>='+GetDateString(AStartDate)+' and A.C510A_010<='+GetDateString(AEndDate));
SYSDM.qryQuery.SQL.Add('group by C.G100_003, D.O150_001, D.O150_003, A.C510A_005');
SYSDM.qryQuery.Open;
while not SYSDM.qryQuery.Eof do
begin
AType:=SYSDM.qryQuery.FieldByName('FType').AsInteger;
AParent:=SYSDM.qryQuery.FieldByName('FParent').Value;
if AParent=0 then AParent:=AType-1;
AAmount:=SYSDM.qryQuery.FieldByName('FAmount').Value;
ANo:=SYSDM.qryQuery.FieldByName('FNo').Value;
AName:=SYSDM.qryQuery.FieldByName('FName').Value;
if ACurNm<>SYSDM.qryQuery.FieldByName('FCurNm').Value then
begin
ACurNm:=SYSDM.qryQuery.FieldByName('FCurNm').Value;
SetParentData(ADataSet,ACurNm); //设置顶层分类数据
end;
ADataSet.Append;
ADataSet.FieldByName('FCurNm').Value:=ACurNm;
ADataSet.FieldByName('FNo').Value:=ANo;
ADataSet.FieldByName('FParent').Value:=AParent;
ADataSet.FieldByName('FName').Value:=AName;
ADataSet.FieldByName('FAmount').Value:=AAmount;
ADataSet.FieldByName('FLevel').Value:=0;
ADataSet.FieldByName('FSeqNo').Value:=0;
ADataSet.Post;
if AType=0 then AIncome:=AIncome+AAmount else APayment:=APayment+AAmount;
SYSDM.qryQuery.Next;
end;
if ADataSet.IsEmpty then Exit;
ABalance:=AIncome-APayment;
//更新收支余额、收入、支出的金额
ADataSet.Locate('FNo',-2,[]);
ADataSet.Edit;
ADataSet.FieldByName('FAmount').Value:=ABalance;
ADataSet.Post;
ADataSet.Locate('FNo',-1,[]);
ADataSet.Edit;
ADataSet.FieldByName('FAmount').Value:=AIncome;
ADataSet.Post;
ADataSet.Locate('FNo',0,[]);
ADataSet.Edit;
ADataSet.FieldByName('FAmount').Value:=APayment;
ADataSet.Post;
end;
//收支分析--按部门
procedure GetDeptAmount(ADataSet:TADODataSet;AStartDate,AEndDate:TDateTime);
var
AType,AParent,ANo:Integer;
AAmount,AIncome,APayment,ABalance:Double;
ACurNm,AName:string;
begin
AIncome:=0;
APayment:=0;
//按部门、收入支出类型分组求和
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select G100_003 as FCurNm, H100_001 as FNo, H100_002 as FName, 0 as FParent, C510A_005 as FType, sum(C510B_006) as FAmount from CSH510A,CSH510B, HRM100, CSH550, GLD100');
SYSDM.qryQuery.SQL.Add('where C510B_009=H100_001 and C510A_004 not in (0,3) and C510A_003=C550_001 and C550_005=G100_001 and C510A_010>='+GetDateString(AStartDate)+' and C510A_010<='+GetDateString(AEndDate)+' and C510A_001=C510B_001');
SYSDM.qryQuery.SQL.Add('group by G100_003, H100_001, H100_002, H100_003, C510A_005');
SYSDM.qryQuery.Open;
while not SYSDM.qryQuery.Eof do
begin
AType:=SYSDM.qryQuery.FieldByName('FType').AsInteger;
AParent:=SYSDM.qryQuery.FieldByName('FParent').Value;
if AParent=0 then AParent:=AType-1;
AAmount:=SYSDM.qryQuery.FieldByName('FAmount').Value;
ANo:=SYSDM.qryQuery.FieldByName('FNo').Value;
AName:=SYSDM.qryQuery.FieldByName('FName').Value;
if ACurNm<>SYSDM.qryQuery.FieldByName('FCurNm').Value then
begin
ACurNm:=SYSDM.qryQuery.FieldByName('FCurNm').Value;
SetParentData(ADataSet,ACurNm); //设置顶层分类数据
end;
ADataSet.Append;
ADataSet.FieldByName('FCurNm').Value:=ACurNm;
ADataSet.FieldByName('FNo').Value:=ANo;
ADataSet.FieldByName('FParent').Value:=AParent;
ADataSet.FieldByName('FName').Value:=AName;
ADataSet.FieldByName('FAmount').Value:=AAmount;
ADataSet.FieldByName('FLevel').Value:=0;
ADataSet.FieldByName('FSeqNo').Value:=0;
ADataSet.Post;
if AType=0 then AIncome:=AIncome+AAmount else APayment:=APayment+AAmount;
SYSDM.qryQuery.Next;
end;
if ADataSet.IsEmpty then Exit;
ABalance:=AIncome-APayment;
//更新收支余额、收入、支出的金额
ADataSet.Locate('FNo',-2,[]);
ADataSet.Edit;
ADataSet.FieldByName('FAmount').Value:=ABalance;
ADataSet.Post;
ADataSet.Locate('FNo',-1,[]);
ADataSet.Edit;
ADataSet.FieldByName('FAmount').Value:=AIncome;
ADataSet.Post;
ADataSet.Locate('FNo',0,[]);
ADataSet.Edit;
ADataSet.FieldByName('FAmount').Value:=APayment;
ADataSet.Post;
end;
//收支分析--按项目
procedure GetProjctAmount(ADataSet:TADODataSet;AStartDate,AEndDate:TDateTime);
var
AType,AParent,ANo:Integer;
AAmount,AIncome,APayment,ABalance:Double;
ACurNm,AName:string;
begin
AIncome:=0;
APayment:=0;
//按项目分组求和
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select G100_003 as FCurNm, C150_001 as FNo, C150_002 as FName, C150_003 as FParent, C510A_005 as FType, sum(C510B_006) as FAmount from CSH510A,CSH510B,CSH150, CSH550, GLD100');
SYSDM.qryQuery.SQL.Add('where C510B_008=C150_001 and C510A_004 not in (0,3) and C510A_003=C550_001 and C550_005=G100_001 and C510A_010>='+GetDateString(AStartDate)+' and C510A_010<='+GetDateString(AEndDate));
SYSDM.qryQuery.SQL.Add('group by G100_003, C150_001, C150_002, C150_003, C510A_005');
SYSDM.qryQuery.Open;
while not SYSDM.qryQuery.Eof do
begin
AType:=SYSDM.qryQuery.FieldByName('FType').AsInteger;
AParent:=SYSDM.qryQuery.FieldByName('FParent').Value;
if AParent=0 then AParent:=AType-1;
AAmount:=SYSDM.qryQuery.FieldByName('FAmount').Value;
if AType=1 then AAmount:=AAmount*-1;
ANo:=SYSDM.qryQuery.FieldByName('FNo').Value;
AName:=SYSDM.qryQuery.FieldByName('FName').Value;
if ACurNm<>SYSDM.qryQuery.FieldByName('FCurNm').Value then
begin
ACurNm:=SYSDM.qryQuery.FieldByName('FCurNm').Value;
ADataSet.Append;
ADataSet.FieldByName('FCurNm').Value:=ACurNm;
ADataSet.FieldByName('FNo').Value:=0;
ADataSet.FieldByName('FParent').Value:=0;
ADataSet.FieldByName('FName').Value:=GetDBString('COM00004008'); //所有项目
ADataSet.FieldByName('FAmount').Value:=0;
ADataSet.FieldByName('FLevel').Value:=0;
ADataSet.FieldByName('FSeqNo').Value:=0;
ADataSet.Post;
end;
ADataSet.Append;
ADataSet.FieldByName('FCurNm').Value:=ACurNm;
ADataSet.FieldByName('FNo').Value:=ANo;
ADataSet.FieldByName('FParent').Value:=AParent;
ADataSet.FieldByName('FName').Value:=AName;
ADataSet.FieldByName('FAmount').Value:=AAmount;
ADataSet.FieldByName('FLevel').Value:=0;
ADataSet.FieldByName('FSeqNo').Value:=0;
ADataSet.Post;
if AType=0 then AIncome:=AIncome+AAmount else APayment:=APayment+AAmount;
SYSDM.qryQuery.Next;
end;
if ADataSet.IsEmpty then Exit;
//插入上级项目
GetParentProject(ADataSet); //取得上级项目
ABalance:=AIncome+APayment;
ADataSet.Locate('FNo',0,[]);
ADataSet.Edit;
ADataSet.FieldByName('FAmount').Value:=ABalance;
ADataSet.Post;
end;
procedure TCsh800_01Form.sbSearchClick(Sender: TObject);
var
AStartDate,AEndDate:TDateTime;
begin
inherited;
//查询
if cbItem.Text='' then Exit;
if (edtFromDate.Text='') or (edtToDate.Text='') then
begin
ShowMsg('UMS10000156'); //起始日期或结束日期不能为空
if edtFromDate.Text='' then edtFromDate.SetFocus else edtToDate.SetFocus;
Abort;
end;
AStartDate:=edtFromDate.Date;
AEndDate:=edtToDate.Date;
if AStartDate>AEndDate then
begin
ShowMsg('UMS10000044'); //起始日期不能大于结束日期
edtFromDate.SetFocus;
Abort;
end;
//建立出纳总帐临时表
Screen.Cursor:=crHourGlass;
ADODataSet1.DisableControls;
ADODataSet1.Close;
ADODataSet1.FieldDefs.Clear;
ADODataSet1.FieldDefs.Add('FCurNm',ftString,30);
ADODataSet1.FieldDefs.Add('FNo',ftInteger,0);
ADODataSet1.FieldDefs.Add('FParent',ftInteger,0);
ADODataSet1.FieldDefs.Add('FName',ftString,50);
ADODataSet1.FieldDefs.Add('FAmount',ftCurrency,0);
ADODataSet1.FieldDefs.Add('FLevel',ftInteger,0);
ADODataSet1.FieldDefs.Add('FSeqNo',ftInteger,0);
ADODataSet1.CreateDataSet;
case cbItem.ItemIndex of
0:GetClassAmount(ADODataSet1,AStartDate,AEndDate); //业务分类
1:GetCustAmount(ADODataSet1,AStartDate,AEndDate); //客户
2:GetDeptAmount(ADODataSet1,AStartDate,AEndDate); //部门
3:GetProjctAmount(ADODataSet1,AStartDate,AEndDate); //项目
end;
ADODataSet1.EnableControls;
DBChart1.RefreshData;
Screen.Cursor:=crDefault;
end;
procedure TCsh800_01Form.ReportGetValue(const ParName: String;
var ParValue: Variant);
begin
inherited;
if ParName='CURNM' then ParValue:=GetDBString('CSH80001005') //币别
else if ParName='TYPNM' then ParValue:=GetDBString('CSH80001006') //名称
else if ParName='AMOUNT' then ParValue:=GetDBString('CSH80001007') //金额
else if ParName='ITEM' then ParValue:=GetDBString('CSH80001014')+cbItem.Text //项目:
else if ParName='DATE1' then ParValue:=GetDBString('CSH80001015')+edtFromDate.Text //起始日期:
else if ParName='DATE2' then ParValue:=GetDBString('CSH80001016')+edtToDate.Text //结束日期:
end;
procedure TCsh800_01Form.cbItemChange(Sender: TObject);
begin
inherited;
sbSearch.Click;
end;
procedure TCsh800_01Form.ActPrintExecute(Sender: TObject);
var
I:Integer;
ALastNode:TdxTreeListNode;
begin
//打印前,先排序,按显示的顺序
I:=1;
ADODataSet1.DisableControls;
dxDBTreeList1.GotoLast(True);
ALastNode:=dxDBTreeList1.FocusedNode;
dxDBTreeList1.GotoFirst;
while dxDBTreeList1.FocusedNode<>ALastNode do
begin
ADODataSet1.Edit;
ADODataSet1.FieldByName('FSeqNo').Value:=I;
ADODataSet1.Post;
dxDBTreeList1.GotoNext(True);
I:=I+1;
end;
ADODataSet1.Edit;
ADODataSet1.FieldByName('FSeqNo').Value:=I;
ADODataSet1.Post;
ADODataSet1.EnableControls;
try
SYSDM.frReport2.OnGetValue:=ReportGetValue;
inherited;
finally
SYSDM.frReport2.OnGetValue:=nil;
end;
end;
procedure TCsh800_01Form.ActOpenExecute(Sender: TObject);
var
AFieldInfo:TwwFieldInfo;
begin
inherited;
//查看
if ADODataSet1.IsEmpty then Exit;
Screen.Cursor:=crHourGlass;
Csh510_01Form:=TCsh510_01Form.Create(Application);
Csh510_01Form.edtFromDate.Date:=edtFromDate.Date;
Csh510_01Form.edtToDate.Date:=edtToDate.Date;
Csh510_01Form.sbSearch.Click;
AFieldInfo:=TwwFieldInfo.Create;
FilterDialog(Csh510_01Form.DataSource1,False);
AFieldInfo.FieldName:='I120_003';
// AFieldInfo.DisplayLabel:=Csh510_01Form.ADOQuery1I120_003.DisplayLabel;
AFieldInfo.MatchType:=fdMatchStart;
AFieldInfo.CaseSensitive:=False;
AFieldInfo.NonMatching:=False;
// AFieldInfo.FilterValue:=ADODataSet1FName.Value;;
SYSDM.wwFilterDialog1.FieldInfo.Add(AFieldInfo);
SYSDM.wwFilterDialog1.ApplyFilter;
Screen.Cursor:=crDefault;
Csh510_01Form.ShowModal;
// if Assigned(AFieldInfo) then AFieldInfo.Free;
end;
procedure TCsh800_01Form.RefreshEvent;
begin
inherited;
sbSearch.Click;
end;
initialization
RegisterClass(TCsh800_01Form);
finalization
UnRegisterClass(TCsh800_01Form);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -