Files
SIG/OS/CatTipoCuentasEquipos.aspx.vb
JORGE LUIS CAUDILLO ESPARZA c35cf91883 Commit inicial Ventas Productivo
2019-08-14 16:40:54 -07:00

100 lines
3.6 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports System.Linq
Imports Extensiones
Partial Class OS_CatTipoCuentasEquipos
Inherits ClsPaginas
#Region "PROPIEDADES"
Private Property CveTipoCuentaEquipo As Integer
Get
Return ViewState("CveTipoCuentaEquipo").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveTipoCuentaEquipo") = 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
CargaTipoCuentas()
End If
End Sub
Private Sub CargaTipoCuentas()
Dim ObjGenerales As New ClsGenerales
If ObjGenerales.GetTipoCuentasEquipos() Then
GvDatos.DataSource = ObjGenerales.DtResultados.FiltraParametros(String.Format("CveEmpresa = {0}", UsuarioActual.CveEmpresa))
End If
GvDatos.DataBind()
ObjGenerales.Dispose()
UpDatos.Update()
End Sub
Private Sub BtnAgregarTipoCuenta_Click(sender As Object, e As EventArgs) Handles BtnAgregarTipoCuenta.Click
BtnGuardarCuenta.Text = "Agregar"
HdnModalidad.Value = "I"
UpFooterCuenta.Update()
RegistraScript("$('#DivAgregarTipoCuenta').modal();LimpiaModal()")
End Sub
Private Sub BtnGuardarCuenta_Click(sender As Object, e As EventArgs) Handles BtnGuardarCuenta.Click
Dim ObjGenerales As New ClsGenerales
Dim TieneError = False
If HdnModalidad.Value = "I" Then
If Not ObjGenerales.AddTipoCuentaEquipo(TxtTipoCuentaEquipo.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
TieneError = True
End If
ElseIf HdnModalidad.Value = "U" Then
If CveTipoCuentaEquipo <> -1 Then
If Not ObjGenerales.UpdateTipoCuentaEquipo(TxtTipoCuentaEquipo.Text.Trim, If(ChkEstatus.Checked, True, False), CveTipoCuentaEquipo) Then
TieneError = True
End If
End If
End If
If Not TieneError Then
GvDatos.EditIndex = -1
CargaTipoCuentas()
Else
Alert("Ocurrio un error al actualizar los datos", TipoMensaje.MsgAdvertencia)
End If
ObjGenerales.Dispose()
UpDatos.Update()
RegistraScript("$('#DivAgregarTipoCuenta').modal('hide');")
End Sub
#Region "GV DATOS"
Public Sub Edit_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
HdnModalidad.Value = "U"
TxtTipoCuentaEquipo.Text = GvRow.DataKey("TipoCuentaEquipo")
ChkEstatus.Checked = If(GvRow.DataKey("Estatus").ToString = "Activo", True, False)
DivEstatus.Visible = True
CveTipoCuentaEquipo = GvRow.DataKey("CveTipoCuentaEquipo").ToEntero
BtnGuardarCuenta.Text = "Actualizar"
UpAgregarCuenta.Update()
UpDatos.Update()
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTipoCuenta"))
End Sub
Private Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
Dim ObjGenerales As New ClsGenerales
Dim CveTipoCuentaEquipo As Integer = GvDatos.Rows(e.RowIndex).DataKey("CveTipoCuentaEquipo").ToEntero
If ObjGenerales.RemoveTipoCuentaEquipo(CveTipoCuentaEquipo) Then
GvDatos.EditIndex = -1
Alert("El Tipo cuenta equipo eliminó correctamente.", TipoMensaje.MsgInformacion)
End If
CargaTipoCuentas()
ObjGenerales.Dispose()
End Sub
#End Region
End Class