223 lines
8.1 KiB
VB.net
223 lines
8.1 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
Partial Class Ventas_CatImpuestosLocales
|
|
Inherits ClsPaginas
|
|
|
|
#Region " PROPIEDADES"
|
|
Private Property DtCuentasContables As Data.DataTable
|
|
Get
|
|
Return CType(ViewState("DtCuentasContables"), DataTable)
|
|
End Get
|
|
Set(value As Data.DataTable)
|
|
ViewState("DtCuentasContables") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property DtImpuestosLocales As Data.DataTable
|
|
Get
|
|
Return CType(ViewState("DtImpuestosLocales"), DataTable)
|
|
End Get
|
|
Set(value As Data.DataTable)
|
|
ViewState("DtImpuestosLocales") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveImpuestoLocal As Integer
|
|
Get
|
|
Return ViewState("CveImpuestoLocal").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveImpuestoLocal") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CveImpuestoLocal = -1
|
|
|
|
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Estatus = 'Activo' AND UsoClasificacion = 2 ")
|
|
DdlClasificacion.DataBind()
|
|
DdlClasificacion.Items.Insert(0, New ListItem("Seleccione una", "-1"))
|
|
|
|
CargaCuentasContables()
|
|
CargaDatos()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim ObjVentas As New ClsVentas()
|
|
If ObjVentas.GetImpuestosLocales(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
GvImpuestos.DataSource = ObjVentas.DtResultados
|
|
GvImpuestos.DataBind()
|
|
End If
|
|
ObjVentas.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaCuentasContables()
|
|
If UsuarioActual.Empresa.UsaContabilidad OrElse UsuarioActual.Empresa.UsaAC Then
|
|
Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa)
|
|
'UsuarioActual.Empresa.Funcionalidad(208).ToEntero
|
|
If ObjContabilidad.GetCuentasRecursiva(1, 1) Then
|
|
DtCuentasContables = ObjContabilidad.DtResultados
|
|
Else
|
|
DtCuentasContables = Nothing
|
|
End If
|
|
ObjContabilidad.Dispose()
|
|
End If
|
|
|
|
|
|
DdlCuentasContables.DataSource = DtCuentasContables
|
|
DdlCuentasContables.DataBind()
|
|
End Sub
|
|
|
|
|
|
#Region "GV IMPUESTOS "
|
|
|
|
|
|
Protected Sub GvImpuestos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvImpuestos.RowDeleting
|
|
Dim ObjVentas As New ClsVentas()
|
|
Dim TieneError = False
|
|
|
|
Dim CveImpuesto As Integer = GvImpuestos.Rows(e.RowIndex).DataKey("CveImpuestoLocal").ToEntero
|
|
|
|
If Not ObjVentas.RemoveImpuestosLocales(CveImpuesto) Then
|
|
TieneError = True
|
|
End If
|
|
ObjVentas.Dispose()
|
|
|
|
|
|
If Not TieneError Then
|
|
GvImpuestos.EditIndex = -1
|
|
Alert("Se elimino correctamente el Impuesto Local.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrio un error al eliminar el Impuesto Local.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
Private Sub GvImpuestos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvImpuestos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If (e.Row.RowState And DataControlRowState.Edit) > 0 Then
|
|
e.Row.FCDropDownList("DdlTipoImpuestoEdit").SelectedValueExist(e.Row.DataKey("TipoImpuesto"))
|
|
|
|
e.Row.FCDropDownList("DdlCuentasContables").DataSource = DtCuentasContables
|
|
e.Row.FCDropDownList("DdlCuentasContables").DataBind()
|
|
e.Row.FCDropDownList("DdlCuentasContables").Items.Add(New ListItem("Seleccione", "-1"))
|
|
e.Row.FCDropDownList("DdlCuentasContables").SelectedValue = e.Row.DBCampo("IdCuentaImpuestoLocal")
|
|
|
|
End If
|
|
|
|
|
|
If e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal Then
|
|
If e.Row.DBCampo("IdCuentaImpuestoLocal").ToEntero > 0 Then
|
|
e.Row.FCLiteral("LtlCuentaContable").Text = DtCuentasContables.FiltroPrimeroValor("CtaCodigo", $"Id = {e.Row.DBCampo("IdCuentaImpuestoLocal")}")
|
|
Else
|
|
e.Row.FCLiteral("LtlCuentaContable").Text = "Sin Cuenta"
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "BTN'S"
|
|
Private Sub BtnAgregarImpuestoModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarImpuestoModal.Click
|
|
CveImpuestoLocal = -1
|
|
|
|
|
|
TxtOrden.Text = ""
|
|
TxtImpuesto.Text = ""
|
|
TxtPorcentaje.Text = ""
|
|
DdlTipoImpuesto.SelectedValueExist("-1")
|
|
DdlCuentasContables.SelectedValueExist("-1")
|
|
DdlClasificacion.SelectedValueExist("-1")
|
|
BtnAgregarImpuesto.Text = "Agregar"
|
|
ChkEstatus.Checked = True
|
|
|
|
UpAddImpuesto.Update()
|
|
UpFooter.Update()
|
|
RegistraScript("$('#divAddImpuestoLocal').modal();LimpiaModal()")
|
|
End Sub
|
|
|
|
Private Sub BtnAgregarImpuesto_Click(sender As Object, e As EventArgs) Handles BtnAgregarImpuesto.Click
|
|
Dim ObjVentas As New ClsVentas
|
|
Dim Estatus = 0
|
|
|
|
If CveImpuestoLocal = -1 Then
|
|
If ChkEstatus.Checked Then Estatus = 1
|
|
|
|
If ObjVentas.AddImpuestosLocales(TxtImpuesto.Text.Trim, TxtPorcentaje.Text.ToDecimal, TxtOrden.Text.ToEntero, DdlTipoImpuesto.SelectedValue.ToEntero, Estatus, DdlCuentasContables.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero) Then
|
|
CargaDatos()
|
|
End If
|
|
TxtImpuesto.Text = ""
|
|
TxtPorcentaje.Text = ""
|
|
TxtOrden.Text = ""
|
|
TxtImpuesto.Focus()
|
|
Else
|
|
If CveImpuestoLocal <> -1 Then
|
|
Dim TieneError = False
|
|
Dim Impuesto As String = TxtImpuesto.Text.Trim
|
|
Dim Porcentaje As Decimal = TxtPorcentaje.Text.ToDecimal
|
|
Dim Orden = TxtOrden.Text.ToEntero
|
|
Dim TipoImpuesto = DdlTipoImpuesto.SelectedValue.ToEntero
|
|
Dim IdCtaContable = DdlCuentasContables.SelectedValue.ToEntero
|
|
If ChkEstatus.Checked Then Estatus = 1
|
|
|
|
If Not ObjVentas.UpdateImpuestosLocales(CveImpuestoLocal, Impuesto, Porcentaje, Orden, TipoImpuesto, Estatus, IdCtaContable, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero) Then
|
|
TieneError = True
|
|
End If
|
|
ObjVentas.Dispose()
|
|
|
|
|
|
If Not TieneError Then
|
|
GvImpuestos.EditIndex = -1
|
|
CargaDatos()
|
|
Else
|
|
Alert("Ocurrio un error al actualizar los datos", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
CveImpuestoLocal = -1
|
|
End If
|
|
End If
|
|
ObjVentas.Dispose()
|
|
UpDatos.Update()
|
|
RegistraScript("$('#divAddImpuestoLocal').modal('hide');")
|
|
End Sub
|
|
|
|
Public Sub Edit_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
DdlTipoImpuesto.SelectedValueExist(GvRow.DataKey("TipoImpuesto"))
|
|
DdlCuentasContables.SelectedValueExist(GvRow.DataKey("IdCuentaImpuestoLocal"))
|
|
TxtImpuesto.Text = GvRow.DataKey("ImpuestoLocal")
|
|
TxtPorcentaje.Text = GvRow.DataKey("Porcentaje")
|
|
TxtOrden.Text = GvRow.DataKey("Orden")
|
|
ChkEstatus.Checked = Boolean.Parse(GvRow.DataKey("EstatusBol")) 'If(GvRow.DataKey("EstatusBol").ToEntero = 1, True, False)
|
|
DdlClasificacion.SelectedValueExist(GvRow.DataKey("CveClasificacion"))
|
|
|
|
BtnAgregarImpuesto.Text = "Actualizar"
|
|
CveImpuestoLocal = GvRow.DataKey("CveImpuestoLocal").ToEntero
|
|
|
|
UpAddImpuesto.Update()
|
|
UpFooter.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "divAddImpuestoLocal"))
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
End Class
|