diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index f0351a9a0..b307f28ef 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -8,6 +8,7 @@ Imports Microsoft.Reporting.WebForms Imports System.Globalization Imports System.Data.SqlTypes Imports DocumentFormat.OpenXml.Drawing.Diagrams +Imports Microsoft.AspNet.SignalR.Infrastructure Partial Class RH_Personal Inherits ClsPaginas @@ -1058,11 +1059,42 @@ Partial Class RH_Personal DVDdlTipoSangre.Visible = True End If + If Not CvePersonal > 0 Then + AsignaSiguienteCodigo() + End If + + End If AgregarEventosAsincronosGvVacaciones() End Sub + Private Sub AsignaSiguienteCodigo() + Dim ObjPersonal As New ClsRH() + If ObjPersonal.GetPersonal(-1, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then + Dim MaxCodigo As Integer = 1 + + If ObjPersonal.DtResultados.Rows.Count > 0 Then + MaxCodigo = ObjPersonal.DtResultados.AsEnumerable() _ + .Select(Function(row) + Dim codigoStr As String = row.Field(Of String)("Codigo") + If Not String.IsNullOrWhiteSpace(codigoStr) Then + Dim codigo As Integer + If Integer.TryParse(codigoStr, codigo) Then + Return codigo + End If + End If + Return 0 + End Function) _ + .DefaultIfEmpty(0) _ + .Max() + End If + + TxtCodigo.Text = (MaxCodigo + 1).ToString("000") + + End If + ObjPersonal.Dispose() + End Sub Private Sub LoadDefaultValues() DdlDepartamento.SelectedIndex = 1