298 lines
13 KiB
VB.net
298 lines
13 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
Imports iTextSharp.text
|
|
Imports iTextSharp.text.html.simpleparser
|
|
Imports iTextSharp.text.pdf
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class AC_CatClasificacionGeografica
|
|
Inherits ClsPaginas
|
|
|
|
Private Property CveClasificacionGeografica() As Integer 'Guardamos el ID de registro para saber cual registro Editar
|
|
Get
|
|
Return If(IsNothing(ViewState("CveClasificacionGeografica")), -1, CInt(ViewState("CveClasificacionGeografica")))
|
|
End Get
|
|
Set
|
|
ViewState("CveClasificacionGeografica") = Value
|
|
End Set
|
|
End Property
|
|
Private Property DtClasificacionGeografica As DataTable
|
|
Get
|
|
Return CType(ViewState("DtClasificacionGeografica"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtClasificacionGeografica") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property PuedeEditar As Boolean
|
|
Get
|
|
Return CBool(ViewState("PuedeEditar"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("PuedeEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property PuedeEliminar As Boolean
|
|
Get
|
|
Return CBool(ViewState("PuedeEditar"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("PuedeEditar") = 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
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjClasificacionGeografica As New ClsAC
|
|
If ObjClasificacionGeografica.GetClasificacionGeografica() Then
|
|
ViewState("DTClasificacionGeografica") = ObjClasificacionGeografica.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTAC_ClasificacionGeografica(UsuarioActual.CveEmpresa) = ObjClasificacionGeografica.DtResultados
|
|
Else
|
|
Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjClasificacionGeografica.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarClasificacionFuncional_Click(sender As Object, e As EventArgs) Handles BtnAgregarClasificacionFuncional.Click
|
|
TxtClasificacionGeografica.Text = ""
|
|
ChkEstatus.Checked = True
|
|
CheckActiveSection.Visible = False
|
|
LbAgregar.Text = "Agregar"
|
|
UpModalTiposD.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarClasifFuncional"))
|
|
End Sub
|
|
|
|
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
|
|
CveClasificacionGeografica = GvRow.DataKey("CveClasificacionGeografica").ToEntero
|
|
TxtClasificacionGeografica.Text = GvRow.DataKey("ClasificacionGeografica")
|
|
CheckActiveSection.Visible = True
|
|
ChkEstatus.Checked = GvRow.DataKey("Estatus") = "Activo"
|
|
LbAgregar.Text = "Actualizar"
|
|
UpModalTiposD.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarClasifFuncional"))
|
|
End Sub
|
|
|
|
Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click
|
|
Dim ObjClasificacionGeografica As New ClsAC
|
|
If LbAgregar.Text = "Agregar" Then
|
|
If ObjClasificacionGeografica.AddClasificacionGeografica(TxtClasificacionGeografica.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
TxtClasificacionGeografica.Text = ""
|
|
Alert("El Nuevo Registro se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
'UpTitulos.Update()
|
|
ViewState("DTClasificacionGeografica") = ObjClasificacionGeografica.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTAC_ClasificacionGeografica(UsuarioActual.CveEmpresa) = ObjClasificacionGeografica.DtResultados
|
|
|
|
End If
|
|
Else
|
|
If ObjClasificacionGeografica.UpdateClasificacionGeografica(TxtClasificacionGeografica.Text.Trim, ChkEstatus.Checked, CveClasificacionGeografica) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTClasificacionGeografica") = ObjClasificacionGeografica.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTAC_ClasificacionGeografica(UsuarioActual.CveEmpresa) = ObjClasificacionGeografica.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');", "DivAgregarClasifFuncional"))
|
|
ObjClasificacionGeografica.Dispose()
|
|
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 ObjClasificacionGeografica As New ClsAC
|
|
If ObjClasificacionGeografica.RemoveClasificacionGeografica(GvRow.DataKey("CveClasificacionGeografica").ToEntero) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTClasificacionGeografica") = ObjClasificacionGeografica.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTAC_ClasificacionGeografica(UsuarioActual.CveEmpresa) = ObjClasificacionGeografica.DtResultados
|
|
Alert("El Registro se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjClasificacionGeografica.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
#Region "G V D A T O S"
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(250)
|
|
e.Row.Cells(1).Width = Unit.Pixel(100)
|
|
e.Row.Cells(2).Width = Unit.Pixel(100)
|
|
e.Row.Cells(3).Width = Unit.Pixel(100)
|
|
'e.Row.Cells(4).Width = Unit.Pixel(50)
|
|
'e.Row.Cells(5).Width = Unit.Pixel(50)
|
|
End If
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
|
|
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
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim ObjClasificacionGeografica As New ClsAC
|
|
If ObjClasificacionGeografica.RemoveClasificacionGeografica(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTClasificacionGeografica") = ObjClasificacionGeografica.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTAC_ClasificacionGeografica(UsuarioActual.CveEmpresa) = ObjClasificacionGeografica.DtResultados
|
|
Alert("El Registro se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjClasificacionGeografica.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 ObjClasificacionGeografica As New ClsAC
|
|
|
|
Dim ClasificacionGeografica As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtClasificacionGeografica"), TextBox).Text.Trim
|
|
Dim Estatus As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstatus").Checked
|
|
Dim CveClasificacionGeografica As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
|
|
If ObjClasificacionGeografica.UpdateClasificacionGeografica(ClasificacionGeografica, Estatus, CveClasificacionGeografica) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTClasificacionGeografica") = ObjClasificacionGeografica.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTAC_ClasificacionGeografica(UsuarioActual.CveEmpresa) = ObjClasificacionGeografica.DtResultados
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjClasificacionGeografica.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 gvi As Integer = 0
|
|
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)
|
|
gvi = Arg(1).ToEntero
|
|
Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal)
|
|
|
|
If ViewState(String.Format("O{0}{1}", Campo, gvi)) IsNot Nothing AndAlso ViewState(String.Format("O{0}{1}", Campo, gvi)).ToString = String.Format("{0} DESC", Campo) Then
|
|
ViewState(String.Format("O{0}{1}", Campo, gvi)) = 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}{1}", Campo, gvi)) = 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}{1}", Campo, gvi)).ToString
|
|
ViewState("Orden") = Orden
|
|
CargaGrid(Orden)
|
|
End Sub
|
|
|
|
Private Sub CargaGrid(ByVal Orden As String)
|
|
If Orden <> String.Empty Then
|
|
Dim DV As New DataView(CType(ViewState("DTClasificacionGeografica"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
Gv.DataSource = DV.ToTable()
|
|
DtClasificacionGeografica = DV.ToTable()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = CType(ViewState("DTClasificacionGeografica"), DataTable)
|
|
Gv.DataSource = CType(ViewState("DTClasificacionGeografica"), DataTable)
|
|
DtClasificacionGeografica = CType(ViewState("DTClasificacionGeografica"), 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 Clasificacion Geografica")
|
|
End Sub
|
|
|
|
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs)
|
|
ImprimiReporte()
|
|
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 ImprimiReporte()
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
params.Add(New ReportParameter("pImg", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
|
|
ImprimirPDF("AC/Reportes/RepClasificacionGeografica.rdlc", DtClasificacionGeografica, params, "ReporteClasificacionGeografica")
|
|
End Sub
|
|
#End Region
|
|
End Class
|