' Copyright (C) 2025  P4pillon.org
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU Affero General Public License as
' published by the Free Software Foundation, either version 3 of the
' License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU Affero General Public License for more details.
'
' You should have received a copy of the GNU Affero General Public License
' along with this program.  If not, see <https://www.gnu.org/licenses/>.
Public Class Ordonnancier

    Public Sub reconstruction_ordonnacier()
        Dim Actes = BDD.ActesTableAdapter.GetData_Stupéfiants

        For r = 0 To Actes.Rows.Count - 1
            Try
                Dim num_prescripteur As String = ""
                If Val(Actes(r).NumFacturesSV) > 0 Then
                    Dim facture = BDD.FacturesTableAdapter.GetDataBy_Num(Val(Actes(r).NumFacturesSV)).Item(0)
                    If facture.G1211C1 <> "" Then
                        num_prescripteur = facture.G1211C1 & facture.G1211C2
                    ElseIf facture.G1213C1 <> "" Then
                        num_prescripteur = facture.G1213C1 & facture.G1213C2
                    ElseIf facture.G1214C1 <> "" Then
                        num_prescripteur = facture.G1214C1 & facture.G1214C2
                    End If
                End If

            Catch ex As Exception
                Main.writelog("Reconstruction ordonnancier: erreur sur traitement acte num " & Actes(r).NumActe & Chr(10) & ex.Message)
            End Try
            
        Next

    End Sub

  
End Class