Utilidades.vb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Module Utilidades
  2. Function CalcularDiasDelAnio(Fecha As Date) As Integer
  3. Dim valor As Integer
  4. Dim Fecha1 As Date
  5. Dim Fecha2 As Date
  6. Fecha1 = Convert.ToDateTime("01/01/" + Fecha.Year.ToString)
  7. Fecha2 = Convert.ToDateTime("31/12/" + Fecha.Year.ToString)
  8. valor = DateDiff(DateInterval.Day, Fecha1, Fecha2)
  9. valor = valor + 1
  10. Return valor
  11. End Function
  12. Function Days360(StartDate As DateTime, EndDate As DateTime) As Integer
  13. Dim Months As Integer = (EndDate.Year - StartDate.Year) * 12 + EndDate.Month - StartDate.Month
  14. Dim Days As Integer = Math.Min(30, EndDate.Day) - Math.Min(30, StartDate.Day)
  15. Return Months * 30 + Days
  16. End Function
  17. Function DiasDeUnPeriodo(vCodigoPeriodo As String) As Integer
  18. Dim valor As Integer = 0
  19. If vCodigoPeriodo = "M" Then
  20. valor = 30
  21. End If
  22. If vCodigoPeriodo = "T" Then
  23. valor = 90
  24. End If
  25. If vCodigoPeriodo = "S" Then
  26. valor = 180
  27. End If
  28. Return valor
  29. End Function
  30. Public Function GenerarTransId() As String
  31. Dim res As String
  32. Dim serialGuid As Guid = Guid.NewGuid()
  33. Dim uniqueSerial As String = serialGuid.ToString("N")
  34. Dim uniqueSerialLength As String = uniqueSerial.Substring(0, 20).ToUpper()
  35. res = "SINV" & uniqueSerialLength
  36. Return res
  37. End Function
  38. End Module