| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- 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();
- }
- }
- }
|