This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2021-03-23 16:26:20 -07:00
parent 43c1ef4732
commit d026079da0
14 changed files with 3834 additions and 3485 deletions

View File

@@ -2406,6 +2406,102 @@ Partial Class Nomina_Nomina
EnvioMasivoCorreo()
End Sub
Private Sub CrearLayout(DTNomina As DataTable)
Dim sb As New StringBuilder
Dim SbErrores As New StringBuilder
Dim ErroresValidaciones As Boolean = False
SbErrores.AppendLine("Se detectaron los siguientes errores en la generación del layout")
For Each dRow As DataRow In DTNomina.Rows
Dim RFC As String = dRow("RFC").ToString()
Dim Nombre As String = dRow("Nombre").ToString()
Dim BancoNumCuenta As String = dRow("BancoNumCuenta").ToString()
Dim Importe As Decimal = dRow("Importe").ToString().ToDecimal
If RFC.Trim().Length = 0 Then
SbErrores.AppendLine($"El RFC es requerido del empleado {Nombre}<br/>")
End If
Dim Coincidencia As Match = System.Text.RegularExpressions.Regex.Match(RFC, "/^([A-Z,Ñ,&]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])[A-Z|\d]{3})$/")
If Not Coincidencia.Success Then
SbErrores.AppendLine($"El RFC {RFC} del empleado {Nombre} no es valido <br/>")
ErroresValidaciones = True
End If
If BancoNumCuenta.Trim().Length <> 10 Then
SbErrores.AppendLine($"Empleado {Nombre} numero de cuenta incorrecto, la cuenta debe de tener 10 caracteres<br/>") 'Bancomer 10 caracteres
ErroresValidaciones = True
End If
If Importe <= 0 Then
SbErrores.AppendLine($"Empleado {Nombre} el importe debe de ser mayor a 0 importe {Importe}") 'importe mayot a 0
ErroresValidaciones = True
End If
Next
ErroresValidaciones = False
If Not ErroresValidaciones Then
Dim Count As Integer = 1
For Each dRow As DataRow In DTNomina.Rows
Dim SbLinea As New StringBuilder
Dim RFC As String = dRow("RFC").ToString()
Dim Nombre As String = dRow("Nombre").ToString()
Dim BancoNumCuenta As String = dRow("BancoNumCuenta").ToString()
Dim Importe As Decimal = dRow("Importe").ToString().ToDecimal.RoundSQL(2)
SbLinea.Append(Count.ToString("000000000"))
SbLinea.Append(RFC.Trim().PadRight(16))
SbLinea.Append("03")
SbLinea.Append(BancoNumCuenta.Trim().PadRight(20))
SbLinea.Append(Importe.ToString("0000000000000.00").Replace(".", ""))
If Nombre.Trim().Length > 40 Then
Nombre = Nombre.Substring(0, 40)
End If
SbLinea.Append(Nombre.Trim().PadRight(40))
SbLinea.Append("012")
SbLinea.Append("000")
sb.AppendLine(SbLinea.ToString())
Count = Count + 1
Next
Response.Clear()
Response.ClearHeaders()
Response.AppendHeader("Content-Length", sb.ToString())
Response.ContentType = "text/plain"
Response.AppendHeader("Content-Disposition", $"attachment;filename=""Nomina{Now.ToString("yyyyMMddhhmmss").ToString()}.txt""")
Response.Write(sb.ToString())
Response.End()
Else
Alert(SbErrores.ToString(), TipoMensaje.MsgAdvertencia)
End If
End Sub
Private Sub EnvioMasivoCorreo()