347 lines
14 KiB
VB.net
347 lines
14 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
Imports System
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class CatClientes
|
|
Inherits ClsPaginas
|
|
|
|
Property DTDatos As DataTable
|
|
Get
|
|
If ViewState("DTDatos") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DTDatos"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTDatos") = 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") = ""
|
|
|
|
CargaNombreClientes()
|
|
|
|
|
|
CargaSucursales()
|
|
CargaClasificaciones()
|
|
CargaVendedor()
|
|
|
|
'CargaCorporativo()
|
|
|
|
'CargaDatos()
|
|
|
|
PanelContrato.Visible = True
|
|
MPContrato.Enabled = True
|
|
|
|
|
|
Me.Form.DefaultButton = LbFiltrar.UniqueID
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaDatos(Optional Nombre As String = "-1", Optional RFC As String = "-1")
|
|
|
|
Dim ObjClientes As New ClsClientes
|
|
|
|
If ObjClientes.GetClientes(-1, Nombre, "-1", "-1", RFC, "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, PermiteCreditoFiltro:=If(ChkPermiteCredito.Checked, 1, -1)) Then
|
|
|
|
DTDatos = ObjClientes.DtResultados
|
|
ObjClientes.Dispose()
|
|
|
|
'ViewState("DTCliente") = DTDatos
|
|
If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 Then
|
|
DTDatos = DTDatos.FiltraParametros("CveCliente IN (10450, 10460, 10458)")
|
|
ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 Then
|
|
DTDatos = DTDatos.FiltraParametros("CveCliente IN (27448)")
|
|
End If
|
|
Else
|
|
Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaSucursales()
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaClasificaciones()
|
|
DdlClasificaciones.DataSource = GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa)
|
|
DdlClasificaciones.DataBind()
|
|
DdlClasificaciones.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
End Sub
|
|
Private Sub CargaNombreClientes()
|
|
DdlClienteAUnificar.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
DdlClienteAUnificar.DataBind()
|
|
|
|
DdlClienteOriginal.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
DdlClienteOriginal.DataBind()
|
|
UpBodyUnificar.Update()
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaVendedor()
|
|
DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
|
|
DdlVendedor.DataBind()
|
|
DdlVendedor.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End Sub
|
|
|
|
Protected Sub LbFiltrar_Click(sender As Object, e As EventArgs) Handles LbFiltrar.Click
|
|
|
|
Dim ObjClientes As New ClsClientes
|
|
Dim Nombre, RFC As String
|
|
Nombre = "-1"
|
|
RFC = "-1"
|
|
|
|
If TxtNombre.Text.Trim <> String.Empty Then Nombre = TxtNombre.Text.Trim
|
|
|
|
If TxtRFC.Text.Trim <> String.Empty Then RFC = TxtRFC.Text.Trim
|
|
|
|
If ObjClientes.GetClientes(-1, Nombre, "-1", "-1", RFC, "-1", "-1", DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, Estatus:=DdlEstatus.SelectedValue.ToEntero, CveClienteClasificacion:=DdlClasificaciones.SelectedValue.ToEntero, TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, PermiteCreditoFiltro:=If(ChkPermiteCredito.Checked, 1, -1)) Then
|
|
If ObjClientes.DtResultados.Rows.Count > 0 Then
|
|
DTDatos = ObjClientes.DtResultados
|
|
Else
|
|
DTDatos = Nothing
|
|
Alert("No se encontraron registros con los parametros solicitados.", Extensiones.TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
|
|
|
|
ObjClientes.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
|
|
UPDatos.Update()
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnPersonalizar_Click(sender As Object, e As System.EventArgs) Handles BtnPersonalizar.Click
|
|
|
|
GvDatos.Columns(0).Visible = ChkCodigo.Checked
|
|
GvDatos.Columns(1).Visible = ChkNombre.Checked
|
|
GvDatos.Columns(2).Visible = ChkRFC.Checked
|
|
GvDatos.Columns(3).Visible = ChkSucursal.Checked
|
|
GvDatos.Columns(4).Visible = ChkTelefono.Checked
|
|
GvDatos.Columns(5).Visible = ChkVendedor.Checked
|
|
|
|
GvDatos.Columns(6).Visible = ChkEstadoSis.Checked
|
|
GvDatos.Columns(7).Visible = ChkFechaIng.Checked
|
|
GvDatos.Columns(8).Visible = ChkUsuario.Checked
|
|
GvDatos.Columns(9).Visible = ChkNombreCorto.Checked
|
|
' GvDatos.Columns(10).Visible = ChkVendedor.Checked
|
|
GvDatos.Columns(10).Visible = ChkNoExt.Checked
|
|
GvDatos.Columns(11).Visible = ChkNoInt.Checked
|
|
GvDatos.Columns(12).Visible = ChkColonia.Checked
|
|
GvDatos.Columns(13).Visible = ChkCiudad.Checked
|
|
GvDatos.Columns(14).Visible = ChkEstado.Checked
|
|
GvDatos.Columns(15).Visible = ChkPais.Checked
|
|
GvDatos.Columns(16).Visible = ChkCP.Checked
|
|
GvDatos.Columns(17).Visible = ChkContacto.Checked
|
|
GvDatos.Columns(18).Visible = ChkMail.Checked
|
|
GvDatos.Columns(19).Visible = ChkRecepcionFacturas.Checked
|
|
GvDatos.Columns(20).Visible = ChkRetIVA.Checked
|
|
GvDatos.Columns(21).Visible = ChkRetISR.Checked
|
|
GvDatos.Columns(22).Visible = ChkPlazoCobranza.Checked
|
|
GvDatos.Columns(23).Visible = ChkLimiteCredito.Checked
|
|
GvDatos.Columns(24).Visible = ChkCIE.Checked
|
|
GvDatos.Columns(25).Visible = ChkCalle.Checked
|
|
GvDatos.Columns(26).Visible = ChkCelular.Checked
|
|
GvDatos.Columns(27).Visible = ChkCorreoCotizacion.Checked
|
|
GvDatos.Columns(28).Visible = ChkOtroTelefono.Checked
|
|
|
|
|
|
CargaDatos()
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
|
GvDatos.ExportToExcel("RepClientes_" & Now.ToShortDateString)
|
|
End Sub
|
|
|
|
#Region "P D F"
|
|
Private Sub LinkPdf_Click(sender As Object, e As EventArgs) Handles LinkPdf.Click
|
|
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
|
|
'OBTENEMOS LOS DATOS
|
|
Dim DtClientes As DataTable
|
|
'Dim ObjClientes As New ClsClientes
|
|
|
|
If DTDatos.Rows.Count > 0 Then
|
|
|
|
DtClientes = DTDatos
|
|
|
|
If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 Then
|
|
DtClientes = DTDatos.FiltraParametros("CveCliente IN (10450, 10460, 10458)")
|
|
ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 Then
|
|
DtClientes = DTDatos.FiltraParametros("CveCliente IN (27448)")
|
|
End If
|
|
Else
|
|
DtClientes = Nothing
|
|
End If
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC))
|
|
params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToString))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepClientes.rdlc", DtClientes, params, "RepClientes")
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#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(1).Width = Unit.Pixel(300)
|
|
e.Row.Cells(2).Width = Unit.Pixel(120)
|
|
e.Row.Cells(3).Width = Unit.Pixel(190)
|
|
e.Row.Cells(4).Width = Unit.Pixel(110)
|
|
e.Row.Cells(5).Width = Unit.Pixel(80)
|
|
e.Row.Cells(6).Width = Unit.Pixel(80)
|
|
e.Row.Cells(7).Width = Unit.Pixel(100)
|
|
End If
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left
|
|
|
|
'e.Row.FCLiteral("LtlNombre").Text = "<a class=""Texto"" href=""javascript:AbrirVentana('/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & "', 700, 500, 'N', 'PS')"">" & e.Row.FCLiteral("LtlNombre").Text & "</a>"
|
|
'e.Row.FCLiteral("LtlRFC").Text = "<a class=""Texto"" href=""javascript:AbrirVentana('/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & "', 700, 500, 'N', 'PS')"">" & e.Row.FCLiteral("LtlRFC").Text & "</a>"
|
|
'e.Row.FCLiteral("LtlSucursal").Text = "<a class=""Texto"" href=""javascript:AbrirVentana('/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & "', 700, 500, 'N', 'PS')"">" & e.Row.FCLiteral("LtlSucursal").Text & "</a>"
|
|
'e.Row.FCLiteral("LtlTelefono").Text = "<a class=""Texto"" href=""javascript:AbrirVentana('/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & "', 700, 500, 'N', 'PS')"">" & e.Row.FCLiteral("LtlTelefono").Text & "</a>"
|
|
|
|
e.Row.FCLiteral("LtlCodigo").Text = "<a class=""Texto"" href=""/Ventas/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & """>" & e.Row.FCLiteral("LtlCodigo").Text & "</a>"
|
|
e.Row.FCLiteral("LtlNombre").Text = "<a class=""Texto"" href=""/Ventas/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & """>" & e.Row.FCLiteral("LtlNombre").Text & "</a>"
|
|
e.Row.FCLiteral("LtlRFC").Text = "<a class=""Texto"" href=""/Ventas/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & """>" & e.Row.FCLiteral("LtlRFC").Text & "</a>"
|
|
e.Row.FCLiteral("LtlSucursal").Text = "<a class=""Texto"" href=""/Ventas/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & """>" & e.Row.FCLiteral("LtlSucursal").Text & "</a>"
|
|
e.Row.FCLiteral("LtlTelefono").Text = "<a class=""Texto"" href=""/Ventas/Clientes.aspx?CveCliente=" & e.Row.DBCampo("CveCliente") & """>" & e.Row.FCLiteral("LtlTelefono").Text & "</a>"
|
|
|
|
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(DTDatos, "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = DTDatos
|
|
End If
|
|
GvDatos.DataBind()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "UNIFICAR CLIENTE"
|
|
Private Sub BtnUnificar_Click(sender As Object, e As EventArgs) Handles BtnUnificar.Click
|
|
Dim ObjCliente As New ClsClientes()
|
|
|
|
ObjCliente.IniciaTransacSQL()
|
|
If ObjCliente.UnificarClientes(DdlClienteAUnificar.SelectedValue.ToEntero, DdlClienteOriginal.SelectedValue.ToEntero) Then
|
|
ObjCliente.Commit()
|
|
Alert("Se han unificado los clientes satisfactoriamente", TipoMensaje.MsgInformacion)
|
|
Else
|
|
ObjCliente.RollBack()
|
|
Alert("Ha ocurrido un error al unificar clientes", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjCliente.Dispose()
|
|
CargaNombreClientes()
|
|
CargaDatos()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
'Protected Sub BtnCorporativo_Click(sender As Object, e As EventArgs)
|
|
|
|
' Dim ObjClientes As New ClsClientes
|
|
|
|
' If ObjClientes.AddCorporativo(-1, Nombre, "-1", "-1", RFC, "-1", "-1", DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, Estatus:=DdlEstatus.SelectedValue.ToEntero, CveClienteClasificacion:=DdlClasificaciones.SelectedValue.ToEntero, TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero) Then
|
|
' If ObjClientes.DtResultados.Rows.Count > 0 Then
|
|
' DTDatos = ObjClientes.DtResultados
|
|
' Else
|
|
' DTDatos = Nothing
|
|
' Alert("No se encontraron registros con los parametros solicitados.", Extensiones.TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
' End If
|
|
|
|
|
|
' ObjClientes.Dispose()
|
|
|
|
' If ViewState("Orden").ToString() <> String.Empty Then
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' Else
|
|
' CargaGrid("")
|
|
' End If
|
|
|
|
' UPDatos.Update()
|
|
|
|
'End Sub
|
|
|
|
'Private Sub CargaCorporativo()
|
|
|
|
' DdlCorporativo.DataSource = GlobalDTCorporativo(UsuarioActual.CveEmpresa)
|
|
' DdlCorporativo.DataBind()
|
|
' DdlCorporativo.Items.Insert(0, New ListItem("Selecione", "-1"))
|
|
|
|
'End Sub
|
|
|
|
|
|
|
|
End Class
|
|
|