⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ffrmcashierdayrec.pas

📁 财务软件:功能尚可,基于UML设计开发的delphi系统,文档齐全
💻 PAS
字号:
unit FfrmCashierDayRec;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FfrmBaseXLGrid, Menus, XLGrids, XLCell, XLStyler, XLActns,
  ImgList, RzPanel, RzButton, ExtCtrls,Account,AccountCode,AccessDB,
  StdCtrls, RzLabel ;

type
  TCashierTerm=class
    private
      BeginPeriod,EndPeriod:Integer;
      AccountCode:String;
  end;

  TfrmCashierDayRec = class(TfrmBaseXLGrid)
    procedure BtnWeekViewClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    aTerm:TCashierTerm;
    aCode:TAccountCode;
    //凭证访问
    aAccount:TAccount;
    aAccountAccess:TAccountProxy;
    aAccountCodeProxy:TAccountCodeProxy;
    procedure ProcessAnalyse;
     procedure  ProcessOneCode(vCode:String);
    //处理一个科目的一个会计区间
    procedure ProcessOneCodeOnePeriod(vCode:String;vPeriod:Integer;Start:Boolean);
  public
    { Public declarations }
  end;

var
  frmCashierDayRec: TfrmCashierDayRec;

implementation

uses FfrmCashierDayRecTerm, FdmMain, BaseVar;

{$R *.dfm}

procedure TfrmCashierDayRec.BtnWeekViewClick(Sender: TObject);
begin
  inherited;
  with TfrmCashierDayRecTerm.Create(nil) do
  begin
    if ShowModal =mrOK then
    begin
      aTerm.BeginPeriod :=StrToInt(floattostr(rseBegin.Value));
      aTerm.EndPeriod :=StrToInt(floattostr(rseEnd.Value));
      aTerm.AccountCode:=cmbCashier.Text;
      ProcessAnalyse;
    end;
    Free;
  end;
end;

procedure TfrmCashierDayRec.FormCreate(Sender: TObject);
begin
  inherited;
  aTerm:=TCashierTerm.Create;
   //创建科目代码访问对象
  aAccountCodeProxy:=TAccountCodeProxy.Create(gAccessDB) ;
  aCode:=TAccountCode.Create;
  //创建凭证访问
  aAccount:=TAccount.Create;
  aAccountAccess:=TAccountProxy.Create(gAccessDB);
end;

procedure TfrmCashierDayRec.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  aTerm.Free;
  //释放对象
  aAccountCodeProxy.Free;
  aCode.Free;
  aAccount.Free;
end;

procedure TfrmCashierDayRec.ProcessAnalyse;
begin
  ProcessOneCode(aTerm.AccountCode); 
end;

procedure TfrmCashierDayRec.ProcessOneCode(vCode: String);
var
  i:Integer;
begin
  //重置网格
  xlsResult.RowCount:=1;
  //第一个期间,显示期初数据
  ProcessOneCodeOnePeriod(vCode,aTerm.BeginPeriod,True);
  for i:=aTerm.BeginPeriod+1 to aTerm.EndPeriod do
    ProcessOneCodeOnePeriod(vCode,i,False);
end;

procedure TfrmCashierDayRec.ProcessOneCodeOnePeriod(vCode: String;
  vPeriod: Integer; Start: Boolean);
var
  CurRow,LastDay,i:Integer;
  sum,SumDebit,SumLender,CurSum,CurDirection:Double;
  vSQL,CodeDirection:String;
begin
    //依次为:
  //科目代码、名称、凭证字号、摘要、借方金额、贷方金额、余额
  aCode:=aAccountCodeProxy.Get(vCode);

  //设置方向
  if aCode.BalanceDirection then
  begin
     CurDirection:=1;
     CodeDirection:='借';
  end
  else
  begin
    CurDirection:=-1;
    CodeDirection:='贷';
  end;

  CurRow:=xlsResult.RowCount;

  vSQL:='select a.*,b.* from accountm as a left join accountd as b on a.凭证ID=b.凭证ID where a.会计区间='
    +inttostr(vPeriod)+' order by a.日期 ';

  dmMain.OpenDataSet(dmMain.adsTT,vSQL);

  with dmMain.adsTT do
  begin
    //第一行
    if not Eof then
    with xlsResult do
    begin
      //增加第一行
      RowCount :=RowCount+1;
      Cells[0,CurRow].Value :='';
      Cells[1,CurRow].Value :='';
      Cells[2,CurRow].Value :='';
      Cells[3,CurRow].Value :='(昨日余额)';
      Cells[4,CurRow].Value :='';
      Cells[5,CurRow].Value :='';
      Cells[6,CurRow].Value :='';
      Cells[7,CurRow].Value :='';
      Cells[8,CurRow].Value := CodeDirection;
      sum:=aAccountCodeProxy.GetCodeStart(vCode);
      SumDebit:=aAccountCodeProxy.GetCodeDebitOrLenderBefore(IntToStr(CurYear),IntToStr(vPeriod),vCode,True);
      SumLender:=aAccountCodeProxy.GetCodeDebitOrLenderBefore(IntToStr(CurYear),IntToStr(vPeriod),vCode,False);

      Sum:=Sum+SumDebit*CurDirection-SumLender*CurDirection;
      Cells[9,CurRow].Value := Sum;
      Cells[10,CurRow].Value :='';

      CurSum:=Sum;
      //xlsResult.Cells[7,CurRow].Value :=aAccountCodeProxy;
      Inc(CurRow);
    end;

    while not dmMain.adsTT.eof do
    with xlsResult do
    begin
      //增加第一行
      RowCount :=RowCount+1;
      Cells[0,CurRow].Value :=FieldByName('日期').AsDateTime;
      Cells[1,CurRow].Value :='序号';
      Cells[2,CurRow].Value :=vPeriod;//FieldByName('摘要').AsString;
      Cells[3,CurRow].Value :=FieldByName('摘要').AsString;
      Cells[4,CurRow].Value :=FieldByName('凭证字').AsString+'-'+FieldByName('凭证号').AsString;
      Cells[5,CurRow].Value :='分录号';
      Cells[6,CurRow].Value :=FieldByName('借方金额').AsFloat;
      Cells[7,CurRow].Value :=FieldByName('贷方金额').AsFloat;
      Cells[8,CurRow].Value :=CodeDirection;
      CurSum :=CurSum+FieldByName('借方金额').AsFloat*CurDirection-FieldByName('贷方金额').AsFloat*CurDirection;
      Cells[9,CurRow].Value :=CurSum;   //余额
      Cells[10,CurRow].Value :=FieldByName('制单').AsString;  //经手人
      Inc(CurRow);
      dmMain.adsTT.Next;
    end;

    //TODO:增加本日合计
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -