' 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.Xml

Public Class Encaissements_Edition_Facture
    Public parameters As String

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


   
        parameters = parameters & "&Date_Facture=" & Format(DateTimePicker1.Value, "yyyy-MM-dd")
        'Dim lines_list = EnTete_RichTextBox.Lines.ToList()

        If EnTete_RichTextBox.Lines.ToList.Count > 0 Then
            parameters = parameters & "&entete="
        End If
        For Each line In EnTete_RichTextBox.Lines
            parameters = parameters & line & "@@LineBreak@@"
        Next
        If PiedPage_RichTextBox.Lines.ToList.Count > 0 Then
            parameters = parameters & "&piedpage="
        End If
        For Each line In PiedPage_RichTextBox.Lines
            parameters = parameters & line & "@@LineBreak@@"
        Next
        Web_browser.Visible = True
        Web_browser.BringToFront()
        If Retrocession_CheckBox.Checked = False Then
            Web_browser.WebBrowser1.Navigate("http://" & Replace(Config.LocalNetwork_ServerName, "\", "") & "/ReportServer_SQLEXPRESS/Pages/ReportViewer.aspx?%2fFactures%2fFacture_Commerciale&rs:Command=Render" & parameters)
        Else
            Web_browser.WebBrowser1.Navigate("http://" & Replace(Config.LocalNetwork_ServerName, "\", "") & "/ReportServer_SQLEXPRESS/Pages/ReportViewer.aspx?%2fFactures%2fFacture_retrocession&rs:Command=Render" & parameters)
        End If

        Me.Close()
    End Sub

    Private Sub Encaissements_Edition_Facture_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        Dim ConfigXml As New XmlDocument
        ConfigXml.Load(Application.StartupPath + "\InfoPro.xml")
        Dim nodeliste As XmlNodeList
        nodeliste = ConfigXml.GetElementsByTagName("Quittance")
        EnTete_RichTextBox.Text = nodeliste.Item(0).Item("EnTete").InnerText
        PiedPage_RichTextBox.Text = nodeliste.Item(0).Item("PiedPage").InnerText
    End Sub





End Class