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

📄 scade_mod.pas

📁 基于OOP设计的一套较好的ERP系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:


begin
   LocalizzaPnota := TTable.Create(Self) ;
   LocalizzaPnota.DatabaseName := 'euro2000' ;
   LocalizzaPnota.TableName := 'TPnota.db' ;
   LocalizzaPnota.IndexName := 'data_numero' ;
   LocalizzaPnota.Open ;
   Progressivo_futuro := 0 ;
   Progressivo_Attuale := TTTPnotaRegistrazione.asInteger ;
   If LocalizzaPnota.Locate('Registrazione',Progressivo_Attuale,[]) then
    begin
     Passi_Fatti := LocalizzaPnota.MoveBy(passi) ;
     If passi_Fatti = Passi then
      Progressivo_Futuro := LocalizzaPnota.FieldByName('Registrazione').AsInteger
     else
      begin
       LocalizzaPnota.Close ;
       LocalizzaPnota.Free ;
       exit ;
      end ;
    end ;
   LocalizzaPnota.Close ;
   LocalizzaPnota.Free ;
   Pnota := TTable.Create(Self) ;
   Pnota.DatabaseName := 'euro2000' ;
   Pnota.TableName := 'TPnota.db' ;
   Pnota.Open ;
   Pnota.Last ;
   PnotaAttuale := TTable.Create(Self) ;
   PnotaAttuale.DatabaseName := 'euro2000' ;
   PnotaAttuale.TableName := 'TPnota.db' ;
   PnotaAttuale.Open ;
   (*Progressivo_futuro := Progressivo_Attuale + passi ;
   If Progressivo_futuro < 1 then exit ;
   If Progressivo_futuro > Max_reg then exit ;*)
   // Sposto la riga nella posizione -1 per evitare key violation
   If PnotaAttuale.Findkey([Progressivo_attuale]) then
    begin
     PnotaAttuale.Edit ;
     PnotaAttuale.FieldByName('Registrazione').asInteger := -1 ;
     PnotaAttuale.Post ;
    end ;
   // Sposto la riga che occupa la posizione futura nella posizione occupata attualmente dalla registrazione che stiamo spostando
   If Pnota.FindKey([Progressivo_futuro]) then
    begin
     Pnota.Edit ;
     Pnota.FieldByName('Registrazione').asInteger := Progressivo_Attuale ;
     Pnota.Post ;
    end ;
   // Sposto definitivamente la riga che volevamo spostare nella posizione finale
   If PnotaAttuale.Findkey([-1]) then
    begin
     PnotaAttuale.Edit ;
     PnotaAttuale.FieldByName('Registrazione').asInteger := Progressivo_futuro ;
     PnotaAttuale.Post ;
    end ;
   Pnota.Close ;
   Pnota.Free ;
   PnotaAttuale.Close ;
   PnotaAttuale.Free ;
   // Rigeneriamo il saldo progressivo ;
   If Progressivo_futuro > Progressivo_attuale then
    TTTPnota.Locate('Registrazione',Progressivo_attuale,[])
   else
    TTTPnota.Locate('Registrazione',Progressivo_futuro,[]) ;
   CalcolaSaldoProgressivoPnota ;
   TTTpnota.Locate('Registrazione',Progressivo_futuro,[]) ;
end ;

Procedure TModuloDatiScadenziario.CalcolaSaldoProgressivoPnota ;
Var
   P1,P2,P3,P4 : Currency ;
   PnotaDb : TTable ;

begin
 P1 := 0 ;
 P2 := 0 ;
 P3 := 0 ;
 P4 := 0 ;
 PnotaDb := TTable.Create(nil) ;
 PnotaDb.DatabaseName := 'euro2000' ;
 PnotaDb.TableName := 'Tpnota.db' ;
 PnotaDb.IndexName := 'data_numero' ;
 PnotaDb.Open ;
 If PnotaDb.Locate('Registrazione',TTTPnotaRegistrazione.AsInteger,[]) then
  begin
   If PnotaDb.RecNo > 1 then
    begin
     PnotaDb.Prior ;
     P1 := PnotaDb.FieldByName('Progressivo C1').asCurrency ;
     P2 := PnotaDb.FieldByName('Progressivo C2').asCurrency ;
     P3 := PnotaDb.FieldByName('Progressivo C3').asCurrency ;
     P4 := PnotaDb.FieldByName('Progressivo C4').asCurrency ;
     PnotaDb.Next ;
    end ;
   While not PnotaDB.Eof do
    begin
     PnotaDb.Edit ;
     PnotaDb.FieldByName('Progressivo C1').asCurrency := P1 + PnotaDb.FieldByName('C1E').asCurrency - PnotaDb.FieldByName('C1U').asCurrency ;
     PnotaDb.FieldByName('Progressivo C2').asCurrency := P2 + PnotaDb.FieldByName('C2E').asCurrency - PnotaDb.FieldByName('C2U').asCurrency ;
     PnotaDb.FieldByName('Progressivo C3').asCurrency := P3 + PnotaDb.FieldByName('C3E').asCurrency - PnotaDb.FieldByName('C3U').asCurrency ;
     PnotaDb.FieldByName('Progressivo C4').asCurrency := P4 + PnotaDb.FieldByName('C4E').asCurrency - PnotaDb.FieldByName('C4U').asCurrency ;
     PnotaDb.Post ;
     P1 := PnotaDb.FieldByName('Progressivo C1').asCurrency ;
     P2 := PnotaDb.FieldByName('Progressivo C2').asCurrency ;
     P3 := PnotaDb.FieldByName('Progressivo C3').asCurrency ;
     P4 := PnotaDb.FieldByName('Progressivo C4').asCurrency ;
     PnotaDb.Next ;
    end ;
  end ;
 PnotaDb.Close ;
 PnotaDb.Free ;
 TTTPnota.Refresh ;
end ;

Procedure TmoduloDatiScadenziario.Salda_Dissalda ;
begin
     If TTEcontoSaldato.asBoolean then
      begin
        // Saldato : quindi portiamo a zero il saldo.
       If TTEcontoSaldoE.asCurrency <> 0 then
        If TTecontoAP.AsString = 'A' then
          begin
            TTecontoDareL.asCurrency := TTEcontoAvereL.asCurrency ;
            TTecontoDareE.AsCurrency := TTEcontoAvereE.asCurrency ;
           end
        else
         begin
          TTEcontoAvereL.AsCurrency := TTecontoDareL.asCurrency ;
          TTecontoAvereE.asCurrency := TTEcontoDareE.asCurrency ;
         end ;
         TTEcontoDataPagamento.Value := Now ;
        end
      else
       begin
        // Non saldato : portiamo a 0 dare o avere in funzione di AP
        If TTEcontoAP.asString = 'A' then
         begin
          TTEcontoDareL.ASCurrency := 0 ;
          TTecontoDareE.AsCurrency := 0 ;
         end
        else
         begin
          TTEcontoAvereL.asCurrency := 0 ;
          TTEcontoAvereE.asCurrency := 0 ;
         end ;
         TTEcontoDataPagamento.Clear ;
       end ;
       TTEcontoManuale.AsBoolean := True ;
end ;
Procedure TModulodatiScadenziario.Rinfresca_scadenze ;
Var
    Filtro : string ;

begin
     // Prepariamo l'elenco sottostante in base ai parametri impostati dall'utente


     If TTParamPartite.AsString = 'Aperte' then
        Filtro := 'Saldato = ' +chr(39)+'False'+chr(39) ;
     if TTParamPartite.AsString = 'Chiuse' then
        Filtro := 'Saldato = ' +chr(39)+'True'+chr(39) ;
     If TTParamPartite.AsString = 'Tutte' then
        Filtro := '' ;

     If TTParamAP.asString = 'Attivo' then
      begin
        If Filtro <> '' then filtro := filtro + ' and ' ;
        Filtro := filtro + ' AP = ' + chr(39) + 'A' + chr(39) ;
      end ;

     If TTParamAP.asString = 'Passivo' then
      begin
        If Filtro <> '' then filtro := filtro + ' and ' ;
        Filtro := filtro + ' AP = ' + chr(39) + 'P' + chr(39) ;
      end ;



     If TTParamSoggetto.asString <> '' then
      begin
        If Filtro <> '' then Filtro := filtro + ' and ' ;
        Filtro := Filtro + ' Soggetto = '+Chr(39)+TTParamSoggetto.asString +Chr(39);
      end ;

     If TTParamScadenzeDal.AsString <> '' then
      begin
        If Filtro <> '' then Filtro := filtro + ' and ' ;
        Filtro := Filtro + ' Scadenza >='+Chr(39)+ MilleniumBugStr(TTParamScadenzeDal.asDatetime) +chr(39);
      end ;

     If TTParamScadenzaAl.AsString <> '' then
      begin
        If Filtro <> '' then Filtro := filtro + ' and ' ;
        Filtro := Filtro + ' Scadenza <='+Chr(39)+ MilleniumBugStr(TTParamScadenzaAl.asDateTime) +chr(39);
      end ;
     Try
       TTEconto.DisableControls ;
       If TTParamOrdinamento.asString = 'Soggetto-scadenza' then
        TTEconto.IndexName := 'Soggetto-scadenza-doc' ;
       If TTParamOrdinamento.asString = 'Scadenza-soggetto' then
        TTEconto.IndexName := 'Scadenza-soggetto-doc' ;
       If TTParamOrdinamento.asString = 'Data documento' then
        TTEconto.IndexName := 'data-num-scad' ;
       If TTParamOrdinamento.AsString = 'Numero documento' then
        TTeconto.indexName := 'num-data-scad' ;
       TTEconto.Filtered := False ;
       TTEconto.Filter := Filtro ;
       TTEconto.Filtered := True ;
    finally
     TTEconto.Enablecontrols ;
    end ;
end ;


procedure TModuloDatiScadenziario.TTEcontoCalcFields(DataSet: TDataSet);
begin
     TTEcontoSaldoL.asCurrency := TTEcontoAvereL.asCurrency - TTEcontoDareL.asCurrency ;
     TTEcontoSaldoE.asCurrency := TTEcontoAvereE.asCurrency - TTEcontoDareE.asCurrency ;
     If TTDocumenti.FindKey([TTEcontoDocumento.asInteger]) then
      begin
       TTEcontoDescrizione.AsString := TTDocumentiTipoDocumento.asString +
                                       ' del ' + TTdocumentiData.AsString +
                                       ' n. ' + TTDocumentiNumero.asString ;
      end ;
end;

procedure TModuloDatiScadenziario.TTParamBeforePost(DataSet: TDataSet);
begin
 Rinfresca_scadenze ;
end;

procedure TModuloDatiScadenziario.TTParamOrdinamentoChange(Sender: TField);
begin
     ModuloDatiScadenziario.TTParam.edit ;
     ModuloDatiScadenziario.Rinfresca_scadenze ;
end;

procedure TModuloDatiScadenziario.TTEcontoSaldatoChange(Sender: TField);
begin

 //Salda_dissalda ;

end;

procedure TModuloDatiScadenziario.TTEcontoDareLChange(Sender: TField);
begin
 if not mod_manuale then
  begin
   mod_manuale := true ;
   TTEcontoDareE.asCurrency := ModuloDatiAnagrafiche.LireEuro(TTecontoDareL.asCurrency) ;
   mod_manuale := false ;
  end ;
end;

procedure TModuloDatiScadenziario.ModuloDatiScadenziarioCreate(
  Sender: TObject);
begin
 mod_manuale := false ;
end;

procedure TModuloDatiScadenziario.TTEcontoAvereLChange(Sender: TField);
begin
 if not mod_manuale then
  begin
   mod_manuale := true ;
   TTEcontoAvereE.asCurrency := ModuloDatiAnagrafiche.LireEuro(TTecontoAvereL.asCurrency) ;
   mod_manuale := false ;
  end ;
end;

procedure TModuloDatiScadenziario.TTEcontoAvereEChange(Sender: TField);
begin
 if not mod_manuale then
  begin
   mod_manuale := true ;
   TTEcontoAvereL.asCurrency := ModuloDatiAnagrafiche.EuroLire(TTecontoAvereE.asCurrency) ;
   mod_manuale := false ;
  end ;
end;

procedure TModuloDatiScadenziario.TTEcontoDareEChange(Sender: TField);
begin
 if not mod_manuale then
  begin
   mod_manuale := true ;
   TTEcontoDareL.asCurrency := ModuloDatiAnagrafiche.EuroLire(TTecontoDareE.asCurrency) ;
   mod_manuale := false ;
  end ;
end;

procedure TModuloDatiScadenziario.TTTpnotaAfterInsert(DataSet: TDataSet);
Var
   Pnota : TTable ;

begin
     TTTpnotaIdGiornale.AsString := ModuloDatiAnagrafiche.LogI(TTTpnota.TableName);
     Pnota := TTable.Create(Self) ;
     Pnota.DatabaseName := 'euro2000' ;
     Pnota.TableName := 'TPnota.db' ;
     Pnota.Open ;
     Pnota.Last ;
     TTTPnotaRegistrazione.asInteger := Pnota.FieldByName('Registrazione').asInteger + 1 ;
     TTTPnotaId.asInteger := ModuloDatiAnagrafiche.IncNumeratore('PP','','','') ;
     Pnota.Close ;
     Pnota.Free ;
     TTTPnotaData.AsDateTime := Now ;
end;

procedure TModuloDatiScadenziario.TTTpnotaCalcFields(DataSet: TDataSet);
begin

     TTTPnotaSaldoC1.asCurrency := TTTPnotaC1E.AsCurrency - TTTpnotaC1U.asCurrency ;
     TTTPnotaSaldoC2.asCurrency := TTTPnotaC2E.AsCurrency - TTTpnotaC2U.asCurrency ;
     TTTPnotaSaldoC3.asCurrency := TTTPnotaC3E.AsCurrency - TTTpnotaC3U.asCurrency ;
     TTTPnotaSaldoC4.asCurrency := TTTPnotaC4E.AsCurrency - TTTpnotaC4U.asCurrency ;
     TTTPnotaSaldo.asCurrency := TTTPnotaEntrata.AsCurrency - TTTpnotaUscita.asCurrency ;
end;

procedure TModuloDatiScadenziario.TTpagamRitCalcFields(DataSet: TDataSet);
begin
     If TTDocumenti.FindKey([TTPagamRitDocumento.asInteger]) then
      begin
       TTPagamRitEstremiDoc.asString := TTDocumentiRagioneSocialeDocumento.AsString +
                                        ' - ' + TTDocumentiNumero.AsString + ' - ' +
                                        TTdocumentiData.AsString ;
      end ;
end;

procedure TModuloDatiScadenziario.TTDocumentiCalcFields(DataSet: TDataSet);
begin
     If ModuloDatiAnagrafiche.TTTipiDoc.FindKey([TTdocumentiTipo.asString]) then
      TTDocumentiTipoDocumento.asString := ModuloDatiAnagrafiche.TTTipidocDescrizione.AsString ;
end;

procedure TModuloDatiScadenziario.TTTpnotaBeforePost(DataSet: TDataSet);
Var
   DecontoDb : TTable ;

begin
   If TTTpnotaDescrizione.AsString = '' then
    begin
     ShowMessage('Descrizione non valida....');
     abort ;
    end ;

   DEcontoDb := TTable.Create(nil) ;
   DecontoDb.DatabaseName := 'euro2000' ;
   DecontoDb.TableName := 'deconto.db' ;
   DecontoDb.open ;
   If DecontoDb.Locate('Registrazione',TTTPnotaId.asInteger,[]) then
    if (MessageDlg('Esistono collegamenti allo scadenziario, si consiglia di eliminare la registrazione e rifarla dallo scadenziario, proseguire con la modifica comunque?',mtConfirmation,[mbYes,mbNo],0)=mrNo) then
      Abort
    else
      begin
 //       modifica_pag ;
      end ;

    //modifica_pag ;
   DecontoDb.Close ;
   DEcontoDb.Free ;
end;

⌨️ 快捷键说明

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