Option Explicit On Option Strict On Imports Extensiones Partial Class Ventas_CatMotivosCancelacion Inherits ClsPaginas Private Property CveMotivoCancelacion As Integer Get Return (IfNull(ViewState("CveMotivoCancelacion"), "-1", ViewState("CveMotivoCancelacion"))).ToString().ToEntero() End Get Set(value As Integer) ViewState("CveMotivoCancelacion") = value End Set End Property Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaCombos() CargaDatos() End If End Sub Private Sub CargaCombos() DdlMotivoSAT.DataSource = GlobalDTSATMotivosCancelacion() DdlMotivoSAT.DataBind() UpModal.Update() End Sub Private Sub CargaDatos() LimpiaDatos() Dim ObjGral As New ClsGenerales() If ObjGral.GetMotivosCancelacionEmpresa(UsuarioActual.CveEmpresa) Then GvDatos.DataSource = ObjGral.DtResultados.Copy() End If ObjGral.Dispose() GvDatos.DataBind() UpDatos.Update() End Sub Protected Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Dim GvRow As GridViewRow = GvDatos.Rows(e.RowIndex) CveMotivoCancelacion = GvRow.DataKey("CveMotivoCancelacion").ToEntero() Using ObjVentas As New ClsGenerales If ObjVentas.RemoveMotivoCancelacionEmpresa(CveMotivoCancelacion, UsuarioActual.CveEmpresa) Then Alert("Se eliminó correctamente") End If End Using CargaDatos() End Sub Protected Sub imgE_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) CveMotivoCancelacion = GvRow.DataKey("CveMotivoCancelacion").ToEntero() TxtMotivo.Text = GvRow.DataKey("MotivoCancelacion") DdlMotivoSAT.SelectedValueExist(GvRow.DataKey("CveSATMotivoCancelacion")) ChkEstatus.Checked = CBool(GvRow.DataKey("Estatus")) UpModal.Update() RegistraScript("$('#DivMotivo').modal('show');") End Sub Private Sub LimpiaDatos() CveMotivoCancelacion = -1 TxtMotivo.Text = "" ChkEstatus.Checked = True End Sub Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Dim Motivo As String = TxtMotivo.Text Dim ObjVentas As New ClsGenerales If CveMotivoCancelacion = -1 Then If ObjVentas.AddMotivoCancelacionEmpresa(DdlMotivoSAT.SelectedValue.ToEntero(), Motivo, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then Alert("El motivo se agrego correctamente") End If Else If ObjVentas.UpdateMotivoCancelacionEmpresa(CveMotivoCancelacion, DdlMotivoSAT.SelectedValue.ToEntero(), Motivo, ChkEstatus.Checked, UsuarioActual.CveEmpresa) Then Alert("El motivo se actualizó correctamente") End If End If ObjVentas.Dispose() GlobalDTMotivosCancelacionEmpresa(UsuarioActual.CveEmpresa) = Nothing RegistraScript("$('#DivMotivo').modal('hide');") CargaDatos() End Sub Protected Sub LnkAgregar_Click(sender As Object, e As EventArgs) LimpiaDatos() RegistraScript("$('#DivMotivo').modal('show');") End Sub End Class