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

📄 gl_enter_accountsubject.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  var_KmCode: String): Boolean;
var
  SqlText,Tmp_KmCode,Tmp_KmId:String;
  KmLength1,KmLength2,KmLength3,KmLength4,KmLength5,KmLength6:Integer;
begin
  SQlText:=' Select Count(*) As reocrd From Gl_AccountSubject Where KmCode Like '''+var_KmCode+'''+''%'' ';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.clear;
  AdoQry_Tmp.SQL.Text := SqlText;
  AdoQry_Tmp.Open;
  if AdoQry_Tmp.fieldbyname('reocrd').AsInteger > 1 then
  begin
    DispInfo('该科目下有子科目,不能删除!',1);
    Result := False;
    exit;
  end;
  SQlText:=' Select KmId From Gl_AccountSubject Where KmCode = '''+var_KmCode+''' ';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.clear;
  AdoQry_Tmp.SQL.Text := SqlText;
  AdoQry_Tmp.Open;
  Tmp_KmId := AdoQry_Tmp.fieldbyname('KmId').AsString;
  SQlText := ' Select * '
            +' From Gl_AccountSubjectBalance '
            +' Where AccountPeriodYear>=(Select AccountUseYear From Gl_AccountParam) '
            +'      And KmId='''+Tmp_KmId+''' And '
            +'(DebitBalance  <> 0 Or '
            +' CreditBalance <> 0 Or '
            +' AmountBalance <> 0 Or '
            +' FirstBalance  <> 0 Or '
            +' FirstFBalance <> 0 Or '
            +' FirstAmountBalance <> 0)';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.clear;
  AdoQry_Tmp.SQL.Text := SqlText;
  AdoQry_Tmp.Open;
  if  AdoQry_Tmp.RecordCount>0 then
  begin
    DispInfo('会计科目余额已设定,不能删除!',1);
    Result := False;
    exit;
  end;

  SQlText := ' Select KmCode From Gl_CredenceLine Join Gl_Credence '
            +'  On  Gl_CredenceLine.CredenceId =  Gl_Credence.CredenceId  '
            +'  Where DatePArt(Year,CredenceDate) = DatePArt(Year,GetDate())  '
            +'       And  KmCode='''+var_KmCode+'''';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.clear;
  AdoQry_Tmp.SQL.Text := SqlText;
  AdoQry_Tmp.Open;
  if not AdoQry_Tmp.Eof then
   begin
    DispInfo('该会计科目已输入凭证,不能删除!',1);
    Result := False;
    exit;
  end;


  SQlText:=' Select *  From Gl_AccountParam  ';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.clear;
  AdoQry_Tmp.SQL.Text := SqlText;
  AdoQry_Tmp.Open;
  KmLength1 := AdoQry_Tmp.fieldbyname('KmLength1').AsInteger;
  KmLength2 := AdoQry_Tmp.fieldbyname('KmLength1').AsInteger+AdoQry_Tmp.fieldbyname('KmLength2').AsInteger;
  KmLength3 := KmLength2+AdoQry_Tmp.fieldbyname('KmLength3').AsInteger;
  KmLength4 := KmLength3+AdoQry_Tmp.fieldbyname('KmLength4').AsInteger;
  KmLength5 := KmLength4+AdoQry_Tmp.fieldbyname('KmLength5').AsInteger;
  KmLength6 := KmLength5+AdoQry_Tmp.fieldbyname('KmLength6').AsInteger;
  if Length(var_KmCode)=KmLength1 then
    begin
{      try
        SQlText:='UpDate Gl_AccountSubject Set endKm=0 Where KmCode='''+var_KmCode+''' ';
        AdoQry_Tmp.Close;
        AdoQry_Tmp.SQL.clear;
        AdoQry_Tmp.SQL.Text := SqlText;
        AdoQry_Tmp.ExecSQL ;
        Result:=True;
      except}
        Result := True;
//      end;
    end
  else
    if Length(var_KmCode)=KmLength2 then
      begin
        try
          Tmp_KmCode := Copy(var_KmCode,1,3);
          SQlText:=' Select Count(*) As reocrd From Gl_AccountSubject Where KmCode Like '''+Tmp_KmCode+'''+''%'' ';
          AdoQry_Tmp.Close;
          AdoQry_Tmp.SQL.clear;
          AdoQry_Tmp.SQL.Text := SqlText;
          AdoQry_Tmp.Open;
          if AdoQry_Tmp.fieldbyname('reocrd').AsInteger <= 2 then
          begin
            SQlText:='UpDate Gl_AccountSubject Set endKm=1 Where KmCode='''+Tmp_KmCode+''' ';
            AdoQry_Tmp.Close;
            AdoQry_Tmp.SQL.clear;
            AdoQry_Tmp.SQL.Text := SqlText;
            AdoQry_Tmp.ExecSQL ;
          end;
          Result:=True;
        except
          Result:=False;
        end;
      end
    else
      if Length(var_KmCode)=KmLength3 then
        begin
          Try
            Tmp_KmCode := Copy(var_KmCode,1,KmLength2);
            SQlText:=' Select Count(*) As reocrd From Gl_AccountSubject Where KmCode Like '''+Tmp_KmCode+'''+''%'' ';
            AdoQry_Tmp.Close;
            AdoQry_Tmp.SQL.clear;
            AdoQry_Tmp.SQL.Text := SqlText;
            AdoQry_Tmp.Open;
            if AdoQry_Tmp.fieldbyname('reocrd').AsInteger <= 2 then
            begin
              SQlText:='UpDate Gl_AccountSubject Set endKm=1 Where KmCode='''+Tmp_KmCode+''' ';
              AdoQry_Tmp.Close;
              AdoQry_Tmp.SQL.clear;
              AdoQry_Tmp.SQL.Text := SqlText;
              AdoQry_Tmp.ExecSQL;
            end;
            Result:=True;
          except
            Result:=False;
          end;
        end
      else
      if Length(var_KmCode)=KmLength4 then
        begin
          Try
            Tmp_KmCode := Copy(var_KmCode,1,KmLength3);
            SQlText:=' Select Count(*) As reocrd From Gl_AccountSubject Where KmCode Like '''+Tmp_KmCode+'''+''%'' ';
            AdoQry_Tmp.Close;
            AdoQry_Tmp.SQL.clear;
            AdoQry_Tmp.SQL.Text := SqlText;
            AdoQry_Tmp.Open;
            if AdoQry_Tmp.fieldbyname('reocrd').AsInteger <= 2 then
            begin
              SQlText:='UpDate Gl_AccountSubject Set endKm=1 Where KmCode='''+Tmp_KmCode+''' ';
              AdoQry_Tmp.Close;
              AdoQry_Tmp.SQL.clear;
              AdoQry_Tmp.SQL.Text := SqlText;
              AdoQry_Tmp.ExecSQL;
            end;
            Result:=True;
          except
           Result:=False;
          end;
        end
      else
        if Length(var_KmCode)=KmLength5 then
          begin
            try
              Tmp_KmCode := Copy(var_KmCode,1,KmLength4);
              SQlText:=' Select Count(*) As reocrd From Gl_AccountSubject Where KmCode Like '''+Tmp_KmCode+'''+''%'' ';
              AdoQry_Tmp.Close;
              AdoQry_Tmp.SQL.clear;
              AdoQry_Tmp.SQL.Text := SqlText;
              AdoQry_Tmp.Open;
              if AdoQry_Tmp.fieldbyname('reocrd').AsInteger <= 2 then
              begin
                SQlText:='UpDate Gl_AccountSubject Set endKm=1 Where KmCode='''+Tmp_KmCode+''' ';
                AdoQry_Tmp.Close;
                AdoQry_Tmp.SQL.clear;
                AdoQry_Tmp.SQL.Text := SqlText;
                AdoQry_Tmp.ExecSQL;
              end;
              Result:=True;
            except
              Result:=False;
            end;
          end
        else
        if Length(var_KmCode)=KmLength6 then
          begin
            try
              Tmp_KmCode := Copy(var_KmCode,1,KmLength5);
              SQlText:=' Select Count(*) As reocrd From Gl_AccountSubject Where KmCode Like '''+Tmp_KmCode+'''+''%'' ';
              AdoQry_Tmp.Close;
              AdoQry_Tmp.SQL.clear;
              AdoQry_Tmp.SQL.Text := SqlText;
              AdoQry_Tmp.Open;
              if AdoQry_Tmp.fieldbyname('reocrd').AsInteger <= 2 then
              begin
                SQlText:='UpDate Gl_AccountSubject Set endKm=1 Where KmCode='''+Tmp_KmCode+''' ';
                AdoQry_Tmp.Close;
                AdoQry_Tmp.SQL.clear;
                AdoQry_Tmp.SQL.Text := SqlText;
                AdoQry_Tmp.ExecSQL;
              end;
              Result:=True;
            except
              Result:=False;
            end ;
          end
          else
              Result:=True;
end;

procedure TFrm_Gl_Enter_AccountSubject.AdoQry_MainKmNameGetText(
  Sender: TField; var Text: String; DisplayText: Boolean);
begin
  inherited;
  case AdoQry_MainKmLevel.Value of
    1: Text := AdoQry_MainKmName.Value;
    2: Text := '  '+AdoQry_MainKmName.Value;
    3: Text := '    '+AdoQry_MainKmName.Value;
    4: Text := '      '+AdoQry_MainKmName.Value;
    5: Text := '        '+AdoQry_MainKmName.Value;
    6: Text := '          '+AdoQry_MainKmName.Value;
  end;
end;

procedure TFrm_Gl_Enter_AccountSubject.endKmCheck(kmCodestr: string;
  kmLevelint: integer);
var
  i:integer;
  k: Array [1..6] of integer;
  t:string;
begin
  for i :=1  to 6 do
    k[i]:=0;
  if kmLevelint>1 then
  begin
    ExecuteSql(AdoQry_Tmp,'select * from Gl_AccountParam',0);
    for i :=1  to 6 do
    begin
      if i=1 then
        k[i]:=AdoQry_tmp.fieldbyname('kmlength'+inttostr(i)).asinteger
      else
        k[i]:=k[i-1]+AdoQry_tmp.fieldbyname('kmlength'+inttostr(i)).asinteger;
    end;

    ExecuteSql(AdoQry_Tmp,'select * from Gl_AccountSubject where kmCode like '+QuotedStr(copy(kmCodestr,1,k[kmLevelint-1])+'%'),0);
    if AdoQry_tmp.recordCount>2 then
      t:=' update Gl_AccountSubject set endkm=0 where kmCode='+QuotedStr(copy(kmCodestr,1,k[kmLevelint-1]))
    else
      t:=' update Gl_AccountSubject set endkm=1 where kmCode='+QuotedStr(copy(kmCodestr,1,k[kmLevelint-1]))
  end
  else
      t:=' update Gl_AccountSubject set endkm=1 where kmCode='+QuotedStr(copy(kmCodestr,1,k[kmLevelint-1]));
  ExecuteSql(AdoQry_Tmp, t,1);

end;

end.

⌨️ 快捷键说明

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