Class1.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. namespace VINClassLib
  2. {
  3. public class VIN_LIB
  4. {
  5. public string VIN_WMI, VIN_VDS, VIN_VIS;
  6. public string GetVINCountry (string vin)
  7. {
  8. if (IsStringValid(vin))
  9. {
  10. try
  11. {
  12. CreateSegmentsFromVIN(vin);
  13. string CountryCode = VIN_WMI.Substring(0, 2);
  14. return $"WMI: {VIN_WMI}\nVDS: {VIN_VDS}\nVIS: {VIN_VIS}\nКод страны: {CountryCode} ";
  15. }
  16. catch (System.ArgumentOutOfRangeException) { return "Исключение"; }
  17. }
  18. else return "Неверный формат VIN-кода";
  19. }
  20. public string CheckVIN(string vin)
  21. {
  22. return "CheckVIN еще не написан";
  23. }
  24. public string GetTransportYear(string vin)
  25. {
  26. return "GetTransportYear еще не написан";
  27. }
  28. public bool IsStringValid (string vin)
  29. {
  30. if (vin.Length == 17)
  31. {
  32. return true;
  33. }
  34. else return false;
  35. }
  36. public void CreateSegmentsFromVIN (string vin)
  37. { if (IsStringValid(vin))
  38. {
  39. VIN_WMI = vin.Substring(0, 3);
  40. VIN_VDS = vin.Substring(4, 6);
  41. VIN_VIS = vin.Substring(10, 7);
  42. }
  43. }
  44. public bool IsSegmentsValid(string VIN_WMI, string VIN_VDS, string VIN_VIS)
  45. {
  46. if (VIN_WMI.Length == 3 && VIN_VDS.Length == 6 && VIN_VIS.Length == 8) return true; else return false;
  47. }
  48. }
  49. }