' 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/>.
Imports System.IO
Public Class Histo_ARL

    Private Sub ARLBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ARLBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.ARLBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.PharmaDataSet)

    End Sub

    Private Sub Histo_ARL_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO : cette ligne de code charge les données dans la table 'PharmaDataSet.ARL'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
        Me.ARLTableAdapter.Fill(Me.PharmaDataSet.ARL)

    End Sub

    Private Sub ARLDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ARLDataGridView.CellContentClick
        DataGridView_Lots.DataSource = Me.LotsTableAdapter1.GetDataByArlIdMessage(ARLDataGridView.Item(MessageId.Index, ARLDataGridView.CurrentRow.Index).Value)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Using sw As New StreamWriter(TextBox1.Text, True)
                sw.WriteLine("___________________________________________________________________")
                For i = 0 To ARLDataGridView.ColumnCount - 1
                    sw.WriteLine(ARLDataGridView.Columns.Item(i).HeaderText + ":" + ARLDataGridView.Item(i, ARLDataGridView.CurrentRow.Index).Value.ToString)
                Next

                For r = 0 To DataGridView_Lots.RowCount - 1
                    sw.WriteLine()
                    sw.WriteLine("LOT " + (r + 1).ToString)
                    For c = 0 To DataGridView_Lots.ColumnCount - 1
                        sw.WriteLine(DataGridView_Lots.Columns.Item(c).HeaderText + ":" + DataGridView_Lots.Item(c, r).Value.ToString)
                    Next
                Next
                sw.WriteLine("___________________________________________________________________")
            End Using
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class