Imports Extensiones Partial Class RH_Asistencias Inherits ClsPaginas Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then 'CargaClientes() DdlCliente.Attributes.Add("onclick", "CargaClientes();") CargaProyecto() CargaTurnos() TxtFechaAsistencia.Text = Now.ToShortDateString If UsuarioActual.CveRol = 1 OrElse UsuarioActual.CveUsuario = 2343 Then PnlMasivo.Visible = True CargaTiposPeriodo() End If End If End Sub #Region "CargaCombos" Private Sub CargaClientes() Dim ObjClientes As New ClsClientes If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1) Then DdlCliente.DataSource = ObjClientes.DtResultados Else DdlCliente.DataSource = Nothing End If ObjClientes.Dispose() 'Application("GlobalDTResponsable") DdlCliente.DataBind() End Sub Protected Sub BtnCargarClientes_Click(sender As Object, e As System.EventArgs) Handles BtnCargarClientes.Click CargaClientes() DdlCliente.Attributes.Remove("onclick") End Sub Private Sub CargaProyecto() DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa).FiltraParametros("", DistinctColumns:={"CveProyecto", "Proyecto"}) DdlProyecto.DataBind() End Sub Private Sub CargaSubProyecto() DdlSubProyecto.Items.Clear() DdlSubProyecto.DataSource = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToEntero) DdlSubProyecto.DataBind() DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1")) End Sub Private Sub CargaTurnos() DdlTurno.DataSource = GlobalDTTurno.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) DdlTurno.DataBind() End Sub #End Region Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged CargaSubProyecto() End Sub Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click If TxtFechaAsistencia.Text.Trim.ToDate.Year.Contiene(Now.Year - 1, Now.Year, Now.Year + 1) Then Dim objpersonal As New ClsRH If objpersonal.GetAsistencias(-1, DdlCliente.SelectedValue.ToEntero, DdlProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlTurno.SelectedValue.ToEntero, 1, TxtFechaAsistencia.Text.Trim.ToDate, TxtFechaAsistencia.Text.Trim.ToDate, UsuarioActual.CveEmpresa) Then GV.DataSource = objpersonal.DtResultados Else GV.DataSource = Nothing End If objpersonal.Dispose() GV.DataBind() BtnGuardar.Visible = (GV.Rows.Count > 0) UpDatos.Update() Else Alert("La Fecha está fuera de los parámetros establecidos, por favor revise. Fecha: " & TxtFechaAsistencia.Text, TipoMensaje.MsgAdvertencia) End If End Sub Protected Sub GV_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GV.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowIndex = 0 Then e.Row.Cells(0).Width = Unit.Pixel(60) e.Row.Cells(1).Width = Unit.Pixel(300) e.Row.Cells(2).Width = Unit.Pixel(100) e.Row.Cells(3).Width = Unit.Pixel(80) e.Row.Cells(4).Width = Unit.Pixel(85) e.Row.Cells(5).Width = Unit.Pixel(85) e.Row.Cells(6).Width = Unit.Pixel(150) e.Row.Cells(7).Width = Unit.Pixel(90) End If e.Row.FCLiteral("LtlCodigo").Text = "" & e.Row.DBCampo("Codigo") & "" e.Row.FCLiteral("LtlPersonal").Text = "" & e.Row.DBCampo("Nombre") & "" e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left e.Row.FCTextBox("TxtPorPago").Text = e.Row.DBCampo("PorcentajePago") e.Row.FCTextBox("TxtHorasDobles").Text = e.Row.DBCampo("HorasDobles") e.Row.FCTextBox("TxtHorasTriples").Text = e.Row.DBCampo("HorasTriples") 'Carga Tipos de Asistencia e.Row.FCDropDownList("DdlTipoAsistencias").DataSource = GlobalDTAsistenciasInasistencias.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) e.Row.FCDropDownList("DdlTipoAsistencias").DataBind() If e.Row.DBCampo("CveAsistenciasInasistencias") <> "-1" Then e.Row.FCDropDownList("DdlTipoAsistencias").SelectedValue = e.Row.DBCampo("CveAsistenciasInasistencias") 'Carga Motivos Horas Extras e.Row.FCDropDownList("DdlMotivoHoraExtra").DataSource = GlobalDTMotivosHorasExtras.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) e.Row.FCDropDownList("DdlMotivoHoraExtra").DataBind() If e.Row.DBCampo("CveMotivoHoraExtra") <> "-1" Then e.Row.FCDropDownList("DdlMotivoHoraExtra").SelectedValue = e.Row.DBCampo("CveMotivoHoraExtra") e.Row.FCTextBox("TxtObservaciones").Text = e.Row.DBCampo("Observacion") If e.Row.DBCampo("SeModifico") = "0" Then e.Row.Cells(0).BackColor = Drawing.Color.LightBlue e.Row.Cells(1).BackColor = Drawing.Color.LightBlue ElseIf e.Row.DBCampo("SeModifico") = "1" Then e.Row.Cells(0).ForeColor = Drawing.Color.Red e.Row.Cells(1).ForeColor = Drawing.Color.Red End If End If End Sub Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click Dim ObjPersonal As New ClsRH() ObjPersonal.IniciaTransacSQL() Dim OcurrioError As Boolean = False For Each Row As GridViewRow In GV.Rows If Not ObjPersonal.AddAsistencia(Row.DataKey("CvePersonal").ToEntero, DdlCliente.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, TxtFechaAsistencia.Text.Trim.ToDate, Row.FCDropDownList("DdlTipoAsistencias").SelectedValue.ToEntero, Row.FCTextBox("TxtPorPago").Text.Trim.ToDouble, Row.FCTextBox("TxtHorasDobles").Text.Trim.ToDouble, Row.FCTextBox("TxtHorasTriples").Text.Trim.ToDouble, Row.FCDropDownList("DdlMotivoHoraExtra").SelectedValue.ToEntero, Row.FCTextBox("TxtObservaciones").Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then OcurrioError = True Exit For End If Next If OcurrioError Then ObjPersonal.RollBack() Alert("Ocurrió un error al guardar las Asistencias.", TipoMensaje.MsgError) Else ObjPersonal.Commit() Alert("Las Asistencias se guardaron correctamente.", TipoMensaje.MsgInformacion) End If ObjPersonal.Dispose() BtnConsultar_Click(sender, e) End Sub Protected Sub BtnCargaMasiva_Click(sender As Object, e As EventArgs) Dim ObjPersonal As New ClsRH() ObjPersonal.IniciaTransacSQL() Dim OcurrioError As Boolean = False If Not ObjPersonal.AddAsistenciaMasiva(DdlPeriodo.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then OcurrioError = True End If If OcurrioError Then ObjPersonal.RollBack() Alert("Ocurrió un error al guardar las Asistencias.", TipoMensaje.MsgError) Else ObjPersonal.Commit() Alert("Las Asistencias se guardaron correctamente.", TipoMensaje.MsgInformacion) End If ObjPersonal.Dispose() End Sub Protected Sub DdlTipoPeriodo_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlTipoPeriodo.SelectedIndexChanged CargaPeriodos() End Sub Private Sub CargaTiposPeriodo() DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo DdlTipoPeriodo.DataBind() End Sub Private Sub CargaPeriodos() Dim ObjPeriodos As New ClsNominas If ObjPeriodos.GetPeriodos(DdlTipoPeriodo.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1, -1, -1) Then DdlPeriodo.DataSource = ObjPeriodos.DtResultados Else DdlPeriodo.DataSource = Nothing End If ObjPeriodos.Dispose() DdlPeriodo.DataBind() DdlPeriodo.Items.Clear() DdlPeriodo.DataBind() DdlPeriodo.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub End Class