Imports System.Data Imports Extensiones Partial Class Acumuladores_CatTiposDefecto Inherits ClsPaginas Private Property CveTipoDefecto As Integer Get If Not ViewState("CveTipoDefecto") Is Nothing Then Return ViewState("CveTipoDefecto").ToString.ToEntero Else Return -1 End If End Get Set(value As Integer) ViewState("CveTipoDefecto") = value End Set End Property Private Property Actualizar As Boolean Get If Not ViewState("Actualizar") Is Nothing Then Return DirectCast(ViewState("Actualizar"), Boolean) Else Return False End If End Get Set(value As Boolean) ViewState("Actualizar") = value End Set End Property Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargadatosGvTiposD() End If End Sub #Region "Tipos Defecto" Private Sub CargadatosGvTiposD() Dim objAcum As New ClsAcumuladores If objAcum.TiposDefectoGet(-1, UsuarioActual.Empresa.CveEmpresa) Then GvTiposD.DataSource = objAcum.DtResultados Else GvTiposD.DataSource = Nothing End If objAcum.Dispose() UPGvTiposD.DataBind() UpGral.Update() 'CargaGvTamanioBitacora() End Sub Private Sub GeneraGlobalDT() Dim ObjAcum As New ClsAcumuladores If ObjAcum.TiposDefectoGet(-1, UsuarioActual.Empresa.CveEmpresa) Then Application("GlobalDTAcumTiposDefecto") = ObjAcum.DtResultados ObjAcum.Dispose() End Sub 'Private Sub CargaGvTamanioBitacora() ' Dim objAcum As New ClsAcumuladores ' If objAcum.TamañoBitacoraGet(UsuarioActual.Empresa.CveEmpresa) Then ' GvBitacora.DataSource = objAcum.DtResultados ' Else ' GvBitacora.DataSource = Nothing ' End If ' objAcum.Dispose() ' UpGvBitacora.DataBind() ' UpGral.Update() 'End Sub Protected Sub BtnAgregarTiposD_Click(sender As Object, e As EventArgs) Handles BtnAgregarTiposD.Click LtlTituloModalTiposD.Text = "Agregar Tipo Defecto" BtnAgregarTiposDModal.Text = "Agregar" TxtTiposD.Text = "" ChkEstatus.Checked = True Actualizar = False UpGral.Update() RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")) End Sub Protected Sub BtnAgregarTiposDModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarTiposDModal.Click Dim ObjAcum As New ClsAcumuladores 'Dim Cargo, Bonificacion, Compra, Puntos As Decimal 'Cargo = If(TxtCargo.Text.ToDecimal > 0, TxtCargo.Text.ToDecimal, -1) 'Bonificacion = If(TxtBonificacion.Text.ToDecimal > 0, TxtBonificacion.Text.ToDecimal, -1) 'Compra = If(TxtCompra.Text.ToDecimal > 0, TxtCompra.Text.ToDecimal, -1) 'Puntos = If(TxtPuntos.Text.ToDecimal > 0, TxtPuntos.Text.ToDecimal, -1) If Not Actualizar Then If ObjAcum.TiposDefectoAdd(TxtTiposD.Text, If(ChkEstatus.Checked = True, 1, 0), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then TxtTiposD.Text = "" ChkEstatus.Checked = True 'TxtCargo.Text = "" 'TxtBonificacion.Text = "" 'TxtCompra.Text = "" 'TxtPuntos.Text = "" CargadatosGvTiposD() RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"), "jsHideModalTiposD") GeneraGlobalDT() UpGral.Update() Alert("Tipo de Defecto Agregado Correctamente", TipoMensaje.MsgInformacion) Else Alert("Ocurrio un error al guardar el Tipo de Defecto", TipoMensaje.MsgError) End If Else If ObjAcum.TiposDefectoUpdate(CveTipoDefecto, TxtTiposD.Text, If(ChkEstatus.Checked = True, 1, 0), UsuarioActual.CveUsuario) Then TxtTiposD.Text = "" ChkEstatus.Checked = True 'TxtCargo.Text = "" 'TxtBonificacion.Text = "" 'TxtCompra.Text = "" 'TxtPuntos.Text = "" CargadatosGvTiposD() GeneraGlobalDT() UpModalTiposD.Update() RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD"), "jsHideModalTiposD") UpGral.Update() Alert("Tipo de Defecto Actualizado Correctamente", TipoMensaje.MsgInformacion) Else Alert("Ocurrio un error al Actualizar el Tipo de Defecto", TipoMensaje.MsgError) End If End If CveTipoDefecto = -1 Actualizar = False ObjAcum.Dispose() End Sub Public Sub Remove_ClickTiposD(sender As Object, e As EventArgs) Dim objAcum As New ClsAcumuladores Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim activo As Boolean = 0 Dim CveCapacitador As Integer = GvRow.DataKey("CveTipoDefecto") If objAcum.TiposDefectoRemove(CveCapacitador, UsuarioActual.CveEmpresa) Then CargadatosGvTiposD() GeneraGlobalDT() Alert("Capacitador Eliminó Correctamente ", TipoMensaje.MsgInformacion) Else Alert("Ocurrio un error al Eliminar el Tipo de Defecto", TipoMensaje.MsgError) End If objAcum.Dispose() CargadatosGvTiposD() CveTipoDefecto = -1 End Sub Public Sub Edit_ClickTiposD(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim activo As Boolean = 0 LtlTituloModalTiposD.Text = "Editar Tipo Defecto" Actualizar = True CveTipoDefecto = GvRow.DataKey("CveTipoDefecto") TxtTiposD.Text = GvRow.DataKey("TipoDefecto") ChkEstatus.Checked = If(GvRow.DataKey("Estatus") = "Activo", True, False) 'TxtCargo.Text = GvRow.DataKey("Cargo").ToDecimal.ToString("###,###,###.00") 'TxtBonificacion.Text = GvRow.DataKey("Bonificacion").ToDecimal.ToString("###,###,###.00") 'TxtCompra.Text = GvRow.DataKey("Compra").ToDecimal.ToString("###,###,###.00") 'TxtPuntos.Text = GvRow.DataKey("Puntos").ToDecimal.ToString("###,###,###.00") 'DdlPS.Items.Clear() 'DdlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) 'DdlPS.DataBind() 'DdlPS.SelectedValueExist(GvRow.DataKey("CvePSCargo").ToEntero) BtnAgregarTiposDModal.Text = "Actualizar" UpModalTiposD.Update() RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")) End Sub #End Region End Class