Browse Source

Merge branch 'feature/PGER_Step01' into develop

Patrick Germain 8 months ago
parent
commit
4d2596b973

+ 28 - 28
Convert/Program.cs

@@ -14,43 +14,43 @@ namespace Convert
         private static string Folder { get;  set; } 
         static void Main(string[] args)
         {
-            Folder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\AsoFuel";
-            DataSet1.tb_epreuveDataTable tb_epr = new DataSet1.tb_epreuveDataTable();
+            //Folder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\AsoFuel";
+            //DataSet1.tb_epreuveDataTable tb_epr = new DataSet1.tb_epreuveDataTable();
 
-            tb_epr.Clear();
-            tb_epr.ReadXml(Path.Combine(Folder,"epreuve.xml"));
-            SaveToJson<DataSet1.tb_epreuveDataTable>(Path.Combine(Folder, "epreuve.json"), tb_epr);
+            //tb_epr.Clear();
+            //tb_epr.ReadXml(Path.Combine(Folder,"epreuve.xml"));
+            //SaveToJson<DataSet1.tb_epreuveDataTable>(Path.Combine(Folder, "epreuve.json"), tb_epr);
 
-            foreach (var item in tb_epr.Rows) 
-            {
-                DataSet1.tb_epreuveRow myrow = item as DataSet1.tb_epreuveRow;
-                string key_epr = myrow["key_epr"].ToString();
-                Console.WriteLine(key_epr);
-                DataSet1.tb_stationDataTable tb_sta = new DataSet1.tb_stationDataTable();
-                tb_sta.Clear();
-                tb_sta.ReadXml(Path.Combine(Folder, key_epr,"station.xml"));
-                SaveToJson<DataSet1.tb_stationDataTable>(Path.Combine(Folder, key_epr, "station.json"), tb_sta);
+            //foreach (var item in tb_epr.Rows) 
+            //{
+            //    DataSet1.tb_epreuveRow myrow = item as DataSet1.tb_epreuveRow;
+            //    string key_epr = myrow["key_epr"].ToString();
+            //    Console.WriteLine(key_epr);
+            //    DataSet1.tb_stationDataTable tb_sta = new DataSet1.tb_stationDataTable();
+            //    tb_sta.Clear();
+            //    tb_sta.ReadXml(Path.Combine(Folder, key_epr,"station.xml"));
+            //    SaveToJson<DataSet1.tb_stationDataTable>(Path.Combine(Folder, key_epr, "station.json"), tb_sta);
 
                 DataSet1.tb_vehiDataTable tb_vehi = new DataSet1.tb_vehiDataTable();
                 tb_vehi.Clear();
-                tb_vehi.ReadXml(Path.Combine(Folder, key_epr, "vehicule.xml"));
-                SaveToJson<DataSet1.tb_vehiDataTable>(Path.Combine(Folder, key_epr, "vehicule.json"), tb_vehi);
+                tb_vehi.ReadXml(Path.Combine("c:\\tmp", "vehicule.xml"));
+                SaveToJson<DataSet1.tb_vehiDataTable>(Path.Combine("c:\\tmp", "vehicule.json"), tb_vehi);
 
-                DataSet1.tb_prestaDataTable tb_presta = new DataSet1.tb_prestaDataTable();
-                tb_presta.Clear();
-                tb_presta.ReadXml(Path.Combine(Folder, key_epr, "presta_base.xml"));
-                SaveToJson<DataSet1.tb_prestaDataTable>(Path.Combine(Folder, key_epr, "presta_base.json"), tb_presta);
+            //    DataSet1.tb_prestaDataTable tb_presta = new DataSet1.tb_prestaDataTable();
+            //    tb_presta.Clear();
+            //    tb_presta.ReadXml(Path.Combine(Folder, key_epr, "presta_base.xml"));
+            //    SaveToJson<DataSet1.tb_prestaDataTable>(Path.Combine(Folder, key_epr, "presta_base.json"), tb_presta);
 
-                tb_presta.Clear();
-                tb_presta.ReadXml(Path.Combine(Folder, key_epr, "presta.xml"));
-                SaveToJson<DataSet1.tb_prestaDataTable>(Path.Combine(Folder, key_epr, "presta.json"), tb_presta);
+            //    tb_presta.Clear();
+            //    tb_presta.ReadXml(Path.Combine(Folder, key_epr, "presta.xml"));
+            //    SaveToJson<DataSet1.tb_prestaDataTable>(Path.Combine(Folder, key_epr, "presta.json"), tb_presta);
 
-                DataSet1.tb_venteDataTable tb_vente = new DataSet1.tb_venteDataTable();
-                tb_vente.Clear();
-                tb_vente.ReadXml(Path.Combine(Folder, key_epr, "vente.xml"));
-                SaveToJson<DataSet1.tb_venteDataTable>(Path.Combine(Folder, key_epr, "vente.json"), tb_vente);
+            //    DataSet1.tb_venteDataTable tb_vente = new DataSet1.tb_venteDataTable();
+            //    tb_vente.Clear();
+            //    tb_vente.ReadXml(Path.Combine(Folder, key_epr, "vente.xml"));
+            //    SaveToJson<DataSet1.tb_venteDataTable>(Path.Combine(Folder, key_epr, "vente.json"), tb_vente);
 
-            }                                                               
+            //}                                                               
 
         }
 

+ 0 - 282
Fuel_ASO/Classes.cs

@@ -1,282 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Fuel01
-{
-
-    public class HubMessage
-    {
-        public string Action { get; set; }
-        public string Source { get; set; }
-        public string Description { get; set; }
-        public string Valeur { get; set; }
-        public string[] Destinataires { get; set; }
-        public string Date { get; set; }
-
-        public HubMessage()
-        {
-            Action = "";
-        }
-
-    }
-
-    public class Achats
-    {
-        public int StationId { get; set; }
-        public String Bandeau { get; set; }
-        public DateTime Date { get; set; }
-        public String KindCarbu { get; set; }
-        public float Volume { get; set; }
-        public float PrixCarbu { get; set; }
-        public float MontantCarbu { get; set; }
-
-        public List<PrestasFournies> Prestas { get; set; }
-
-        public float MontantTotal { get; set; }
-        public float TxTva { get; set; }
-
-    }
-
-    public class PrestasFournies
-    {
-        public String Libel { get; set; }
-        public String Name { get; set; }
-        public float Quantity { get; set; }
-        public float PrixUnitaire { get; set; }
-        public float Total { get; set; }
-        public float TxTva { get; set; }
-    }
-
-
-    public class vehi_achat
-    {
-        public string keyvehi_achat { get; set; }
-        public string date_achat { get; set; }
-        public string KindCarbu_achat { get; set; }
-        public float Volume_achat { get; set; }
-        public float PrixCarbu_achat { get; set; }
-        public float MontantCarbu_achat { get; set; }
-        public List<Presta_achat> Prestas_achat { get; set; }
-        public float TxTva_achat { get; set; }
-
-
-    }
-
-    public class Presta_achat
-    {
-        public string name_presta { get; set; }
-        public float Quantity_presta { get; set; }
-        public float PrixUnitaire_presta { get; set; }
-        public float TxTva_presta { get; set; }
-
-    }
-
-    public class pays
-    {
-        public string key_pays { get; set; }
-        public string nom_pays { get; set; }
-        public string code_pays { get; set; }
-        public string concat_pays { get; set; }
-    }
-
-    public class produit
-    {
-        public string key_prod { get; set; }
-        public string lib_prod { get; set; }
-        public string type_prod { get; set; }
-    }
-
-    public class famille
-    {
-        public string key_fam { get; set; }
-    }
-
-    public class vehicule
-    {
-        public string key_vehi { get; set; }
-        public string ope_vehi { get; set; }        
-        public string num_vehi { get; set; }           
-        public string cmpnum_vehi { get; set; }
-        public string immat_vehi { get; set; }
-        public string type_vehi { get; set; }
-        public bool ok_vehi { get; set; }
-        public string carbu_vehi { get; set; }
-        public int kmdep_vehi { get; set; }
-        public int kmarr_vehi { get; set; }
-        public string cond_vehi { get; set; }
-        public string famille_vehi { get; set; }
-        public string order_vehi { get; set; }
-           
-        public vehicule()
-        {           
-        }
-        public vehicule(string _key)
-        {
-            key_vehi = _key;
-        }
-        public vehicule(vehicule orig)
-        {
-            key_vehi = orig.key_vehi;
-            ope_vehi = orig.ope_vehi;
-            num_vehi = orig.num_vehi;
-            cmpnum_vehi = orig.cmpnum_vehi;
-            immat_vehi = orig.immat_vehi;
-            type_vehi = orig.type_vehi;
-            ok_vehi = orig.ok_vehi;
-            carbu_vehi = orig.carbu_vehi;
-            kmdep_vehi = orig.kmdep_vehi;
-            kmarr_vehi = orig.kmarr_vehi;
-            cond_vehi = orig.cond_vehi;
-            famille_vehi = orig.famille_vehi;
-            order_vehi = orig.order_vehi;
-        }
-        public void maj_vehi()
-        {
-            order_vehi = (num_vehi == null ? " ".PadLeft(5) : num_vehi.PadLeft(5)) + (cmpnum_vehi == null ? " ".PadLeft(5) : cmpnum_vehi.PadLeft(5));
-        }
-        public string ToLigne()
-        {
-            string ret = "";
-            ret = string.Format("{0}##^##{1}##^##{2}##^##{3}##^##{4}##^##{5}##^##{6}##^##{7}##^##{8}##^##{9}##^##{10}##^##{11}##^##",
-                           key_vehi,
-                           ope_vehi,
-                           num_vehi,
-                           cmpnum_vehi,
-                           immat_vehi,
-                           type_vehi,
-                           ok_vehi,
-                           carbu_vehi,
-                           kmdep_vehi,
-                           kmarr_vehi,
-                           cond_vehi,
-                           famille_vehi);
-
-            return ret;
-
-        }
-
-    }
-
-    public class TVI
-    {
-        private List<vehicule> Vehis;
-
-        public TVI()
-        {
-            Vehis = new List<vehicule>();
-            loadData_Vehi();
-        }
-
-        public List<vehicule> GetVehi()
-        {
-            var cont = (from vi in Vehis
-                        orderby vi.num_vehi
-                        select vi).ToList();
-            return cont;
-
-        }
-
-        private bool loadData_Vehi()
-        {
-            bool ret = false;
-            string path = @"c:\temp\MyTest.txt";
-            try
-            {
-                string[] lignes = File.ReadAllLines(path);
-                foreach (string lig in lignes)
-                {
-                    string[] val = lig.Split(new string[] { "##^##" }, StringSplitOptions.None);
-                    vehicule vi = new vehicule
-                    {
-                        key_vehi = val[0],
-                        ope_vehi = val[1],
-                        num_vehi = val[2],
-                        cmpnum_vehi = val[3],
-                        immat_vehi = val[4],
-                        type_vehi = val[5],
-                        ok_vehi = val[6] == "true",
-                        carbu_vehi = val[7],
-                        kmdep_vehi = Convert.ToInt32(val[8]),
-                        kmarr_vehi = Convert.ToInt32(val[9]),
-                        cond_vehi = val[10],
-                        famille_vehi = val[11]
-                    };
-                    Vehis.Add(vi);
-                }
-                ret = true;
-            }
-            catch (Exception ex)
-            {
-                ret = false;
-            }
-            return ret;
-        }
-
-    }
-
-    public class id_prod
-    {
-        public string type_pro { get; set; }
-        public string code_pro { get; set; }
-        public decimal ttc_pro { get; set; }
-        public decimal tva_pro { get; set; }
-        public string lib_pro { get; set; }
-
-    }
-    class vente_tot
-    {
-        public DataSet1.tb_venteRow vente { get; set; }
-        public decimal total_qtt { get; set; }
-        public decimal total_ht { get; set; }
-        public decimal total_ttc { get; set; }
-    }
-
-    class vente_tva
-    {
-        public decimal taux_tva { get; set; }
-        public decimal base_tva { get; set; }
-        public decimal mnt_tva { get; set; }
-        public decimal mnt_ttc { get; set; }
-    }
-    class ProdEqualityComparer : IEqualityComparer<id_prod>
-    {
-        public bool Equals(id_prod b1, id_prod b2)
-        {
-            if (b2 == null && b1 == null)
-                return true;
-            else if (b1 == null | b2 == null)
-                return false;
-            else if (b1.code_pro == b2.code_pro &
-                        b1.lib_pro== b2.lib_pro &
-                        b1.ttc_pro == b2.ttc_pro &
-                        b1.tva_pro == b2.tva_pro &
-                        b1.type_pro == b2.type_pro )
-                return true;
-            else
-                return false;
-        }
-
-        public int GetHashCode(id_prod bx)
-        {
-            int hCode = 0;
-            //for (int i = 0; i < bx.code_pro.Length; i++)
-            //    hCode += bx.code_pro[i];
-            //for (int i = 0; i < bx.lib_pro.Length; i++)
-            //    hCode += bx.lib_pro[i];
-            hCode += bx.code_pro.GetHashCode();
-            hCode += bx.lib_pro.GetHashCode();
-            hCode += bx.type_pro.GetHashCode();
-            hCode += (int)(bx.ttc_pro * 100);
-            hCode += (int)(bx.tva_pro * 100);
-            Console.WriteLine(string.Format(" Hash:{0} Prod:{1}  Prix:{2}  Tva:{3} Hash2:{4} ", bx.GetHashCode(), bx.code_pro, bx.ttc_pro, bx.tva_pro, hCode.GetHashCode()));
-            return hCode.GetHashCode();
-
-            //return bx.GetHashCode();
-        }
-    }
-
-}

+ 93 - 1
Fuel_ASO/DbUtil.cs

@@ -1,4 +1,5 @@
-using Newtonsoft.Json;
+using Fuel01.Models;
+using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -42,6 +43,97 @@ namespace Fuel01
 
         }
 
+        public static DataSet1.tb_prestaDataTable LoadPrestaFromJson(string filename,List<Produit> lprod)
+        {
+            if (!File.Exists(filename))
+            {
+                return default;
+            }
+
+            var datas = File.ReadAllText(filename);
+
+            var tmData = JsonConvert.DeserializeObject<List<PrestaSta>>(datas);
+            var prestas = new List<Presta>();
+            foreach (var data in tmData) 
+            {
+                if (data.autres != null)
+                {
+                    foreach (var autre in data.autres)
+                    {
+                        var prod= lprod.FirstOrDefault(x=>x.lib_prod.Equals(autre.lib_prod))?.key_prod;
+                        if (prod != null)
+                        {
+                            var presta = new Presta();
+                            presta.sta_pr = data.sta_pr;
+                            presta.prod_pr = prod;
+                            presta.kind_pr = "Service";
+                            presta.unite_pr = autre.unite_pr;
+                            presta.pu_pr = double.Parse(autre.pu_pr);
+                            presta.tva_pr = double.Parse(autre.tva_pr);
+                            presta.ttc_pr = double.Parse(autre.ttc_pr);
+                            prestas.Add(presta);
+                        }
+                    }
+                }
+                if (data.carburants != null)
+                {
+                    foreach (var autre in data.carburants)
+                    {
+                        var prod = lprod.FirstOrDefault(x => x.lib_prod.Equals(autre.lib_prod))?.key_prod;
+                        if (prod != null)
+                        {
+                            var presta = new Presta();
+                            presta.sta_pr = data.sta_pr;
+                            presta.prod_pr = prod;
+                            presta.kind_pr = "Carburant";
+                            presta.unite_pr = autre.unite_pr;
+                            presta.pu_pr = double.Parse(autre.pu_pr);
+                            presta.tva_pr = double.Parse(autre.tva_pr);
+                            presta.ttc_pr = double.Parse(autre.ttc_pr);
+                            prestas.Add(presta);
+                        }
+                    }
+                }
+            }
+            var json = JsonConvert.SerializeObject(prestas, Formatting.Indented);
+
+            var returnData = JsonConvert.DeserializeObject<DataSet1.tb_prestaDataTable>(json);
+
+            return returnData;
+
+        }
+
+
+        public static T LoadFromJson<T>(string filename)
+        {
+            if (!File.Exists(filename))
+            {
+                return default(T);
+            }
+
+            var datas = File.ReadAllText(filename);
+
+            var tmData = JsonConvert.DeserializeObject<T>(datas);
+
+            return tmData;
+
+        }
+
+        public static bool SaveToJson(object o,string filename)
+        {
+            try
+            {
+                var result = JsonConvert.SerializeObject(o, Formatting.Indented);
+                File.WriteAllText(filename, result);
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        }
+
+
         public static bool SaveToJson<T>(string filename, T ds)
         {
             try

+ 17 - 2
Fuel_ASO/Fuel_ASO.csproj

@@ -141,6 +141,7 @@
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Net.Http" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="System.Data" />
@@ -150,7 +151,11 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Classes.cs" />
+    <Compile Include="Models\Achats.cs" />
+    <Compile Include="Models\Achats3.cs" />
+    <Compile Include="Models\Presta.cs" />
+    <Compile Include="Models\PrestaSta.cs" />
+    <Compile Include="Models\ProdEqualityComparer.cs" />
     <Compile Include="DataSet1.cs">
       <DependentUpon>DataSet1.xsd</DependentUpon>
     </Compile>
@@ -262,7 +267,17 @@
     <Compile Include="f_ticket.Designer.cs">
       <DependentUpon>f_ticket.cs</DependentUpon>
     </Compile>
+    <Compile Include="Models\Famille.cs" />
+    <Compile Include="Models\HubMessage.cs" />
+    <Compile Include="Models\IdProd.cs" />
+    <Compile Include="Models\Pays.cs" />
+    <Compile Include="Models\PrestasFournies.cs" />
+    <Compile Include="Models\Produit.cs" />
+    <Compile Include="Models\Vehicule.cs" />
+    <Compile Include="Models\VenteTot.cs" />
+    <Compile Include="Models\VenteTva.cs" />
     <Compile Include="Settings.cs" />
+    <Compile Include="TdfFile.cs" />
     <Compile Include="Utils.cs" />
     <Compile Include="xmlvrac.cs">
       <SubType>Form</SubType>
@@ -413,7 +428,7 @@
   </PropertyGroup>
   <ProjectExtensions>
     <VisualStudio>
-      <UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_StartDate="2018/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_UseUniversalClock="True" BuildVersion_BuildVersioningStyle="None.None.YearDayOfYearStamp.Increment" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_IncrementBeforeBuild="False" BuildVersion_DetectChanges="False" />
+      <UserProperties BuildVersion_DetectChanges="False" BuildVersion_IncrementBeforeBuild="False" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_BuildVersioningStyle="None.None.YearDayOfYearStamp.Increment" BuildVersion_UseUniversalClock="True" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2018/1/1" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
     </VisualStudio>
   </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 29 - 45
Fuel_ASO/Main.Designer.cs

@@ -110,10 +110,10 @@
             this.eprstat,
             this.stastat,
             this.tslbl1});
-            this.statusBar.Location = new System.Drawing.Point(0, 556);
+            this.statusBar.Location = new System.Drawing.Point(0, 354);
             this.statusBar.Name = "statusBar";
-            this.statusBar.Padding = new System.Windows.Forms.Padding(2, 0, 15, 0);
-            this.statusBar.Size = new System.Drawing.Size(1147, 22);
+            this.statusBar.Padding = new System.Windows.Forms.Padding(1, 0, 10, 0);
+            this.statusBar.Size = new System.Drawing.Size(765, 22);
             this.statusBar.TabIndex = 0;
             this.statusBar.Text = "statusStrip1";
             // 
@@ -152,7 +152,6 @@
             // 
             this.tbepreuveBindingSource.DataMember = "tb_epreuve";
             this.tbepreuveBindingSource.DataSource = this.dataSet1;
-            this.tbepreuveBindingSource.CurrentChanged += new System.EventHandler(this.tbepreuveBindingSource_CurrentChanged);
             // 
             // vehiculeBindingSource
             // 
@@ -169,7 +168,6 @@
             // 
             this.mainContainer.Dock = System.Windows.Forms.DockStyle.Fill;
             this.mainContainer.Location = new System.Drawing.Point(0, 0);
-            this.mainContainer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.mainContainer.Name = "mainContainer";
             this.mainContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
             // 
@@ -180,9 +178,8 @@
             // mainContainer.Panel2
             // 
             this.mainContainer.Panel2.Controls.Add(this.splitContainer1);
-            this.mainContainer.Size = new System.Drawing.Size(1147, 556);
-            this.mainContainer.SplitterDistance = 41;
-            this.mainContainer.SplitterWidth = 6;
+            this.mainContainer.Size = new System.Drawing.Size(765, 354);
+            this.mainContainer.SplitterDistance = 26;
             this.mainContainer.TabIndex = 13;
             // 
             // main_mnu
@@ -200,9 +197,8 @@
             this.mnu_about});
             this.main_mnu.Location = new System.Drawing.Point(0, 0);
             this.main_mnu.Name = "main_mnu";
-            this.main_mnu.Padding = new System.Windows.Forms.Padding(0, 0, 3, 0);
             this.main_mnu.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
-            this.main_mnu.Size = new System.Drawing.Size(1147, 34);
+            this.main_mnu.Size = new System.Drawing.Size(765, 34);
             this.main_mnu.TabIndex = 12;
             this.main_mnu.Text = "Menu";
             // 
@@ -346,7 +342,7 @@
             // 
             this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
             this.splitContainer1.Location = new System.Drawing.Point(0, 0);
-            this.splitContainer1.Margin = new System.Windows.Forms.Padding(45, 46, 45, 46);
+            this.splitContainer1.Margin = new System.Windows.Forms.Padding(30, 30, 30, 30);
             this.splitContainer1.Name = "splitContainer1";
             // 
             // splitContainer1.Panel1
@@ -356,9 +352,8 @@
             // splitContainer1.Panel2
             // 
             this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
-            this.splitContainer1.Size = new System.Drawing.Size(1147, 509);
-            this.splitContainer1.SplitterDistance = 379;
-            this.splitContainer1.SplitterWidth = 6;
+            this.splitContainer1.Size = new System.Drawing.Size(765, 324);
+            this.splitContainer1.SplitterDistance = 252;
             this.splitContainer1.TabIndex = 10;
             // 
             // splitContainer3
@@ -366,7 +361,6 @@
             this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
             this.splitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
             this.splitContainer3.Location = new System.Drawing.Point(0, 0);
-            this.splitContainer3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.splitContainer3.Name = "splitContainer3";
             this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
             // 
@@ -381,9 +375,8 @@
             this.splitContainer3.Panel2.Controls.Add(this.bt_retry);
             this.splitContainer3.Panel2.Controls.Add(this.bt_test);
             this.splitContainer3.Panel2.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.splitContainer3_Panel2_MouseDoubleClick);
-            this.splitContainer3.Size = new System.Drawing.Size(379, 509);
-            this.splitContainer3.SplitterDistance = 455;
-            this.splitContainer3.SplitterWidth = 6;
+            this.splitContainer3.Size = new System.Drawing.Size(252, 324);
+            this.splitContainer3.SplitterDistance = 270;
             this.splitContainer3.TabIndex = 1;
             // 
             // dg_epr
@@ -399,12 +392,11 @@
             this.dg_epr.DataSource = this.tbepreuveBindingSource;
             this.dg_epr.Dock = System.Windows.Forms.DockStyle.Fill;
             this.dg_epr.Location = new System.Drawing.Point(0, 0);
-            this.dg_epr.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.dg_epr.Name = "dg_epr";
             this.dg_epr.ReadOnly = true;
             this.dg_epr.RowHeadersWidth = 62;
             this.dg_epr.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
-            this.dg_epr.Size = new System.Drawing.Size(379, 455);
+            this.dg_epr.Size = new System.Drawing.Size(252, 270);
             this.dg_epr.TabIndex = 6;
             this.dg_epr.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dg_epr_CellMouseDoubleClick);
             // 
@@ -440,10 +432,9 @@
             // bt_doAll
             // 
             this.bt_doAll.Dock = System.Windows.Forms.DockStyle.Left;
-            this.bt_doAll.Location = new System.Drawing.Point(225, 0);
-            this.bt_doAll.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.bt_doAll.Location = new System.Drawing.Point(150, 0);
             this.bt_doAll.Name = "bt_doAll";
-            this.bt_doAll.Size = new System.Drawing.Size(75, 48);
+            this.bt_doAll.Size = new System.Drawing.Size(50, 50);
             this.bt_doAll.TabIndex = 4;
             this.bt_doAll.Text = "ALL";
             this.bt_doAll.UseVisualStyleBackColor = true;
@@ -453,10 +444,9 @@
             // bt_do
             // 
             this.bt_do.Dock = System.Windows.Forms.DockStyle.Left;
-            this.bt_do.Location = new System.Drawing.Point(150, 0);
-            this.bt_do.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.bt_do.Location = new System.Drawing.Point(100, 0);
             this.bt_do.Name = "bt_do";
-            this.bt_do.Size = new System.Drawing.Size(75, 48);
+            this.bt_do.Size = new System.Drawing.Size(50, 50);
             this.bt_do.TabIndex = 3;
             this.bt_do.Text = "Do";
             this.bt_do.UseVisualStyleBackColor = true;
@@ -466,10 +456,9 @@
             // bt_retry
             // 
             this.bt_retry.Dock = System.Windows.Forms.DockStyle.Left;
-            this.bt_retry.Location = new System.Drawing.Point(75, 0);
-            this.bt_retry.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.bt_retry.Location = new System.Drawing.Point(50, 0);
             this.bt_retry.Name = "bt_retry";
-            this.bt_retry.Size = new System.Drawing.Size(75, 48);
+            this.bt_retry.Size = new System.Drawing.Size(50, 50);
             this.bt_retry.TabIndex = 1;
             this.bt_retry.Text = "ReTry SigR";
             this.bt_retry.UseVisualStyleBackColor = true;
@@ -480,9 +469,8 @@
             // 
             this.bt_test.Dock = System.Windows.Forms.DockStyle.Left;
             this.bt_test.Location = new System.Drawing.Point(0, 0);
-            this.bt_test.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_test.Name = "bt_test";
-            this.bt_test.Size = new System.Drawing.Size(75, 48);
+            this.bt_test.Size = new System.Drawing.Size(50, 50);
             this.bt_test.TabIndex = 0;
             this.bt_test.Text = "Msg test";
             this.bt_test.UseVisualStyleBackColor = true;
@@ -494,7 +482,6 @@
             this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
             this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
             this.splitContainer2.Location = new System.Drawing.Point(0, 0);
-            this.splitContainer2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.splitContainer2.Name = "splitContainer2";
             this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
             // 
@@ -506,9 +493,8 @@
             // 
             this.splitContainer2.Panel2.Controls.Add(this.text_file);
             this.splitContainer2.Panel2.Controls.Add(this.bt_fact);
-            this.splitContainer2.Size = new System.Drawing.Size(762, 509);
-            this.splitContainer2.SplitterDistance = 455;
-            this.splitContainer2.SplitterWidth = 6;
+            this.splitContainer2.Size = new System.Drawing.Size(509, 324);
+            this.splitContainer2.SplitterDistance = 270;
             this.splitContainer2.TabIndex = 0;
             // 
             // dg_sta
@@ -525,12 +511,11 @@
             this.dg_sta.DataSource = this.tbstationBindingSource;
             this.dg_sta.Dock = System.Windows.Forms.DockStyle.Fill;
             this.dg_sta.Location = new System.Drawing.Point(0, 0);
-            this.dg_sta.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.dg_sta.Name = "dg_sta";
             this.dg_sta.ReadOnly = true;
             this.dg_sta.RowHeadersWidth = 62;
             this.dg_sta.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
-            this.dg_sta.Size = new System.Drawing.Size(762, 455);
+            this.dg_sta.Size = new System.Drawing.Size(509, 270);
             this.dg_sta.TabIndex = 7;
             this.dg_sta.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dg_sta_CellMouseDoubleClick);
             // 
@@ -576,20 +561,18 @@
             // 
             // text_file
             // 
-            this.text_file.Location = new System.Drawing.Point(4, 17);
-            this.text_file.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.text_file.Location = new System.Drawing.Point(3, 11);
             this.text_file.Name = "text_file";
-            this.text_file.Size = new System.Drawing.Size(559, 26);
+            this.text_file.Size = new System.Drawing.Size(374, 20);
             this.text_file.TabIndex = 3;
             this.text_file.Visible = false;
             // 
             // bt_fact
             // 
             this.bt_fact.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.bt_fact.Location = new System.Drawing.Point(629, 15);
-            this.bt_fact.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.bt_fact.Location = new System.Drawing.Point(420, 10);
             this.bt_fact.Name = "bt_fact";
-            this.bt_fact.Size = new System.Drawing.Size(112, 35);
+            this.bt_fact.Size = new System.Drawing.Size(75, 23);
             this.bt_fact.TabIndex = 0;
             this.bt_fact.Text = "Facture";
             this.bt_fact.UseVisualStyleBackColor = true;
@@ -603,13 +586,14 @@
             // 
             // Main
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1147, 578);
+            this.ClientSize = new System.Drawing.Size(765, 376);
             this.Controls.Add(this.mainContainer);
             this.Controls.Add(this.statusBar);
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.IsMdiContainer = true;
+            this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.Name = "Main";
             this.Tag = "vide";
             this.Text = "Aucune opération sélectionnée";

+ 48 - 66
Fuel_ASO/Main.cs

@@ -1,17 +1,15 @@
-using System;
+using Ionic.Utils.Zip;
+using Microsoft.AspNet.SignalR.Client;
+using System;
 using System.Collections.Generic;
+using System.Data;
 using System.IO;
 using System.Net;
+using System.Reflection;
 using System.Text;
+using System.Threading.Tasks;
 using System.Windows.Forms;
-using System.Xml.Serialization;
-using System.Xml.Linq;
-using System.Data;
 using Excel = Microsoft.Office.Interop.Excel;
-using Microsoft.AspNet.SignalR.Client;
-using Ionic.Utils.Zip;
-using System.Reflection;
-using System.Threading.Tasks;
 
 namespace Fuel01
 {
@@ -84,18 +82,15 @@ namespace Fuel01
             }
             tbepreuveBindingSource.DataSource = tb_epr;
             refreshData(1);
-            
-            tbepreuveBindingSource.PositionChanged += new System.EventHandler(this.tbepreuveBindingSource_PositionChanged);
 
-           
-            //PGER init_signalR();
+            tbepreuveBindingSource.PositionChanged += new System.EventHandler(this.tbepreuveBindingSource_PositionChanged);
 
             if (tb_epr.Rows.Count >= 1)
             {
                 tbepreuveBindingSource.MoveLast();
                 tbepreuveBindingSource.MoveFirst();
             }
-            mnu_vehi_imp.Enabled = Program.isExcel = true ;
+            mnu_vehi_imp.Enabled = Program.isExcel = true;
             spy();
         }
 
@@ -128,8 +123,6 @@ namespace Fuel01
             else
 
                 toolStripStatusLabel1.Image = global::Fuel01.Properties.Resources.red;
-
-            //toolStripStatusLabel1.Visible = (toolStripStatusLabel1.Text == "OK");
         }
 
 
@@ -138,11 +131,6 @@ namespace Fuel01
         #region Menu Principal
 
         #region operations
-
-        private void opérationToolStripMenuItem_Click(object sender, EventArgs e)
-        {
-        }
-
         private void mnu_ope_Click(object sender, EventArgs e)
         {
             f_epreuve fepr = new f_epreuve(tb_epr);
@@ -164,14 +152,14 @@ namespace Fuel01
 
         private void mnu_vehi_imp_parc_Click(object sender, EventArgs e)
         {
-            f_impvehi fvehi = new f_impvehi("parc");
+            F_impvehi fvehi = new F_impvehi("parc");
             fvehi.ShowDialog();
 
         }
 
         private void mnu_vehi_imp_tdf_Click(object sender, EventArgs e)
         {
-            f_impvehi fvehi = new f_impvehi("tdf");
+            F_impvehi fvehi = new F_impvehi("tdf");
             fvehi.ShowDialog();
 
         }
@@ -254,15 +242,19 @@ namespace Fuel01
             try
             {
                 try
-                { hostname = Dns.GetHostName(); }
-                catch (Exception ex)
-                { hostname = "inconnu"; }
+                {
+                    hostname = Dns.GetHostName();
+                }
+                catch (Exception)
+                {
+                    hostname = "inconnu";
+                }
 
                 if (Program.site != 1) return;
-             
+
                 Dictionary<string, string> queryStringData = new Dictionary<string, string>();
                 mySignalRiD = DateTime.Now.Ticks.ToString();
-                mySignalRiD= mySignalRiD.Substring(mySignalRiD.Length-5);
+                mySignalRiD = mySignalRiD.Substring(mySignalRiD.Length - 5);
                 mySignalRiD = hostname + "__" + mySignalRiD;
                 queryStringData.Add("Login", mySignalRiD);
                 try
@@ -288,7 +280,7 @@ namespace Fuel01
                 }
                 catch (Exception ee)
                 {
-                    Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() +  " Connexion à " + srv+ " impossible " + ee.Message);
+                    Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() + " Connexion à " + srv + " impossible " + ee.Message);
                     myHubproxy = null;
                     Program.okSignalR = false;
                     toolStripStatusLabel1.Text = "NOK";
@@ -314,7 +306,7 @@ namespace Fuel01
                 Program.okSignalR = true;
                 toolStripStatusLabel1.Text = "OK";
             }
-            Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() +  " de " + obj.OldState.ToString() + " à " + obj.NewState.ToString() );
+            Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() + " de " + obj.OldState.ToString() + " à " + obj.NewState.ToString());
 
         }
 
@@ -324,24 +316,19 @@ namespace Fuel01
             switch (hubmsg.Action)
             {
                 case "maj":
-
                     break;
                 case "msg":
-                    string msg = hubmsg.Source + "/" + hubmsg.Action + "/" + hubmsg.Description + "/" + hubmsg.Valeur;
                     if (hubmsg.Description == "send")
                     {
                         if (hubmsg.Source != mySignalRiD)
-                            sendFile(hubmsg.Valeur);
+                            SendFile(hubmsg.Valeur);
                     }
                     else
                         MessageBox.Show(String.Format("Message de {0} \r\n {1} \r\n \r\n {2}", hubmsg.Source, hubmsg.Valeur, hubmsg.Date.ToString()), "SMS ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     break;
                 case "cnx":
-                    //majusers(hubmsg.Valeur);
-                    //MessageBox.Show(hubmsg.Valeur);
                     break;
             }
-            //makeTdo();
 
         }
 
@@ -361,7 +348,7 @@ namespace Fuel01
             }
             catch (Exception ex)
             {
-                Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() + " Send_msg  Action:"+action+" Valeur:"+valeur+" Desc:"+description+"  "+ex.Message);
+                Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() + " Send_msg  Action:" + action + " Valeur:" + valeur + " Desc:" + description + "  " + ex.Message);
             }
         }
 
@@ -394,7 +381,7 @@ namespace Fuel01
                         tbstationBindingSource.DataSource = tb_station;
                         Console.WriteLine(tb_station.Count);
                     }
-                        //tb_station.ReadXml(Program.subfolder + @"\station.xml");
+                    //tb_station.ReadXml(Program.subfolder + @"\station.xml");
                 }
                 //tbstationBindingSource.DataSource = tb_station;
                 eprstat.Text = mydata.key_epr + "-" + mydata.abrev_epr + "-" + mydata.nom_epr;
@@ -409,7 +396,7 @@ namespace Fuel01
 
             if (indice == 1)
             {
-                tb_epr=DbUtil.LoadFromJson<DataSet1.tb_epreuveDataTable>(Program.folder + @"\epreuve.json", tb_epr);
+                tb_epr = DbUtil.LoadFromJson<DataSet1.tb_epreuveDataTable>(Program.folder + @"\epreuve.json", tb_epr);
                 tbepreuveBindingSource.DataSource = tb_epr;
                 Console.WriteLine(tb_epr.Count);
                 if (string.IsNullOrEmpty(Program.key_ope))
@@ -429,13 +416,6 @@ namespace Fuel01
                     this.Tag = Program.key_ope;
 
                     tbepreuveBindingSource.MoveFirst();
-                    DataRowView myRow2 = tbepreuveBindingSource.Current as DataRowView;
-                    if (myRow2 != null)
-                        while (myRow2 != null && myRow2.Row["key_epr"].ToString() != myrow["key_epr"].ToString())
-                        {
-                            tbepreuveBindingSource.MoveNext();
-                            myRow2 = myRow2 = tbepreuveBindingSource.Current as DataRowView;
-                        }
                 }
                 tbepreuveBindingSource.PositionChanged += new System.EventHandler(this.tbepreuveBindingSource_PositionChanged);
                 Program.subfolder = Program.folder + @"\" + Program.key_ope;
@@ -495,7 +475,7 @@ namespace Fuel01
                 fw.Renamed += Fw_Spy;
                 fw.EnableRaisingEvents = true;
             }
-            catch (Exception ex)
+            catch (Exception )
             {
                 tslbl1.Text = "  Surveillance du répertoire de réception impossible !!!";
             }
@@ -523,29 +503,31 @@ namespace Fuel01
         private void button2_Click(object sender, EventArgs e)
         {
             if (!Program.okSignalR)
-                init_signalR();
+                init_signalR().Wait();
         }
 
         int timerCount = 0;
-        int sigRCount = 0;
+
         private void timerSigR_Tick(object sender, EventArgs e)
         {
             timerSigR.Interval = 60000;
             if (!Program.okSignalR)
-                init_signalR();
-            if ( checkVersion_activated && timerCount%5==0)
+            {
+                _ = init_signalR();
+            }
+            if (checkVersion_activated && timerCount % 5 == 0)
                 checkVersion();
 
             timerCount++;
 
         }
 
-        private void sendFile(string fileName)
+        private static void SendFile(string fileName)
         {
             string chaine = @"http://www.aformatix.com/stationservice/api/FileUpLoad/upLoadFiles";
             WebClient client = new WebClient();
-            //fileName = @"C:\ProgramData\ASOFuel\7516\" + fileName;
             client.UploadFileAsync(new Uri(chaine), "POST", fileName);
+            client.Dispose();
 
         }
 
@@ -568,7 +550,7 @@ namespace Fuel01
         private void actZip(string seek)
         {
             string path = "";
-            string mask="";
+            string mask = "";
             try
             {
                 path = seek.Substring(0, seek.LastIndexOf("\\"));
@@ -594,7 +576,7 @@ namespace Fuel01
             }
             catch (Exception ex)
             {
-                Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() + " Err Make zip - seek:" + seek + "  Path:" + path +"  Mask:"+mask+"\r\n"+ex.Message);
+                Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() + " Err Make zip - seek:" + seek + "  Path:" + path + "  Mask:" + mask + "\r\n" + ex.Message);
             }
 
         }
@@ -608,7 +590,7 @@ namespace Fuel01
         {
             string[] strVersion = AssemblyVersion.Split('.');
             double version = Convert.ToDouble(strVersion[0]) * 100000 + Convert.ToDouble(strVersion[1]) * 1000 + Convert.ToDouble(strVersion[2]) + Convert.ToDouble(strVersion[3]) / 10000;
-            
+
             WebRequest request = WebRequest.Create(Properties.Settings.Default.server_adress_bin + ".txt");
             try
             {
@@ -617,17 +599,20 @@ namespace Fuel01
                 string retour = sr.ReadToEnd();
                 sr.Close();
                 double baseVersion = 0;
-                if (double.TryParse(retour, out baseVersion))
-                    if (baseVersion > version)
-                        if (MessageBox.Show("Veuillez lancer la mise à jour depuis le bouton MAJ\r\nde la fenêtre A Propos.\r\n Pour ne plus voir ce message, cliquer sur Annuler.", "Nouvelle version disponible", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel)
-                            checkVersion_activated = false; ;
+                if (double.TryParse(retour, out baseVersion) && 
+                    baseVersion > version && 
+                    MessageBox.Show("Veuillez lancer la mise à jour depuis le bouton MAJ\r\nde la fenêtre A Propos.\r\n Pour ne plus voir ce message, cliquer sur Annuler.", "Nouvelle version disponible", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel )
+                {
+                    checkVersion_activated = false;
+                }
             }
-            catch (Exception e) {
-                Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() +"Check Version "+ e.Message);
+            catch (Exception e)
+            {
+                Program.traces(Program.folder + @"\tmp\traces.txt", DateTime.Now.ToString() + "Check Version " + e.Message);
             }
         }
 
-        public string AssemblyVersion
+        public static string AssemblyVersion
         {
             get
             {
@@ -643,14 +628,11 @@ namespace Fuel01
 
         private void parisNice17ToolStripMenuItem_Click(object sender, EventArgs e)
         {
-            f_impvehi fvehi = new f_impvehi("nice17");
+            F_impvehi fvehi = new F_impvehi("nice17");
             fvehi.ShowDialog();
 
         }
 
-        private void tbepreuveBindingSource_CurrentChanged(object sender, EventArgs e)
-        {
 
-        }
     }
 }

+ 24 - 0
Fuel_ASO/Models/Achats.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+
+namespace Fuel01
+{
+    public class Achats
+    {
+
+        public int StationId { get; set; }
+        public String Bandeau { get; set; }
+        public DateTime Date { get; set; }
+        public String KindCarbu { get; set; }
+        public float Volume { get; set; }
+        public float PrixCarbu { get; set; }
+        public float MontantCarbu { get; set; }
+
+        public List<PrestasFournies> Prestas { get; set; }
+
+        public float MontantTotal { get; set; }
+        public float TxTva { get; set; }
+
+    }
+
+}

+ 16 - 0
Fuel_ASO/Models/Achats3.cs

@@ -0,0 +1,16 @@
+namespace Fuel01
+{
+    public class Achats3
+    {
+        public int stationKey { get; set; }
+        public string bandeau { get; set; }
+        public string kindAchat { get; set; }
+        public string libel { get; set; }
+        public string moment { get; set; }
+        public float montantTTC { get; set; }
+        public string pu { get; set; }
+        public string qtty { get; set; }
+
+    }
+
+}

+ 8 - 0
Fuel_ASO/Models/Famille.cs

@@ -0,0 +1,8 @@
+namespace Fuel01
+{
+    public class Famille
+    {
+        public string key_fam { get; set; }
+    }
+
+}

+ 19 - 0
Fuel_ASO/Models/HubMessage.cs

@@ -0,0 +1,19 @@
+namespace Fuel01
+{
+    public class HubMessage
+    {
+        public string Action { get; set; }
+        public string Source { get; set; }
+        public string Description { get; set; }
+        public string Valeur { get; set; }
+        public string[] Destinataires { get; set; }
+        public string Date { get; set; }
+
+        public HubMessage()
+        {
+            Action = "";
+        }
+
+    }
+
+}

+ 13 - 0
Fuel_ASO/Models/IdProd.cs

@@ -0,0 +1,13 @@
+namespace Fuel01
+{
+    public class IdProd
+    {
+        public string type_pro { get; set; }
+        public string code_pro { get; set; }
+        public decimal ttc_pro { get; set; }
+        public decimal tva_pro { get; set; }
+        public string lib_pro { get; set; }
+
+    }
+
+}

+ 11 - 0
Fuel_ASO/Models/Pays.cs

@@ -0,0 +1,11 @@
+namespace Fuel01
+{
+    public class Pays
+    {
+        public string key_pays { get; set; }
+        public string nom_pays { get; set; }
+        public string code_pays { get; set; }
+        public string concat_pays { get; set; }
+    }
+
+}

+ 19 - 0
Fuel_ASO/Models/Presta.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel01.Models
+{
+    public class Presta
+    {
+        public string sta_pr { get; set; }
+        public string prod_pr { get; set; }
+        public string kind_pr { get; set; }
+        public string unite_pr { get; set; }
+        public double pu_pr { get; set; }
+        public double tva_pr { get; set; }
+        public double ttc_pr { get; set; }
+    }
+}

+ 31 - 0
Fuel_ASO/Models/PrestaSta.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel01.Models
+{
+    public class PrestaSta
+    {
+        public string sta_pr { get; set; } = string.Empty;
+        public List<Prod> carburants { get; set; } = new List<Prod>();
+        public List<Prod> autres { get; set; } = new List<Prod>();
+    }
+
+    public class Prod
+    {
+        public string prod_pr { get; set; }
+        public string lib_prod { get; set; }
+        public string unite_pr { get; set; }
+        public string pu_pr { get; set; }
+        public string tva_pr { get; set; }
+        public string ttc_pr { get; set; }
+    }
+
+    
+
+
+
+   
+}

+ 15 - 0
Fuel_ASO/Models/PrestasFournies.cs

@@ -0,0 +1,15 @@
+using System;
+
+namespace Fuel01
+{
+    public class PrestasFournies
+    {
+        public String Libel { get; set; }
+        public String Name { get; set; }
+        public float Quantity { get; set; }
+        public float PrixUnitaire { get; set; }
+        public float Total { get; set; }
+        public float TxTva { get; set; }
+    }
+
+}

+ 41 - 0
Fuel_ASO/Models/ProdEqualityComparer.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel01
+{
+    class ProdEqualityComparer : IEqualityComparer<IdProd>
+    {
+        public bool Equals(IdProd b1, IdProd b2)
+        {
+            if (b2 == null && b1 == null)
+                return true;
+            else if (b1 == null || b2 == null)
+                return false;
+            else if (b1.code_pro == b2.code_pro &&
+                        b1.lib_pro== b2.lib_pro &&
+                        b1.ttc_pro == b2.ttc_pro &&
+                        b1.tva_pro == b2.tva_pro &&
+                        b1.type_pro == b2.type_pro )
+                return true;
+            else
+                return false;
+        }
+
+        public int GetHashCode(IdProd bx)
+        {
+            int hCode = 0;
+            hCode += bx.code_pro.GetHashCode();
+            hCode += bx.lib_pro.GetHashCode();
+            hCode += bx.type_pro.GetHashCode();
+            hCode += (int)(bx.ttc_pro * 100);
+            hCode += (int)(bx.tva_pro * 100);
+            Console.WriteLine(string.Format(" Hash:{0} Prod:{1}  Prix:{2}  Tva:{3} Hash2:{4} ", bx.GetHashCode(), bx.code_pro, bx.ttc_pro, bx.tva_pro, hCode.GetHashCode()));
+            return hCode.GetHashCode();
+        }
+    }
+
+}

+ 10 - 0
Fuel_ASO/Models/Produit.cs

@@ -0,0 +1,10 @@
+namespace Fuel01
+{
+    public class Produit
+    {
+        public string key_prod { get; set; }
+        public string lib_prod { get; set; }
+        public string type_prod { get; set; }
+    }
+
+}

+ 69 - 0
Fuel_ASO/Models/Vehicule.cs

@@ -0,0 +1,69 @@
+namespace Fuel01
+{
+    public class Vehicule
+    {
+        public string key_vehi { get; set; }
+        public string ope_vehi { get; set; }        
+        public string num_vehi { get; set; }           
+        public string cmpnum_vehi { get; set; }
+        public string immat_vehi { get; set; }
+        public string type_vehi { get; set; }
+        public bool ok_vehi { get; set; }
+        public string carbu_vehi { get; set; }
+        public int kmdep_vehi { get; set; }
+        public int kmarr_vehi { get; set; }
+        public string cond_vehi { get; set; }
+        public string famille_vehi { get; set; }
+        public string order_vehi { get; set; }
+           
+        public Vehicule()
+        {           
+        }
+        public Vehicule(string _key)
+        {
+            key_vehi = _key;
+        }
+        public Vehicule(Vehicule orig)
+        {
+            key_vehi = orig.key_vehi;
+            ope_vehi = orig.ope_vehi;
+            num_vehi = orig.num_vehi;
+            cmpnum_vehi = orig.cmpnum_vehi;
+            immat_vehi = orig.immat_vehi;
+            type_vehi = orig.type_vehi;
+            ok_vehi = orig.ok_vehi;
+            carbu_vehi = orig.carbu_vehi;
+            kmdep_vehi = orig.kmdep_vehi;
+            kmarr_vehi = orig.kmarr_vehi;
+            cond_vehi = orig.cond_vehi;
+            famille_vehi = orig.famille_vehi;
+            order_vehi = orig.order_vehi;
+        }
+        public void maj_vehi()
+        {
+            order_vehi = (num_vehi == null ? " ".PadLeft(5) : num_vehi.PadLeft(5)) + (cmpnum_vehi == null ? " ".PadLeft(5) : cmpnum_vehi.PadLeft(5));
+        }
+        public string ToLigne()
+        {
+            string ret = "";
+            ret = string.Format("{0}##^##{1}##^##{2}##^##{3}##^##{4}##^##{5}##^##{6}##^##{7}##^##{8}##^##{9}##^##{10}##^##{11}##^##",
+                           key_vehi,
+                           ope_vehi,
+                           num_vehi,
+                           cmpnum_vehi,
+                           immat_vehi,
+                           type_vehi,
+                           ok_vehi,
+                           carbu_vehi,
+                           kmdep_vehi,
+                           kmarr_vehi,
+                           cond_vehi,
+                           famille_vehi);
+
+            return ret;
+
+        }
+
+    }
+
+}

+ 11 - 0
Fuel_ASO/Models/VenteTot.cs

@@ -0,0 +1,11 @@
+namespace Fuel01
+{
+    class VenteTot
+    {
+        public DataSet1.tb_venteRow vente { get; set; }
+        public decimal total_qtt { get; set; }
+        public decimal total_ht { get; set; }
+        public decimal total_ttc { get; set; }
+    }
+
+}

+ 11 - 0
Fuel_ASO/Models/VenteTva.cs

@@ -0,0 +1,11 @@
+namespace Fuel01
+{
+    class VenteTva
+    {
+        public decimal taux_tva { get; set; }
+        public decimal base_tva { get; set; }
+        public decimal mnt_tva { get; set; }
+        public decimal mnt_ttc { get; set; }
+    }
+
+}

+ 21 - 17
Fuel_ASO/Program.cs

@@ -16,14 +16,14 @@ namespace Fuel01
         public static int site = 1;
         public static string auteur = "Test";
         public static bool okSignalR = false;
-        public static string key_sta="";
-        public static string key_ope="";
-        public static string abrev_ope="";
-        public static string nom_ope="";
+        public static string key_sta = "";
+        public static string key_ope = "";
+        public static string abrev_ope = "";
+        public static string nom_ope = "";
         public static string folder = "";
         public static string subfolder = "";
         public static bool debug = false;
-        public static bool isExcel= false;
+        public static bool isExcel = false;
 #pragma warning restore S2223 // Non-constant static fields should not be visible
 
 
@@ -33,7 +33,7 @@ namespace Fuel01
         [STAThread]
         static void Main()
         {
-            debug = ( Environment.MachineName=="PCPAT");
+            debug = (Environment.MachineName == "PCPAT");
 
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
@@ -47,10 +47,16 @@ namespace Fuel01
             {
                 MailMessage message = new MailMessage();
                 message.From = new MailAddress(fromEmail);
-                string[] emails = toEmail.Split(new Char[] { ',', ';' });
+                
+                var seps = new Char[] { ',', ';' };
+                string[] emails = toEmail.Split(seps);
                 for (int i = 0; i < emails.Length; i++)
+                {
                     message.To.Add(new MailAddress(emails[i]));
+                }
+                
                 message.Subject = subject;
+                
                 ContentType ct = new ContentType();
                 ct.MediaType = MediaTypeNames.Application.Octet;
                 if (pj != null)
@@ -58,7 +64,6 @@ namespace Fuel01
                     Attachment att = new Attachment(pj, ct);
                     ContentDisposition cd = att.ContentDisposition;
                     cd.FileName = pj.Substring(pj.LastIndexOf(@"\") + 1);
-                    //cd.FileName = "Traces_Erreurs_Race_Mngt.txt";
                     message.Attachments.Add(att);
                 }
                 message.Body = body;
@@ -72,7 +77,6 @@ namespace Fuel01
                 smtp.Port = 587;
                 smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                 smtp.Send(message);
-                //MessageBox.Show("Un E-mail décrivant le problème a été envoyé.\r\n Nous cherchons à corriger l'erreur rencontrée.", "Gestion des erreurs");
                 return true;
             }
             catch (Exception ex)
@@ -82,9 +86,9 @@ namespace Fuel01
             }
         }
 
-        public static DialogResult ShowInputDialog(string title,string message,ref string input,bool hidden)
+        public static DialogResult ShowInputDialog(string title, string message, ref string input, bool hidden)
         {
-            System.Drawing.Size size = new System.Drawing.Size(220, 70 + 25 );
+            System.Drawing.Size size = new System.Drawing.Size(220, 70 + 25);
             Form inputBox = new Form();
 
             inputBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@@ -100,9 +104,9 @@ namespace Fuel01
 
             System.Windows.Forms.TextBox textBox = new TextBox();
             textBox.Size = new System.Drawing.Size(size.Width - 10, 23);
-            textBox.Location = new System.Drawing.Point(5, 5 + 25 );
+            textBox.Location = new System.Drawing.Point(5, 5 + 25);
             textBox.Text = input;
-            if ( hidden) textBox.PasswordChar = '*';
+            if (hidden) textBox.PasswordChar = '*';
             inputBox.Controls.Add(textBox);
 
             Button okButton = new Button();
@@ -110,7 +114,7 @@ namespace Fuel01
             okButton.Name = "okButton";
             okButton.Size = new System.Drawing.Size(95, 23);
             okButton.Text = "&OK";
-            okButton.Location = new System.Drawing.Point(5  , 39 +25 );
+            okButton.Location = new System.Drawing.Point(5, 39 + 25);
             inputBox.Controls.Add(okButton);
 
             Button cancelButton = new Button();
@@ -118,7 +122,7 @@ namespace Fuel01
             cancelButton.Name = "cancelButton";
             cancelButton.Size = new System.Drawing.Size(75, 23);
             cancelButton.Text = "&Cancel";
-            cancelButton.Location = new System.Drawing.Point(5 + 95 + 10  , 39 + 25);
+            cancelButton.Location = new System.Drawing.Point(5 + 95 + 10, 39 + 25);
             inputBox.Controls.Add(cancelButton);
 
             inputBox.AcceptButton = okButton;
@@ -129,7 +133,7 @@ namespace Fuel01
             return result;
         }
 
-        public static void traces(string fic,string datas)
+        public static void traces(string fic, string datas)
         {
             bool done = false;
             int retry = 0;
@@ -142,7 +146,7 @@ namespace Fuel01
                 }
                 catch (Exception ex)
                 {
-                    datas += ( "\r\n Retry " + retry++.ToString() + " Ex:" + ex.Message );
+                    datas += ("\r\n Retry " + retry++.ToString() + " Ex:" + ex.Message);
                 }
             }
 

+ 16 - 0
Fuel_ASO/TdfFile.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel01
+{
+    public class TdfFile
+    {
+        public string Name { get; set; } = string.Empty;
+        public byte[] Data { get; set; } = new byte[0];
+
+    }
+}
+

+ 164 - 115
Fuel_ASO/f_about.Designer.cs

@@ -105,33 +105,34 @@
             this.tableLayoutPanel.Controls.Add(this.okButton, 2, 8);
             this.tableLayoutPanel.Controls.Add(this.progressBar1, 0, 9);
             this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.tableLayoutPanel.Location = new System.Drawing.Point(3, 3);
+            this.tableLayoutPanel.Location = new System.Drawing.Point(4, 5);
+            this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.tableLayoutPanel.Name = "tableLayoutPanel";
             this.tableLayoutPanel.RowCount = 11;
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 90F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
-            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
-            this.tableLayoutPanel.Size = new System.Drawing.Size(494, 337);
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 138F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 46F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 46F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 46F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 46F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F));
+            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F));
+            this.tableLayoutPanel.Size = new System.Drawing.Size(745, 524);
             this.tableLayoutPanel.TabIndex = 0;
-            this.tableLayoutPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.tableLayoutPanel_Paint);
             // 
             // bt_clean
             // 
             this.bt_clean.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.bt_clean.Location = new System.Drawing.Point(416, 173);
+            this.bt_clean.Location = new System.Drawing.Point(629, 267);
+            this.bt_clean.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_clean.Name = "bt_clean";
-            this.bt_clean.Size = new System.Drawing.Size(75, 24);
+            this.bt_clean.Size = new System.Drawing.Size(112, 36);
             this.bt_clean.TabIndex = 34;
             this.bt_clean.Text = "Nettoyage";
             this.bt_clean.UseVisualStyleBackColor = true;
@@ -139,9 +140,10 @@
             // 
             // lblClean
             // 
-            this.lblClean.Location = new System.Drawing.Point(185, 170);
+            this.lblClean.Location = new System.Drawing.Point(278, 262);
+            this.lblClean.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.lblClean.Name = "lblClean";
-            this.lblClean.Size = new System.Drawing.Size(189, 27);
+            this.lblClean.Size = new System.Drawing.Size(284, 42);
             this.lblClean.TabIndex = 33;
             this.lblClean.Text = "Nettoyage des données \r\n(fichiers inutiles)";
             this.lblClean.TextAlign = System.Drawing.ContentAlignment.TopRight;
@@ -149,9 +151,10 @@
             // button3
             // 
             this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.button3.Location = new System.Drawing.Point(416, 233);
+            this.button3.Location = new System.Drawing.Point(629, 359);
+            this.button3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.button3.Name = "button3";
-            this.button3.Size = new System.Drawing.Size(75, 24);
+            this.button3.Size = new System.Drawing.Size(112, 36);
             this.button3.TabIndex = 30;
             this.button3.Text = "Restauration";
             this.button3.UseVisualStyleBackColor = true;
@@ -161,10 +164,10 @@
             // 
             this.tableLayoutPanel.SetColumnSpan(this.labelProductName, 2);
             this.labelProductName.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.labelProductName.Location = new System.Drawing.Point(188, 0);
-            this.labelProductName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
+            this.labelProductName.Location = new System.Drawing.Point(283, 0);
+            this.labelProductName.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0);
             this.labelProductName.Name = "labelProductName";
-            this.labelProductName.Size = new System.Drawing.Size(303, 20);
+            this.labelProductName.Size = new System.Drawing.Size(458, 31);
             this.labelProductName.TabIndex = 19;
             this.labelProductName.Text = "Nom du produit";
             this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -173,10 +176,10 @@
             // 
             this.tableLayoutPanel.SetColumnSpan(this.labelVersion, 2);
             this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.labelVersion.Location = new System.Drawing.Point(188, 20);
-            this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
+            this.labelVersion.Location = new System.Drawing.Point(283, 31);
+            this.labelVersion.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0);
             this.labelVersion.Name = "labelVersion";
-            this.labelVersion.Size = new System.Drawing.Size(303, 20);
+            this.labelVersion.Size = new System.Drawing.Size(458, 31);
             this.labelVersion.TabIndex = 0;
             this.labelVersion.Text = "Version Version Version Version";
             this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -185,10 +188,10 @@
             // 
             this.tableLayoutPanel.SetColumnSpan(this.labelCopyright, 2);
             this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.labelCopyright.Location = new System.Drawing.Point(188, 40);
-            this.labelCopyright.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
+            this.labelCopyright.Location = new System.Drawing.Point(283, 62);
+            this.labelCopyright.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0);
             this.labelCopyright.Name = "labelCopyright";
-            this.labelCopyright.Size = new System.Drawing.Size(303, 20);
+            this.labelCopyright.Size = new System.Drawing.Size(458, 31);
             this.labelCopyright.TabIndex = 21;
             this.labelCopyright.Text = "Copyright";
             this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -197,10 +200,10 @@
             // 
             this.tableLayoutPanel.SetColumnSpan(this.labelCompanyName, 2);
             this.labelCompanyName.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.labelCompanyName.Location = new System.Drawing.Point(188, 60);
-            this.labelCompanyName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
+            this.labelCompanyName.Location = new System.Drawing.Point(283, 93);
+            this.labelCompanyName.Margin = new System.Windows.Forms.Padding(9, 0, 4, 0);
             this.labelCompanyName.Name = "labelCompanyName";
-            this.labelCompanyName.Size = new System.Drawing.Size(303, 20);
+            this.labelCompanyName.Size = new System.Drawing.Size(458, 31);
             this.labelCompanyName.TabIndex = 22;
             this.labelCompanyName.Text = "Nom de la société";
             this.labelCompanyName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -209,13 +212,13 @@
             // 
             this.tableLayoutPanel.SetColumnSpan(this.textBoxDescription, 2);
             this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.textBoxDescription.Location = new System.Drawing.Point(188, 83);
-            this.textBoxDescription.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
+            this.textBoxDescription.Location = new System.Drawing.Point(283, 129);
+            this.textBoxDescription.Margin = new System.Windows.Forms.Padding(9, 5, 4, 5);
             this.textBoxDescription.Multiline = true;
             this.textBoxDescription.Name = "textBoxDescription";
             this.textBoxDescription.ReadOnly = true;
             this.textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both;
-            this.textBoxDescription.Size = new System.Drawing.Size(303, 84);
+            this.textBoxDescription.Size = new System.Drawing.Size(458, 128);
             this.textBoxDescription.TabIndex = 23;
             this.textBoxDescription.TabStop = false;
             this.textBoxDescription.Text = "Patrick Germain\r\npgermain@aformatix.com\r\ntel : 04 94 00 39 40\r\nmob: 06 07 02 66 8" +
@@ -224,10 +227,11 @@
             // logoPictureBox
             // 
             this.logoPictureBox.Image = global::Fuel01.Properties.Resources.aPompe;
-            this.logoPictureBox.Location = new System.Drawing.Point(3, 83);
+            this.logoPictureBox.Location = new System.Drawing.Point(4, 129);
+            this.logoPictureBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.logoPictureBox.Name = "logoPictureBox";
             this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 3);
-            this.logoPictureBox.Size = new System.Drawing.Size(127, 144);
+            this.logoPictureBox.Size = new System.Drawing.Size(190, 220);
             this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
             this.logoPictureBox.TabIndex = 12;
             this.logoPictureBox.TabStop = false;
@@ -235,19 +239,21 @@
             // pictureBox1
             // 
             this.pictureBox1.Image = global::Fuel01.Properties.Resources.aax3;
-            this.pictureBox1.Location = new System.Drawing.Point(3, 3);
+            this.pictureBox1.Location = new System.Drawing.Point(4, 5);
+            this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.pictureBox1.Name = "pictureBox1";
             this.tableLayoutPanel.SetRowSpan(this.pictureBox1, 4);
-            this.pictureBox1.Size = new System.Drawing.Size(158, 74);
+            this.pictureBox1.Size = new System.Drawing.Size(237, 114);
             this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
             this.pictureBox1.TabIndex = 26;
             this.pictureBox1.TabStop = false;
             // 
             // lbl_Send
             // 
-            this.lbl_Send.Location = new System.Drawing.Point(185, 200);
+            this.lbl_Send.Location = new System.Drawing.Point(278, 308);
+            this.lbl_Send.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.lbl_Send.Name = "lbl_Send";
-            this.lbl_Send.Size = new System.Drawing.Size(189, 27);
+            this.lbl_Send.Size = new System.Drawing.Size(284, 42);
             this.lbl_Send.TabIndex = 32;
             this.lbl_Send.Text = "Envoi des données pour saisie tablettes\r\n";
             this.lbl_Send.TextAlign = System.Drawing.ContentAlignment.TopRight;
@@ -255,9 +261,10 @@
             // button1
             // 
             this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.button1.Location = new System.Drawing.Point(321, 233);
+            this.button1.Location = new System.Drawing.Point(485, 359);
+            this.button1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(75, 24);
+            this.button1.Size = new System.Drawing.Size(112, 36);
             this.button1.TabIndex = 28;
             this.button1.Text = "Sauvegarde";
             this.button1.UseVisualStyleBackColor = true;
@@ -266,9 +273,10 @@
             // bt_send
             // 
             this.bt_send.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.bt_send.Location = new System.Drawing.Point(416, 203);
+            this.bt_send.Location = new System.Drawing.Point(629, 313);
+            this.bt_send.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_send.Name = "bt_send";
-            this.bt_send.Size = new System.Drawing.Size(75, 24);
+            this.bt_send.Size = new System.Drawing.Size(112, 36);
             this.bt_send.TabIndex = 31;
             this.bt_send.Text = "Envoi Serveur";
             this.bt_send.UseVisualStyleBackColor = true;
@@ -277,9 +285,10 @@
             // bt_maj
             // 
             this.bt_maj.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.bt_maj.Location = new System.Drawing.Point(321, 263);
+            this.bt_maj.Location = new System.Drawing.Point(485, 405);
+            this.bt_maj.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_maj.Name = "bt_maj";
-            this.bt_maj.Size = new System.Drawing.Size(75, 24);
+            this.bt_maj.Size = new System.Drawing.Size(112, 36);
             this.bt_maj.TabIndex = 35;
             this.bt_maj.Text = "MAJ";
             this.bt_maj.UseVisualStyleBackColor = true;
@@ -289,20 +298,21 @@
             // 
             this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
-            this.okButton.Location = new System.Drawing.Point(416, 263);
+            this.okButton.Location = new System.Drawing.Point(629, 405);
+            this.okButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.okButton.Name = "okButton";
-            this.okButton.Size = new System.Drawing.Size(75, 24);
+            this.okButton.Size = new System.Drawing.Size(112, 36);
             this.okButton.TabIndex = 24;
             this.okButton.Text = "&Fermer";
-            this.okButton.Click += new System.EventHandler(this.okButton_Click);
             // 
             // progressBar1
             // 
             this.tableLayoutPanel.SetColumnSpan(this.progressBar1, 3);
             this.progressBar1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.progressBar1.Location = new System.Drawing.Point(3, 293);
+            this.progressBar1.Location = new System.Drawing.Point(4, 451);
+            this.progressBar1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.progressBar1.Name = "progressBar1";
-            this.progressBar1.Size = new System.Drawing.Size(488, 14);
+            this.progressBar1.Size = new System.Drawing.Size(737, 21);
             this.progressBar1.TabIndex = 36;
             // 
             // opfile
@@ -313,9 +323,10 @@
             // 
             this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.label1.ForeColor = System.Drawing.Color.Red;
-            this.label1.Location = new System.Drawing.Point(21, 95);
+            this.label1.Location = new System.Drawing.Point(32, 146);
+            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(460, 40);
+            this.label1.Size = new System.Drawing.Size(690, 62);
             this.label1.TabIndex = 1;
             this.label1.Text = "Envoi en cours";
             this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -326,20 +337,22 @@
             this.tabControl1.Controls.Add(this.tabAbout);
             this.tabControl1.Controls.Add(this.tabParam);
             this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.tabControl1.Location = new System.Drawing.Point(9, 9);
+            this.tabControl1.Location = new System.Drawing.Point(14, 14);
+            this.tabControl1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.tabControl1.Name = "tabControl1";
             this.tabControl1.SelectedIndex = 0;
-            this.tabControl1.Size = new System.Drawing.Size(508, 369);
+            this.tabControl1.Size = new System.Drawing.Size(761, 567);
             this.tabControl1.TabIndex = 2;
             // 
             // tabAbout
             // 
             this.tabAbout.Controls.Add(this.label1);
             this.tabAbout.Controls.Add(this.tableLayoutPanel);
-            this.tabAbout.Location = new System.Drawing.Point(4, 22);
+            this.tabAbout.Location = new System.Drawing.Point(4, 29);
+            this.tabAbout.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.tabAbout.Name = "tabAbout";
-            this.tabAbout.Padding = new System.Windows.Forms.Padding(3);
-            this.tabAbout.Size = new System.Drawing.Size(500, 343);
+            this.tabAbout.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.tabAbout.Size = new System.Drawing.Size(753, 534);
             this.tabAbout.TabIndex = 0;
             this.tabAbout.Text = "Informations";
             this.tabAbout.UseVisualStyleBackColor = true;
@@ -369,10 +382,11 @@
             this.tabParam.Controls.Add(this.textSrvDatas);
             this.tabParam.Controls.Add(this.bt_checkDatas);
             this.tabParam.Controls.Add(this.checkBoxLocale);
-            this.tabParam.Location = new System.Drawing.Point(4, 22);
+            this.tabParam.Location = new System.Drawing.Point(4, 29);
+            this.tabParam.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.tabParam.Name = "tabParam";
-            this.tabParam.Padding = new System.Windows.Forms.Padding(3);
-            this.tabParam.Size = new System.Drawing.Size(500, 343);
+            this.tabParam.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.tabParam.Size = new System.Drawing.Size(753, 534);
             this.tabParam.TabIndex = 1;
             this.tabParam.Text = "Paramètres";
             this.tabParam.UseVisualStyleBackColor = true;
@@ -382,18 +396,20 @@
             this.checkBoxAPI.AutoSize = true;
             this.checkBoxAPI.Checked = true;
             this.checkBoxAPI.CheckState = System.Windows.Forms.CheckState.Indeterminate;
-            this.checkBoxAPI.Location = new System.Drawing.Point(362, 168);
+            this.checkBoxAPI.Location = new System.Drawing.Point(543, 94);
+            this.checkBoxAPI.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkBoxAPI.Name = "checkBoxAPI";
-            this.checkBoxAPI.Size = new System.Drawing.Size(55, 17);
+            this.checkBoxAPI.Size = new System.Drawing.Size(80, 24);
             this.checkBoxAPI.TabIndex = 60;
             this.checkBoxAPI.Text = "Vérifié";
             this.checkBoxAPI.UseVisualStyleBackColor = true;
             // 
             // bt_chekAPI
             // 
-            this.bt_chekAPI.Location = new System.Drawing.Point(256, 163);
+            this.bt_chekAPI.Location = new System.Drawing.Point(384, 87);
+            this.bt_chekAPI.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_chekAPI.Name = "bt_chekAPI";
-            this.bt_chekAPI.Size = new System.Drawing.Size(89, 23);
+            this.bt_chekAPI.Size = new System.Drawing.Size(134, 35);
             this.bt_chekAPI.TabIndex = 59;
             this.bt_chekAPI.Text = "Vérifier serveur";
             this.bt_chekAPI.UseVisualStyleBackColor = true;
@@ -402,52 +418,61 @@
             // label6
             // 
             this.label6.AutoSize = true;
-            this.label6.Location = new System.Drawing.Point(3, 172);
+            this.label6.Location = new System.Drawing.Point(4, 101);
+            this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label6.Name = "label6";
-            this.label6.Size = new System.Drawing.Size(162, 13);
+            this.label6.Size = new System.Drawing.Size(241, 20);
             this.label6.TabIndex = 58;
             this.label6.Text = "Adresse pour envoi des données";
             // 
             // textCopieAPI
             // 
-            this.textCopieAPI.Location = new System.Drawing.Point(35, 187);
+            this.textCopieAPI.Location = new System.Drawing.Point(52, 124);
+            this.textCopieAPI.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.textCopieAPI.Name = "textCopieAPI";
-            this.textCopieAPI.Size = new System.Drawing.Size(382, 20);
+            this.textCopieAPI.Size = new System.Drawing.Size(571, 26);
             this.textCopieAPI.TabIndex = 57;
             // 
             // bt_fold
             // 
-            this.bt_fold.Location = new System.Drawing.Point(436, 228);
+            this.bt_fold.Location = new System.Drawing.Point(654, 351);
+            this.bt_fold.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_fold.Name = "bt_fold";
-            this.bt_fold.Size = new System.Drawing.Size(24, 23);
+            this.bt_fold.Size = new System.Drawing.Size(36, 35);
             this.bt_fold.TabIndex = 56;
             this.bt_fold.Text = "...";
             this.bt_fold.UseVisualStyleBackColor = true;
+            this.bt_fold.Visible = false;
             this.bt_fold.Click += new System.EventHandler(this.bt_fold_Click);
             // 
             // label5
             // 
             this.label5.AutoSize = true;
-            this.label5.Location = new System.Drawing.Point(2, 216);
+            this.label5.Location = new System.Drawing.Point(3, 332);
+            this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label5.Name = "label5";
-            this.label5.Size = new System.Drawing.Size(218, 13);
+            this.label5.Size = new System.Drawing.Size(322, 20);
             this.label5.TabIndex = 54;
             this.label5.Text = "Chemin pour copie locale vers le serveur ISS";
+            this.label5.Visible = false;
             // 
             // textCopieLocal
             // 
             this.textCopieLocal.DataBindings.Add(new System.Windows.Forms.Binding("Enabled", global::Fuel01.Properties.Settings.Default, "use_locale", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
             this.textCopieLocal.Enabled = global::Fuel01.Properties.Settings.Default.use_locale;
-            this.textCopieLocal.Location = new System.Drawing.Point(35, 231);
+            this.textCopieLocal.Location = new System.Drawing.Point(52, 355);
+            this.textCopieLocal.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.textCopieLocal.Name = "textCopieLocal";
-            this.textCopieLocal.Size = new System.Drawing.Size(382, 20);
+            this.textCopieLocal.Size = new System.Drawing.Size(571, 26);
             this.textCopieLocal.TabIndex = 53;
+            this.textCopieLocal.Visible = false;
             // 
             // bt_sav
             // 
-            this.bt_sav.Location = new System.Drawing.Point(318, 309);
+            this.bt_sav.Location = new System.Drawing.Point(477, 166);
+            this.bt_sav.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_sav.Name = "bt_sav";
-            this.bt_sav.Size = new System.Drawing.Size(99, 23);
+            this.bt_sav.Size = new System.Drawing.Size(148, 35);
             this.bt_sav.TabIndex = 52;
             this.bt_sav.Text = "Sauvegarder";
             this.bt_sav.UseVisualStyleBackColor = true;
@@ -456,9 +481,10 @@
             // checkAll
             // 
             this.checkAll.AutoSize = true;
-            this.checkAll.Location = new System.Drawing.Point(47, 313);
+            this.checkAll.Location = new System.Drawing.Point(22, 163);
+            this.checkAll.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkAll.Name = "checkAll";
-            this.checkAll.Size = new System.Drawing.Size(265, 17);
+            this.checkAll.Size = new System.Drawing.Size(389, 24);
             this.checkAll.TabIndex = 51;
             this.checkAll.Text = "Forcer la sauvegarde des données non vérifiées !!!";
             this.checkAll.UseVisualStyleBackColor = true;
@@ -468,33 +494,38 @@
             this.checkBoxSignalR.AutoSize = true;
             this.checkBoxSignalR.Checked = true;
             this.checkBoxSignalR.CheckState = System.Windows.Forms.CheckState.Indeterminate;
-            this.checkBoxSignalR.Location = new System.Drawing.Point(362, 122);
+            this.checkBoxSignalR.Location = new System.Drawing.Point(543, 401);
+            this.checkBoxSignalR.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkBoxSignalR.Name = "checkBoxSignalR";
-            this.checkBoxSignalR.Size = new System.Drawing.Size(55, 17);
+            this.checkBoxSignalR.Size = new System.Drawing.Size(80, 24);
             this.checkBoxSignalR.TabIndex = 50;
             this.checkBoxSignalR.Text = "Vérifié";
             this.checkBoxSignalR.UseVisualStyleBackColor = true;
+            this.checkBoxSignalR.Visible = false;
             // 
             // checkBoxBin
             // 
             this.checkBoxBin.AutoSize = true;
             this.checkBoxBin.Checked = true;
             this.checkBoxBin.CheckState = System.Windows.Forms.CheckState.Indeterminate;
-            this.checkBoxBin.Location = new System.Drawing.Point(362, 69);
+            this.checkBoxBin.Location = new System.Drawing.Point(543, 259);
+            this.checkBoxBin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkBoxBin.Name = "checkBoxBin";
-            this.checkBoxBin.Size = new System.Drawing.Size(55, 17);
+            this.checkBoxBin.Size = new System.Drawing.Size(80, 24);
             this.checkBoxBin.TabIndex = 49;
             this.checkBoxBin.Text = "Vérifié";
             this.checkBoxBin.UseVisualStyleBackColor = true;
+            this.checkBoxBin.Visible = false;
             // 
             // checkBoxDatas
             // 
             this.checkBoxDatas.AutoSize = true;
             this.checkBoxDatas.Checked = true;
             this.checkBoxDatas.CheckState = System.Windows.Forms.CheckState.Indeterminate;
-            this.checkBoxDatas.Location = new System.Drawing.Point(362, 10);
+            this.checkBoxDatas.Location = new System.Drawing.Point(543, 15);
+            this.checkBoxDatas.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkBoxDatas.Name = "checkBoxDatas";
-            this.checkBoxDatas.Size = new System.Drawing.Size(55, 17);
+            this.checkBoxDatas.Size = new System.Drawing.Size(80, 24);
             this.checkBoxDatas.TabIndex = 48;
             this.checkBoxDatas.Text = "Vérifié";
             this.checkBoxDatas.UseVisualStyleBackColor = true;
@@ -503,85 +534,101 @@
             // 
             this.lblRes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.lblRes.AutoSize = true;
-            this.lblRes.Location = new System.Drawing.Point(444, 314);
+            this.lblRes.Location = new System.Drawing.Point(665, 482);
+            this.lblRes.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.lblRes.Name = "lblRes";
-            this.lblRes.Size = new System.Drawing.Size(16, 13);
+            this.lblRes.Size = new System.Drawing.Size(21, 20);
             this.lblRes.TabIndex = 47;
             this.lblRes.Text = "...";
             // 
             // label4
             // 
             this.label4.AutoSize = true;
-            this.label4.Location = new System.Drawing.Point(3, 126);
+            this.label4.Location = new System.Drawing.Point(4, 407);
+            this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(138, 13);
+            this.label4.Size = new System.Drawing.Size(206, 20);
             this.label4.TabIndex = 46;
             this.label4.Text = "Adresse du serveur SignalR";
+            this.label4.Visible = false;
             // 
             // textSignalR
             // 
-            this.textSignalR.Location = new System.Drawing.Point(39, 141);
+            this.textSignalR.Location = new System.Drawing.Point(58, 430);
+            this.textSignalR.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.textSignalR.Name = "textSignalR";
-            this.textSignalR.Size = new System.Drawing.Size(382, 20);
+            this.textSignalR.Size = new System.Drawing.Size(571, 26);
             this.textSignalR.TabIndex = 44;
+            this.textSignalR.Visible = false;
             // 
             // bt_checkR
             // 
-            this.bt_checkR.Location = new System.Drawing.Point(256, 117);
+            this.bt_checkR.Location = new System.Drawing.Point(384, 393);
+            this.bt_checkR.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_checkR.Name = "bt_checkR";
-            this.bt_checkR.Size = new System.Drawing.Size(89, 23);
+            this.bt_checkR.Size = new System.Drawing.Size(134, 35);
             this.bt_checkR.TabIndex = 45;
             this.bt_checkR.Text = "Vérifier serveur";
             this.bt_checkR.UseVisualStyleBackColor = true;
+            this.bt_checkR.Visible = false;
             this.bt_checkR.Click += new System.EventHandler(this.bt_check_Click);
             // 
             // label3
             // 
             this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(3, 73);
+            this.label3.Location = new System.Drawing.Point(4, 265);
+            this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(236, 13);
+            this.label3.Size = new System.Drawing.Size(351, 20);
             this.label3.TabIndex = 43;
             this.label3.Text = "Adresse du serveur pour la mise à jour du logiciel";
+            this.label3.Visible = false;
             // 
             // textSrvBin
             // 
-            this.textSrvBin.Location = new System.Drawing.Point(39, 88);
+            this.textSrvBin.Location = new System.Drawing.Point(58, 288);
+            this.textSrvBin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.textSrvBin.Name = "textSrvBin";
-            this.textSrvBin.Size = new System.Drawing.Size(382, 20);
+            this.textSrvBin.Size = new System.Drawing.Size(571, 26);
             this.textSrvBin.TabIndex = 41;
+            this.textSrvBin.Visible = false;
             // 
             // bt_checkBin
             // 
-            this.bt_checkBin.Location = new System.Drawing.Point(256, 64);
+            this.bt_checkBin.Location = new System.Drawing.Point(384, 251);
+            this.bt_checkBin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_checkBin.Name = "bt_checkBin";
-            this.bt_checkBin.Size = new System.Drawing.Size(89, 23);
+            this.bt_checkBin.Size = new System.Drawing.Size(134, 35);
             this.bt_checkBin.TabIndex = 42;
             this.bt_checkBin.Text = "Vérifier serveur";
             this.bt_checkBin.UseVisualStyleBackColor = true;
+            this.bt_checkBin.Visible = false;
             this.bt_checkBin.Click += new System.EventHandler(this.bt_check_Click);
             // 
             // label2
             // 
             this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(3, 14);
+            this.label2.Location = new System.Drawing.Point(4, 22);
+            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(244, 13);
+            this.label2.Size = new System.Drawing.Size(365, 20);
             this.label2.TabIndex = 40;
             this.label2.Text = "Adresse du serveur pour la récupération des datas";
             // 
             // textSrvDatas
             // 
-            this.textSrvDatas.Location = new System.Drawing.Point(39, 29);
+            this.textSrvDatas.Location = new System.Drawing.Point(58, 45);
+            this.textSrvDatas.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.textSrvDatas.Name = "textSrvDatas";
-            this.textSrvDatas.Size = new System.Drawing.Size(382, 20);
+            this.textSrvDatas.Size = new System.Drawing.Size(571, 26);
             this.textSrvDatas.TabIndex = 38;
             // 
             // bt_checkDatas
             // 
-            this.bt_checkDatas.Location = new System.Drawing.Point(256, 5);
+            this.bt_checkDatas.Location = new System.Drawing.Point(384, 8);
+            this.bt_checkDatas.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_checkDatas.Name = "bt_checkDatas";
-            this.bt_checkDatas.Size = new System.Drawing.Size(89, 23);
+            this.bt_checkDatas.Size = new System.Drawing.Size(134, 35);
             this.bt_checkDatas.TabIndex = 39;
             this.bt_checkDatas.Text = "Vérifier serveur";
             this.bt_checkDatas.UseVisualStyleBackColor = true;
@@ -592,30 +639,32 @@
             this.checkBoxLocale.AutoSize = true;
             this.checkBoxLocale.Checked = global::Fuel01.Properties.Settings.Default.use_locale;
             this.checkBoxLocale.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::Fuel01.Properties.Settings.Default, "use_locale", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
-            this.checkBoxLocale.Location = new System.Drawing.Point(236, 215);
+            this.checkBoxLocale.Location = new System.Drawing.Point(354, 331);
+            this.checkBoxLocale.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkBoxLocale.Name = "checkBoxLocale";
-            this.checkBoxLocale.Size = new System.Drawing.Size(128, 17);
+            this.checkBoxLocale.Size = new System.Drawing.Size(186, 24);
             this.checkBoxLocale.TabIndex = 55;
             this.checkBoxLocale.Text = "Utiliser la copie locale";
             this.checkBoxLocale.UseVisualStyleBackColor = true;
+            this.checkBoxLocale.Visible = false;
             // 
             // f_about
             // 
             this.AcceptButton = this.okButton;
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(526, 387);
+            this.ClientSize = new System.Drawing.Size(789, 595);
             this.Controls.Add(this.tabControl1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+            this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.MaximizeBox = false;
             this.MinimizeBox = false;
             this.Name = "f_about";
-            this.Padding = new System.Windows.Forms.Padding(9);
+            this.Padding = new System.Windows.Forms.Padding(14);
             this.ShowIcon = false;
             this.ShowInTaskbar = false;
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
             this.Text = "A propos";
-            this.Load += new System.EventHandler(this.f_about_Load);
             this.tableLayoutPanel.ResumeLayout(false);
             this.tableLayoutPanel.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit();

+ 90 - 91
Fuel_ASO/f_about.cs

@@ -1,26 +1,24 @@
 using Ionic.Utils.Zip;
+using Newtonsoft.Json;
 using System;
-using System.Collections.Generic;
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Drawing;
 using System.IO;
-using System.Linq;
 using System.Net;
+using System.Net.Http;
 using System.Reflection;
 using System.Text;
-using System.Text.RegularExpressions;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 
-
 namespace Fuel01
 {
     partial class f_about : Form
     {
         string runApp = "";
-        Boolean isSending = false;
+
         public f_about()
         {
             InitializeComponent();
@@ -28,27 +26,31 @@ namespace Fuel01
             this.labelProductName.Text = AssemblyProduct;
 
             string[] strVersion = AssemblyVersion.Split('.');
-            double version = Convert.ToDouble(strVersion[0]) * 100000 + Convert.ToDouble(strVersion[1]) * 1000 + Convert.ToDouble(strVersion[2])+ Convert.ToDouble(strVersion[3])/10000;
+            double version = Convert.ToDouble(strVersion[0]) * 100000 + Convert.ToDouble(strVersion[1]) * 1000 + Convert.ToDouble(strVersion[2]) + Convert.ToDouble(strVersion[3]) / 10000;
             double baseVersion = 0;
 
-            WebRequest request = WebRequest.Create(Properties.Settings.Default.server_adress_bin+".txt");
+            WebRequest request = WebRequest.Create(Properties.Settings.Default.server_adress_datas);
             try
             {
                 WebResponse response = request.GetResponse();
                 StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.ASCII);
                 string retour = sr.ReadToEnd();
                 sr.Close();
-                
-                if (double.TryParse(retour, out baseVersion))
-                    if (baseVersion > version)
-                        bt_maj.BackColor = Color.LightGreen;
+
+                if (double.TryParse(retour, out baseVersion) && baseVersion > version)
+                {
+                    bt_maj.BackColor = Color.LightGreen;
+                }
+            }
+            catch (Exception e)
+            {
+                MessageBox.Show(e.Message);
             }
-            catch (Exception e) {; }
 
-            this.labelVersion.Text = String.Format("Version {0}-{1}-{2}", AssemblyVersion,version,baseVersion);
+            this.labelVersion.Text = String.Format("Version {0}-{1}-{2}", AssemblyVersion, version, baseVersion);
             this.labelCopyright.Text = AssemblyCopyright;
             this.labelCompanyName.Text = AssemblyCompany;
-            this.textBoxDescription.Text = AssemblyDescription+"\r\n"+ this.textBoxDescription.Text;
+            this.textBoxDescription.Text = AssemblyDescription + "\r\n" + this.textBoxDescription.Text;
             this.textBoxDescription.Text += "\r\n" + Program.folder;
             this.textBoxDescription.Text += "\r\n" + Program.subfolder;
 
@@ -59,12 +61,12 @@ namespace Fuel01
             checkBoxLocale.Checked = Properties.Settings.Default.use_locale;
             textCopieAPI.Text = Properties.Settings.Default.adresse_copie_api;
 
-            bt_send.Enabled = File.Exists(Program.subfolder + @"\station.json"); 
+            bt_send.Enabled = File.Exists(Program.subfolder + @"\station.json");
         }
 
         #region Accesseurs d'attribut de l'assembly
 
-        public string AssemblyTitle
+        public static string AssemblyTitle
         {
             get
             {
@@ -81,7 +83,7 @@ namespace Fuel01
             }
         }
 
-        public string AssemblyVersion
+        public static string AssemblyVersion
         {
             get
             {
@@ -89,7 +91,7 @@ namespace Fuel01
             }
         }
 
-        public string AssemblyDescription
+        public static string AssemblyDescription
         {
             get
             {
@@ -102,7 +104,7 @@ namespace Fuel01
             }
         }
 
-        public string AssemblyProduct
+        public static string AssemblyProduct
         {
             get
             {
@@ -115,7 +117,7 @@ namespace Fuel01
             }
         }
 
-        public string AssemblyCopyright
+        public static string AssemblyCopyright
         {
             get
             {
@@ -128,7 +130,7 @@ namespace Fuel01
             }
         }
 
-        public string AssemblyCompany
+        public static string AssemblyCompany
         {
             get
             {
@@ -142,11 +144,6 @@ namespace Fuel01
         }
         #endregion
 
-        private void tableLayoutPanel_Paint(object sender, PaintEventArgs e)
-        {
-
-        }
-
         private void button2_Click(object sender, EventArgs e)
         {
 
@@ -168,12 +165,12 @@ namespace Fuel01
             if (dr == DialogResult.OK)
             {
                 DateTime dt = DateTime.Now;
-                string filename = fold.SelectedPath + @"\Result_" +dt.ToString("yy_MM_dd_hh_mm_ss") + ".txt";
+                string filename = fold.SelectedPath + @"\Result_" + dt.ToString("yy_MM_dd_hh_mm_ss") + ".txt";
                 StreamWriter writer = File.CreateText(filename);
-                var zip = new ZipFile(fold.SelectedPath + @"\Backup_" +dt.ToString("yy_MM_dd_hh_mm_ss") + ".zip", writer);
-                string tmpDir= Path.GetTempPath();
-                if (! Directory.Exists(tmpDir))
-                    tmpDir= Environment.GetEnvironmentVariable("temp");
+                var zip = new ZipFile(fold.SelectedPath + @"\Backup_" + dt.ToString("yy_MM_dd_hh_mm_ss") + ".zip", writer);
+                string tmpDir = Path.GetTempPath();
+                if (!Directory.Exists(tmpDir))
+                    tmpDir = Environment.GetEnvironmentVariable("temp");
                 if (!Directory.Exists(tmpDir))
                     tmpDir = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                 zip.TempFileFolder = tmpDir;
@@ -190,8 +187,7 @@ namespace Fuel01
             label1.Visible = true;
             this.Cursor = Cursors.WaitCursor;
             System.Windows.Forms.Application.DoEvents();
-            DateTime deb = DateTime.Now;
-
+            int i = 1;
             Properties.Settings.Default.chemin_copie_locale = textCopieLocal.Text;
             if (Properties.Settings.Default.use_locale)
             {
@@ -199,72 +195,74 @@ namespace Fuel01
                 File.Copy(Program.subfolder + @"\presta.json", Properties.Settings.Default.chemin_copie_locale + @"\presta.json", true);
                 File.Copy(Program.subfolder + @"\vehicule.json", Properties.Settings.Default.chemin_copie_locale + @"\vehicule.json", true);
                 File.Copy(Program.folder + @"\param\produit.json", Properties.Settings.Default.chemin_copie_locale + @"\produit.json", true);
-                sendFile(Program.subfolder + @"\station.json", 2);
-                sendFile(Program.subfolder + @"\presta.json", 2);
-                sendFile(Program.subfolder + @"\vehicule.json", 2);
-                sendFile(Program.folder + @"\param\produit.json", 2);
+                SendFile(Program.subfolder + @"\station.json").Wait();
+                UploadProgressChanged(i++, 4);
+                SendFile(Program.subfolder + @"\presta.json").Wait();
+                UploadProgressChanged(i++, 4);
+                SendFile(Program.subfolder + @"\vehicule.json").Wait() ;
+                UploadProgressChanged(i++, 4);
+                SendFile(Program.folder + @"\param\produit.json").Wait();
+                UploadProgressChanged(i, 4);
             }
             else
             {
 
-                sendFile(Program.subfolder + @"\station.json",3);
-                sendFile(Program.subfolder + @"\presta.json",3);
-                sendFile(Program.subfolder + @"\vehicule.json",3);
-                sendFile(Program.folder + @"\param\produit.json",3);
+                SendFile(Program.subfolder + @"\station.json").Wait();
+                UploadProgressChanged(i++, 4);
+                SendFile(Program.subfolder + @"\presta.json").Wait();
+                UploadProgressChanged(i++, 4);
+                SendFile(Program.subfolder + @"\vehicule.json").Wait();
+                UploadProgressChanged(i++, 4);
+                SendFile(Program.folder + @"\param\produit.json").Wait();
+                UploadProgressChanged(i, 4);
 
             }
-            Thread.Sleep(5000);
+            Thread.Sleep(500);
             label1.Visible = false;
             this.Cursor = Cursors.Default;
             System.Windows.Forms.Application.DoEvents();
-            
+
         }
 
-        private void sendFile(string fileName,int mode)
-        {
-            isSending = true;
-            if ( (mode & 1)==1)
+        private async Task SendFile(string fileName)
+        {           
+            var file = new TdfFile
+            {
+                Name = Path.GetFileName(fileName),
+                Data = Encoding.UTF8.GetBytes(File.ReadAllText(fileName))
+            };
+            try
             {
-                string chaine = Properties.Settings.Default.adresse_copie_api;
-                WebClient client = new WebClient();
-                client.UploadProgressChanged += new UploadProgressChangedEventHandler(Client_UploadProgressChanged);
-                client.UploadFileCompleted += new UploadFileCompletedEventHandler(Client_UploadFileCompleted);
-                client.UploadFileAsync(new Uri(chaine), "POST", fileName);
+                var client = new HttpClient();
+                var request = new HttpRequestMessage(HttpMethod.Post, $"{Properties.Settings.Default.adresse_copie_api}GetFile");
+                var content = new StringContent(JsonConvert.SerializeObject(file), null, "application/json");
+                request.Content = content;
+                var response = client.SendAsync(request).Result;
+                response.EnsureSuccessStatusCode();
+
+                client = new HttpClient();
+                request = new HttpRequestMessage(HttpMethod.Post, $"https://tdf.axpower.eu/api/FileUpload/GetFile");
+                content = new StringContent(JsonConvert.SerializeObject(file), null, "application/json");
+                request.Content = content;
+                var responseWeb = client.SendAsync(request).Result;
+                responseWeb.EnsureSuccessStatusCode();
+
+                Console.WriteLine(await response.Content.ReadAsStringAsync());
             }
-            if ((mode & 2) == 2)
+            catch (Exception ex)
             {
-                string chaine2 = @"http://www.aformatix.com/ASOStationService/api/FileUpLoad/upLoadFiles";
-                WebClient clientAfo = new WebClient();
-                clientAfo.UploadFileAsync(new Uri(chaine2), "POST", fileName);
+                Console.WriteLine($"ERRRRRRRRRRRRRRRREUUUUUUUUUURRRRRRRRRRR {ex.Message}");
             }
 
         }
 
-        private void Client_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
-        {
-            isSending = false;
-        }
-
-        private void Client_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
+        private void UploadProgressChanged(int value,int maxValue)
         {
-            double bytesIn = double.Parse(e.BytesSent.ToString());
-            double totalBytes = double.Parse(e.TotalBytesToSend.ToString());
-            double percentage = bytesIn / totalBytes * 100;
-
+            double percentage = value / maxValue * 100;
             progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
-
-
-        }
-
-        private void f_about_Load(object sender, EventArgs e)
-        {
-
+            System.Windows.Forms.Application.DoEvents();
         }
 
-        private void okButton_Click(object sender, EventArgs e)
-        {
-
-        }
 
         private void bt_clean_Click(object sender, EventArgs e)
         {
@@ -274,7 +272,7 @@ namespace Fuel01
 
         private void button2_Click_1(object sender, EventArgs e)
         {
-            string appName = Properties.Settings.Default.server_adress_bin.Substring(Properties.Settings.Default.server_adress_bin.LastIndexOf('/')+1);
+            string appName = Properties.Settings.Default.server_adress_bin.Substring(Properties.Settings.Default.server_adress_bin.LastIndexOf('/') + 1);
             string chaine = Properties.Settings.Default.server_adress_bin;
             string tmpDir = Path.GetTempPath();
             if (!Directory.Exists(tmpDir))
@@ -285,6 +283,7 @@ namespace Fuel01
             WebClient client = new WebClient();
             client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
             client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
+            client.Dispose();
 
             try
             {
@@ -300,7 +299,7 @@ namespace Fuel01
                 MessageBox.Show("Le téléchargement a échoué");
             }
             bt_maj.Text = "En cours..";
-            bt_maj.Enabled = false; ;
+            bt_maj.Enabled = false;
 
         }
 
@@ -326,7 +325,7 @@ namespace Fuel01
             }
             bt_maj.Text = "MAJ";
             bt_maj.Enabled = true;
-            bt_maj.BackColor = Color.Transparent; 
+            bt_maj.BackColor = Color.Transparent;
 
         }
 
@@ -356,24 +355,24 @@ namespace Fuel01
             }
 
             lblRes.Text = "....";
-            bool result = checkUrl(from.Text + ( (Button)sender == bt_chekAPI ? "test" : "" ));
-            chk.CheckState = result ? CheckState.Checked :CheckState.Unchecked ;
-            lblRes.Text= result.ToString();
+            bool result = checkUrl(from.Text + ((Button)sender == bt_chekAPI ? "test" : ""));
+            chk.CheckState = result ? CheckState.Checked : CheckState.Unchecked;
+            lblRes.Text = result.ToString();
 
         }
 
 
-        private bool checkUrl(string url)
+        private static bool checkUrl(string url)
         {
             bool ret = false;
 
             try
             {
                 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
-                request.Timeout = 5000; 
+                request.Timeout = 5000;
                 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                 ret = true;
-                response.Dispose();               
+                response.Dispose();
             }
             catch (Exception ex)
             {
@@ -386,12 +385,12 @@ namespace Fuel01
 
         private void bt_sav_Click(object sender, EventArgs e)
         {
-            if ( checkBoxDatas.CheckState == CheckState.Checked || checkAll.Checked )
-                Properties.Settings.Default.server_adress_datas=textSrvDatas.Text ;
+            if (checkBoxDatas.CheckState == CheckState.Checked || checkAll.Checked)
+                Properties.Settings.Default.server_adress_datas = textSrvDatas.Text;
             if (checkBoxBin.CheckState == CheckState.Checked || checkAll.Checked)
-                Properties.Settings.Default.server_adress_bin= textSrvBin.Text ;
+                Properties.Settings.Default.server_adress_bin = textSrvBin.Text;
             if (checkBoxSignalR.CheckState == CheckState.Checked || checkAll.Checked)
-                Properties.Settings.Default.server_signalr= textSignalR.Text ;
+                Properties.Settings.Default.server_signalr = textSignalR.Text;
 
             Properties.Settings.Default.chemin_copie_locale = textCopieLocal.Text;
             Properties.Settings.Default.use_locale = checkBoxLocale.Checked;
@@ -407,7 +406,7 @@ namespace Fuel01
             fold2.SelectedPath = textCopieLocal.Text;
             DialogResult res = fold2.ShowDialog();
             if (res == DialogResult.OK)
-                textCopieLocal.Text = fold2.SelectedPath; 
+                textCopieLocal.Text = fold2.SelectedPath;
 
         }
     }

+ 62 - 61
Fuel_ASO/f_facture.cs

@@ -18,21 +18,20 @@ namespace Fuel01
     {
 
         static ProdEqualityComparer prodEqC = new ProdEqualityComparer();
-        Dictionary<id_prod, vente_tot> lvente_tot = new Dictionary<id_prod, vente_tot>(prodEqC);
-        Dictionary<decimal, vente_tva> lvente_tva = new Dictionary<decimal, vente_tva>();
-        Dictionary<string, vente_tot> lvente_fact = new Dictionary<string, vente_tot>();
+        Dictionary<IdProd, VenteTot> lvente_tot = new Dictionary<IdProd, VenteTot>(prodEqC);
+        Dictionary<decimal, VenteTva> lvente_tva = new Dictionary<decimal, VenteTva>();
         DataSet1.tb_venteDataTable tb_vente = new DataSet1.tb_venteDataTable();
         DataSet1.tb_stationDataTable tb_station = new DataSet1.tb_stationDataTable();
 
         DataSet1.tb_stationRow current_sta = null;
+        string Id_sta { get; set; } 
 
-        string id_sta = "";
-        List<produit> lproduit = new List<produit>();
+        List<Produit> lproduit = new List<Produit>();
 
 
         public f_facture(string _id_sta)
         {
-            id_sta = _id_sta;
+            Id_sta = _id_sta;
             InitializeComponent();
 
             if (File.Exists(Program.subfolder + @"\station.json"))
@@ -48,9 +47,9 @@ namespace Fuel01
         private void f_facture_Load(object sender, EventArgs e)
         {
             tbventeBindingSource.DataSource = tb_vente;
-            tbventeBindingSource.Filter = " station_vt='" + id_sta + "'";
+            tbventeBindingSource.Filter = " station_vt='" + Id_sta + "'";
 
-            current_sta = tb_station.FindBykey_sta(id_sta);
+            current_sta = tb_station.FindBykey_sta(Id_sta);
 
             init_list_produit();
         }
@@ -71,7 +70,7 @@ namespace Fuel01
                     MessageBox.Show("Fichier de base " + Program.subfolder + @"\Facture_Carbu.xlsx non trouvé!!!", "Erreur");
                     return;
                 }
-                fileName = Program.subfolder + @"\Facture_" + id_sta + ".xlsx";
+                fileName = Program.subfolder + @"\Facture_" + Id_sta + ".xlsx";
                 File.Copy(Program.subfolder + @"\Facture_Carbu.xlsx", fileName, true);
 
 
@@ -87,7 +86,7 @@ namespace Fuel01
                 }
                 catch (Exception ex)
                 {
-                    MessageBox.Show("Vérifier que le fichier n'est pas ouvert et est un fichier Excel correct", "Ouverture de " + fileName + " impossible", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    MessageBox.Show($"Vérifier que le fichier n'est pas ouvert et est un fichier Excel correct  \r\n+ {ex.Message} ", "Ouverture de " + fileName + " impossible", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     if (xlApp != null)
                         xlApp.Quit();
                     this.Cursor = Cursors.Default;
@@ -110,34 +109,40 @@ namespace Fuel01
                 xlWorkSheet.Cells[48, 2].Value = makeItCLean(xlWorkSheet.Cells[48, 2].Value, current_sta["divers_sta"].ToString());
 
 
-                Dictionary<string, vente_tot> lvente_fact = new Dictionary<string, vente_tot>();
-                lvente_fact.Add("A - DIESEL", new vente_tot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
-                lvente_fact.Add("B - AUTRES CARBURANTS", new vente_tot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
+                Dictionary<string, VenteTot> lvente_fact = new Dictionary<string, VenteTot>();
+                lvente_fact.Add("A - DIESEL", new VenteTot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
+                lvente_fact.Add("B - AUTRES CARBURANTS", new VenteTot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
 
-                List<simul> lsimul = new List<simul>();
                 lvente_tot.Clear();
 
                 try
                 {
 
 
-                    foreach (DataSet1.tb_venteRow myrow in tb_vente.Where(p => p.station_vt == id_sta))
+                    foreach (DataSet1.tb_venteRow myrow in tb_vente.Where(p => p.station_vt == Id_sta))
                     {
-                        vente_tot myFact = null;
-                        produit pdt = lproduit.Find(xx => xx.key_prod == myrow.prod_vt);
-                        string lib_produit = "";
+                        VenteTot myFact = null;
+                        Produit pdt = lproduit.Find(xx => xx.key_prod == myrow.prod_vt);
                         string sort = "Z";
                         if (pdt != null) // Produit référencé
                         {
-                            sort = pdt.type_prod == "Carburant" ? (myrow.prod_vt.ToUpper().Contains("DIESEL") ? "A - DIESEL" : "B - AUTRES CARBURANTS") : "C - PRODUITS DIVERS";
-                            lib_produit = pdt.lib_prod;
+                            var isDIesel = myrow.prod_vt.ToUpper().Contains("DIESEL");
+                            if (isDIesel)
+                            {
+                                sort = pdt.type_prod == "Carburant" ? ("A - DIESEL") : "C - PRODUITS DIVERS";
+                            }
+                            else
+                            {
+                                sort = pdt.type_prod == "Carburant" ? ("B - AUTRES CARBURANTS") : "C - PRODUITS DIVERS";
+                            }
                         }
                         else
+                        {
                             sort = "C - PRODUITS DIVERS";
-                        id_prod my_id = new id_prod { code_pro = myrow.prod_vt, ttc_pro = myrow.pu_vt, tva_pro = myrow.tva_vt, lib_pro = lib_produit, type_pro = sort };
+                        }
 
                         if (!lvente_fact.ContainsKey(sort))
-                            lvente_fact.Add(sort, new vente_tot { vente = myrow, total_ttc = 0, total_qtt = 0, total_ht = 0 });
+                            lvente_fact.Add(sort, new VenteTot { vente = myrow, total_ttc = 0, total_qtt = 0, total_ht = 0 });
 
                         myFact = lvente_fact[sort];
                         myFact.total_qtt += myrow.qtt_vt;
@@ -149,7 +154,7 @@ namespace Fuel01
 
                     int lig = 21;
                     decimal totgal = 0;
-                    foreach (KeyValuePair<string, vente_tot> myVente in lvente_fact)
+                    foreach (KeyValuePair<string, VenteTot> myVente in lvente_fact)
                     {
 
                         Console.WriteLine(string.Format(" Type :{0}  ", myVente.Key));
@@ -164,8 +169,6 @@ namespace Fuel01
                     }
 
                     xlWorkSheet.Cells[41, 6].Value = totgal;
-                    lig = 44;
-
                     xlWorkBook.Save();
                     xlWorkBook.Close();
                 }
@@ -180,7 +183,7 @@ namespace Fuel01
 
 
                 ProcessStartInfo notepadStartInfo = new ProcessStartInfo(fileName);
-                Process notepad = Process.Start(notepadStartInfo);
+                Process.Start(notepadStartInfo);
             }
             catch (Exception ex)
             {
@@ -190,12 +193,13 @@ namespace Fuel01
         }
 
 
-        private string makeItCLean(string strExcel, string data)
+        private static  string makeItCLean(string strExcel, string data)
         {
             string ret = data;
-            if (strExcel.Length > 0)
-                if (strExcel.Substring(0, 1) == "#")
+            if (strExcel.Length > 0 && strExcel.Substring(0, 1) == "#") 
+            { 
                     ret = strExcel.Substring(1) + data;
+            }
             return ret;
         }
         private void f_facture_FormClosing(object sender, FormClosingEventArgs e)
@@ -210,7 +214,7 @@ namespace Fuel01
             XDocument xRoot = XDocument.Load(Program.folder + @"\param\produit.xml");
             var data = from item in xRoot.Descendants("tb_prod")
                        orderby item.Element("type_prod").Value, item.Element("lib_prod").Value
-                       select new produit()
+                       select new Produit()
                        {
                            key_prod = item.Element("key_prod").Value,
                            lib_prod = item.Element("lib_prod").Value,
@@ -221,39 +225,45 @@ namespace Fuel01
 
         private void bt_simul_Click(object sender, EventArgs e)
         {
+            Dictionary<string, VenteTot> lvente_fact = new Dictionary<string, VenteTot>();
+            lvente_fact.Add("A - DIESEL", new VenteTot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
+            lvente_fact.Add("B - AUTRES CARBURANTS", new VenteTot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
 
-            //makeChange();
-            Dictionary<string, vente_tot> lvente_fact = new Dictionary<string, vente_tot>();
-            lvente_fact.Add("A - DIESEL", new vente_tot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
-            lvente_fact.Add("B - AUTRES CARBURANTS", new vente_tot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
-
-            List<simul> lsimul = new List<simul>();
+            List<Simul> lsimul = new List<Simul>();
             lvente_tot.Clear();
             lvente_tva.Clear();
 
             try
             {
 
-                foreach (DataSet1.tb_venteRow myrow in tb_vente.Where(p => p.station_vt == id_sta))
+                foreach (DataSet1.tb_venteRow myrow in tb_vente.Where(p => p.station_vt == Id_sta))
                 {
-                    vente_tot myTot = null;
-                    vente_tot myFact = null;
-                    produit pdt = lproduit.Find(xx => xx.key_prod == myrow.prod_vt);
+                    VenteTot myTot = null;
+                    VenteTot myFact = null;
+                    Produit pdt = lproduit.Find(xx => xx.key_prod == myrow.prod_vt);
                     string lib_produit = "";
                     string sort = "Z";
                     if (pdt != null) // Produit référencé
                     {
-                        sort = pdt.type_prod == "Carburant" ? (myrow.prod_vt.ToUpper().Contains("DIESEL") ? "A - DIESEL" : "B - AUTRES CARBURANTS") : "C - PRODUITS DIVERS";
+                        var isDIesel = myrow.prod_vt.ToUpper().Contains("DIESEL");
+                        if (isDIesel)
+                        {
+                            sort = pdt.type_prod == "Carburant" ? ("A - DIESEL") : "C - PRODUITS DIVERS";
+                        }
+                        else
+                        {
+                            sort = pdt.type_prod == "Carburant" ? ("B - AUTRES CARBURANTS") : "C - PRODUITS DIVERS";
+                        }
                         lib_produit = pdt.lib_prod;
                     }
                     else
                         sort = "C - PRODUITS DIVERS";
-                    id_prod my_id = new id_prod { code_pro = myrow.prod_vt, ttc_pro = myrow.pu_vt, tva_pro = myrow.tva_vt, lib_pro = lib_produit, type_pro = sort };
+                    IdProd my_id = new IdProd { code_pro = myrow.prod_vt, ttc_pro = myrow.pu_vt, tva_pro = myrow.tva_vt, lib_pro = lib_produit, type_pro = sort };
 
                     if (!lvente_fact.ContainsKey(sort))
-                        lvente_fact.Add(sort, new vente_tot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
+                        lvente_fact.Add(sort, new VenteTot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
                     if (!lvente_tot.ContainsKey(my_id))
-                        lvente_tot.Add(my_id, new vente_tot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
+                        lvente_tot.Add(my_id, new VenteTot { vente = null, total_ttc = 0, total_qtt = 0, total_ht = 0 });
 
                     myTot = lvente_tot[my_id];
                     myTot.total_qtt += myrow.qtt_vt;
@@ -265,11 +275,11 @@ namespace Fuel01
                     myFact.total_ht += myrow.ht_vt;
                     myFact.total_ttc += myrow.ttc_vt;
 
-                    vente_tva myTva = null;
+                    VenteTva myTva = null;
                     if (myrow.tva_vt != 0)
                     {
                         if (!lvente_tva.ContainsKey(myrow.tva_vt))
-                            lvente_tva.Add(myrow.tva_vt, new vente_tva { taux_tva = myrow.tva_vt, base_tva = 0, mnt_ttc = 0, mnt_tva = 0 });
+                            lvente_tva.Add(myrow.tva_vt, new VenteTva { taux_tva = myrow.tva_vt, base_tva = 0, mnt_ttc = 0, mnt_tva = 0 });
 
                         myTva = lvente_tva[myrow.tva_vt];
                         myTva.base_tva += myrow.ht_vt;
@@ -282,27 +292,23 @@ namespace Fuel01
 
 
                 int nbprod = 0;
-                int lig = 21;
                 decimal totgal = 0;
 
-                foreach (KeyValuePair<string, vente_tot> myVente in lvente_fact)
+                foreach (KeyValuePair<string, VenteTot> myVente in lvente_fact)
                 {
 
                     Console.WriteLine(string.Format(" Type :{0}  ", myVente.Key));
-                    DataSet1.tb_venteRow detailVente = myVente.Value.vente;
-                    simul sm = new simul();
+                    Simul sm = new Simul();
                     sm.libel = myVente.Key;
                     sm.qtt = 0;
                     sm.pu = 0;
                     sm.prix = myVente.Value.total_ttc;
                     totgal += sm.prix;
-                    lig += 1;
                     nbprod += 1;
                     lsimul.Add(sm);
                 }
-                lsimul.Add(new simul { libel = "Total", prix = totgal, qtt = null, pu = null });
+                lsimul.Add(new Simul { libel = "Total", prix = totgal, qtt = null, pu = null });
 
-                lig = 44;
                 dg_simul.DataSource = lsimul;
 
                 dg_simul.Columns[0].Width = 300;
@@ -366,15 +372,10 @@ namespace Fuel01
             float tva = 0;
             float ttc = 0;
             float ht = 0;
-            bool ok = true;
-            ok = float.TryParse(vt_ttc.Text, out ttc);
-            if (ok) ok = float.TryParse(vt_pu.Text, out puttc);
-            if (ok) ok = float.TryParse(vt_tva.Text, out tva);
-            if (ok) ok = float.TryParse(vt_ht.Text, out ht);
-            if (ok) ok = float.TryParse(vt_ttc.Text, out ttc);
+            
             qtt = ttc / puttc;
             ht = (qtt * puttc) / (1 + (tva / 100));
-            float dif = ttc - ht;
+
             vt_qtt.Text = String.Format("{0:0.00}", qtt);
             vt_ht.Text = String.Format("{0:0.00}", ht);
 
@@ -399,7 +400,7 @@ namespace Fuel01
         }
     }
 
-    public class simul
+    public class Simul
     {
         public string libel { get; set; }
         public decimal? qtt { get; set; }

+ 12 - 15
Fuel_ASO/f_impvehi.Designer.cs

@@ -1,6 +1,6 @@
 namespace Fuel01
 {
-    partial class f_impvehi
+    partial class F_impvehi
     {
         /// <summary>
         /// Required designer variable.
@@ -162,7 +162,7 @@
             this.bt_ok.TabIndex = 2;
             this.bt_ok.Text = "GO !";
             this.bt_ok.UseVisualStyleBackColor = true;
-            this.bt_ok.Click += new System.EventHandler(this.bt_ok_Click);
+            this.bt_ok.Click += new System.EventHandler(this.Bt_ok_Click);
             // 
             // bt_openFile
             // 
@@ -172,7 +172,7 @@
             this.bt_openFile.TabIndex = 1;
             this.bt_openFile.Text = "Choisir le fichier Parc";
             this.bt_openFile.UseVisualStyleBackColor = true;
-            this.bt_openFile.Click += new System.EventHandler(this.bt_openFile_Click);
+            this.bt_openFile.Click += new System.EventHandler(this.Bt_openFile_Click);
             // 
             // textNomFile
             // 
@@ -403,7 +403,7 @@
             this.tb_allValid.TabIndex = 47;
             this.tb_allValid.Text = "Valider";
             this.tb_allValid.UseVisualStyleBackColor = true;
-            this.tb_allValid.Click += new System.EventHandler(this.tb_allValid_Click);
+            this.tb_allValid.Click += new System.EventHandler(this.Tb_allValid_Click);
             // 
             // bt_Sup
             // 
@@ -414,7 +414,7 @@
             this.bt_Sup.TabIndex = 15;
             this.bt_Sup.Text = "Supprimer";
             this.bt_Sup.UseVisualStyleBackColor = true;
-            this.bt_Sup.Click += new System.EventHandler(this.bt_Sup_Click);
+            this.bt_Sup.Click += new System.EventHandler(this.Bt_Sup_Click);
             // 
             // Bt_Abort
             // 
@@ -436,7 +436,7 @@
             this.bt_Valid.TabIndex = 16;
             this.bt_Valid.Text = "Valider";
             this.bt_Valid.UseVisualStyleBackColor = true;
-            this.bt_Valid.Click += new System.EventHandler(this.bt_Valid_Click);
+            this.bt_Valid.Click += new System.EventHandler(this.Bt_Valid_Click);
             // 
             // bt_Aj
             // 
@@ -447,7 +447,7 @@
             this.bt_Aj.TabIndex = 14;
             this.bt_Aj.Text = "Ajouter";
             this.bt_Aj.UseVisualStyleBackColor = true;
-            this.bt_Aj.Click += new System.EventHandler(this.bt_Aj_Click);
+            this.bt_Aj.Click += new System.EventHandler(this.Bt_Aj_Click);
             // 
             // bt_Mod
             // 
@@ -458,7 +458,7 @@
             this.bt_Mod.TabIndex = 13;
             this.bt_Mod.Text = "Modifier";
             this.bt_Mod.UseVisualStyleBackColor = true;
-            this.bt_Mod.Click += new System.EventHandler(this.bt_Mod_Click);
+            this.bt_Mod.Click += new System.EventHandler(this.Bt_Mod_Click);
             // 
             // combo_famille
             // 
@@ -537,8 +537,8 @@
             this.combo_energy.Name = "combo_energy";
             this.combo_energy.Size = new System.Drawing.Size(164, 21);
             this.combo_energy.TabIndex = 8;
-            this.combo_energy.TextUpdate += new System.EventHandler(this.combo_energy_TextUpdate);
-            this.combo_energy.TextChanged += new System.EventHandler(this.combo_energy_TextUpdate);
+            this.combo_energy.TextUpdate += new System.EventHandler(this.Combo_energy_TextUpdate);
+            this.combo_energy.TextChanged += new System.EventHandler(this.Combo_energy_TextUpdate);
             // 
             // label3
             // 
@@ -660,8 +660,8 @@
             this.ShowIcon = false;
             this.ShowInTaskbar = false;
             this.Text = "Importation Véhicules";
-            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.f_vehi_FormClosing);
-            this.Load += new System.EventHandler(this.vehi_Load);
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.F_vehi_FormClosing);
+            this.Load += new System.EventHandler(this.Vehi_Load);
             this.statusStrip1.ResumeLayout(false);
             this.statusStrip1.PerformLayout();
             this.splitContainer1.Panel1.ResumeLayout(false);
@@ -685,9 +685,6 @@
         #endregion
 
         private System.Windows.Forms.BindingSource tbvehiculeBindingSource;
-        private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn;
-        private System.Windows.Forms.DataGridViewTextBoxColumn immatDataGridViewTextBoxColumn;
-        private System.Windows.Forms.DataGridViewTextBoxColumn familleDataGridViewTextBoxColumn;
         private System.Windows.Forms.StatusStrip statusStrip1;
         private System.Windows.Forms.ToolStripStatusLabel st1;
         private DataSet1 dataSet1;

+ 370 - 361
Fuel_ASO/f_impvehi.cs

@@ -1,261 +1,83 @@
 using System;
 using System.Collections.Generic;
-using System.ComponentModel;
 using System.Data;
-using System.Drawing;
 using System.IO;
 using System.Linq;
 using System.Text;
-using System.Threading.Tasks;
+using System.Threading;
 using System.Windows.Forms;
 using System.Xml.Linq;
 using Excel = Microsoft.Office.Interop.Excel;
 
-
 namespace Fuel01
 {
-    public partial class f_impvehi : Form
+    public partial class F_impvehi : Form
     {
-        DataSet1.tb_vehiDataTable tb_vehi = new DataSet1.tb_vehiDataTable();
+        private readonly string mode;
         private bool hasChanged = false;
-        string mode = "";
-        List<produit> lproduit = new List<produit>();
-        List<produit> lcarbu = new List<produit>();
-        List<famille> lfamille = new List<famille>();
+        private List<Produit> lcarbu = new List<Produit>();
+        private List<Famille> lfamille = new List<Famille>();
+        private List<Produit> lproduit = new List<Produit>();
+        private DataSet1.tb_vehiDataTable tb_vehi = new DataSet1.tb_vehiDataTable();
 
-        public f_impvehi(string _mode)
+        public F_impvehi(string _mode)
         {
             InitializeComponent();
             mode = _mode;
         }
 
-        private void vehi_Load(object sender, EventArgs e)
+        private void Bt_ok_Click(object sender, EventArgs e)
         {
-
-            Program.subfolder = Program.folder + @"\" + Program.key_ope;
-
-            if (!Directory.Exists(Program.subfolder))
-                Directory.CreateDirectory(Program.subfolder);
-            else
+            if (checkZero.Checked)
             {
-                if (File.Exists(Program.subfolder + @"\vehicule.json"))
-                    tb_vehi = DbUtil.LoadFromJson<DataSet1.tb_vehiDataTable>(Program.subfolder + @"\vehicule.json", tb_vehi);
+                tb_vehi.Clear();
             }
-            tb_vehi.AcceptChanges();
-            tbvehiculeBindingSource.DataSource = tb_vehi;
-
-            turn_txt(false);
-            turn_bt(false);
-            if (Program.key_ope != null)
-                this.Text = "Importation Véhicules " + Program.nom_ope;
-
-            if (File.Exists(Program.folder + @"\param\famille.xml"))
-                init_list_famille();
-            if (File.Exists(Program.folder + @"\param\produit.xml"))
-                init_list_produit();
-
-
-        }
-
-        private void init_list_famille()
-        {
-            XDocument xRoot = XDocument.Load(Program.folder + @"\param\famille.xml");
-            var data = from item in xRoot.Descendants("tb_famille")
-                       orderby item.Element("key_fam").Value
-                       select new famille()
-                       {
-                           key_fam = item.Element("key_fam").Value
-                       };
-            lfamille = data.ToList();
-            combo_famille.Items.Clear();
-            combo_famille.DisplayMember = "key_fam";
-            foreach (famille f in lfamille)
-                combo_famille.Items.Add(f);
-        }
-
-        private void init_list_produit()
-        {
-
-            XDocument xRoot = XDocument.Load(Program.folder + @"\param\produit.xml");
-            var data = from item in xRoot.Descendants("tb_prod")
-                       orderby item.Element("type_prod").Value, item.Element("lib_prod").Value
-                       select new produit()
-                       {
-                           key_prod = item.Element("key_prod").Value,
-                           lib_prod = item.Element("lib_prod").Value,
-                           type_prod = item.Element("type_prod").Value
-                       };
-            lproduit = data.ToList();
-            lcarbu = lproduit.Where(p => p.type_prod == "Carburant").ToList();
-            combo_energy.Items.Clear();
-            combo_energy.DisplayMember = "key_prod";
-            foreach (produit p in lcarbu)
-                combo_energy.Items.Add(p);
-        }
-
-        #region affichage
-        private void turn_txt(bool act)
-        {
-            text_immat_vehi.Enabled = act;
-            text_num_vehi.Enabled = act;
-            text_cmpnum_vehi.Enabled = act;
-            text_type_vehi.Enabled = act;
-            text_kmdep_vehi.Enabled = act;
-            text_kmarr_vehi.Enabled = act;
-            text_cond_vehi.Enabled = act;
-            combo_energy.Enabled = act;
-            combo_famille.Enabled = act;
-            text_sort_vehi.Enabled = act;
-
-        }
-
-        private void turn_bt(bool act)
-        {
-            Bt_Abort.Enabled = act;
-            bt_Valid.Enabled = act;
-            bt_Mod.Enabled = !act;
-            bt_Aj.Enabled = !act;
-            bt_Sup.Enabled = !act;
-            dg_vehi.Enabled = !act;
-        }
-        #endregion
-
-        #region Boutons
-
-
-        private void bt_Mod_Click(object sender, EventArgs e)
-        {
-            turn_bt(true);
-            turn_txt(true);
-        }
-
-        private void bt_Aj_Click(object sender, EventArgs e)
-        {
-            turn_txt(true);
-            turn_bt(true);
-            string key = findNewkey();
-            DataSet1.tb_vehiRow myNewRow = tb_vehi.Newtb_vehiRow();
-            myNewRow["key_vehi"] = key;
-            myNewRow["ope_vehi"] = Program.nom_ope;
-            tb_vehi.Addtb_vehiRow(myNewRow);
-            tbvehiculeBindingSource.MoveFirst();
-            DataRowView myRow = tbvehiculeBindingSource.Current as DataRowView;
-            while (myRow.Row["key_vehi"].ToString() != key)
+            if (mode == "tdf")
             {
-                tbvehiculeBindingSource.MoveNext();
-                myRow = tbvehiculeBindingSource.Current as DataRowView;
+                Import_tdf();
             }
-        }
-
-        private void bt_Sup_Click(object sender, EventArgs e)
-        {
-            DataRowView myRow = tbvehiculeBindingSource.Current as DataRowView;
-            if (myRow == null) return;
-            string msg = string.Format("Vehicule {0}\nEtes-vous certain de vouloir supprimer \n{1}", myRow.Row["num_vehi"].ToString(), myRow.Row["immat_vehi"].ToString());
-            string caption = "Suppression définitive";
-            if (MessageBox.Show(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
+            else if (mode == "parc")
             {
-                DataSet1.tb_vehiRow vehiRow = tb_vehi.FindBykey_vehi(myRow.Row["key_vehi"].ToString());
-                if (vehiRow != null)
-                    tb_vehi.Removetb_vehiRow(vehiRow);
-                hasChanged = true;
+                Import_parc();
             }
-        }
-
-        private void bt_Valid_Click(object sender, EventArgs e)
-        {
-            tb_vehi.AcceptChanges();
-            turn_txt(false);
-            turn_bt(false);
-            hasChanged = true;
-
-        }
-
-        private void Bt_Abort_Click(object sender, EventArgs e)
-        {
-            tb_vehi.RejectChanges();
-            turn_txt(false);
-            turn_bt(false);
-        }
-        #endregion
-
-        #region fonctions
-
-        private string findNewkey()
-        {
-            Random rand1 = new Random();
-            string key = rand1.Next(99999).ToString();
-            while (tb_vehi.FindBykey_vehi(key) != null)
+            else
             {
-                //MessageBox.Show(key);
-                key = rand1.Next(99999).ToString();
+                Import_PN();
             }
-            return key;
-        }
-
-        private DataSet1.tb_vehiRow findOnekey(int bandeau, string cmp, string typevehi)
-        {
-            DataSet1.tb_vehiRow onevevi = tb_vehi.FirstOrDefault(v => v.num_vehi == bandeau);
-            //while (tb_vehi.FindBykey_vehi(key) != null)
-            //{
-            //    //MessageBox.Show(key);
-            //    key = rand1.Next(99999).ToString();
-            //}
-            //return key;
-            return onevevi;
-        }
-        #endregion
-
-        private void f_vehi_FormClosing(object sender, FormClosingEventArgs e)
-        {
-            if (hasChanged) saveData();
-            DataTable tb_vehi_change = tb_vehi.GetChanges();
-            tb_vehi_change = null;
-            if (tb_vehi_change != null) MessageBox.Show("Veuillez Valider ou Abandonner", "Modifications en cours");
-            e.Cancel = (tb_vehi_change != null);
         }
 
-        private void saveData()
+        private void Bt_openFile_Click(object sender, EventArgs e)
         {
-            if (File.Exists(Program.subfolder + @"\vehicule.json"))
-                File.Copy(Program.subfolder + @"\vehicule.json", Program.subfolder + @"\vehicule.back.json", true);
-            
-            DbUtil.SaveToJson<DataSet1.tb_vehiDataTable>(Program.subfolder + @"\statvehiculeion.json", tb_vehi);
+            System.Windows.Forms.DialogResult res = openFileParc.ShowDialog();
+            if (res == System.Windows.Forms.DialogResult.OK)
+            {
+                textNomFile.Text = openFileParc.FileName;
+            }
+            bt_ok.Enabled = (res == System.Windows.Forms.DialogResult.OK);
         }
 
-        private void combo_energy_TextUpdate(object sender, EventArgs e)
+        private void Combo_energy_TextUpdate(object sender, EventArgs e)
         {
-            produit cur_Prod = lproduit.Find(p => p.key_prod == combo_energy.Text);
+            Produit cur_Prod = lproduit.Find(p => p.key_prod == combo_energy.Text);
             if (cur_Prod != null)
                 StatusLabel1.Text = cur_Prod.lib_prod;
             else
                 StatusLabel1.Text = "...";
         }
 
-        private void bt_openFile_Click(object sender, EventArgs e)
+        private void F_vehi_FormClosing(object sender, FormClosingEventArgs e)
         {
-            System.Windows.Forms.DialogResult res = openFileParc.ShowDialog();
-            if (res == System.Windows.Forms.DialogResult.OK)
+            if (hasChanged) SaveData();
+            DataTable tb_vehi_change = tb_vehi.GetChanges();
+
+            if (tb_vehi_change != null)
             {
-                textNomFile.Text = openFileParc.FileName;
+                MessageBox.Show("Veuillez Valider ou Abandonner", "Modifications en cours");
             }
-            bt_ok.Enabled = (res == System.Windows.Forms.DialogResult.OK);
-        }
-
-        private void bt_ok_Click(object sender, EventArgs e)
-        {
-            if (checkZero.Checked)
-                tb_vehi.Clear();
-            if (mode == "tdf")
-                import_tdf();
-            else
-                if (mode == "parc")
-                import_parc();
-            else
-                import_PN(); ;
+            e.Cancel = (tb_vehi_change != null);
         }
 
-        private void import_PN()
+        private void Import_parc()
         {
             Excel.Application xlApp;
             Excel.Workbook xlWorkBook;
@@ -266,29 +88,28 @@ namespace Fuel01
                 xlApp = new Excel.Application();
                 xlWorkBook = xlApp.Workbooks.Open(textNomFile.Text, misValue);
                 xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
-
             }
             catch (Exception ex)
             {
-                MessageBox.Show("Vérifier que le fichier n'est pas ouvert et est un fichier Excel correct", "Ouverture de " + textNomFile.Text + " impossible", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                MessageBox.Show($"Vérifier que le fichier n'est pas ouvert et est un fichier Excel correct {ex.Message}", "Ouverture de " + textNomFile.Text + " impossible", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
-            uint[] indexCol = { 1, 3, 4, 6, 7, 8, 9 };
-            string categ = "A";
-            for (uint row = 2; row < 200; row++)
+
+            uint[] indexCol = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15 };
+            for (uint row = 3; row < 800; row++)
             {
                 string model = "";
                 string immat = "";
                 string bandeau = "";
-                string carbu = "";
                 string famille = "";
                 string pilote = "";
-                bool ligneVide = true;
+                string carbu = "D";
+                string cmp = "";
+                string categ = "A";
 
                 int vide = 0;
                 for (int colNdx = 0; colNdx < indexCol.Length; colNdx++)
                 {
-
                     uint col = indexCol[colNdx];
                     var varex = xlWorkSheet.Cells[row, col].Value;
                     if (varex != null)
@@ -303,47 +124,56 @@ namespace Fuel01
                             case "System.Double":
                                 b = ((Int32)varex).ToString();
                                 break;
+
                             default:
                                 b = (string)varex;
                                 break;
-
                         }
 
-
-                        b = b.Replace('\n', ' ');
                         while (b.Contains("  "))
                             b = b.Replace("  ", " ");
                         switch (col)
                         {
                             case 1:
                                 bandeau = b;
-                                ligneVide = false;
                                 break;
-                            case 3:
+
+                            case 2:
                                 famille = b;
-                                ligneVide = false;
                                 break;
-                            case 4:
+
+                            case 3:
                                 pilote = b;
-                                ligneVide = false;
                                 break;
+
+                            case 4:
+                                pilote = new StringBuilder(pilote).Append(" ").Append(b).ToString();
+                                break;
+
+                            case 5:
+                                carbu = b;
+                                break;
+
                             case 6:
                                 model = b;
                                 break;
+
                             case 7:
-                                carbu = b;
-                                ligneVide = false;
+                                immat = new StringBuilder(immat).Append(b).Append(" ").ToString();
                                 break;
+
                             case 8:
-                                immat = b;
-                                ligneVide = false;
+                                immat = new StringBuilder(immat).Append(b).Append(" ").ToString();
                                 break;
+
                             case 9:
-                                categ = b;
-                                ligneVide = false;
+                                immat = new StringBuilder(immat).Append(b).Append(" ").ToString();
                                 break;
-                        }
 
+                            case 15:
+                                categ = b.ToUpper() == "M" ? "M" : "A";
+                                break;
+                        }
                     }
                 }
 
@@ -357,31 +187,69 @@ namespace Fuel01
                     {
                         if (!checkZero.Checked)
                         {
-                            myNewRow = findOnekey(Convert.ToInt32(bandeau), "", categ);
-                            if (myNewRow != null)
+
+                            myNewRow = FindOnekey(bandeau);
+                            if (myNewRow == null)
+                            {
+                                continue;
+                            }
+                            else
+                            {
                                 key = myNewRow["key_vehi"].ToString();
+                            }
                         }
                         if (myNewRow == null)
                         {
-                            key = findNewkey();
+                            key = FindNewkey();
                             myNewRow = tb_vehi.Newtb_vehiRow();
                             newrow = true;
                         }
                         myNewRow["key_vehi"] = key;
                         myNewRow["ope_vehi"] = Program.key_ope;
                         myNewRow["num_vehi"] = bandeau;
-                        myNewRow["cmpnum_vehi"] = "";
+                        myNewRow["cmpnum_vehi"] = cmp;
                         myNewRow["immat_vehi"] = immat;
                         myNewRow["type_vehi"] = model;
                         myNewRow["famille_vehi"] = famille;
                         myNewRow["categ_vehi"] = categ;
                         myNewRow["cond_vehi"] = pilote;
                         myNewRow["sort1_vehi"] = string.Format("{0}{1:00000}{2}", myNewRow["categ_vehi"], myNewRow["num_vehi"], myNewRow["cmpnum_vehi"]);
-                        myNewRow["carbu_vehi"] = carbu == "E" ? "SP98" : "DIESEL";
+                        switch (carbu)
+                        {
+                            case "D":
+                                carbu = "DIESEL";
+                                break;
+
+                            case "E":
+                                carbu = "SP98";
+                                break;
+
+                            default:
+                                carbu = "?";
+                                break;
+                        }
+
+                        if (carbu == "?")
+                        {
+                            if (categ == "M")
+                            {
+                                myNewRow["carbu_vehi"] = "SP98";
+                            }
+                            else
+                            {
+                                myNewRow["carbu_vehi"] = "DIESEL";
+                            }
+                        }
+                        else
+                        {
+                            myNewRow["carbu_vehi"] = carbu;
+                        }
+
                         if (newrow)
                             tb_vehi.Addtb_vehiRow(myNewRow);
                         StatusLabel1.Text = string.Format("{0}{1:00000}{2}-{3}-{4}", myNewRow["categ_vehi"], myNewRow["num_vehi"], myNewRow["cmpnum_vehi"], myNewRow["cond_vehi"], myNewRow["immat_vehi"]);
                         Application.DoEvents();
+                        Thread.Sleep(5);
                     }
                     catch (Exception ex)
                     {
@@ -389,22 +257,20 @@ namespace Fuel01
                     }
                 }
                 else
-                    vide++;
+                { vide++; }
                 if (vide > 10)
+                {
                     break;
-
+                }
             }
-            if (xlApp != null)
-                xlApp.Quit();
 
-            StatusLabel1.Text = "F I N I .................";
+            xlApp?.Quit();
 
+            StatusLabel1.Text = "F I N I .................";
         }
 
-
-        private void import_tdf()
+        private void Import_PN()
         {
-
             Excel.Application xlApp;
             Excel.Workbook xlWorkBook;
             Excel.Worksheet xlWorkSheet;
@@ -414,31 +280,26 @@ namespace Fuel01
                 xlApp = new Excel.Application();
                 xlWorkBook = xlApp.Workbooks.Open(textNomFile.Text, misValue);
                 xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
-
             }
             catch (Exception ex)
             {
-                MessageBox.Show("Vérifier que le fichier n'est pas ouvert et est un fichier Excel correct", "Ouverture de " + textNomFile.Text + " impossible", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                MessageBox.Show($"Vérifier que le fichier n'est pas ouvert et est un fichier Excel correct \r\n {ex.Message}", "Ouverture de " + textNomFile.Text + " impossible", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
-
-            //uint[] indexCol = { 1, 3, 4, 5, 6, 7, 10, 11 };
-            uint[] indexCol = { 2, 4, 5, 6, 7, 8, 11, 12 };
+            uint[] indexCol = { 1, 3, 4, 6, 7, 8, 9 };
             string categ = "A";
-            for (uint row = 2; row < 800; row++)
+            for (uint row = 2; row < 200; row++)
             {
                 string model = "";
                 string immat = "";
                 string bandeau = "";
-                string cmp = "";
+                string carbu = "";
                 string famille = "";
                 string pilote = "";
-                bool ligneVide = true;
 
                 int vide = 0;
                 for (int colNdx = 0; colNdx < indexCol.Length; colNdx++)
                 {
-
                     uint col = indexCol[colNdx];
                     var varex = xlWorkSheet.Cells[row, col].Value;
                     if (varex != null)
@@ -453,68 +314,48 @@ namespace Fuel01
                             case "System.Double":
                                 b = ((Int32)varex).ToString();
                                 break;
+
                             default:
                                 b = (string)varex;
                                 break;
-
                         }
 
-                        int p;
-                        if (col == 12 && (p = b.IndexOf('\n')) != -1)
-                            b = b.Substring(0, p);
                         b = b.Replace('\n', ' ');
                         while (b.Contains("  "))
                             b = b.Replace("  ", " ");
                         switch (col)
                         {
-                            case 2:
-                                model = b;
-                                ligneVide = false;
+                            case 1:
+                                bandeau = b;
                                 break;
-                            case 4:
-                                immat = immat + b + " ";
+
+                            case 3:
+                                famille = b;
                                 break;
-                            case 5:
-                                ligneVide = false;
-                                immat = immat + b + " ";
+
+                            case 4:
+                                pilote = b;
                                 break;
+
                             case 6:
-                                ligneVide = false;
-                                immat = immat + b + " ";
+                                model = b;
                                 break;
+
                             case 7:
-                                bandeau = b;
-                                ligneVide = false;
+                                carbu = b;
                                 break;
-                            case 8:
-                                cmp = b;
-                                ligneVide = false;
 
+                            case 8:
+                                immat = b;
                                 break;
-                            case 11:
-                                famille = b;
-                                ligneVide = false;
-                                break;
-                            case 12:
-                                pilote = b;
-                                ligneVide = false;
+
+                            case 9:
+                                categ = b;
                                 break;
                         }
-
                     }
                 }
 
-                if (ligneVide)
-                {
-                    try
-                    {
-                        string m = (string)(xlWorkSheet.Cells[row, 4].Value);
-                        if (m != null)
-                            if (m.Contains("MOTOS"))
-                                categ = "M";
-                    }
-                    catch (Exception ex) {; }
-                }
                 if (bandeau != "")
                 {
                     vide = 0;
@@ -525,27 +366,29 @@ namespace Fuel01
                     {
                         if (!checkZero.Checked)
                         {
-                            myNewRow = findOnekey(Convert.ToInt32(bandeau), cmp, categ);
+                            myNewRow = FindOnekey(bandeau);
                             if (myNewRow != null)
+                            {
                                 key = myNewRow["key_vehi"].ToString();
+                            }
                         }
                         if (myNewRow == null)
                         {
-                            key = findNewkey();
+                            key = FindNewkey();
                             myNewRow = tb_vehi.Newtb_vehiRow();
                             newrow = true;
                         }
                         myNewRow["key_vehi"] = key;
                         myNewRow["ope_vehi"] = Program.key_ope;
                         myNewRow["num_vehi"] = bandeau;
-                        myNewRow["cmpnum_vehi"] = cmp;
+                        myNewRow["cmpnum_vehi"] = "";
                         myNewRow["immat_vehi"] = immat;
                         myNewRow["type_vehi"] = model;
                         myNewRow["famille_vehi"] = famille;
                         myNewRow["categ_vehi"] = categ;
                         myNewRow["cond_vehi"] = pilote;
                         myNewRow["sort1_vehi"] = string.Format("{0}{1:00000}{2}", myNewRow["categ_vehi"], myNewRow["num_vehi"], myNewRow["cmpnum_vehi"]);
-                        myNewRow["carbu_vehi"] = categ == "M" ? "SP98" : "DIESEL";
+                        myNewRow["carbu_vehi"] = carbu == "E" ? "SP98" : "DIESEL";
                         if (newrow)
                             tb_vehi.Addtb_vehiRow(myNewRow);
                         StatusLabel1.Text = string.Format("{0}{1:00000}{2}-{3}-{4}", myNewRow["categ_vehi"], myNewRow["num_vehi"], myNewRow["cmpnum_vehi"], myNewRow["cond_vehi"], myNewRow["immat_vehi"]);
@@ -560,17 +403,14 @@ namespace Fuel01
                     vide++;
                 if (vide > 10)
                     break;
-
             }
-            if (xlApp != null)
-                xlApp.Quit();
 
-            StatusLabel1.Text = "F I N I .................";
+            xlApp?.Quit();
 
+            StatusLabel1.Text = "F I N I .................";
         }
 
-
-        private void import_parc()
+        private void Import_tdf()
         {
             Excel.Application xlApp;
             Excel.Workbook xlWorkBook;
@@ -581,32 +421,28 @@ namespace Fuel01
                 xlApp = new Excel.Application();
                 xlWorkBook = xlApp.Workbooks.Open(textNomFile.Text, misValue);
                 xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
-
             }
             catch (Exception ex)
             {
-                MessageBox.Show("Vérifier que le fichier n'est pas ouvert et est un fichier Excel correct", "Ouverture de " + textNomFile.Text + " impossible", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                MessageBox.Show($"Vérifier que le fichier n'est pas ouvert et est un fichier Excel correct\r\n{ex.Message}", "Ouverture de " + textNomFile.Text + " impossible", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
 
-            uint[] indexCol = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15 };
-            for (uint row = 3; row < 800; row++)
+            uint[] indexCol = { 2, 4, 5, 6, 7, 8, 11, 12 };
+            string categ = "A";
+            for (uint row = 2; row < 800; row++)
             {
                 string model = "";
                 string immat = "";
                 string bandeau = "";
+                string cmp = "";
                 string famille = "";
                 string pilote = "";
-                string carbu = "D";
-                string cmp = "";
-                string categ = "A";
-
                 bool ligneVide = true;
 
                 int vide = 0;
                 for (int colNdx = 0; colNdx < indexCol.Length; colNdx++)
                 {
-
                     uint col = indexCol[colNdx];
                     var varex = xlWorkSheet.Cells[row, col].Value;
                     if (varex != null)
@@ -621,61 +457,71 @@ namespace Fuel01
                             case "System.Double":
                                 b = ((Int32)varex).ToString();
                                 break;
+
                             default:
                                 b = (string)varex;
                                 break;
-
                         }
 
                         int p;
+                        if (col == 12 && (p = b.IndexOf('\n')) != -1)
+                            b = b.Substring(0, p);
+                        b = b.Replace('\n', ' ');
                         while (b.Contains("  "))
                             b = b.Replace("  ", " ");
                         switch (col)
                         {
-                            case 1:
-                                bandeau = b;
-                                ligneVide = false;
-                                break;
                             case 2:
-                                famille = b;
-                                ligneVide = false;
-                                break;
-                            case 3:
-                                pilote = b;
-                                ligneVide = false;
+                                model = b;
                                 break;
+
                             case 4:
-                                pilote = pilote + " " + b;
-                                ligneVide = false;
+
+                                immat = new StringBuilder(immat).Append(" ").Append(b).ToString();
                                 break;
+
                             case 5:
-                                carbu = b;
-                                ligneVide = false;
+                                immat = new StringBuilder(immat).Append(" ").Append(b).ToString();
                                 break;
+
                             case 6:
-                                model = b;
-                                ligneVide = false;
+                                immat = new StringBuilder(immat).Append(" ").Append(b).ToString();
                                 break;
+
                             case 7:
-                                immat = immat + b + " ";
+                                bandeau = b;
                                 break;
+
                             case 8:
-                                ligneVide = false;
-                                immat = immat + b + " ";
+                                cmp = b;
                                 break;
-                            case 9:
-                                ligneVide = false;
-                                immat = immat + b + " ";
+
+                            case 11:
+                                famille = b;
                                 break;
-                            case 15:
-                                ligneVide = false;
-                                categ = b.ToUpper() == "M" ? "M" : "A";
+
+                            case 12:
+                                pilote = b;
                                 break;
                         }
-
                     }
                 }
 
+                if (ligneVide)
+                {
+                    try
+                    {
+                        string m = (string)(xlWorkSheet.Cells[row, 4].Value);
+                        if (m != null && m.Contains("MOTOS"))
+                        {
+                            categ = "M";
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        Console.WriteLine(e.Message);
+                    }
+                }
                 if (bandeau != "")
                 {
                     vide = 0;
@@ -686,13 +532,15 @@ namespace Fuel01
                     {
                         if (!checkZero.Checked)
                         {
-                            myNewRow = findOnekey(Convert.ToInt32(bandeau), cmp, categ);
+                            myNewRow = FindOnekey(bandeau);
                             if (myNewRow != null)
+                            {
                                 key = myNewRow["key_vehi"].ToString();
+                            }
                         }
                         if (myNewRow == null)
                         {
-                            key = findNewkey();
+                            key = FindNewkey();
                             myNewRow = tb_vehi.Newtb_vehiRow();
                             newrow = true;
                         }
@@ -706,19 +554,7 @@ namespace Fuel01
                         myNewRow["categ_vehi"] = categ;
                         myNewRow["cond_vehi"] = pilote;
                         myNewRow["sort1_vehi"] = string.Format("{0}{1:00000}{2}", myNewRow["categ_vehi"], myNewRow["num_vehi"], myNewRow["cmpnum_vehi"]);
-                        switch (carbu)
-                        {
-                            case "D":
-                                carbu = "DIESEL";
-                                break;
-                            case "E":
-                                carbu = "SP98";
-                                break;
-                            default:
-                                carbu = "?";
-                                break;
-                        }
-                        myNewRow["carbu_vehi"] = carbu == "?" ? (categ == "M" ? "SP98" : "DIESEL") : carbu;
+                        myNewRow["carbu_vehi"] = categ == "M" ? "SP98" : "DIESEL";
                         if (newrow)
                             tb_vehi.Addtb_vehiRow(myNewRow);
                         StatusLabel1.Text = string.Format("{0}{1:00000}{2}-{3}-{4}", myNewRow["categ_vehi"], myNewRow["num_vehi"], myNewRow["cmpnum_vehi"], myNewRow["cond_vehi"], myNewRow["immat_vehi"]);
@@ -733,20 +569,193 @@ namespace Fuel01
                     vide++;
                 if (vide > 10)
                     break;
-
             }
-            if (xlApp != null)
-                xlApp.Quit();
+
+            xlApp?.Quit();
 
             StatusLabel1.Text = "F I N I .................";
+        }
 
+        private void Init_list_famille()
+        {
+            XDocument xRoot = XDocument.Load(Program.folder + @"\param\famille.xml");
+            var data = from item in xRoot.Descendants("tb_famille")
+                       orderby item.Element("key_fam").Value
+                       select new Famille()
+                       {
+                           key_fam = item.Element("key_fam").Value
+                       };
+            lfamille = data.ToList();
+            combo_famille.Items.Clear();
+            combo_famille.DisplayMember = "key_fam";
+            foreach (Famille f in lfamille)
+                combo_famille.Items.Add(f);
         }
 
-        private void tb_allValid_Click(object sender, EventArgs e)
+        private void Init_list_produit()
+        {
+            XDocument xRoot = XDocument.Load(Program.folder + @"\param\produit.xml");
+            var data = from item in xRoot.Descendants("tb_prod")
+                       orderby item.Element("type_prod").Value, item.Element("lib_prod").Value
+                       select new Produit()
+                       {
+                           key_prod = item.Element("key_prod").Value,
+                           lib_prod = item.Element("lib_prod").Value,
+                           type_prod = item.Element("type_prod").Value
+                       };
+            lproduit = data.ToList();
+            lcarbu = lproduit.Where(p => p.type_prod == "Carburant").ToList();
+            combo_energy.Items.Clear();
+            combo_energy.DisplayMember = "key_prod";
+            foreach (Produit p in lcarbu)
+                combo_energy.Items.Add(p);
+        }
+
+        private void SaveData()
+        {
+            if (File.Exists(Program.subfolder + @"\vehicule.json"))
+                File.Copy(Program.subfolder + @"\vehicule.json", Program.subfolder + @"\vehicule.back.json", true);
+
+            DbUtil.SaveToJson<DataSet1.tb_vehiDataTable>(Program.subfolder + @"\statvehiculeion.json", tb_vehi);
+        }
+
+        private void Tb_allValid_Click(object sender, EventArgs e)
         {
             hasChanged = true;
             this.Close();
         }
 
+        private void Vehi_Load(object sender, EventArgs e)
+        {
+            if (!Directory.Exists(Program.subfolder))
+                Directory.CreateDirectory(Program.subfolder);
+            else
+            {
+                if (File.Exists(Program.subfolder + @"\vehicule.json"))
+                    tb_vehi = DbUtil.LoadFromJson<DataSet1.tb_vehiDataTable>(Program.subfolder + @"\vehicule.json", tb_vehi);
+            }
+            tb_vehi.AcceptChanges();
+            tbvehiculeBindingSource.DataSource = tb_vehi;
+
+            Turn_txt(false);
+            Turn_bt(false);
+            if (Program.key_ope != null)
+                this.Text = "Importation Véhicules " + Program.nom_ope;
+
+            if (File.Exists(Program.folder + @"\param\famille.xml"))
+                Init_list_famille();
+            if (File.Exists(Program.folder + @"\param\produit.xml"))
+                Init_list_produit();
+        }
+        #region affichage
+
+        private void Turn_bt(bool act)
+        {
+            Bt_Abort.Enabled = act;
+            bt_Valid.Enabled = act;
+            bt_Mod.Enabled = !act;
+            bt_Aj.Enabled = !act;
+            bt_Sup.Enabled = !act;
+            dg_vehi.Enabled = !act;
+        }
+
+        private void Turn_txt(bool act)
+        {
+            text_immat_vehi.Enabled = act;
+            text_num_vehi.Enabled = act;
+            text_cmpnum_vehi.Enabled = act;
+            text_type_vehi.Enabled = act;
+            text_kmdep_vehi.Enabled = act;
+            text_kmarr_vehi.Enabled = act;
+            text_cond_vehi.Enabled = act;
+            combo_energy.Enabled = act;
+            combo_famille.Enabled = act;
+            text_sort_vehi.Enabled = act;
+        }
+        #endregion affichage
+
+        #region Boutons
+
+        private void Bt_Abort_Click(object sender, EventArgs e)
+        {
+            tb_vehi.RejectChanges();
+            Turn_txt(false);
+            Turn_bt(false);
+        }
+
+        private void Bt_Aj_Click(object sender, EventArgs e)
+        {
+            Turn_txt(true);
+            Turn_bt(true);
+            string key = FindNewkey();
+            DataSet1.tb_vehiRow myNewRow = tb_vehi.Newtb_vehiRow();
+            myNewRow["key_vehi"] = key;
+            myNewRow["ope_vehi"] = Program.nom_ope;
+            tb_vehi.Addtb_vehiRow(myNewRow);
+            tbvehiculeBindingSource.MoveFirst();
+            DataRowView myRow = tbvehiculeBindingSource.Current as DataRowView;
+            while (myRow.Row["key_vehi"].ToString() != key)
+            {
+                tbvehiculeBindingSource.MoveNext();
+                myRow = tbvehiculeBindingSource.Current as DataRowView;
+            }
+        }
+
+        private void Bt_Mod_Click(object sender, EventArgs e)
+        {
+            Turn_bt(true);
+            Turn_txt(true);
+        }
+        private void Bt_Sup_Click(object sender, EventArgs e)
+        {
+            DataRowView myRow = tbvehiculeBindingSource.Current as DataRowView;
+            if (myRow == null) return;
+            string msg = string.Format("Vehicule {0}\nEtes-vous certain de vouloir supprimer \n{1}", myRow.Row["num_vehi"].ToString(), myRow.Row["immat_vehi"].ToString());
+            string caption = "Suppression définitive";
+            if (MessageBox.Show(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
+            {
+                DataSet1.tb_vehiRow vehiRow = tb_vehi.FindBykey_vehi(myRow.Row["key_vehi"].ToString());
+                if (vehiRow != null)
+                    tb_vehi.Removetb_vehiRow(vehiRow);
+                hasChanged = true;
+            }
+        }
+
+        private void Bt_Valid_Click(object sender, EventArgs e)
+        {
+            tb_vehi.AcceptChanges();
+            Turn_txt(false);
+            Turn_bt(false);
+            hasChanged = true;
+        }
+        #endregion Boutons
+
+        #region fonctions
+
+        private string FindNewkey()
+        {
+            Random rand1 = new Random();
+            string key = rand1.Next(99999).ToString();
+            while (tb_vehi.FindBykey_vehi(key) != null)
+            {
+                key = rand1.Next(99999).ToString();
+            }
+            return key;
+        }
+
+        private DataSet1.tb_vehiRow FindOnekey(string bandeau)
+        {
+            if (Int32.TryParse(bandeau, out int bandoNum))
+            {
+                DataSet1.tb_vehiRow onevevi = tb_vehi.FirstOrDefault(v => v.num_vehi == bandoNum);
+                return onevevi;
+            }
+            else
+            {
+                return null;
+            }
+
+        }
+        #endregion fonctions
     }
-}
+}

+ 0 - 3
Fuel_ASO/f_presta.Designer.cs

@@ -370,7 +370,6 @@
             this.dg_vente.TabIndex = 1;
             this.dg_vente.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dg_vente_CellBeginEdit);
             this.dg_vente.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dg_vente_CellEndEdit);
-            this.dg_vente.CellLeave += new System.Windows.Forms.DataGridViewCellEventHandler(this.dg_vente_CellLeave);
             this.dg_vente.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.dg_vente_DataError);
             this.dg_vente.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.dg_vente_RowsAdded);
             // 
@@ -527,7 +526,6 @@
             this.ShowInTaskbar = false;
             this.Text = "Prestations";
             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.f_presta_FormClosing);
-            this.Load += new System.EventHandler(this.f_presta_Load);
             this.splitContainer1.Panel1.ResumeLayout(false);
             this.splitContainer1.Panel2.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
@@ -576,7 +574,6 @@
         private System.Windows.Forms.SplitContainer splitContainer4;
         private System.Windows.Forms.Button t_facture;
         private System.Windows.Forms.DataGridView dg_vente;
-        private System.Windows.Forms.DataGridViewTextBoxColumn dg_vt_ht;
         private System.Windows.Forms.DataGridViewTextBoxColumn dg_presta_ttc;
         private System.Windows.Forms.DataGridViewTextBoxColumn dg_presta_tva;
         private System.Windows.Forms.DataGridViewTextBoxColumn dg_presta_pu;

+ 83 - 109
Fuel_ASO/f_presta.cs

@@ -1,4 +1,6 @@
-using System;
+using Fuel01.Models;
+using Newtonsoft.Json;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -6,6 +8,7 @@ using System.Diagnostics;
 using System.Drawing;
 using System.IO;
 using System.Linq;
+using System.Security.Cryptography.X509Certificates;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
@@ -22,36 +25,31 @@ namespace Fuel01
         DataSet1.tb_stationDataTable tb_station = new DataSet1.tb_stationDataTable();
 
         DataSet1.tb_stationRow current_sta = null;
-        List<produit> lproduit = new List<produit>();
+        List<Produit> lproduit = new List<Produit>();
 
         DataGridViewRow myrow = null;
         float oldqtt = 0;
-        static ProdEqualityComparer prodEqC = new ProdEqualityComparer();
-        Dictionary<id_prod, vente_tot> lvente_tot = new Dictionary<id_prod, vente_tot>(prodEqC);
-        Dictionary<decimal, vente_tva> lvente_tva = new Dictionary<decimal, vente_tva>();
-
-
-        string id_sta = "";
+        
+        string id_sta;
         public f_presta(TextBox key_sta)
         {
             InitializeComponent();
-            
-            if (File.Exists(Program.subfolder + @"\station.json"))
-                tb_station = DbUtil.LoadFromJson<DataSet1.tb_stationDataTable>(Program.subfolder + @"\station.json", tb_station);
 
             if (File.Exists(Program.folder + @"\param\produit.xml"))
                 init_list_produit();
 
-            if (File.Exists(Program.subfolder + @"\presta_base.json"))
-                tb_presta = DbUtil.LoadFromJson<DataSet1.tb_prestaDataTable>(Program.subfolder + @"\presta_base.json", tb_presta);
-            tb_presta.AcceptChanges();
+            if (File.Exists(Program.subfolder + @"\presta.json"))
+            {
+                tb_presta = DbUtil.LoadPrestaFromJson(Program.subfolder + @"\presta.json", lproduit);
+                tb_presta.AcceptChanges();
+            }
             tbprestaBindingSource.DataSource = tb_presta;
 
             if (File.Exists(Program.subfolder + @"\vente.json"))
                 tb_vente = DbUtil.LoadFromJson<DataSet1.tb_venteDataTable>(Program.subfolder + @"\vente.json", tb_vente);
             tb_vente.AcceptChanges();
             tbventeBindingSource.DataSource = tb_vente;
-            
+
             id_sta = key_sta.Text;
             tbprestaBindingSource.Filter = " sta_pr='" + id_sta + "'";
             tbventeBindingSource.Filter = " station_vt='" + id_sta + "'";
@@ -65,12 +63,6 @@ namespace Fuel01
 
         }
 
-        private void f_presta_Load(object sender, EventArgs e)
-        {
-            
-        }
-
-
         void key_sta_TextChanged(object sender, EventArgs e)
         {
             TextBox mytxtb = sender as TextBox;
@@ -83,30 +75,15 @@ namespace Fuel01
 
         private void f_presta_FormClosing(object sender, FormClosingEventArgs e)
         {
-            DbUtil.SaveToJson<DataSet1.tb_prestaDataTable>(Program.subfolder + @"\presta_base.json", tb_presta);
-
-            DbUtil.SaveToJson<DataSet1.tb_venteDataTable>(Program.subfolder + @"\presta_base.json", tb_vente);
-
-            tbprestaBindingSource.Filter = "";
-            tbprestaBindingSource.Sort = "sta_pr,kind_pr,prod_pr";
-            tbprestaBindingSource.MoveFirst();
-            int i = 0;
-            while (tbprestaBindingSource.Position<tbprestaBindingSource.Count-1)
-            {
-                DataSet1.tb_prestaRow myNewRow = tb_presta.Rows[i++] as DataSet1.tb_prestaRow;
-                string a=i.ToString()+"-"+myNewRow["sta_pr"].ToString()+"-"+myNewRow["kind_pr"].ToString()+"-"+myNewRow["prod_pr"].ToString(); 
-                Console.WriteLine(a);
-                tbprestaBindingSource.MoveNext();
-            }
+            SavePresta();
         }
 
         private void init_list_produit()
         {
-
             XDocument xRoot = XDocument.Load(Program.folder + @"\param\produit.xml");
             var data = from item in xRoot.Descendants("tb_prod")
                        orderby item.Element("type_prod").Value, item.Element("lib_prod").Value
-                       select new produit()
+                       select new Produit()
                        {
                            key_prod = item.Element("key_prod").Value,
                            lib_prod = item.Element("lib_prod").Value,
@@ -116,7 +93,7 @@ namespace Fuel01
 
             dg_presta_prod.Items.Clear();
             dg_presta_prod.DataSource = lproduit;
-            dg_presta_prod.DisplayMember ="lib_prod" ;
+            dg_presta_prod.DisplayMember = "lib_prod";
             dg_presta_prod.ValueMember = "key_prod";
 
         }
@@ -138,7 +115,7 @@ namespace Fuel01
 
         private void bt_ajCarbu_Click(object sender, EventArgs e)
         {
-            foreach (produit p in lproduit.Where(p => p.type_prod == "Carburant"))
+            foreach (Produit p in lproduit.Where(p => p.type_prod == "Carburant"))
             {
                 bool ok = false;
                 for (int i = 0; i < dg_presta.RowCount - 1 && !ok; i++)
@@ -162,7 +139,7 @@ namespace Fuel01
 
         private void bt_ajProd_Click(object sender, EventArgs e)
         {
-            foreach (produit p in lproduit)
+            foreach (Produit p in lproduit)
             {
                 bool ok = false;
                 for (int i = 0; i < dg_presta.RowCount - 1 && !ok; i++)
@@ -221,7 +198,7 @@ namespace Fuel01
             }
         }
 
-      
+
         private void dg_vente_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
         {
             if (e.RowIndex > 0)
@@ -243,7 +220,7 @@ namespace Fuel01
         private void dg_presta_CellEndEdit(object sender, DataGridViewCellEventArgs e)
         {
             if (e.ColumnIndex != 1) return;
-            string typeProd="";
+            string typeProd = "";
             string prod = dg_presta.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
             if (lproduit.Exists(xx => xx.key_prod == prod))
                 typeProd = lproduit.Find(xx => xx.key_prod == prod).type_prod;
@@ -251,75 +228,77 @@ namespace Fuel01
 
         }
 
-        private void button1_Click(object sender, EventArgs e)
+        private void SavePresta()
         {
-            try
+            List<PrestaSta> prestaStas = new List<PrestaSta>();
+            tb_presta.AcceptChanges();
+            string filter = tbprestaBindingSource.Filter;
+            tbprestaBindingSource.Filter = "";
+            tbprestaBindingSource.Sort = "sta_pr,kind_pr,prod_pr";
+            bool isEmpty = tb_presta.Count == 0;
+
+            var result0 = isEmpty ? "[]" : JsonConvert.SerializeObject(tb_presta);
+            var result1 = isEmpty ? new List<Presta>() : JsonConvert.DeserializeObject<List<Presta>>(result0);
+            var oldPr = "*";
+            Prod prod;
+            PrestaSta newPresta=new PrestaSta() ;
+            foreach (var presta in result1)
             {
-                string filter = tbprestaBindingSource.Filter;
-                tbprestaBindingSource.Filter = "";
-                tbprestaBindingSource.Sort = "sta_pr,kind_pr,prod_pr";
-                tbprestaBindingSource.MoveFirst();
-                int size = tbprestaBindingSource.Count;
-                System.Data.DataRowView[] arr = new System.Data.DataRowView[8192];
-                tbprestaBindingSource.CopyTo(arr, 0);
-                int id_sta = 9999;
-                string kind_carbu = "####";
-                XElement station = null;
-                XElement prod = null;
-                XElement detail = null;
-                XElement presta = new XElement("tb_prestas", null);
-                for (int i = 0; i < tbprestaBindingSource.Count; i++)
+                var l_pr = lproduit.FirstOrDefault(x => x.key_prod == presta.prod_pr);
+                if (l_pr == null)
                 {
-                    string a = i.ToString() + "-" + arr[i].Row["sta_pr"].ToString() + "-" + arr[i].Row["kind_pr"].ToString() + "-" + arr[i].Row["prod_pr"].ToString();
-                    Console.WriteLine(a);
-                    if (id_sta != Convert.ToInt32(arr[i].Row["sta_pr"]))
-                    {
-                        station = new XElement("tb_presta", new XElement("sta_pr", arr[i].Row["sta_pr"].ToString()));
-                        presta.Add(station);
-                        id_sta = Convert.ToInt32(arr[i].Row["sta_pr"]);
-                        kind_carbu = "####";
-                    }
-                    if (kind_carbu != arr[i].Row["kind_pr"].ToString())
-                    {
-                        prod = new XElement(arr[i].Row["kind_pr"].ToString() == "Carburant" ? "carburants" : "autres", null);
-                        station.Add(prod);
-                        kind_carbu = arr[i].Row["kind_pr"].ToString();
-                    }
-                    if (lproduit.Find(xx => xx.key_prod == arr[i].Row["prod_pr"].ToString()) != null)
-                    {
+                    continue;
+                }
+
+                var idSta = presta.sta_pr;
+                var kind = presta.kind_pr;
+                if (idSta != oldPr)
+                {
+                    newPresta = new PrestaSta();
+                    newPresta.sta_pr = presta.sta_pr ;                    
+                    prestaStas.Add(newPresta);
+                    oldPr = idSta;
+                }
 
-                        detail = new XElement(arr[i].Row["kind_pr"].ToString() == "Carburant" ? "carburant" : "autre",
-                                    new XElement("prod_pr", arr[i].Row["prod_pr"].ToString()),
-                                    new XElement("lib_prod", lproduit.Find(xx => xx.key_prod == arr[i].Row["prod_pr"].ToString()).lib_prod),
-                                    new XElement("unite_pr", arr[i].Row["unite_pr"].ToString()),
-                                    new XElement("pu_pr", arr[i].Row["pu_pr"].ToString()),
-                                    new XElement("tva_pr", arr[i].Row["ttc_pr"].ToString()),
-                                    new XElement("ttc_pr", arr[i].Row["ttc_pr"].ToString()));
-                        prod.Add(detail);
+                prod = new Prod
+                {
+                    lib_prod = l_pr.lib_prod,
+                    prod_pr = presta.prod_pr,
+                    unite_pr = presta.unite_pr,
+                    pu_pr = presta.pu_pr.ToString("0.000"),
+                    tva_pr = presta.tva_pr.ToString("0.000"),
+                    ttc_pr = presta.ttc_pr.ToString("0.000")
+                };
+
+                if (newPresta != null)
+                {
+                    if (kind == "Carburant")
+                    {
+                        newPresta.carburants.Add(prod);
                     }
                     else
                     {
-                        MessageBox.Show(arr[i].Row["prod_pr"].ToString() + " Produit supprimé !!","Attention",MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+                        newPresta.autres.Add(prod);
                     }
                 }
-                presta.Save(Program.subfolder + @"\presta.xml");
+            }
+            tbprestaBindingSource.Filter = filter;
 
-                DbUtil.SaveToJson<DataSet1.tb_prestaDataTable>(Program.subfolder + @"\presta_base.json", tb_presta);
+            DbUtil.SaveToJson<DataSet1.tb_prestaDataTable>(Program.subfolder + @"\prestalocal.json", tb_presta);
 
-                tbprestaBindingSource.Filter = filter;
-                MessageBox.Show("Sauvegarde effectuée, il faut maintenant envoyer les fichiers !!","Terminé", MessageBoxButtons.OK, MessageBoxIcon.Information);
-            }
-            catch (Exception ex)
-            {
-                MessageBox.Show("Sauvegarde non effectuée!!!!"+"\r\n"+ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
-            }
+            DbUtil.SaveToJson(prestaStas, Program.subfolder + @"\presta.json");
 
         }
 
+        private void button1_Click(object sender, EventArgs e)
+        {
+            SavePresta();         
+        }
+
         private void t_facture_Click(object sender, EventArgs e)
         {
             f_facture ffac = new f_facture(current_sta["key_sta"].ToString());
-            ffac.ShowDialog();        
+            ffac.ShowDialog();
 
         }
 
@@ -343,12 +322,12 @@ namespace Fuel01
 
                 if (!ok)
                 {
-                    MessageBox.Show("Erreur de saisie");                    
+                    MessageBox.Show("Erreur de saisie");
                     dg_vente.Rows[e.RowIndex].Cells[5].Value = oldqtt;
                     return;
                 }
                 dg_vente.Rows[e.RowIndex].Cells[9].Value = qtt * puttc;
-                dg_vente.Rows[e.RowIndex].Cells[8].Value = ( qtt * puttc) / ( 1 + (tva/100));
+                dg_vente.Rows[e.RowIndex].Cells[8].Value = (qtt * puttc) / (1 + (tva / 100));
             }
             myrow = null;
             oldqtt = 0;
@@ -359,21 +338,16 @@ namespace Fuel01
         {
             Console.WriteLine("BEGIN  EDIT");
             myrow = dg_vente.Rows[e.RowIndex];
-            if ( !float.TryParse(myrow.Cells[5].Value.ToString(), out oldqtt))
+            if (!float.TryParse(myrow.Cells[5].Value.ToString(), out oldqtt))
                 e.Cancel = true;
-            
-        }
 
-        private void dg_vente_CellLeave(object sender, DataGridViewCellEventArgs e)
-        {
-          
         }
 
         private void dg_vente_DataError(object sender, DataGridViewDataErrorEventArgs e)
         {
             if (myrow != null)
             {
-                MessageBox.Show("Appuyez sur la touche Echappe (ESC Escape) \r\n dans la grille de saisie pour Abndonner l'opération","Erreur de saisie");
+                MessageBox.Show("Appuyez sur la touche Echappe (ESC Escape) \r\n dans la grille de saisie pour Abndonner l'opération", "Erreur de saisie");
                 dg_vente.Rows[e.RowIndex].Cells[5].Value = oldqtt;
                 myrow = null;
                 oldqtt = 0;
@@ -383,16 +357,16 @@ namespace Fuel01
         private void chk_modif_CheckedChanged(object sender, EventArgs e)
         {
             dg_vt_qtt.ReadOnly = !chk_modif.Checked;
-            for (int i=0; i<dg_vente.ColumnCount;i++)
+            for (int i = 0; i < dg_vente.ColumnCount; i++)
             {
-                if (i==5)
-                    dg_vente.Columns[i].DefaultCellStyle.BackColor =    chk_modif.Checked? Color.LimeGreen: Color.Empty;
+                if (i == 5)
+                    dg_vente.Columns[i].DefaultCellStyle.BackColor = chk_modif.Checked ? Color.LimeGreen : Color.Empty;
                 else
                     dg_vente.Columns[i].DefaultCellStyle.BackColor = chk_modif.Checked ? Color.OrangeRed : Color.Empty;
             }
         }
 
-        
+
     }
-   
+
 }

+ 4 - 4
Fuel_ASO/f_saisie2.cs

@@ -44,7 +44,7 @@ namespace Fuel01
             Program.subfolder = Program.folder + @"\" + Program.key_ope;
 
             if (File.Exists(Program.subfolder + @"\vehicule.json"))
-                tb_vehi = DbUtil.LoadFromJson<DataSet1.tb_vehiDataTable>(Program.subfolder + @"\station.json", tb_vehi); 
+                tb_vehi = DbUtil.LoadFromJson<DataSet1.tb_vehiDataTable>(Program.subfolder + @"\Vehicule.json", tb_vehi); 
             tbvehiBindingSource.DataSource = tb_vehi;
 
 
@@ -73,8 +73,8 @@ namespace Fuel01
 
             }
 
-            if (File.Exists(Program.subfolder + @"\presta_base.json"))
-                tb_presta = DbUtil.LoadFromJson<DataSet1.tb_prestaDataTable>(Program.subfolder + @"\presta_base.json", tb_presta);
+            if (File.Exists(Program.subfolder + @"\presta.json"))
+                tb_presta = DbUtil.LoadFromJson<DataSet1.tb_prestaDataTable>(Program.subfolder + @"\presta.json", tb_presta);
 
             tbprestaBindingSource.DataSource = tb_presta;
 
@@ -435,7 +435,7 @@ namespace Fuel01
 
         private void bt_save_Click(object sender, EventArgs e)
         {
-            DbUtil.SaveToJson<DataSet1.tb_venteDataTable>(Program.subfolder + @"\vebnte.json", tb_vente);
+            DbUtil.SaveToJson<DataSet1.tb_venteDataTable>(Program.subfolder + @"\vente.json", tb_vente);
 
             hasChanged = false;
             bt_save.Enabled = hasChanged;

+ 4 - 4
Fuel_ASO/f_station.cs

@@ -19,7 +19,7 @@ namespace Fuel01
         DataSet1.tb_stationDataTable tb_station = new DataSet1.tb_stationDataTable();
         string keysta;
         f_presta fpresta;
-        List<pays> lpays = new List<pays>();
+        List<Pays> lpays = new List<Pays>();
 
         public f_station(DataSet1.tb_stationDataTable tb_station,string keysta)
         {
@@ -111,7 +111,7 @@ namespace Fuel01
             XDocument xRoot = XDocument.Load(Program.folder + @"\param\pays.xml");
             var data = from item in xRoot.Descendants("tb_pays")
                        orderby item.Element("order_pays").Value
-                       select new pays()
+                       select new Pays()
                        {
                            key_pays = item.Element("key_pays").Value,
                            nom_pays = item.Element("nom_pays").Value,
@@ -121,7 +121,7 @@ namespace Fuel01
             lpays = data.ToList();
             combo_pays_sta.Items.Clear();
             combo_pays_sta.DisplayMember = "key_pays";
-            foreach (pays p in lpays)
+            foreach (Pays p in lpays)
                 combo_pays_sta.Items.Add(p);
         }
 
@@ -200,7 +200,7 @@ namespace Fuel01
 
         private void combo_pays_sta_SelectedIndexChanged(object sender, EventArgs e)
         {
-            pays cur_Pays=lpays.Find(p => p.key_pays == combo_pays_sta.Text);
+            Pays cur_Pays=lpays.Find(p => p.key_pays == combo_pays_sta.Text);
             if ( cur_Pays!=null)
                 StatusLabel1.Text = cur_Pays.nom_pays;
             else

+ 56 - 25
Fuel_ASO/f_tools.Designer.cs

@@ -85,24 +85,27 @@
             // 
             // statusStrip1
             // 
+            this.statusStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
             this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.tsLbl1});
-            this.statusStrip1.Location = new System.Drawing.Point(0, 449);
+            this.statusStrip1.Location = new System.Drawing.Point(0, 703);
             this.statusStrip1.Name = "statusStrip1";
-            this.statusStrip1.Size = new System.Drawing.Size(744, 22);
+            this.statusStrip1.Padding = new System.Windows.Forms.Padding(2, 0, 21, 0);
+            this.statusStrip1.Size = new System.Drawing.Size(1116, 22);
             this.statusStrip1.TabIndex = 0;
             this.statusStrip1.Text = "statusStrip1";
             // 
             // tsLbl1
             // 
             this.tsLbl1.Name = "tsLbl1";
-            this.tsLbl1.Size = new System.Drawing.Size(0, 17);
+            this.tsLbl1.Size = new System.Drawing.Size(0, 15);
             // 
             // splitContainer1
             // 
             this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
             this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
             this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.splitContainer1.Name = "splitContainer1";
             // 
             // splitContainer1.Panel1
@@ -115,16 +118,18 @@
             // splitContainer1.Panel2
             // 
             this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
-            this.splitContainer1.Size = new System.Drawing.Size(744, 449);
+            this.splitContainer1.Size = new System.Drawing.Size(1116, 703);
             this.splitContainer1.SplitterDistance = 181;
+            this.splitContainer1.SplitterWidth = 6;
             this.splitContainer1.TabIndex = 1;
             // 
             // check_move
             // 
             this.check_move.AutoSize = true;
-            this.check_move.Location = new System.Drawing.Point(22, 150);
+            this.check_move.Location = new System.Drawing.Point(33, 231);
+            this.check_move.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.check_move.Name = "check_move";
-            this.check_move.Size = new System.Drawing.Size(147, 17);
+            this.check_move.Size = new System.Drawing.Size(219, 24);
             this.check_move.TabIndex = 3;
             this.check_move.Text = "Déplacer après traitement";
             this.toolTip1.SetToolTip(this.check_move, "Déplce dans le sous-répertoire in/done les fichiers après traitement");
@@ -133,9 +138,10 @@
             // 
             // bt_loadVT
             // 
-            this.bt_loadVT.Location = new System.Drawing.Point(22, 336);
+            this.bt_loadVT.Location = new System.Drawing.Point(33, 517);
+            this.bt_loadVT.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_loadVT.Name = "bt_loadVT";
-            this.bt_loadVT.Size = new System.Drawing.Size(147, 38);
+            this.bt_loadVT.Size = new System.Drawing.Size(220, 58);
             this.bt_loadVT.TabIndex = 2;
             this.bt_loadVT.Text = "Charger Ventes";
             this.toolTip1.SetToolTip(this.bt_loadVT, "Charge les ventes dans le tableau de droite");
@@ -145,9 +151,10 @@
             // 
             // bt_trait
             // 
-            this.bt_trait.Location = new System.Drawing.Point(22, 89);
+            this.bt_trait.Location = new System.Drawing.Point(33, 137);
+            this.bt_trait.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_trait.Name = "bt_trait";
-            this.bt_trait.Size = new System.Drawing.Size(147, 38);
+            this.bt_trait.Size = new System.Drawing.Size(220, 58);
             this.bt_trait.TabIndex = 1;
             this.bt_trait.Text = "Traitement des fichiers";
             this.toolTip1.SetToolTip(this.bt_trait, "Intègre les données préalabement récupérées depuis le serveur");
@@ -156,9 +163,10 @@
             // 
             // bt_getdatas
             // 
-            this.bt_getdatas.Location = new System.Drawing.Point(22, 36);
+            this.bt_getdatas.Location = new System.Drawing.Point(33, 55);
+            this.bt_getdatas.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_getdatas.Name = "bt_getdatas";
-            this.bt_getdatas.Size = new System.Drawing.Size(147, 36);
+            this.bt_getdatas.Size = new System.Drawing.Size(220, 55);
             this.bt_getdatas.TabIndex = 0;
             this.bt_getdatas.Text = "Télécharger Achats";
             this.toolTip1.SetToolTip(this.bt_getdatas, "Récupère les informations saisies sur les tablettes sur le serveur");
@@ -170,6 +178,7 @@
             this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
             this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
             this.splitContainer2.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.splitContainer2.Name = "splitContainer2";
             this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
             // 
@@ -180,8 +189,9 @@
             // splitContainer2.Panel2
             // 
             this.splitContainer2.Panel2.Controls.Add(this.splitContainer3);
-            this.splitContainer2.Size = new System.Drawing.Size(559, 449);
+            this.splitContainer2.Size = new System.Drawing.Size(929, 703);
             this.splitContainer2.SplitterDistance = 26;
+            this.splitContainer2.SplitterWidth = 6;
             this.splitContainer2.TabIndex = 4;
             // 
             // label1
@@ -189,8 +199,9 @@
             this.label1.AutoSize = true;
             this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
             this.label1.Location = new System.Drawing.Point(0, 0);
+            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(43, 13);
+            this.label1.Size = new System.Drawing.Size(61, 20);
             this.label1.TabIndex = 3;
             this.label1.Text = "Traces ";
             // 
@@ -198,6 +209,7 @@
             // 
             this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
             this.splitContainer3.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.splitContainer3.Name = "splitContainer3";
             this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
             // 
@@ -208,8 +220,9 @@
             // splitContainer3.Panel2
             // 
             this.splitContainer3.Panel2.Controls.Add(this.splitContainer4);
-            this.splitContainer3.Size = new System.Drawing.Size(559, 419);
-            this.splitContainer3.SplitterDistance = 133;
+            this.splitContainer3.Size = new System.Drawing.Size(929, 671);
+            this.splitContainer3.SplitterDistance = 212;
+            this.splitContainer3.SplitterWidth = 6;
             this.splitContainer3.TabIndex = 0;
             // 
             // textResult
@@ -218,11 +231,12 @@
             this.textResult.AcceptsTab = true;
             this.textResult.Dock = System.Windows.Forms.DockStyle.Fill;
             this.textResult.Location = new System.Drawing.Point(0, 0);
+            this.textResult.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.textResult.Multiline = true;
             this.textResult.Name = "textResult";
             this.textResult.ReadOnly = true;
             this.textResult.ScrollBars = System.Windows.Forms.ScrollBars.Both;
-            this.textResult.Size = new System.Drawing.Size(559, 133);
+            this.textResult.Size = new System.Drawing.Size(929, 212);
             this.textResult.TabIndex = 1;
             this.toolTip1.SetToolTip(this.textResult, "Affiche les informations de traitement");
             // 
@@ -231,6 +245,7 @@
             this.splitContainer4.Dock = System.Windows.Forms.DockStyle.Fill;
             this.splitContainer4.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
             this.splitContainer4.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.splitContainer4.Name = "splitContainer4";
             this.splitContainer4.Orientation = System.Windows.Forms.Orientation.Horizontal;
             // 
@@ -242,16 +257,18 @@
             // splitContainer4.Panel2
             // 
             this.splitContainer4.Panel2.Controls.Add(this.dg_vente);
-            this.splitContainer4.Size = new System.Drawing.Size(559, 282);
+            this.splitContainer4.Size = new System.Drawing.Size(929, 453);
             this.splitContainer4.SplitterDistance = 28;
+            this.splitContainer4.SplitterWidth = 6;
             this.splitContainer4.TabIndex = 0;
             // 
             // check_modif
             // 
             this.check_modif.AutoSize = true;
-            this.check_modif.Location = new System.Drawing.Point(172, 8);
+            this.check_modif.Location = new System.Drawing.Point(258, 12);
+            this.check_modif.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.check_modif.Name = "check_modif";
-            this.check_modif.Size = new System.Drawing.Size(263, 17);
+            this.check_modif.Size = new System.Drawing.Size(392, 24);
             this.check_modif.TabIndex = 5;
             this.check_modif.Text = "Autoriser les modifications des ventes dans la grille";
             this.toolTip1.SetToolTip(this.check_modif, "ATTENTION.... Les modifications faites dans la grille sont dangereuses !!!");
@@ -264,9 +281,10 @@
             this.label2.AutoSize = true;
             this.label2.Dock = System.Windows.Forms.DockStyle.Fill;
             this.label2.Location = new System.Drawing.Point(0, 0);
+            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label2.Name = "label2";
-            this.label2.Padding = new System.Windows.Forms.Padding(0, 8, 0, 0);
-            this.label2.Size = new System.Drawing.Size(40, 21);
+            this.label2.Padding = new System.Windows.Forms.Padding(0, 12, 0, 0);
+            this.label2.Size = new System.Drawing.Size(60, 32);
             this.label2.TabIndex = 4;
             this.label2.Text = "Ventes";
             // 
@@ -289,9 +307,11 @@
             this.dg_vente.DataSource = this.tbventeBindingSource;
             this.dg_vente.Dock = System.Windows.Forms.DockStyle.Fill;
             this.dg_vente.Location = new System.Drawing.Point(0, 0);
+            this.dg_vente.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.dg_vente.Name = "dg_vente";
             this.dg_vente.ReadOnly = true;
-            this.dg_vente.Size = new System.Drawing.Size(559, 250);
+            this.dg_vente.RowHeadersWidth = 62;
+            this.dg_vente.Size = new System.Drawing.Size(929, 419);
             this.dg_vente.TabIndex = 2;
             this.dg_vente.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dg_vente_CellEndEdit);
             // 
@@ -299,14 +319,17 @@
             // 
             this.epreuvevtDataGridViewTextBoxColumn.DataPropertyName = "epreuve_vt";
             this.epreuvevtDataGridViewTextBoxColumn.HeaderText = "epreuve_vt";
+            this.epreuvevtDataGridViewTextBoxColumn.MinimumWidth = 8;
             this.epreuvevtDataGridViewTextBoxColumn.Name = "epreuvevtDataGridViewTextBoxColumn";
             this.epreuvevtDataGridViewTextBoxColumn.ReadOnly = true;
             this.epreuvevtDataGridViewTextBoxColumn.Visible = false;
+            this.epreuvevtDataGridViewTextBoxColumn.Width = 150;
             // 
             // stationvtDataGridViewTextBoxColumn
             // 
             this.stationvtDataGridViewTextBoxColumn.DataPropertyName = "station_vt";
             this.stationvtDataGridViewTextBoxColumn.HeaderText = "Station";
+            this.stationvtDataGridViewTextBoxColumn.MinimumWidth = 8;
             this.stationvtDataGridViewTextBoxColumn.Name = "stationvtDataGridViewTextBoxColumn";
             this.stationvtDataGridViewTextBoxColumn.ReadOnly = true;
             this.stationvtDataGridViewTextBoxColumn.Width = 60;
@@ -315,6 +338,7 @@
             // 
             this.vehivtDataGridViewTextBoxColumn.DataPropertyName = "vehi_vt";
             this.vehivtDataGridViewTextBoxColumn.HeaderText = "Bandeau";
+            this.vehivtDataGridViewTextBoxColumn.MinimumWidth = 8;
             this.vehivtDataGridViewTextBoxColumn.Name = "vehivtDataGridViewTextBoxColumn";
             this.vehivtDataGridViewTextBoxColumn.ReadOnly = true;
             this.vehivtDataGridViewTextBoxColumn.Width = 60;
@@ -324,6 +348,7 @@
             this.prodvtDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
             this.prodvtDataGridViewTextBoxColumn.DataPropertyName = "prod_vt";
             this.prodvtDataGridViewTextBoxColumn.HeaderText = "Produit";
+            this.prodvtDataGridViewTextBoxColumn.MinimumWidth = 8;
             this.prodvtDataGridViewTextBoxColumn.Name = "prodvtDataGridViewTextBoxColumn";
             this.prodvtDataGridViewTextBoxColumn.ReadOnly = true;
             // 
@@ -334,6 +359,7 @@
             dataGridViewCellStyle1.NullValue = null;
             this.datevtDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1;
             this.datevtDataGridViewTextBoxColumn.HeaderText = "Date";
+            this.datevtDataGridViewTextBoxColumn.MinimumWidth = 8;
             this.datevtDataGridViewTextBoxColumn.Name = "datevtDataGridViewTextBoxColumn";
             this.datevtDataGridViewTextBoxColumn.ReadOnly = true;
             this.datevtDataGridViewTextBoxColumn.Width = 50;
@@ -345,6 +371,7 @@
             dataGridViewCellStyle2.Format = "N2";
             this.qttvtDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle2;
             this.qttvtDataGridViewTextBoxColumn.HeaderText = "Qtt";
+            this.qttvtDataGridViewTextBoxColumn.MinimumWidth = 8;
             this.qttvtDataGridViewTextBoxColumn.Name = "qttvtDataGridViewTextBoxColumn";
             this.qttvtDataGridViewTextBoxColumn.ReadOnly = true;
             this.qttvtDataGridViewTextBoxColumn.Width = 50;
@@ -356,6 +383,7 @@
             dataGridViewCellStyle3.Format = "N2";
             this.puvtDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle3;
             this.puvtDataGridViewTextBoxColumn.HeaderText = "PU";
+            this.puvtDataGridViewTextBoxColumn.MinimumWidth = 8;
             this.puvtDataGridViewTextBoxColumn.Name = "puvtDataGridViewTextBoxColumn";
             this.puvtDataGridViewTextBoxColumn.ReadOnly = true;
             this.puvtDataGridViewTextBoxColumn.Width = 50;
@@ -367,6 +395,7 @@
             dataGridViewCellStyle4.Format = "N2";
             this.tvavtDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle4;
             this.tvavtDataGridViewTextBoxColumn.HeaderText = "TVA";
+            this.tvavtDataGridViewTextBoxColumn.MinimumWidth = 8;
             this.tvavtDataGridViewTextBoxColumn.Name = "tvavtDataGridViewTextBoxColumn";
             this.tvavtDataGridViewTextBoxColumn.ReadOnly = true;
             this.tvavtDataGridViewTextBoxColumn.Width = 50;
@@ -379,6 +408,7 @@
             dataGridViewCellStyle5.NullValue = null;
             this.ttcvtDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle5;
             this.ttcvtDataGridViewTextBoxColumn.HeaderText = "PrixTTC";
+            this.ttcvtDataGridViewTextBoxColumn.MinimumWidth = 8;
             this.ttcvtDataGridViewTextBoxColumn.Name = "ttcvtDataGridViewTextBoxColumn";
             this.ttcvtDataGridViewTextBoxColumn.ReadOnly = true;
             this.ttcvtDataGridViewTextBoxColumn.Width = 60;
@@ -400,11 +430,12 @@
             // 
             // f_tools
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(744, 471);
+            this.ClientSize = new System.Drawing.Size(1116, 725);
             this.Controls.Add(this.splitContainer1);
             this.Controls.Add(this.statusStrip1);
+            this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.Name = "f_tools";
             this.ShowIcon = false;
             this.ShowInTaskbar = false;

+ 34 - 24
Fuel_ASO/f_tools.cs

@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -29,8 +30,8 @@ namespace Fuel01
             if (!Directory.Exists(Program.subfolder))
                 Directory.CreateDirectory(Program.subfolder);
 
-            if (File.Exists(Program.subfolder + @"\presta_base.json"))
-                tb_presta = DbUtil.LoadFromJson<DataSet1.tb_prestaDataTable>(Program.subfolder + @"\presta_base.json", tb_presta);
+            if (File.Exists(Program.subfolder + @"\presta.json"))
+                tb_presta = DbUtil.LoadFromJson<DataSet1.tb_prestaDataTable>(Program.subfolder + @"\presta.json", tb_presta);
         }
 
         private void bt_getdatas_Click(object sender, EventArgs e)
@@ -97,40 +98,49 @@ namespace Fuel01
         private List<string> readHttp_Dir(string url_txt)
         {
 
-            string dep = "<A HREF=\"";
-            string fin = "\">";
-            string block = "";
             Uri url = new Uri(url_txt);
             List<string> lines = new List<string>();
             try
             {
                 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
-
-                //// Set some reasonable limits on resources used by this request
-                //request.MaximumAutomaticRedirections = 4;
-                //request.MaximumResponseHeadersLength = 4;
-                //// Set credentials to use for this request.
-                //request.Credentials = CredentialCache.DefaultCredentials;
                 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                 Stream receiveStream = response.GetResponseStream();
                 StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
-                block = readStream.ReadToEnd();
+                var block = readStream.ReadToEnd();
                 response.Close();
                 readStream.Close();
+                var files = JsonConvert.DeserializeObject<List<string>>(block);
 
-
-                int posd = 0;
-                int posf = 0;
-                while ((posd = block.IndexOf(dep, posd)) > 0)
+                foreach(var file in files)
                 {
-                    Console.WriteLine(posd);
-                    posd += dep.Length;
-                    posf = block.IndexOf(fin, posd);
-                    if (posf < 0) break;
-                    string line = block.Substring(posd, posf - posd);
-                    if (line.Contains("/Station_") && line.ToUpper().EndsWith(".XML"))
-                        lines.Add("http://" + response.ResponseUri.Host + line);
+
+                    var fileUrl = Path.Combine(url_txt, file);
+                    request = (HttpWebRequest)WebRequest.Create(fileUrl);
+                    response = (HttpWebResponse)request.GetResponse();
+                    receiveStream = response.GetResponseStream();
+                    readStream = new StreamReader(receiveStream, Encoding.UTF8);
+                    block = readStream.ReadToEnd();
+                    response.Close();
+                    readStream.Close();
+                    Console.WriteLine(block);
+                    var json = JsonConvert.DeserializeObject<string>(block);
+                    var achats = JsonConvert.DeserializeObject<List<Achats3>>(json);
+
                 }
+
+
+                //int posd = 0;
+                //int posf = 0;
+                //while ((posd = block.IndexOf(dep, posd)) > 0)
+                //{
+                //    Console.WriteLine(posd);
+                //    posd += dep.Length;
+                //    posf = block.IndexOf(fin, posd);
+                //    if (posf < 0) break;
+                //    string line = block.Substring(posd, posf - posd);
+                //    if (line.Contains("/Station_") && line.ToUpper().EndsWith(".XML"))
+                //        lines.Add("http://" + response.ResponseUri.Host + line);
+                //}
             }
             catch (System.Net.WebException ex)
             {

+ 0 - 3
Fuel_ASO/f_vehi.Designer.cs

@@ -543,9 +543,6 @@
         #endregion
 
         private System.Windows.Forms.BindingSource tbvehiculeBindingSource;
-        private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn;
-        private System.Windows.Forms.DataGridViewTextBoxColumn immatDataGridViewTextBoxColumn;
-        private System.Windows.Forms.DataGridViewTextBoxColumn familleDataGridViewTextBoxColumn;
         private System.Windows.Forms.StatusStrip statusStrip1;
         private System.Windows.Forms.ToolStripStatusLabel st1;
         private DataSet1 dataSet1;

+ 9 - 9
Fuel_ASO/f_vehi.cs

@@ -17,9 +17,9 @@ namespace Fuel01
         DataSet1.tb_vehiDataTable tb_vehi = new DataSet1.tb_vehiDataTable();
         private bool hasChanged = false;
 
-        List<produit> lproduit = new List<produit>();
-        List<produit> lcarbu = new List<produit>();
-        List<famille> lfamille = new List<famille>();
+        List<Produit> lproduit = new List<Produit>();
+        List<Produit> lcarbu = new List<Produit>();
+        List<Famille> lfamille = new List<Famille>();
 
         public f_vehi()
         {
@@ -57,14 +57,14 @@ namespace Fuel01
             XDocument xRoot = XDocument.Load(Program.folder + @"\param\famille.xml");
             var data = from item in xRoot.Descendants("tb_famille")
                        orderby item.Element("key_fam").Value
-                       select new famille()
+                       select new Famille()
                        {
                            key_fam = item.Element("key_fam").Value
                        };
             lfamille = data.ToList();
             combo_famille.Items.Clear();
             combo_famille.DisplayMember = "key_fam";
-            foreach (famille f in lfamille)
+            foreach (Famille f in lfamille)
                 combo_famille.Items.Add(f);
         }
 
@@ -74,7 +74,7 @@ namespace Fuel01
             XDocument xRoot = XDocument.Load(Program.folder + @"\param\produit.xml");
             var data = from item in xRoot.Descendants("tb_prod")
                        orderby item.Element("type_prod").Value, item.Element("lib_prod").Value
-                       select new produit()
+                       select new Produit()
                        {
                            key_prod = item.Element("key_prod").Value,
                            lib_prod = item.Element("lib_prod").Value,
@@ -84,7 +84,7 @@ namespace Fuel01
             lcarbu=lproduit.Where(p => p.type_prod == "Carburant").ToList();
             combo_energy.Items.Clear();
             combo_energy.DisplayMember = "key_prod";
-            foreach (produit p in lcarbu)
+            foreach (Produit p in lcarbu)
                 combo_energy.Items.Add(p);
         }
 
@@ -207,12 +207,12 @@ namespace Fuel01
             if (File.Exists(Program.subfolder + @"\vehicule.json"))
                 File.Copy(Program.subfolder + @"\vehicule.json", Program.subfolder + @"\vehicule.back.json",true);
 
-            tb_vehi = DbUtil.LoadFromJson<DataSet1.tb_vehiDataTable>(Program.subfolder + @"\vehicule.json", tb_vehi);
+            DbUtil.SaveToJson<DataSet1.tb_vehiDataTable>(Program.subfolder + @"\vehicule.json", tb_vehi);
         }
 
         private void combo_energy_TextUpdate(object sender, EventArgs e)
         {
-            produit cur_Prod = lproduit.Find(p => p.key_prod == combo_energy.Text);
+            Produit cur_Prod = lproduit.Find(p => p.key_prod == combo_energy.Text);
             if (cur_Prod != null)
                 StatusLabel1.Text = cur_Prod.lib_prod;
             else