Imports System.Data Imports Extensiones Imports Microsoft.Reporting.WebForms Partial Class Contabilidad_CatClasificacionPorcentaje Inherits ClsPaginas Private Property DtClasificacionPorcentaje As DataTable Get Return CType(ViewState("DtClasificacionPorcentaje"), DataTable) End Get Set(value As DataTable) ViewState("DtClasificacionPorcentaje") = value End Set End Property Private Property CveClasificacion As Integer Get Return CType(ViewState("CveClasificacion"), Integer) End Get Set(value As Integer) ViewState("CveClasificacion") = value End Set End Property Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaDatos() CargaContPaq() End If End Sub Protected Sub CargaDatos() Dim ObjGenerales As New ClsGenerales If ObjGenerales.GetClasificacionPorcentaje(UsuarioActual.CveEmpresa, CveClasificacionPorcentaje:=-1, CveClasificacion:=-1, PorcentajeIVA:=-1, Opcion:=2) Then GvDatos.DataSource = ObjGenerales.DtResultados DtClasificacionPorcentaje = ObjGenerales.DtResultados End If ObjGenerales.Dispose() GvDatos.DataBind() DdlClasificaciones.Items.Add(New ListItem("Seleccione", "-1")) DdlClasificaciones.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) DdlClasificaciones.DataBind() End Sub Protected Sub CargaContPaq() Dim Empresa As DataTable = GlobalDTEmpresas(UsuarioActual.CveEmpresa) Dim Servidor As String = Empresa.FiltroPrimeroValor("ServerContPAQi") Dim BD As String = Empresa.FiltroPrimeroValor("BDContPAQi") Dim Usuario As String = Empresa.FiltroPrimeroValor("UsrContPAQi") Dim Contra As String = Empresa.FiltroPrimeroValor("PwdContPAQi") Dim ObjPaq As New ClsContPAQi(Servidor, BD, Usuario, Contra) DdlIdCtaIVAXAcreditar.Items.Add(New ListItem("Seleccione una cuenta", "-1")) DdlIdCtaIVAAcreditable.Items.Add(New ListItem("Seleccione una cuenta", "-1")) DdlIdCtaIVAXTrasladar.Items.Add(New ListItem("Seleccione una cuenta", "-1")) DdlIdCtaIVATrasladado.Items.Add(New ListItem("Seleccione una cuenta", "-1")) DdlIdCtaIVANoAcreditable.Items.Add(New ListItem("Seleccione una cuenta", "-1")) If ObjPaq.GetCuentas(-1, "-1", -1, IdPadre:=-1) Then DdlIdCtaIVAXAcreditar.DataSource = ObjPaq.DtResultados DdlIdCtaIVAAcreditable.DataSource = ObjPaq.DtResultados DdlIdCtaIVAXTrasladar.DataSource = ObjPaq.DtResultados DdlIdCtaIVATrasladado.DataSource = ObjPaq.DtResultados DdlIdCtaIVANoAcreditable.DataSource = ObjPaq.DtResultados End If ObjPaq.Dispose() DdlIdCtaIVAXAcreditar.DataBind() DdlIdCtaIVAAcreditable.DataBind() DdlIdCtaIVAXTrasladar.DataBind() DdlIdCtaIVATrasladado.DataBind() DdlIdCtaIVANoAcreditable.DataBind() End Sub Protected Sub BtnAgregarMotivo_Click(sender As Object, e As EventArgs) Handles BtnAgregarClas.Click BtnAgregarTiposDModal.Text = "Agregar" BtnEditarTiposDModal.Visible = False BtnAgregarTiposDModal.Visible = True TxtPorcentajeIva.Text = "" UpModalTiposD.Update() RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")) End Sub Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles BtnAgregarTiposDModal.Click 'esta funcion es la que agrega un nuevo motivo de baja se activa con el boton "Agregar" de la ventana modal" Dim ObjGenerales As New ClsGenerales If BtnAgregarTiposDModal.Text = "Agregar" Then If ObjGenerales.AddClasificacionPorcentaje(DdlClasificaciones.SelectedValue, TxtPorcentajeIva.Text.ToDouble, DdlIdCtaIVAXAcreditar.SelectedValue, DdlIdCtaIVAAcreditable.SelectedValue, DdlIdCtaIVAXTrasladar.SelectedValue, DdlIdCtaIVATrasladado.SelectedValue, UsuarioActual.CveEmpresa) Then RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")) Alert("Clasificación porcentaje agregado correctamente") If ObjGenerales.GetClasificacionPorcentaje(-1) Then GlobalDTClasificacionPorcentaje(-1) = ObjGenerales.DtResultados End If CargaDatos() CargaContPaq() UpDatos.Update() End If ElseIf BtnAgregarTiposDModal.Text = "Actualizar" Then If ObjGenerales.UpdateClasificacionPorcentaje(CveClasificacion, DdlClasificaciones.SelectedValue, TxtPorcentajeIva.Text.ToDouble, DdlIdCtaIVAXAcreditar.SelectedValue, DdlIdCtaIVAAcreditable.SelectedValue, DdlIdCtaIVAXTrasladar.SelectedValue, DdlIdCtaIVATrasladado.SelectedValue) Then RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")) Alert("Clasificación porcentaje actualizado correctamente") If ObjGenerales.GetClasificacionPorcentaje(-1) Then GlobalDTClasificacionPorcentaje(-1) = ObjGenerales.DtResultados End If CargaDatos() CargaContPaq() UpDatos.Update() End If End If ObjGenerales.Dispose() End Sub Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting Dim objgenerales As New ClsGenerales If objgenerales.RemoveClasificacionPorcentaje(GvDatos.DataKeys(e.RowIndex).Value.ToString) Then Alert("la clasificación porcentaje se eliminó correctamente") If objgenerales.GetClasificacionPorcentaje(-1) Then GlobalDTClasificacionPorcentaje(-1) = objgenerales.DtResultados End If CargaDatos() CargaContPaq() UpDatos.Update() End If objgenerales.Dispose() End Sub Public Sub GvDatos_RowEditing(sender As Object, e As EventArgs) BtnAgregarTiposDModal.Text = "Actualizar" Dim renglon As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) DdlClasificaciones.SelectedValue = If(renglon.DataKey("CveClasificacion").ToString IsNot "", renglon.DataKey("CveClasificacion"), "-1") TxtPorcentajeIva.Text = renglon.DataKey("PorcentajeIVA") DdlIdCtaIVAXAcreditar.SelectedValue = If(renglon.DataKey("IdCtaIVAXAcreditar").ToString IsNot "", renglon.DataKey("IdCtaIVAXAcreditar"), "-1") DdlIdCtaIVAAcreditable.SelectedValue = If(renglon.DataKey("IdCtaIVAAcreditable").ToString IsNot "", renglon.DataKey("IdCtaIVAAcreditable"), "-1") DdlIdCtaIVAXTrasladar.SelectedValue = If(renglon.DataKey("IdCtaIVAXTrasladar").ToString IsNot "", renglon.DataKey("IdCtaIVAXTrasladar"), "-1") DdlIdCtaIVATrasladado.SelectedValue = If(renglon.DataKey("IdCtaIVATrasladado").ToString IsNot "", renglon.DataKey("IdCtaIVATrasladado"), "-1") DdlIdCtaIVANoAcreditable.SelectedValue = If(renglon.DataKey("IdCtaIVANoAcreditable").ToString IsNot "", renglon.DataKey("IdCtaIVANoAcreditable"), "-1") BtnEditarTiposDModal.Visible = False BtnAgregarTiposDModal.Visible = True UpModalTiposD.Update() RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")) End Sub End Class