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

📄 gl_enter_startuseaccount.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  //-----------------------------------------------------------------------
  //------------------------------------------------------------------------
  //--负债类借贷方
{  sqltext:='select sum( case when BalanceDirection=1 then isnull(FirstBalance,0) else 0 end ) as ff,'
          +'       sum( case when BalanceDirection=2 then isnull(FirstBalance,0) else 0 end ) as gg'
          +' from Gl_AccountSubjectBalance'
          +' where exists(select * from Gl_AccountSubject where Gl_AccountSubjectBalance.kmid=Gl_AccountSubject.kmid'
          +'   and Gl_AccountSubject.kmlevel=1  and kmType=2)';
  Executesql(AdoQry_tmp,sqltext,0);
  Balance20:=AdoQry_tmp.fieldbyname('ff').asfloat;
  Balance21:=AdoQry_tmp.fieldbyname('gg').asfloat;
}
  SqlText := ' Select JAmount=Sum(Case When BalanceDirection=1 And KmProperty=1 Then -FirstBalance     '
                               +'       When BalanceDirection=2 And KmProperty=1 Then FirstBalance   '
                               +'       When BalanceDirection=2 And KmProperty=2 Then FirstBalance   '
                               +'       When BalanceDirection=1 And KmProperty=2 Then -FirstBalance    '
                               +    ' end )                                                        '
              +'   From Gl_AccountSubjectBalance                                                   '
              +'       Join Gl_AccountSubject ON Gl_AccountSubjectBalance.KMID=Gl_AccountSubject.KMId '
              +'   where Gl_AccountSubjectBalance.kmid in (Select KmID       '
              +'                         From Gl_AccountSubject              '
              +'                         Where endkm=1 And kmType in (2))  ';
  ExecuteSql(AdoQry_Tmp,SqlText,0);
  Balance20 := AdoQry_Tmp.fieldbyname('JAmount').AsFloat;

  //-----------------------------------------------------------------------
  //------------------------------------------------------------------------
  //--权益类借贷方
{  sqltext:='select sum( case when BalanceDirection=1 then isnull(FirstBalance,0) else 0 end ) as ff,'
          +'       sum( case when BalanceDirection=2 then isnull(FirstBalance,0) else 0 end ) as gg'
          +' from Gl_AccountSubjectBalance'
          +' where exists(select * from Gl_AccountSubject where Gl_AccountSubjectBalance.kmid=Gl_AccountSubject.kmid'
          +'   and Gl_AccountSubject.kmlevel=1  and kmType=3)';
  Executesql(AdoQry_tmp,sqltext,0);
  Balance30:=AdoQry_tmp.fieldbyname('ff').asfloat;
  Balance31:=AdoQry_tmp.fieldbyname('gg').asfloat;
}
  SqlText := ' Select JAmount=Sum(Case When BalanceDirection=1 And KmProperty=1 Then -FirstBalance     '
                               +'       When BalanceDirection=2 And KmProperty=1 Then FirstBalance   '
                               +'       When BalanceDirection=2 And KmProperty=2 Then FirstBalance   '
                               +'       When BalanceDirection=1 And KmProperty=2 Then -FirstBalance    '
                               +    ' end )                                                        '
              +'   From Gl_AccountSubjectBalance                                                   '
              +'       Join Gl_AccountSubject ON Gl_AccountSubjectBalance.KMID=Gl_AccountSubject.KMId '
              +'   where Gl_AccountSubjectBalance.kmid in (Select KmID       '
              +'                         From Gl_AccountSubject              '
              +'                         Where endkm=1 And kmType in (3))  ';
  ExecuteSql(AdoQry_Tmp,SqlText,0);
  Balance30 := AdoQry_Tmp.fieldbyname('JAmount').AsFloat;

  //-----------------------------------------------------------------------
  //------------------------------------------------------------------------
  //--成本类借贷方
{  sqltext:='select sum( case when BalanceDirection=1 then isnull(FirstBalance,0) else 0 end ) as ff,'
          +'       sum( case when BalanceDirection=2 then isnull(FirstBalance,0) else 0 end ) as gg'
          +' from Gl_AccountSubjectBalance'
          +' where exists(select * from Gl_AccountSubject where Gl_AccountSubjectBalance.kmid=Gl_AccountSubject.kmid'
          +'   and Gl_AccountSubject.kmlevel=1  and kmType=4)';
  Executesql(AdoQry_tmp,sqltext,0);
  Balance40:=AdoQry_tmp.fieldbyname('ff').asfloat;
  Balance41:=AdoQry_tmp.fieldbyname('gg').asfloat;
}
  SqlText := ' Select JAmount=Sum(Case When BalanceDirection=1 And KmProperty=1 Then FirstBalance     '
                               +'       When BalanceDirection=2 And KmProperty=1 Then -FirstBalance   '
                               +'       When BalanceDirection=2 And KmProperty=2 Then -FirstBalance   '
                               +'       When BalanceDirection=1 And KmProperty=2 Then FirstBalance    '
                               +    ' end )                                                        '
              +'   From Gl_AccountSubjectBalance                                                   '
              +'       Join Gl_AccountSubject ON Gl_AccountSubjectBalance.KMID=Gl_AccountSubject.KMId '
              +'   where Gl_AccountSubjectBalance.kmid in (Select KmID       '
              +'                         From Gl_AccountSubject              '
              +'                         Where endkm=1 And kmType in (4))  ';
  ExecuteSql(AdoQry_Tmp,SqlText,0);
  Balance40 := AdoQry_Tmp.fieldbyname('JAmount').AsFloat;

  //-----------------------------------------------------------------------
  //------------------------------------------------------------------------
  //--损益类借贷方
{  sqltext:='select sum( case when BalanceDirection=1 then isnull(FirstBalance,0) else 0 end ) as ff,'
          +'       sum( case when BalanceDirection=2 then isnull(FirstBalance,0) else 0 end ) as gg'
          +' from Gl_AccountSubjectBalance'
          +' where exists(select * from Gl_AccountSubject where Gl_AccountSubjectBalance.kmid=Gl_AccountSubject.kmid'
          +'   and Gl_AccountSubject.kmlevel=1  and kmType=5)';
  Executesql(AdoQry_tmp,sqltext,0);
  Balance50:=AdoQry_tmp.fieldbyname('ff').asfloat;
  Balance51:=AdoQry_tmp.fieldbyname('gg').asfloat;
}
  SqlText := ' Select JAmount=Sum(Case When BalanceDirection=1 And KmProperty=1 Then -FirstBalance     '
                               +'       When BalanceDirection=2 And KmProperty=1 Then FirstBalance   '
                               +'       When BalanceDirection=2 And KmProperty=2 Then FirstBalance   '
                               +'       When BalanceDirection=1 And KmProperty=2 Then -FirstBalance    '
                               +    ' end )                                                        '
              +'   From Gl_AccountSubjectBalance                                                   '
              +'       Join Gl_AccountSubject ON Gl_AccountSubjectBalance.KMID=Gl_AccountSubject.KMId '
              +'   where Gl_AccountSubjectBalance.kmid in (Select KmID       '
              +'                         From Gl_AccountSubject              '
              +'                         Where endkm=1 And kmType in (5))  ';
  ExecuteSql(AdoQry_Tmp,SqlText,0);
  Balance50 := AdoQry_Tmp.fieldbyname('JAmount').AsFloat;

  //-----------------------------------------------------------------------
//  if Balance10+Balance20+Balance30+Balance40+Balance50<>Balance11+Balance21+Balance31+Balance41+Balance51 then
  If abs((Balance10+Balance40)-(Balance20+Balance30+Balance50))>0.000001 then 
  begin
    Conclusion := '试算不平衡!';
  //-----------------------------------------------------------------------
    DispInfo(Conclusion,3);
    Abort;
  end;
  if conclusion='' then
   conclusion:='试算平衡!';
  Result := True;
end;


procedure TFrm_Gl_Enter_StartUseAccount.InitForm(AdoConnection: TAdoConnection;
  ReadOnly: Boolean);
var I: integer;
    yy,mm,dd:word;
begin
  FReadOnly:=ReadOnly;
  AdoQry_Tmp.Connection:=AdOConnection;
  dbconnect := AdoConnection;
  Executesql(AdoQry_tmp,'select * from Gl_AccountParam',0);
  yy:=AdoQry_tmp.fieldbyname('AccountuseYear').asinteger;
  mm:=AdoQry_tmp.fieldbyname('AccountuseMonth').asinteger;
  edt_Month.Text:=formatdatetime('yyyy.mm',enCodedate(yy,mm,1));
  AdoQry_Tmp.Close ;
  AdoQry_Tmp.SQL.clear ;
  AdoQry_Tmp.SQL.Add('select * from Gl_Param');
  AdoQry_Tmp.Open ;
  With AdoQry_Tmp do
  begin
   if locate('ParamCode','StartUseAccount',[]) then
     cmb_CashCtrl.ItemIndex:=fieldbyname('ParamValuen').asinteger
   else cmb_CashCtrl.ItemIndex:=0;
  end;
  if cmb_CashCtrl.ItemIndex=1 then
   btn_ok.Enabled:=False;
end;

procedure TFrm_Gl_Enter_StartUseAccount.Edt_BuyerCtrlTypeChange(Sender: TObject);
begin
  inherited;
  if not FReadOnly then
    Btn_Ok.Enabled :=True;
end;

procedure TFrm_Gl_Enter_StartUseAccount.btn_okClick(Sender: TObject);
var sqltext:string;
begin
  inherited;
  if DispInfo('您真的想正式启用帐套吗?',2)<>'y' then exit;
  Executesql(AdoQry_tmp,'select * from Gl_AccountParam',0);
  if AdoQry_tmp.RecordCount=0 then 
    begin
      DispInfo('没有设置帐套参数!',3);
      exit;
    end;
  Executesql(AdoQry_tmp,'select * from Gl_AccountSubject',0);
  if AdoQry_tmp.RecordCount=0 then 
    begin
      DispInfo('没有设置会计科目!',3);
      exit;
    end;
  isBalance;
  sqltext:='select * from Gl_Param'
          +' where ParamCode=''StartUseAccount''';
  Executesql(AdoQry_tmp,sqltext,0);
  if AdoQry_tmp.RecordCount=0 then 
    begin
      sqltext:='insert into Gl_Param(ParamCode,ParamName,ParamValuen,ParamValuec)'
              +' Values( '+quotedstr('StartUseAccount')+','
              +            quotedstr('帐套启用否')+','
              +            inttostr(1)+','
              +'null)';
      Executesql(AdoQry_tmp,sqltext,1)              ;
    end
  else
  Executesql(AdoQry_tmp,'update Gl_Param set ParamValuen=1 where ParamCode=''StartUseAccount''',1);
  ExecuteSQl(AdoQry_Tmp,'select * from Gl_AccountPeriod'
                      +'  where AccountPeriodYear='+Copy(Edt_Month.Text,1,4)
                      +'    and AccountPeriodMonth='+Copy(Edt_Month.Text,6,2),0)  ;
  If AdoQry_Tmp.RecordCount=0 then 
  begin
    SqlText := 'Insert Into Gl_AccountPeriod(AccountPeriodYear,AccountPeriodMonth,CurrentPeriod,FreezeMonth) '
             +'  Values ('+Copy(Edt_Month.Text,1,4)+','
             +Copy(Edt_Month.Text,6,2)+','
             +'1,0)';
    ExecuteSql(AdoQry_Tmp,SQlText,1)             ;
              
  end
  else ExecuteSQl(AdoQry_Tmp,'update Gl_AccountPeriod '
                            +'   set CurrentPeriod=1 '
                            +' where AccountPeriodYear='+Copy(Edt_Month.Text,1,4)
                            +'   and AccountPeriodMonth='+Copy(Edt_Month.Text,6,2),1)                      ;
  Close;
end;

procedure TFrm_Gl_Enter_StartUseAccount.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action:=CaFree;
end;

procedure TFrm_Gl_Enter_StartUseAccount.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  If Key=Vk_EScApe then
    Close;
end;

procedure TFrm_Gl_Enter_StartUseAccount.btn_CancelClick(Sender: TObject);
begin
  inherited;
  Close;
end;

procedure TFrm_Gl_Enter_StartUseAccount.MEdt_AutoRunPSI1Change(Sender: TObject);
begin
  inherited;
  if not FReadOnly then
    Btn_Ok.Enabled :=True;
end;

end.

⌨️ 快捷键说明

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