127 lines
4.3 KiB
VB.net
127 lines
4.3 KiB
VB.net
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
Partial Class GPS_CatUMControles
|
|
Inherits ClsPaginas
|
|
|
|
|
|
#Region "Propiedades"
|
|
Public Property CveUnidadMedida As Integer
|
|
Get
|
|
Return ViewState("CveUnidadMedida").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUnidadMedida") = value
|
|
End Set
|
|
End Property
|
|
Public Property EsEditar As Integer
|
|
Get
|
|
Return ViewState("EsEditar").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("EsEditar") = 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
|
|
CveUnidadMedida = -1
|
|
EsEditar = 0
|
|
dvEstatus.Visible = False
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim GPS As New ClsGPS
|
|
If GPS.UnidadMedidaGet() Then
|
|
GvDatos.DataSource = GPS.DtResultados
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
GPS.Dispose()
|
|
GvDatos.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub imgE_Click(sender As Object, e As EventArgs)
|
|
Dim Boton = CType(sender, LinkButton)
|
|
CveUnidadMedida = Boton.CommandArgument.ToEntero
|
|
Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow)
|
|
TxtUnidadMedida.Text = GvRow.DataKey("UnidadMedida").ToString
|
|
chkEstatus.Checked = CBool(GvRow.DataKey("Estatus"))
|
|
EsEditar = 1
|
|
BtnAgregarCatalogo.Text = "Actualizar"
|
|
dvEstatus.Visible = True
|
|
UpBodyCompuesto.Update()
|
|
UpFooter.Update()
|
|
RegistraScript("$('#divAgregar').modal()")
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarCatalogo_Click(sender As Object, e As EventArgs) Handles BtnAgregarCatalogo.Click
|
|
Dim GPS As New ClsGPS
|
|
|
|
If EsEditar = 0 Then
|
|
If GPS.UnidadMedidaAdd(TxtUnidadMedida.Text) Then
|
|
Alert("La unidad de medida se agregó correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ElseIf EsEditar = 1 Then
|
|
If GPS.UnidadMedidalUpdate(TxtUnidadMedida.Text, CveUnidadMedida, chkEstatus.Checked) Then
|
|
Alert("La unidad de medida se editó correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
EsEditar = 0
|
|
dvEstatus.Visible = False
|
|
BtnAgregarCatalogo.Text = "Agregar"
|
|
End If
|
|
RegistraScript("$('#divAgregar').modal('hide')")
|
|
GPS.Dispose()
|
|
TxtUnidadMedida.Text = ""
|
|
CargaDatos()
|
|
UpDatos.Update()
|
|
UpBodyCompuesto.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim GPS As New ClsGPS
|
|
Dim CveUnidadMedida As Integer = GvDatos.Rows(e.RowIndex).DataKey("CveUnidadMedida").ToEntero
|
|
If GPS.UnidadMedidaDelete(CveUnidadMedida) Then
|
|
Alert("La unidad de medida se eliminó correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
GPS.Dispose()
|
|
CargaDatos()
|
|
UpDatos.Update()
|
|
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.VerticalAlign = VerticalAlign.Middle
|
|
e.Row.FCLinkButton("ImgE").CommandArgument = e.Row.DataKey("CveUnidadMedida").ToString
|
|
|
|
If CBool(e.Row.DBCampo("Estatus")) = True Then
|
|
e.Row.FCLabel("LblEstatus").Text = "Activo"
|
|
e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Green
|
|
|
|
Else
|
|
e.Row.FCLabel("LblEstatus").Text = "Inactivo"
|
|
e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Red
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles BtnOpenDiv.Click
|
|
EsEditar = 0
|
|
RegistraScript("$('#divAgregar').modal()")
|
|
BtnAgregarCatalogo.Text = "Agregar"
|
|
TxtUnidadMedida.Text = ""
|
|
dvEstatus.Visible = False
|
|
UpBodyCompuesto.Update()
|
|
UpFooter.Update()
|
|
End Sub
|
|
|
|
End Class
|