Option Strict On Imports Extensiones Partial Class General_CatDiasInhabiles Inherits ClsPaginas Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaDatos() End If End Sub Private Sub CargaDatos() Dim ObjGrl As New ClsGenerales() If ObjGrl.DiasInhabiles_Get(-1, -1, UsuarioActual.Empresa.CveEmpresa) Then GvDiasInhabiles.DataSource = ObjGrl.DtResultados GvDiasInhabiles.DataBind() End If ObjGrl.Dispose() UpDatos.Update() End Sub Private Sub BtnAgregarDiaInhabil_Click(sender As Object, e As EventArgs) Handles BtnAgregarDiaInhabil.Click Dim ObjGrl As New ClsGenerales Dim Estatus As Integer = 0 If ChkEstatus.Checked Then Estatus = 1 If HdnModalidad.Value = "A" Then If ObjGrl.DiasInhabiles_Add(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, TxtDiaInhabil.Text, TxtDescripcion.Text, Estatus, TxtFechaInhabil.Text.ToDate) Then CargaDatos() Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion) End If ElseIf HdnModalidad.Value = "U" Then If ObjGrl.DiasInhabiles_Update(HdnID.Value.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, TxtDiaInhabil.Text, TxtDescripcion.Text, Estatus, Date.Now, TxtFechaInhabil.Text.ToDate) Then CargaDatos() Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion) End If End If RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddDiasInhabiles")) ObjGrl.Dispose() UpDatos.Update() End Sub Public Sub Edit_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) HdnModalidad.Value = "U" HdnID.Value = GvRow.DataKey("CveDiaInhabil") UpDatos.Update() BtnAgregarDiaInhabil.Text = "Actualizar" TxtDiaInhabil.Text = GvRow.DataKey("DiaInhabil") TxtDescripcion.Text = GvRow.DataKey("Descripcion") ChkEstatus.Checked = CBool(GvRow.DataKey("Estatus")) TxtFechaInhabil.Text = (GvRow.DataKey("FechaInhabil")) UpAddDiasInhabiles.Update() RegistraScript(String.Format("$('#{0}').modal('show');", "divAddDiasInhabiles")) End Sub Private Sub LnkDiaInhabil_Click(sender As Object, e As EventArgs) Handles LnkDiaInhabil.Click Agregar() End Sub Public Sub Delete_Click(sender As Object, e As EventArgs) Dim ObjGrl As New ClsGenerales() Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) HdnID.Value = GvRow.DataKey("CveDiaInhabil") UpDatos.Update() If ObjGrl.DiasInhabiles_Remove(HdnID.Value.ToEntero) Then CargaDatos() End If ObjGrl.Dispose() UpDatos.Update() End Sub Public Sub Agregar() HdnModalidad.Value = "A" UpDatos.Update() BtnAgregarDiaInhabil.Text = "Agregar" TxtDiaInhabil.Text = "" TxtDescripcion.Text = "" ChkEstatus.Checked = False UpAddDiasInhabiles.Update() TxtFechaInhabil.Text = Date.Now.ToString RegistraScript(String.Format("$('#{0}').modal('show');", "divAddDiasInhabiles")) End Sub Private Sub GvDiasInhabiles_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDiasInhabiles.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("Estatus") = True.ToString Then e.Row.FCLabel("LblEstatus").Text = "Activo" e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Green Else e.Row.FCLabel("LblEstatus").Text = "Inactivo" e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Red End If End If End Sub End Class