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

    Private Sub SMTPBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Validate()
        Me.SMTPBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.PharmaDataSet)

    End Sub

    Private Sub Histo_SMTP_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.SMTP'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
        Me.SMTPTableAdapter.Fill(Me.PharmaDataSet.SMTP)

    End Sub


    Private Sub SMTPDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles SMTPDataGridView.CellContentClick
        DataGridView_Lots.DataSource = Me.LotsTableAdapter1.GetDataByFichierLots(SMTPDataGridView.Item(SMTP_NomFichier.Index, SMTPDataGridView.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 SMTPDataGridView.ColumnCount - 1
                    sw.WriteLine(SMTPDataGridView.Columns.Item(i).HeaderText + ":" + SMTPDataGridView.Item(i, SMTPDataGridView.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
            MyMsg_Box.Presentation("Officine", ex.ToString, False, "", False, "", True, "OK")
            MyMsg_Box.ShowDialog()
        End Try
    End Sub
End Class