244 lines
9.5 KiB
VB.net
244 lines
9.5 KiB
VB.net
Option Strict On
|
|
Imports System.Data
|
|
Imports System.Collections.Generic
|
|
Imports System.Linq
|
|
Imports System.Web
|
|
Imports System.Web.UI.WebControls
|
|
Imports Extensiones
|
|
|
|
Partial Class CGame_CatCGameClientes
|
|
Inherits ClsPaginas
|
|
#Region "Propiedades"
|
|
Private Property RcveCliente() As Int32
|
|
Get
|
|
Return If(IsNothing(ViewState("RcveCliente")), 0, CInt(ViewState("RcveCliente")))
|
|
End Get
|
|
Set
|
|
ViewState("RcveCliente") = Value
|
|
End Set
|
|
End Property
|
|
Private Property CveCliente() As Int32
|
|
Get
|
|
Return If(IsNothing(ViewState("CcveCliente")), 0, CInt(ViewState("CcveCliente")))
|
|
End Get
|
|
Set
|
|
ViewState("CcveCliente") = Value
|
|
End Set
|
|
End Property
|
|
Private Property RcveUsuario() As Int32
|
|
Get
|
|
Return If(IsNothing(ViewState("RcveUsuario")), 0, CInt(ViewState("RcveUsuario")))
|
|
End Get
|
|
Set
|
|
ViewState("RcveUsuario") = Value
|
|
End Set
|
|
End Property
|
|
Private Property RcveEmpresa() As Int32
|
|
Get
|
|
Return If(IsNothing(ViewState("RcveEmpresa")), 0, CInt(ViewState("RcveEmpresa")))
|
|
End Get
|
|
Set
|
|
ViewState("RcveEmpresa") = Value
|
|
End Set
|
|
End Property
|
|
Private Property DtCargosFijos As DataTable
|
|
Get
|
|
DtCargosFijos = DirectCast(ViewState("DtCargosFijos"), DataTable)
|
|
End Get
|
|
|
|
Set(ByVal value As DataTable)
|
|
ViewState("DtCargosFijos") = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
RcveCliente = If(IsNothing(Request("cveCliente")), -1, Request("cveCliente").ToString().ToEntero())
|
|
RcveUsuario = If(IsNothing(Request("cveUsuario")), -1, Request("cveUsuario").ToString().ToEntero())
|
|
CargaClientes()
|
|
CargaCargosFijos()
|
|
ChkCGamestatus.Checked = True
|
|
End If
|
|
End Sub
|
|
Protected Sub CargaClientes()
|
|
Dim ObjCGam As New ClsCGame()
|
|
If ObjCGam.GetCliente(RcveCliente, RcveUsuario, UsuarioActual.CveEmpresa) Then
|
|
GVCGame_Clientes.DataSource = ObjCGam.DtResultados
|
|
End If
|
|
ObjCGam.Dispose()
|
|
GVCGame_Clientes.DataBind()
|
|
upDatosCGam.Update()
|
|
End Sub
|
|
|
|
Protected Sub CargaCargosFijos()
|
|
Dim ObjCGame As New ClsCGame()
|
|
If ObjCGame.GetCargoFijo(UsuarioActual.CveEmpresa) Then
|
|
DdlCargoFijo.DataSource = ObjCGame.DtResultados
|
|
DdlCargoFijo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
ObjCGame.Dispose()
|
|
DdlCargoFijo.DataBind()
|
|
UPModalCGam.Update()
|
|
End Sub
|
|
|
|
Protected Sub CargaCargosFijosClientes(CveCliente As Integer)
|
|
Dim ObjCGame As New ClsCGame()
|
|
If ObjCGame.GetCargoFijoCliente(CveCliente) Then
|
|
GvCargosFijos.DataSource = ObjCGame.DtResultados
|
|
DtCargosFijos = ObjCGame.DtResultados
|
|
End If
|
|
ObjCGame.Dispose()
|
|
GvCargosFijos.DataBind()
|
|
End Sub
|
|
Protected Sub LimpiaCGame_Clientes()
|
|
TxtCGamcliente.Text = ""
|
|
DdlCargoFijo.SelectedIndex = 0
|
|
TxtImporte.Text = ""
|
|
GvCargosFijos.DataSource = Nothing
|
|
GvCargosFijos.DataBind()
|
|
UPModalCGam.Update()
|
|
End Sub
|
|
Protected Sub LnkEditarCGam_Click(sender As Object, e As EventArgs)
|
|
DivEstatus.Visible = True
|
|
ltlCGamtitulo.Text = "Editar Cliente"
|
|
LimpiaCGame_Clientes()
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
CveCliente = gvRow.DataKey("CveCliente").ToEntero()
|
|
Dim cliente As String = gvRow.DataKey("Cliente")
|
|
Dim estatus As Boolean = CBool(gvRow.DataKey("Estatus").ToString())
|
|
Dim fechaIng As DateTime = gvRow.DataKey("FechaIng").ToDateTime()
|
|
Dim cveUsuario As Int32 = gvRow.DataKey("CveUsuario").ToEntero()
|
|
Dim cveEmpresa As Int32 = gvRow.DataKey("CveEmpresa").ToEntero()
|
|
|
|
TxtCGamcliente.Text = cliente.ToString()
|
|
CargaCargosFijosClientes(CveCliente)
|
|
RegistraScript("$('#DModalCGame_Clientes').modal()")
|
|
BtnCGamADD.Visible = False
|
|
BtnCGamEdit.Visible = True
|
|
UPModalCGam.Update()
|
|
End Sub
|
|
Protected Sub LnkAgregarCGam_Click(sender As Object, e As EventArgs)
|
|
DivEstatus.Visible = False
|
|
ltlCGamtitulo.Text = "Agregar Cliente"
|
|
RegistraScript("$('#DModalCGame_Clientes').modal('show')")
|
|
LimpiaCGame_Clientes()
|
|
CargaCargosFijosClientes(-1)
|
|
BtnCGamADD.Visible = True
|
|
BtnCGamEdit.Visible = False
|
|
UPModalCGam.Update()
|
|
End Sub
|
|
Protected Sub BtnCGamADD_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim cliente As String = TxtCGamcliente.Text
|
|
Dim estatus As Boolean = ChkCGamestatus.Checked
|
|
Dim fechaIng As DateTime = Now
|
|
Dim cveUsuario As Int32 = UsuarioActual.CveUsuario
|
|
Dim cveEmpresa As Int32 = UsuarioActual.CveEmpresa
|
|
Dim ObjCGam As New ClsCGame()
|
|
ObjCGam.IniciaTransacSQL()
|
|
Dim Continuar As Boolean = ObjCGam.AddCliente(cliente, True, fechaIng, cveUsuario, cveEmpresa)
|
|
For Each Dr As DataRow In DtCargosFijos.Rows
|
|
Continuar = ObjCGam.AddCargoFijoCliente(Dr("CveCargoFijo").ToString.ToEntero, ObjCGam.CveCliente, Dr("Importe").ToString.ToDouble)
|
|
Next
|
|
If (Continuar) Then
|
|
ObjCGam.Commit()
|
|
RegistraScript("$('#DModalCGame_Clientes').modal('hide')")
|
|
LimpiaCGame_Clientes()
|
|
UPModalCGam.Update()
|
|
CargaClientes()
|
|
Alert("El Cliente se ha agregado correctamente.")
|
|
Else
|
|
ObjCGam.RollBack()
|
|
End If
|
|
ObjCGam.Dispose()
|
|
End Sub
|
|
Protected Sub BtnCGamEdit_Click(sender As Object, e As EventArgs)
|
|
Dim cliente As String = TxtCGamcliente.Text
|
|
Dim estatus As Boolean = ChkCGamestatus.Checked
|
|
Dim cveUsuario As Int32 = UsuarioActual.CveUsuario
|
|
Dim ObjCGam As New ClsCGame()
|
|
ObjCGam.IniciaTransacSQL()
|
|
Dim Continuar As Boolean = ObjCGam.UpdateCliente(CveCliente, cliente, estatus, DateTime.Now, cveUsuario, UsuarioActual.CveEmpresa)
|
|
Continuar = ObjCGam.RemoveCargoFijoCliente(CveCliente)
|
|
For Each Dr As DataRow In DtCargosFijos.Rows
|
|
Continuar = ObjCGam.AddCargoFijoCliente(Dr("CveCargoFijo").ToString.ToEntero, CveCliente, Dr("Importe").ToString.ToDouble)
|
|
Next
|
|
If (Continuar) Then
|
|
ObjCGam.Commit()
|
|
RegistraScript("$('#DModalCGame_Clientes').modal('hide')")
|
|
LimpiaCGame_Clientes()
|
|
UPModalCGam.Update()
|
|
CargaClientes()
|
|
Alert("El Cliente se ha actualizado correctamente.")
|
|
Else
|
|
ObjCGam.RollBack()
|
|
End If
|
|
ObjCGam.Dispose()
|
|
End Sub
|
|
Protected Sub LnkEliminarCGam_Click(sender As Object, e As EventArgs)
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
CveCliente = gvRow.DataKey("CveCliente").ToEntero()
|
|
Dim ObjCGam As New ClsCGame()
|
|
ObjCGam.IniciaTransacSQL()
|
|
Dim Continuar As Boolean = ObjCGam.RemoveCliente(CveCliente)
|
|
Continuar = ObjCGam.RemoveCargoFijoCliente(CveCliente)
|
|
If (Continuar) Then
|
|
ObjCGam.Commit()
|
|
CargaClientes()
|
|
Alert("El Cliente se ha eliminado correctamente.")
|
|
Else
|
|
ObjCGam.RollBack()
|
|
End If
|
|
ObjCGam.Dispose()
|
|
End Sub
|
|
Protected Sub LnkEliminarCargoFijo_Click(sender As Object, e As EventArgs)
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
DtCargosFijos.Rows.RemoveAt(gvRow.RowIndex)
|
|
DtCargosFijos.AcceptChanges()
|
|
CargaGvCargosFijos()
|
|
End Sub
|
|
Protected Sub LnkAgregarCargoFijo_Click(sender As Object, e As EventArgs)
|
|
If DtCargosFijos.FiltraParametros($"CveCargoFijo = {DdlCargoFijo.SelectedValue.ToEntero}").Rows.Count > 0 Then
|
|
Alert("Ya se agrego el cargo fijo seleccionado.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Dim Dr As DataRow = Nothing
|
|
Dr = DtCargosFijos.NewRow
|
|
Dr("CveCargoFijo") = DdlCargoFijo.SelectedValue.ToEntero
|
|
Dr("Concepto") = DdlCargoFijo.SelectedItem.Text
|
|
Dr("Importe") = TxtImporte.Text.ToDouble
|
|
DtCargosFijos.Rows.InsertAt(Dr, DtCargosFijos.Rows.Count)
|
|
DtCargosFijos.AcceptChanges()
|
|
LimpiaAgregarCargoFijo()
|
|
CargaGvCargosFijos()
|
|
End Sub
|
|
|
|
Protected Sub LimpiaAgregarCargoFijo()
|
|
DdlCargoFijo.SelectedIndex = 0
|
|
TxtImporte.Text = ""
|
|
End Sub
|
|
|
|
Protected Sub CargaGvCargosFijos()
|
|
GvCargosFijos.DataSource = DtCargosFijos
|
|
GvCargosFijos.DataBind()
|
|
UPModalCGam.Update()
|
|
End Sub
|
|
Protected Sub DdlCargoFijo_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
RFVImporte.Enabled = True
|
|
TxtImporte.Enabled = True
|
|
If DdlCargoFijo.SelectedValue.ToEntero > 1 Then
|
|
Dim ObjCGame As New ClsCGame
|
|
If ObjCGame.GetCargoFijo(UsuarioActual.CveEmpresa, DdlCargoFijo.SelectedValue.ToEntero) Then
|
|
If ObjCGame.DtResultados.Rows.Count > 0 Then
|
|
If ObjCGame.DtResultados.Rows(0)("TipoCalculado").ToString.Contiene("COR", "MAQ", "FHE", "PEF", "FHN") Then
|
|
RFVImporte.Enabled = False
|
|
TxtImporte.Enabled = False
|
|
End If
|
|
End If
|
|
End If
|
|
ObjCGame.Dispose
|
|
End If
|
|
End Sub
|
|
End Class
|