' 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
Imports System.Text
Public Class PRODUITS_MAIN



    Private Sub BDM_Prix_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BDM_Prix_Button.Click
        OpenFileDialog1.InitialDirectory = Application.StartupPath + "\Tables\"
        OpenFileDialog1.FileName = ""
        OpenFileDialog1.ShowDialog()
        If OpenFileDialog1.FileName = "" Then Exit Sub
        Me.BDM_PrixTableAdapter.DeleteAll()
        Using sr As New StreamReader(OpenFileDialog1.FileName, Encoding.Default)
            Dim line, CIP13, CIP7, Date_ As String
            Dim Prix_Public_TTC, Prix_Fabricant_HT As Long
            line = sr.ReadLine
            line = sr.ReadLine
            Do
                CIP13 = Mid(line, 1, InStr(line, ";") - 1)
                line = Mid(line, InStr(line, ";") + 1)
                CIP7 = Mid(line, 1, InStr(line, ";") - 1)
                line = Mid(line, InStr(line, ";") + 1)
                line = Mid(line, InStr(line, ";") + 1)
                Prix_Public_TTC = Mid(line, 1, InStr(line, ";") - 1)
                line = Mid(line, InStr(line, ";") + 1)
                line = Mid(line, InStr(line, ";") + 1)
                Prix_Fabricant_HT = Mid(line, 1, InStr(line, ";") - 1)
                line = Mid(line, InStr(line, ";") + 1)
                line = Mid(line, InStr(line, ";") + 1)
                Date_ = Mid(Mid(line, 1, InStr(line, ";") - 1), 7, 4) + Mid(Mid(line, 1, InStr(line, ";") - 1), 4, 2) + Mid(Mid(line, 1, InStr(line, ";") - 1), 1, 2)
                Me.BDM_PrixTableAdapter.Insert(CIP13, CIP7, Prix_Public_TTC, Prix_Fabricant_HT, Date_)
                line = sr.ReadLine
            Loop Until line Is Nothing

        End Using
    End Sub
End Class