291 lines
13 KiB
VB.net
291 lines
13 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class AC_CatOGClasificaciones
|
|
Inherits ClsPaginas
|
|
|
|
Private Property CveClasificacion() As Integer 'Guardamos el ID de registro para saber cual registro Editar
|
|
Get
|
|
Return If(IsNothing(ViewState("CveClasificacion")), -1, CInt(ViewState("CveClasificacion")))
|
|
End Get
|
|
Set
|
|
ViewState("CveClasificacion") = Value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property DtOGClasificaciones As DataTable
|
|
Get
|
|
Return CType(ViewState("DtOGClasificaciones"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtOGClasificaciones") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
ViewState("Orden") = ""
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnMostrarModal_Click(sender As Object, e As EventArgs) Handles BtnMostrarModal.Click
|
|
TxtCodigo.Text = ""
|
|
TxtOGClasificacion.Text = ""
|
|
ChkEstatus.Checked = True
|
|
CheckActiveSection.Visible = False
|
|
DivAfectable.Visible = False
|
|
LbAgregar.Text = "Agregar"
|
|
UpModalTiposD.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivModal"))
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjClasificaciones As New ClsClasificaciones
|
|
If ObjClasificaciones.GetClasificaciones() Then
|
|
ViewState("DTOGClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("Codigo <> '' AND CveEmpresa = " & UsuarioActual.CveEmpresa, "Codigo")
|
|
GlobalDTClasificaciones = ObjClasificaciones.DtResultados
|
|
GlobalDTACClasificadorObjetoGasto = ObjClasificaciones.DtResultados.FiltraParametros("Codigo <> '' ")
|
|
Else
|
|
Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjClasificaciones.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click
|
|
Dim ObjClasificaciones As New ClsClasificaciones
|
|
|
|
If LbAgregar.Text = "Agregar" Then
|
|
If ObjClasificaciones.AddClasificaciones(TxtOGClasificacion.Text.Trim, TxtCodigo.Text.Trim, -1, "", -1, "", -1, "", 0, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
TxtOGClasificacion.Text = ""
|
|
TxtCodigo.Text = ""
|
|
Alert("La Clasificacion de Objeto de Gasto se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
'UpTitulos.Update()
|
|
ViewState("DTOGClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTClasificaciones = ObjClasificaciones.DtResultados
|
|
|
|
End If
|
|
Else
|
|
If ObjClasificaciones.UpdateClasificacion(TxtOGClasificacion.Text, TxtCodigo.Text, -1, "", -1, "", -1, "", ChkEstatus.Checked, ChkAfectable.Checked, 0, UsuarioActual.CveUsuario, CveClasificacion) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTOGClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTClasificaciones = ObjClasificaciones.DtResultados
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivModal"))
|
|
ObjClasificaciones.Dispose()
|
|
|
|
|
|
CargaDatos()
|
|
|
|
End Sub
|
|
|
|
#Region "G V D A T O S"
|
|
Protected Sub LnkEditar_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) 'obtenemos el renglon que acabamos de seleccionar
|
|
CveClasificacion = GvRow.DataKey("CveClasificacion").ToEntero
|
|
TxtCodigo.Text = GvRow.DataKey("Codigo")
|
|
TxtOGClasificacion.Text = GvRow.DataKey("Clasificacion")
|
|
ChkAfectable.Checked = GvRow.DataKey("Afectable") = "True"
|
|
ChkEstatus.Checked = GvRow.DataKey("Estatus") = "Activo"
|
|
DivAfectable.Visible = True
|
|
CheckActiveSection.Visible = True
|
|
LbAgregar.Text = "Actualizar"
|
|
UpModalTiposD.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivModal"))
|
|
End Sub
|
|
|
|
Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) 'obtenemos el renglon que acabamos de seleccionar
|
|
Dim ObjClasificaciones As New ClsClasificaciones
|
|
If ObjClasificaciones.RemoveClasificacion(GvRow.DataKey("CveClasificacion").ToEntero) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTOGClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTClasificaciones = ObjClasificaciones.DtResultados
|
|
Alert("la Clasificacion de Objeto de Gasto se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjClasificaciones.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(75)
|
|
e.Row.Cells(1).Width = Unit.Pixel(406)
|
|
e.Row.Cells(2).Width = Unit.Pixel(90)
|
|
e.Row.Cells(3).Width = Unit.Pixel(80)
|
|
e.Row.Cells(4).Width = Unit.Pixel(100)
|
|
e.Row.Cells(5).Width = Unit.Pixel(100)
|
|
'e.Row.Cells(6).Width = Unit.Pixel(50)
|
|
'e.Row.Cells(7).Width = Unit.Pixel(50)
|
|
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Center
|
|
'e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Center
|
|
'e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Center
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim ObjClasificaciones As New ClsClasificaciones
|
|
If ObjClasificaciones.RemoveClasificacion(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTOGClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTClasificaciones = ObjClasificaciones.DtResultados
|
|
Alert("la Clasificacion de Objeto de Gasto se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjClasificaciones.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
|
|
GvDatos.EditIndex = -1
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
|
|
|
|
Dim ObjOGClasificaciones As New ClsClasificaciones
|
|
|
|
Dim OGClasificacion As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtOGClasificacion"), TextBox).Text.Trim
|
|
Dim Estatus As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstatus").Checked
|
|
Dim Afectable As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkAfectable").Checked
|
|
Dim CveOGClasificacion As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
Dim Codigo As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtCodigo"), TextBox).Text.Trim
|
|
|
|
If ObjOGClasificaciones.UpdateClasificacion(OGClasificacion, Codigo, -1, "", -1, "", -1, "", Estatus, Afectable, 0, UsuarioActual.CveUsuario, CveOGClasificacion) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTOGClasificaciones") = ObjOGClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTClasificaciones = ObjOGClasificaciones.DtResultados
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjOGClasificaciones.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatos.RowEditing
|
|
GvDatos.EditIndex = e.NewEditIndex
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "O R D E N A M I E N T O"
|
|
Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim Orden As String = ""
|
|
Dim Campo As String = ""
|
|
Dim Literal As Literal = Nothing
|
|
Const OrdenInicial As String = ""
|
|
Dim Arg(2) As String
|
|
|
|
Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c)
|
|
Campo = Arg(0)
|
|
Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal)
|
|
|
|
If ViewState(String.Format("O{0}", Campo)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo)).ToString = String.Format("{0} DESC", Campo) Then
|
|
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo)
|
|
Literal.Text = String.Format("<i class='fa fa-sort-asc' style='color:#999' ></i>")
|
|
Else
|
|
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo)
|
|
Literal.Text = String.Format("<i class='fa fa-sort-desc' style='color:#999' ></i>")
|
|
End If
|
|
Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString
|
|
ViewState("Orden") = Orden
|
|
CargaGrid(Orden)
|
|
End Sub
|
|
|
|
Private Sub CargaGrid(Orden As String)
|
|
If Orden <> String.Empty Then
|
|
Dim DV As New DataView(CType(ViewState("DTOGClasificaciones"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
Gv.DataSource = DV.ToTable()
|
|
DtOGClasificaciones = DV.Table()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = CType(ViewState("DTOGClasificaciones"), DataTable)
|
|
Gv.DataSource = CType(ViewState("DTOGClasificaciones"), DataTable)
|
|
DtOGClasificaciones = CType(ViewState("DTOGClasificaciones"), DataTable)
|
|
End If
|
|
GvDatos.DataBind()
|
|
Gv.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " EXPORTAR - PDF - EXCEL "
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs)
|
|
Tbl.ExportToExcel("Catalogo de Clasificaciones de Objeto de Gasto ")
|
|
End Sub
|
|
|
|
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs)
|
|
ImprimirReporte()
|
|
End Sub
|
|
'No quitar porque no funciona el exporta PDF
|
|
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
|
|
' Verifies that the control is rendered
|
|
End Sub
|
|
|
|
Protected Sub ImprimirReporte()
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("pImg", New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Logo.png", UsuarioActual.CveEmpresa))).AbsoluteUri))
|
|
|
|
ImprimirPDF("AC/Reportes/RepOGClasificaciones.rdlc", DtOGClasificaciones, params, "ReporteOGClasificaciones")
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
End Class
|