Classes.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Fuel01
  8. {
  9. public class HubMessage
  10. {
  11. public string Action { get; set; }
  12. public string Source { get; set; }
  13. public string Description { get; set; }
  14. public string Valeur { get; set; }
  15. public string[] Destinataires { get; set; }
  16. public string Date { get; set; }
  17. public HubMessage()
  18. {
  19. Action = "";
  20. }
  21. }
  22. public class Achats
  23. {
  24. public int StationId { get; set; }
  25. public String Bandeau { get; set; }
  26. public DateTime Date { get; set; }
  27. public String KindCarbu { get; set; }
  28. public float Volume { get; set; }
  29. public float PrixCarbu { get; set; }
  30. public float MontantCarbu { get; set; }
  31. public List<PrestasFournies> Prestas { get; set; }
  32. public float MontantTotal { get; set; }
  33. public float TxTva { get; set; }
  34. }
  35. public class PrestasFournies
  36. {
  37. public String Libel { get; set; }
  38. public String Name { get; set; }
  39. public float Quantity { get; set; }
  40. public float PrixUnitaire { get; set; }
  41. public float Total { get; set; }
  42. public float TxTva { get; set; }
  43. }
  44. public class vehi_achat
  45. {
  46. public string keyvehi_achat { get; set; }
  47. public string date_achat { get; set; }
  48. public string KindCarbu_achat { get; set; }
  49. public float Volume_achat { get; set; }
  50. public float PrixCarbu_achat { get; set; }
  51. public float MontantCarbu_achat { get; set; }
  52. public List<Presta_achat> Prestas_achat { get; set; }
  53. public float TxTva_achat { get; set; }
  54. }
  55. public class Presta_achat
  56. {
  57. public string name_presta { get; set; }
  58. public float Quantity_presta { get; set; }
  59. public float PrixUnitaire_presta { get; set; }
  60. public float TxTva_presta { get; set; }
  61. }
  62. public class pays
  63. {
  64. public string key_pays { get; set; }
  65. public string nom_pays { get; set; }
  66. public string code_pays { get; set; }
  67. public string concat_pays { get; set; }
  68. }
  69. public class produit
  70. {
  71. public string key_prod { get; set; }
  72. public string lib_prod { get; set; }
  73. public string type_prod { get; set; }
  74. }
  75. public class famille
  76. {
  77. public string key_fam { get; set; }
  78. }
  79. public class vehicule
  80. {
  81. public string key_vehi { get; set; }
  82. public string ope_vehi { get; set; }
  83. public string num_vehi { get; set; }
  84. public string cmpnum_vehi { get; set; }
  85. public string immat_vehi { get; set; }
  86. public string type_vehi { get; set; }
  87. public bool ok_vehi { get; set; }
  88. public string carbu_vehi { get; set; }
  89. public int kmdep_vehi { get; set; }
  90. public int kmarr_vehi { get; set; }
  91. public string cond_vehi { get; set; }
  92. public string famille_vehi { get; set; }
  93. public string order_vehi { get; set; }
  94. public vehicule()
  95. {
  96. }
  97. public vehicule(string _key)
  98. {
  99. key_vehi = _key;
  100. }
  101. public vehicule(vehicule orig)
  102. {
  103. key_vehi = orig.key_vehi;
  104. ope_vehi = orig.ope_vehi;
  105. num_vehi = orig.num_vehi;
  106. cmpnum_vehi = orig.cmpnum_vehi;
  107. immat_vehi = orig.immat_vehi;
  108. type_vehi = orig.type_vehi;
  109. ok_vehi = orig.ok_vehi;
  110. carbu_vehi = orig.carbu_vehi;
  111. kmdep_vehi = orig.kmdep_vehi;
  112. kmarr_vehi = orig.kmarr_vehi;
  113. cond_vehi = orig.cond_vehi;
  114. famille_vehi = orig.famille_vehi;
  115. order_vehi = orig.order_vehi;
  116. }
  117. public void maj_vehi()
  118. {
  119. order_vehi = (num_vehi == null ? " ".PadLeft(5) : num_vehi.PadLeft(5)) + (cmpnum_vehi == null ? " ".PadLeft(5) : cmpnum_vehi.PadLeft(5));
  120. }
  121. public string ToLigne()
  122. {
  123. string ret = "";
  124. ret = string.Format("{0}##^##{1}##^##{2}##^##{3}##^##{4}##^##{5}##^##{6}##^##{7}##^##{8}##^##{9}##^##{10}##^##{11}##^##",
  125. key_vehi,
  126. ope_vehi,
  127. num_vehi,
  128. cmpnum_vehi,
  129. immat_vehi,
  130. type_vehi,
  131. ok_vehi,
  132. carbu_vehi,
  133. kmdep_vehi,
  134. kmarr_vehi,
  135. cond_vehi,
  136. famille_vehi);
  137. return ret;
  138. }
  139. }
  140. public class TVI
  141. {
  142. private List<vehicule> Vehis;
  143. public TVI()
  144. {
  145. Vehis = new List<vehicule>();
  146. loadData_Vehi();
  147. }
  148. public List<vehicule> GetVehi()
  149. {
  150. var cont = (from vi in Vehis
  151. orderby vi.num_vehi
  152. select vi).ToList();
  153. return cont;
  154. }
  155. private bool loadData_Vehi()
  156. {
  157. bool ret = false;
  158. string path = @"c:\temp\MyTest.txt";
  159. try
  160. {
  161. string[] lignes = File.ReadAllLines(path);
  162. foreach (string lig in lignes)
  163. {
  164. string[] val = lig.Split(new string[] { "##^##" }, StringSplitOptions.None);
  165. vehicule vi = new vehicule
  166. {
  167. key_vehi = val[0],
  168. ope_vehi = val[1],
  169. num_vehi = val[2],
  170. cmpnum_vehi = val[3],
  171. immat_vehi = val[4],
  172. type_vehi = val[5],
  173. ok_vehi = val[6] == "true",
  174. carbu_vehi = val[7],
  175. kmdep_vehi = Convert.ToInt32(val[8]),
  176. kmarr_vehi = Convert.ToInt32(val[9]),
  177. cond_vehi = val[10],
  178. famille_vehi = val[11]
  179. };
  180. Vehis.Add(vi);
  181. }
  182. ret = true;
  183. }
  184. catch (Exception ex)
  185. {
  186. ret = false;
  187. }
  188. return ret;
  189. }
  190. }
  191. public class id_prod
  192. {
  193. public string type_pro { get; set; }
  194. public string code_pro { get; set; }
  195. public decimal ttc_pro { get; set; }
  196. public decimal tva_pro { get; set; }
  197. public string lib_pro { get; set; }
  198. }
  199. class vente_tot
  200. {
  201. public DataSet1.tb_venteRow vente { get; set; }
  202. public decimal total_qtt { get; set; }
  203. public decimal total_ht { get; set; }
  204. public decimal total_ttc { get; set; }
  205. }
  206. class vente_tva
  207. {
  208. public decimal taux_tva { get; set; }
  209. public decimal base_tva { get; set; }
  210. public decimal mnt_tva { get; set; }
  211. public decimal mnt_ttc { get; set; }
  212. }
  213. class ProdEqualityComparer : IEqualityComparer<id_prod>
  214. {
  215. public bool Equals(id_prod b1, id_prod b2)
  216. {
  217. if (b2 == null && b1 == null)
  218. return true;
  219. else if (b1 == null | b2 == null)
  220. return false;
  221. else if (b1.code_pro == b2.code_pro &
  222. b1.lib_pro== b2.lib_pro &
  223. b1.ttc_pro == b2.ttc_pro &
  224. b1.tva_pro == b2.tva_pro &
  225. b1.type_pro == b2.type_pro )
  226. return true;
  227. else
  228. return false;
  229. }
  230. public int GetHashCode(id_prod bx)
  231. {
  232. int hCode = 0;
  233. //for (int i = 0; i < bx.code_pro.Length; i++)
  234. // hCode += bx.code_pro[i];
  235. //for (int i = 0; i < bx.lib_pro.Length; i++)
  236. // hCode += bx.lib_pro[i];
  237. hCode += bx.code_pro.GetHashCode();
  238. hCode += bx.lib_pro.GetHashCode();
  239. hCode += bx.type_pro.GetHashCode();
  240. hCode += (int)(bx.ttc_pro * 100);
  241. hCode += (int)(bx.tva_pro * 100);
  242. 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()));
  243. return hCode.GetHashCode();
  244. //return bx.GetHashCode();
  245. }
  246. }
  247. }