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 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 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 Vehis; public TVI() { Vehis = new List(); loadData_Vehi(); } public List 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 { 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(); } } }