' 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 AMC_edition



 



    Private Sub Num_org_payeurComboBox_KeyUp(sender As Object, e As EventArgs) Handles Num_org_payeurComboBox.KeyUp
        Num_org_payeurComboBox.Items.Clear()
        'If Num_org_payeurComboBox.Text.Length >= 3 Then
        Dim mut = Me.AMC_OrganismesTableAdapter.GetData_Recherche(Num_org_payeurComboBox.Text)
        Dim listmut As New List(Of String)

        For r = 0 To mut.Count - 1
            listmut.Add(mut.Item(r).Intitulé & " " & mut.Item(r).Num)
        Next

        If listmut.Count > 0 Then
            listmut.Sort()
            For Each mut_ In listmut
                Num_org_payeurComboBox.Items.Add(mut_)
            Next
        End If
        'End If
        Num_org_payeurComboBox.SelectionStart = Num_org_payeurComboBox.Text.Length
        Num_org_payeurComboBox.SelectionLength = 0

    End Sub

    Private Sub NumTextBox_TextChanged(sender As Object, e As EventArgs) Handles NumTextBox.TextChanged
        NumTextBox.Text = UCase(Replace(NumTextBox.Text, " ", ""))
    End Sub

    Private Sub Enregistrer_LinkLabel_Click(sender As Object, e As EventArgs) Handles Enregistrer_LinkLabel.Click
        If Me.AMC_OrganismesTableAdapter.GetDataBy_Num(NumTextBox.Text).Rows.Count > 0 Then
            Me.AMC_OrganismesTableAdapter.Delete_By_Num(NumTextBox.Text)
        End If
        Me.AMC_OrganismesTableAdapter.Insert(NumTextBox.Text.ToString, IntituléTextBox.Text.ToString, AdresseTextBox.Text.ToString, TelephoneTextBox.Text.ToString, _
                                             Mid(Num_org_payeurComboBox.Text, InStrRev(Num_org_payeurComboBox.Text, " ") + 1).ToString)
        Me.Close()
    End Sub

End Class