Imports System.Data Imports Extensiones Partial Class Acumuladores_CatFoliosGarantia Inherits ClsPaginas Private Property CveGarantiaMes As Integer Get If Not ViewState("CveGarantiaMes") Is Nothing Then Return ViewState("CveGarantiaMes").ToString.ToEntero Else Return -1 End If End Get Set(value As Integer) ViewState("CveGarantiaMes") = 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 CargaCombos() CargadatosGvFolioGarantia() End If End Sub #Region "Folios Garantía" Protected Sub btConsultar_Click(sender As Object, e As EventArgs) Handles btConsultar.Click CargadatosGvFolioGarantia() End Sub Private Sub CargadatosGvFolioGarantia() Dim objAcum As New ClsAcumuladores If objAcum.GarantiasMesesGet(-1, UsuarioActual.Empresa.CveEmpresa, DdlMarca.SelectedValue.ToEntero, DdlTipoUso.SelectedValue.ToEntero) Then GvFolioGarantia.DataSource = objAcum.DtResultados Else GvFolioGarantia.DataSource = Nothing End If objAcum.Dispose() UPGvFolioGarantia.DataBind() UpGral.Update() 'CargaGvTamanioBitacora() End Sub Private Sub CargaCombos() Dim ObjPS As New ClsProductosServicios If ObjPS.GetMarcas(UsuarioActual.CveEmpresa) Then DdlMarca.DataSource = ObjPS.DtResultados DdlMarca.DataBind() DdlMarca.Items.Insert(0, New ListItem("Todos", "-1")) DdlMarca.SelectedValue = "-1" End If ObjPS.Dispose() DdlTipoUso.DataSource = GlobalDTAcumTiposUso() DdlTipoUso.DataBind() DdlTipoUso.Items.Insert(0, New ListItem("Todos", "-1")) DdlTipoUso.SelectedValue = "-1" End Sub Protected Sub BtnAgregarFolioGarantia_Click(sender As Object, e As EventArgs) Handles BtnAgregarFolioGarantia.Click LtlTituloModalFolioGarantia.Text = "Agregar Garantía de Mes" BtnAgregarFolioGarantiaModal.Text = "Agregar" CargaCombosModal() If DdlMarca.SelectedValue <> -1 Then DdlMarcaM.SelectedValueExist(DdlMarca.SelectedValue.ToEntero) If DdlTipoUso.SelectedValue <> -1 Then DdlTipoUsoM.SelectedValueExist(DdlTipoUso.SelectedValue.ToEntero) TxtMes.Text = TxtMes.Text.ToEntero + 1 TxtValor.Text = "" TxtMes.Focus() Actualizar = False UpGral.Update() RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarFolioGarantia")) End Sub Private Sub CargaCombosModal() Dim ObjPS As New ClsProductosServicios If ObjPS.GetMarcas(UsuarioActual.CveEmpresa) Then DdlMarcaM.DataSource = ObjPS.DtResultados End If ObjPS.Dispose() DdlMarcaM.DataBind() DdlTipoUsoM.DataSource = GlobalDTAcumTiposUso() DdlTipoUsoM.DataBind() End Sub Protected Sub BtnAgregarFolioGarantiaModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarFolioGarantiaModal.Click Dim ObjAcum As New ClsAcumuladores If Not Actualizar Then If ObjAcum.GarantiasMesesAdd(DdlMarcaM.SelectedValue.ToEntero, DdlTipoUsoM.SelectedValue.ToEntero, TxtMes.Text.ToEntero, TxtValor.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then TxtMes.Text = TxtMes.Text.ToEntero + 1 TxtValor.Text = "" TxtMes.Focus() CargadatosGvFolioGarantia() If Not ChkSeguir.Checked Then RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarFolioGarantia"), "jsHideModalFolioGarantia") Alert("Garantía de Mes Agregada Correctamente", TipoMensaje.MsgInformacion) Else RegistraScript(String.Format("$('#{0}').modal('show');", "DivAgregarFolioGarantia"), "jsHideModalFolioGarantia") End If UpGral.Update() Else Alert("Ocurrió un error al guardar la Garantía de Mes", TipoMensaje.MsgError) End If Else If ObjAcum.GarantiasMesesUpdate(CveGarantiaMes, DdlMarcaM.SelectedValue.ToEntero, DdlTipoUsoM.SelectedValue.ToEntero, TxtMes.Text.ToEntero, TxtValor.Text.ToDecimal, UsuarioActual.CveUsuario) Then TxtMes.Text = "" TxtValor.Text = "" CargadatosGvFolioGarantia() UpModalFolioGarantia.Update() If Not ChkSeguir.Checked Then RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarFolioGarantia"), "jsHideModalFolioGarantia") Alert("Garantía de Mes Actualizada Correctamente", TipoMensaje.MsgInformacion) Else RegistraScript(String.Format("$('#{0}').modal('show');", "DivAgregarFolioGarantia"), "jsHideModalFolioGarantia") End If UpGral.Update() Else Alert("Ocurrió un error al Actualizar la Garantía de Mes", TipoMensaje.MsgError) End If End If CveGarantiaMes = -1 Actualizar = False ObjAcum.Dispose() End Sub Public Sub Remove_ClickFolioGarantia(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("CveGarantiaMes") If objAcum.GarantiasMesesRemove(CveCapacitador, UsuarioActual.CveEmpresa) Then CargadatosGvFolioGarantia() Alert("Capacitador Eliminó Correctamente ", TipoMensaje.MsgInformacion) Else Alert("Ocurrió un error al Eliminar la Garantía de Mes", TipoMensaje.MsgError) End If objAcum.Dispose() CargadatosGvFolioGarantia() CveGarantiaMes = -1 End Sub Public Sub Edit_ClickFolioGarantia(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim activo As Boolean = 0 LtlTituloModalFolioGarantia.Text = "Editar Garantía de Mes" Actualizar = True CveGarantiaMes = GvRow.DataKey("CveGarantiaMes") TxtMes.Text = GvRow.DataKey("Mes") TxtValor.Text = GvRow.DataKey("Valor") CargaCombosModal() DdlMarcaM.SelectedValueExist(GvRow.DataKey("CveMarca").ToEntero) DdlTipoUsoM.SelectedValueExist(GvRow.DataKey("CveTipoUso").ToEntero) BtnAgregarFolioGarantiaModal.Text = "Actualizar" UpModalFolioGarantia.Update() RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarFolioGarantia")) End Sub #End Region End Class