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

    Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Dim Nom_inventaire As String = ""
        MyInptBox.my_showdialog("Nommez l'inventaire.", VarType(Nom_inventaire), 100, "")
        Nom_inventaire = MyInptBox.result
        Dim inventaire_form As New Inventaire
        inventaire_form.Nom_Inventaire = Nom_inventaire
        inventaire_form.Visible = True
        inventaire_form.BringToFront()
        Me.Close()
    End Sub

    Private Sub Choix_inventaire_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim inventaires = BDD.InventaireTableAdapter.Select_Distinct_Inventaire
        For r = 0 To inventaires.Rows.Count - 1
            DataGridView1.Rows.Add()
        Next
        For r = 0 To inventaires.Rows.Count - 1
            DataGridView1.Item(Inventaire.Index, r).Value = inventaires(r).Inventaire
        Next
    End Sub

    Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        If DataGridView1.Rows.Count = 0 Then Exit Sub

        If e.RowIndex >= 0 Then
            Dim inventaire_form As New Inventaire
            inventaire_form.Nom_Inventaire = DataGridView1.Item(Inventaire.Index, e.RowIndex).Value
            inventaire_form.Visible = True
            inventaire_form.BringToFront()
            Me.Close()
        End If
    End Sub

 
End Class