Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

980
CxC/RepCxCDetalle.aspx.vb Normal file
View File

@@ -0,0 +1,980 @@

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports GemBox.Spreadsheet
Imports System.IO
Partial Class RepCxCDetalle
Inherits ClsPaginas
'pRivate ReadOnly Property ColumnasVisibles As
#Region "PROPIEDADES"
Public Property Anio() As Integer
Get
Return ViewState("Anio").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("Anio") = value
End Set
End Property
Public Property Mes() As Integer
Get
Return ViewState("Mes").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("Mes") = value
End Set
End Property
Public Property AnioMes() As String
Get
Return ViewState("AnioMes").ToString
End Get
Set(value As String)
ViewState("AnioMes") = value
End Set
End Property
Public Property Fecha() As String
Get
Return ViewState("Fecha").ToString
End Get
Set(value As String)
ViewState("Fecha") = value
End Set
End Property
Public Property FechaVI() As String
Get
Return ViewState("FechaVInicio").ToString
End Get
Set(value As String)
ViewState("FechaVInicio") = value
End Set
End Property
Public Property FechaVF() As String
Get
Return ViewState("FechaVFin").ToString
End Get
Set(value As String)
ViewState("FechaVFin") = value
End Set
End Property
Public Property FechaI() As String
Get
Return ViewState("FechaInicio").ToString
End Get
Set(value As String)
ViewState("FechaInicio") = value
End Set
End Property
Public Property FechaF() As String
Get
Return ViewState("FechaFin").ToString
End Get
Set(value As String)
ViewState("FechaFin") = value
End Set
End Property
Public Property FechaCorte() As String
Get
Return ViewState("FechaCorte").ToString
End Get
Set(value As String)
ViewState("FechaCorte") = value
End Set
End Property
Public Property Iva() As String
Get
Return ViewState("IVA").ToString
End Get
Set(value As String)
ViewState("IVA") = value
End Set
End Property
Public Property Agrupador() As Integer
Get
Return ViewState("Agrupador").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("Agrupador") = value
End Set
End Property
Public Property Opcion() As String
Get
Return ViewState("Opcion").ToString
End Get
Set(value As String)
ViewState("Opcion") = value
End Set
End Property
Public Property TipoDocto() As String
Get
Return ViewState("TipoDocto").ToString
End Get
Set(value As String)
ViewState("TipoDocto") = value
End Set
End Property
Public Property TipoCambio() As Integer
Get
Return ViewState("TipoCambio").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("TipoCambio") = value
End Set
End Property
Public Property TCEspecifico() As Double
Get
Return ViewState("TCEspecifico").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TCEspecifico") = value
End Set
End Property
Public Property SePersonalizo() As Integer
Get
Return ViewState("SePersonalizo").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("SePersonalizo") = value
End Set
End Property
Private Property CveClienteSucursal As Integer
Get
If ViewState("CveClienteSucursal") Is Nothing Then
Return -1
Else
Return DirectCast(ViewState("CveClienteSucursal"), Integer)
End If
End Get
Set(value As Integer)
ViewState("CveClienteSucursal") = value
End Set
End Property
Private Property CveCobranzaEstatus As Integer
Get
If ViewState("CveCobranzaEstatus") Is Nothing Then
Return -1
Else
Return DirectCast(ViewState("CveCobranzaEstatus"), Integer)
End If
End Get
Set(value As Integer)
ViewState("CveCobranzaEstatus") = value
End Set
End Property
Private Property LimiteCredito As Decimal
Get
If ViewState("LimiteCredito") Is Nothing Then
Return -1
Else
Return DirectCast(ViewState("LimiteCredito"), Decimal)
End If
End Get
Set(value As Decimal)
ViewState("LimiteCredito") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
ViewState("Opcion") = IfNull(Request("Op"), "-1")
CargaCombos()
If Request("Op") IsNot Nothing Then
CargaDatos()
End If
If UsuarioActual.CveEmpresa = 7 Then
ChkCuentaContableReferencia.Visible = True
End If
CargaAsignarCobranza()
TxtFechaCobranza.Text = Now.ToShortDateString
End If
End Sub
#Region "CARGAS"
Private Sub CargaCombos()
Dim CveCliente, CveVendedor, CveUsuario, CveSubProyecto,
CveEstatus, CveResponsable, CveAgrupador, CveClienteClasificacion As Integer
'CargaClientes
'CargaClientes
If UsuarioActual.CveEmpresa = 119 Then
DdlClientesWS.setEsWebService(True)
Else
DdlClientesWS.setEsWebService(False)
DdlClientesWS.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1)
DdlClientesWS.DataBind()
DdlClientesWS.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
End If
'DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1)
'DdlClientes.DataBind()
'CargaSubProyectos
DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
DdlSubProyecto.DataBind()
'CargaUsuarios
DdlUsuario.DataSource = GlobalDTUsuarios.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlUsuario.DataBind()
'CargaResponsable
DdlResponsable.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
DdlResponsable.DataBind()
'Tipo Docto
DdlTipoDocto.Items.Add(New ListItem("Ing X Comp", "IxC"))
'Carga Cobranza Estatus
DdlCobranzaEstatusFiltro.DataSource = GlobalDTCobranzaEstatus(UsuarioActual.CveEmpresa)
DdlCobranzaEstatusFiltro.DataBind()
DdlCobranzaEstatusFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
'Carga Clasificacion Cliente
DdlClienteClasificacion.DataSource = GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa)
DdlClienteClasificacion.DataBind()
DdlClienteClasificacion.Items.Insert(0, New ListItem("Todos", "-1"))
'Cargamos las fechas
Anio = If(Request("Anio") IsNot Nothing, Request("Anio").ToString, "-1").ToString.ToEntero
Mes = If(Request("Mes") IsNot Nothing, Request("Mes").ToString, "-1").ToString.ToEntero
AnioMes = If(Request("AnioMes") IsNot Nothing, Request("AnioMes").ToString, "-1").ToString
Fecha = If(Request("Fecha") IsNot Nothing, Request("Fecha").ToString, "-1").ToString
FechaI = If(Request("FechaI") IsNot Nothing, Request("FechaI").ToString, "-1").ToString
FechaF = If(Request("FechaF") IsNot Nothing, Request("FechaF").ToString, "-1").ToString
FechaVI = If(Request("FechaVI") IsNot Nothing, Request("FechaVI").ToString, "-1").ToString
FechaVF = If(Request("FechaVF") IsNot Nothing, Request("FechaVF").ToString, "-1").ToString
FechaCorte = IfNull(Request("FechaCorte"), Now.ToDate.ToString).ToString
CveCobranzaEstatus = If(Request("CveCobranzaEstatus") IsNot Nothing, Request("CveCobranzaEstatus").ToString, "-1").ToString.ToEntero
CveClienteClasificacion = If(Request("CveClienteClasificacion") IsNot Nothing, Request("CveClienteClasificacion").ToString, "-1").ToString.ToEntero
LimiteCredito = If(Request("LimiteCredito") IsNot Nothing, Request("LimiteCredito").ToString, "-1").ToString.ToDecimal
If FechaF <> "-1" Then
txtFechaF.Text = FechaF
End If
If FechaI <> "-1" Then
txtFechaI.Text = FechaI
End If
If FechaVF <> "-1" Then
txtFechaVF.Text = FechaVF
End If
If FechaVI <> "-1" Then
txtFechaVI.Text = FechaVI
End If
If Fecha <> "-1" Then
txtFechaI.Text = Fecha
txtFechaF.Text = Fecha
End If
txtCorteA.Text = $"31/12/{Now.Year}"
txtFechaI.Text = If(Anio <> -1, String.Format("01/01/{0}", Anio), txtFechaI.Text)
txtFechaI.Text = If(Mes <> -1, txtFechaI.Text, txtFechaI.Text)
txtFechaI.Text = If(AnioMes <> "-1", String.Format("01/{0}/{1}", AnioMes.Substring(5, 2).PadLeft(2, "0"c), AnioMes.Substring(0, 4)), txtFechaI.Text)
If Request("FechaCorte") <> "-1" AndAlso IsDate(Request("FechaCorte")) Then txtCorteA.Text = Request("FechaCorte")
If Anio <> -1 Then
txtFechaF.Text = String.Format("31/12/{0}", Anio)
ElseIf Mes <> -1 Then
'txtFechaF.Text = txtFechaI.Text.ToDate.LastDayOfMonth.ToShortDateString
ElseIf AnioMes <> "-1" Then
txtFechaF.Text = txtFechaI.Text.ToDate.LastDayOfMonth.ToShortDateString
End If
TipoCambio = IfNull(Request("TipoCambio"), -1).ToString.ToEntero
TCEspecifico = IfNull(Request("TCEspecifico"), -1).ToString.ToDouble
TipoDocto = IfNull(Request("TipoDocto"), "-1").ToString
CveClienteSucursal = IfNull(Request("CveClienteSucursal"), "-1").ToString.ToEntero
CveSubProyecto = IfNull(Request("CveSubProyecto"), "-1").ToString.ToEntero
CveVendedor = IfNull(Request("Vendedor"), "-1").ToString.ToEntero
CveCliente = IfNull(Request("CveCliente"), "-1").ToString.ToEntero
CveUsuario = IfNull(Request("CveUsuario"), "-1").ToString.ToEntero
CveEstatus = IfNull(Request("CveEstatusFactura"), "-1").ToString.ToEntero
CveResponsable = IfNull(Request("CveUsuarioResponsable"), "-1").ToString.ToEntero
CveAgrupador = IfNull(Request("GPO"), "-1").ToString.ToEntero
Iva = IfNull(Request("IVA"), "-1").ToString
DdlSubProyecto.SelectedValueExist(CveSubProyecto)
DdlClienteClasificacion.SelectedValueExist(CveClienteClasificacion)
CargaClientes()
If CveCliente > 0 Then
DdlClientesWS.SelectedValue = CveCliente.ToString
DdlClientesWS.SelectedText = GlobalDTCliente(UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("NombreComercial", $"CveCliente = {CveCliente}")
End If
'DdlClientes.SelectedValueExist(CveCliente)
DdlUsuario.SelectedValueExist(CveUsuario)
DdlResponsable.SelectedValueExist(CveResponsable)
DdlGrupo.SelectedValueExist(CveAgrupador)
'Carga Vendedor
DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
DdlVendedor.DataBind()
If UsuarioActual.CveVendedor > 0 AndAlso Not UsuarioActual.TienePermisoProceso(263) Then
DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor.ToString())
DdlVendedor.Attributes.Add("disabled", "disabled")
DdlVendedor.Enabled = False
End If
'Nuevos
DdlTipoDocto.SelectedValuesIfExistM(TipoDocto)
RblTipoCambio.SelectedValue = CType(TipoCambio, String)
'13/04/2018 - Carga filtro estatus cobranza
DdlCobranzaEstatusFiltro.SelectedValueExist(CveCobranzaEstatus.ToString)
If RblTipoCambio.SelectedValue.ToEntero = 3 Then
If TCEspecifico <> -1 Then
LiEspecifico.Visible = True
TxtEspecifico.Text = TCEspecifico.ToString
Else
Dim TipoCambio As Double
LiEspecifico.Visible = True
TipoCambio = GlobalTipoCambio(Now)
TxtEspecifico.Text = TipoCambio.ToString
End If
End If
If CveClienteSucursal > 0 Then
DdlClientesWS.Attributes.Add("style", "!important width: 60%;")
DdlClienteSucursal.Visible = True
DivClientes.Attributes.Remove("class")
DivClientes.Attributes.Add("class", "col-md-4")
Dim ObjCliente As New ClsClientes
If ObjCliente.GetSucursales(CveCliente) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
DdlClienteSucursal.DataSource = ObjCliente.DtResultados
End If
End If
ObjCliente.Dispose()
DdlClienteSucursal.DataBind()
DdlClienteSucursal.Items.Insert(0, New ListItem("Todas", "-1"))
DdlClienteSucursal.SelectedValueExist(CveClienteSucursal)
Else
DdlClientesWS.Attributes.Add("style", "!important width: 100%;")
End If
End Sub
Private Function CargaDatos() As DataTable
Dim dt As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos()
Dim FechaI, FechaF, FechaVI, FechaVF As String
If RblTipoCambio.SelectedValue.ToEntero = 3 And TxtEspecifico.Text <> "" Then
TCEspecifico = TxtEspecifico.Text.ToDouble
Else
TCEspecifico = -1
End If
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
FechaVI = If(IsDate(txtFechaVI.Text.Trim()), txtFechaVI.Text.Trim(), "-1")
FechaVF = If(IsDate(txtFechaVF.Text.Trim()), txtFechaVF.Text.Trim(), "-1")
'FechaI, FechaF, -1, UsuarioActual.CveEmpresa, DdlGrupo.SelectedValue.ToEntero
Dim CveCliente = If(DdlClientesWS.SelectedValue.ToEntero > 0, DdlClientesWS.SelectedValue.ToEntero, -1)
If ObjMovtos.GetCxCDetalle(FechaI, FechaF, CveCliente, DdlSubProyecto.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero,
Anio, Mes, AnioMes, Fecha, CveClienteSucursal, Opcion, -1,
Iva.ToString, DdlGrupo.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlResponsable.SelectedValue.ToEntero,
RblTipoCambio.SelectedValue.ToEntero, TCEspecifico, If(DdlTipoDocto.GetSelectedValuesM = "", "-1", DdlTipoDocto.GetSelectedValuesM), FechaVI, FechaVF,
FechaCorte:=txtCorteA.Text.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveCobranzaEstatus:=DdlCobranzaEstatusFiltro.SelectedValue.ToEntero,
CveClienteClasificacion:=DdlClienteClasificacion.SelectedValue.ToEntero, LimiteCredito:=LimiteCredito) Then
GvDatos.DataSource = ObjMovtos.DtResultados
dt = ObjMovtos.DtResultados
Else
GvDatos.DataSource = Nothing
End If
ObjMovtos.Dispose()
GvDatos.DataBind()
UPDatos.Update()
Return dt
End Function
Private Sub ConfiguraEmpresa()
'Dim ObjEmpresa As New ClsEmpresas()
'If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then
If Not UsuarioActual.Empresa.MostrarRetIVA Then GvDatos.Columns(7).Visible = False
If Not UsuarioActual.Empresa.MostrarRetISR Then GvDatos.Columns(8).Visible = False
'End If
'ObjEmpresa.Dispose()
End Sub
#End Region
#Region "CONSULTAR"
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
CargaDatos()
ConfiguraEmpresa()
UPDatos.Update()
End Sub
#End Region
#Region "GRIDVIEW"
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(70)
e.Row.Cells(2).Width = Unit.Pixel(75)
End If
If e.Row.DBCampo("SubProyecto") = "" And e.Row.DBCampo("CveMoneda") = "1" Then
e.Row.Cells(11).Text = "Total Pesos"
e.Row.CssClass = "Totales"
e.Row.FCCheckBox("ChkCobranza").Visible = False
e.Row.Cells(39).Text = ""
e.Row.Cells(21).Text = ""
e.Row.Cells(28).Text = ""
ElseIf e.Row.DBCampo("SubProyecto") = "" And e.Row.DBCampo("CveMoneda") = "2" Then
e.Row.Cells(12).Text = "Total Dólares"
e.Row.CssClass = "Totales"
e.Row.FCCheckBox("ChkCobranza").Visible = False
e.Row.Cells(39).Text = ""
e.Row.Cells(21).Text = ""
e.Row.Cells(28).Text = ""
ElseIf e.Row.DBCampo("CveVenta") = "" Then
e.Row.CssClass = "SubTotales"
e.Row.FCCheckBox("ChkCobranza").Visible = False
e.Row.Cells(39).Text = ""
e.Row.Cells(21).Text = ""
e.Row.Cells(28).Text = ""
End If
End If
End Sub
#End Region
#Region "PERSONALIZAR COLUMNAS"
Protected Sub BtnPersonalizar_Click(sender As Object, e As EventArgs) Handles BtnPersonalizar.Click
If ChkFecha.Checked Then
GvDatos.Columns(1).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(1).Visible = False
End If
If ChkFolio.Checked Then
GvDatos.Columns(2).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(2).Visible = False
End If
If ChkTotal.Checked Then
GvDatos.Columns(3).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(3).Visible = False
End If
If ChkSubTotal.Checked Then
GvDatos.Columns(4).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(4).Visible = False
End If
If ChkIVA.Checked Then
GvDatos.Columns(5).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(5).Visible = False
End If
If ChkDescuento.Checked Then
GvDatos.Columns(6).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(6).Visible = False
End If
If ChkAmortizacion.Checked Then
GvDatos.Columns(7).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(7).Visible = False
End If
If ChkRetIVA.Checked Then
GvDatos.Columns(8).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(8).Visible = False
End If
If ChkRetISR.Checked Then
GvDatos.Columns(9).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(9).Visible = False
End If
If ChkMoneda.Checked Then
GvDatos.Columns(10).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(10).Visible = False
End If
If ChkSucursal.Checked Then
GvDatos.Columns(11).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(11).Visible = False
End If
If ChkCodigo.Checked Then
GvDatos.Columns(15).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(15).Visible = False
End If
If ChkCliente.Checked Then
GvDatos.Columns(16).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(16).Visible = False
End If
If ChkSucursalCliente.Checked Then
GvDatos.Columns(17).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(17).Visible = False
End If
If ChkVendedor.Checked Then
GvDatos.Columns(18).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(18).Visible = False
End If
If ChlMotivoDescuento.Checked Then
GvDatos.Columns(19).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(19).Visible = False
End If
If ChkEstatusFactura.Checked Then
GvDatos.Columns(20).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(20).Visible = False
End If
If ChkSeTimbro.Checked Then
GvDatos.Columns(21).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(21).Visible = False
End If
If ChkCuentaContableReferencia.Checked Then
GvDatos.Columns(22).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(22).Visible = False
End If
If ChkCuentaContable.Checked Then
GvDatos.Columns(23).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(23).Visible = False
End If
If ChkUsuario.Checked Then
GvDatos.Columns(24).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(24).Visible = False
End If
If ChkMotivoCancelacion.Checked Then
GvDatos.Columns(25).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(25).Visible = False
End If
If ChkObservaciones.Checked Then
GvDatos.Columns(26).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(26).Visible = False
End If
If ChkSucursalEjecucion.Checked Then
GvDatos.Columns(27).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(27).Visible = False
End If
If ChkTelefono.Checked Then
GvDatos.Columns(28).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(28).Visible = False
End If
If ChkMail.Checked Then
GvDatos.Columns(29).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(29).Visible = False
End If
If ChkLimiteCredito.Checked Then
GvDatos.Columns(30).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(30).Visible = False
End If
If ChkSucursalCobranza.Checked Then
GvDatos.Columns(31).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(31).Visible = False
End If
If ChkEstatusCobranza.Checked Then
GvDatos.Columns(33).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(33).Visible = False
End If
If ChkTurnoCobranza.Checked Then
GvDatos.Columns(34).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(34).Visible = False
End If
If ChkObsCobranza.Checked Then
GvDatos.Columns(35).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(35).Visible = False
End If
If ChkFechaCobranza.Checked Then
GvDatos.Columns(36).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(36).Visible = False
End If
If ChkHorario.Checked Then
GvDatos.Columns(37).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(37).Visible = False
End If
If ChkDiasPago.Checked Then
GvDatos.Columns(38).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(38).Visible = False
End If
If ChkSeEnvioMail.Checked Then
GvDatos.Columns(39).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(39).Visible = False
End If
If ChkEstatusCliente.Checked Then
GvDatos.Columns(40).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(40).Visible = False
End If
If ChkIEPS.Checked Then
GvDatos.Columns(41).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(41).Visible = False
End If
If ChkDiasTranscurridos.Checked Then
GvDatos.Columns(42).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(42).Visible = False
End If
If ChkTC.Checked Then
GvDatos.Columns(43).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(43).Visible = False
End If
If ChkFechaEjecucion.Checked Then
GvDatos.Columns(44).Visible = True
SePersonalizo = 1
Else
GvDatos.Columns(44).Visible = False
End If
If SePersonalizo = 1 Then
ImgExcelPersonalizado.Visible = True
Else
ImgExcelPersonalizado.Visible = False
End If
CargaDatos()
RegistraScript("$('#DivPersonalizar').modal('hide');")
End Sub
#End Region
#Region "IMPRESIONES"
Protected Sub ImgExcel_Click(sender As Object, e As System.EventArgs) Handles ImgExcel.Click
GenerarImpresion("EXCEL")
End Sub
Private Sub ImgExcelPersonalizado_Click(sender As Object, e As EventArgs) Handles ImgExcelPersonalizado.Click
SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet())
Dim ef As ExcelFile = New ExcelFile
Dim ws As ExcelWorksheet = ef.Worksheets.Add("DataTable to Sheet")
Dim dt As DataTable = New DataTable
Dim response As HttpResponse = Me.Response
'Recorrer columnas
For index = 0 To GvDatos.Columns.Count - 1
If GvDatos.Columns(index).Visible Then
dt.Columns.Add(GvDatos.Columns(index).HeaderText)
End If
Next
'Recorrer filas
For Each fila As GridViewRow In GvDatos.Rows
Dim dr As DataRow = dt.NewRow()
For index = 0 To GvDatos.Columns.Count - 1
If GvDatos.Columns(index).Visible Then
If TypeOf GvDatos.Columns(index) Is HyperLinkField Then
dr(GvDatos.Columns(index).HeaderText) = DirectCast(fila.Cells(index).Controls(0), HyperLink).Text.Replace("&nbsp;", "")
Else
dr(GvDatos.Columns(index).HeaderText) = fila.Cells(index).Text.Replace("&nbsp;", "")
End If
End If
Next
dt.Rows.Add(dr)
Next
' Insert DataTable into an Excel worksheet.
ws.InsertDataTable(dt,
New InsertDataTableOptions() With
{
.ColumnHeaders = True,
.StartRow = 1
})
ef.Save(response, "RepCxC.xlsx")
End Sub
Private Sub GenerarImpresion(Optional TipoImpresion As String = "PDF")
'Dim ObjMovtos As New ClsMovimientos()
Dim FechaI As String = txtFechaI.Text
Dim FechaF As String = txtFechaF.Text
If txtFechaI.Text = "" Then FechaI = "-1"
If txtFechaF.Text = "" Then FechaF = "-1"
If RblTipoCambio.SelectedValue.ToEntero = 3 And TxtEspecifico.Text <> "" Then
TCEspecifico = TxtEspecifico.Text.ToDouble
Else
TCEspecifico = -1
End If
Dim Cliente = If(DdlClientesWS.SelectedValue = "-1", "", $"&emsp;<b>Cliente:</b>&nbsp;{DdlClientesWS.SelectedText}")
Dim Sucursal = If(DdlSubProyecto.SelectedValue = "-1", "", $"&emsp;<b>Sucursal:</b>&nbsp;{DdlSubProyecto.SelectedItem.Text}")
Dim Grupo = $"&emsp;<b>Agrupado Por:</b>&nbsp;{DdlGrupo.SelectedItem.Text}" 'If(DdlGrupo.SelectedValue = "3", "", $"&emsp;<b>Agrupado Por:</b>&nbsp;{DdlGrupo.SelectedItem.Text}")
Dim TipoDocto = If(DdlTipoDocto.GetSelectedText = "", "", $"&emsp;<b>Documentos:</b>&nbsp;{DdlTipoDocto.GetSelectedText}")
Dim Vendedor = If(DdlVendedor.SelectedValue = "-1", "", $"&emsp;<b>Vendedor:</b>&nbsp;{DdlVendedor.SelectedItem.Text}")
Dim FechaIn As String = If(txtFechaI.Text = "", "", $"&emsp;<b>Fecha Inicio Docto:</b>&nbsp;{txtFechaI.Text}")
Dim FechaFn As String = If(txtFechaF.Text = "", "", $"&emsp;<b>Fecha Fin Docto:</b>&nbsp;{txtFechaF.Text}")
Dim FVI As String = If(txtFechaVI.Text = "", "", $"&emsp;<b>Fecha Venc. Inic.:</b>&nbsp;{txtFechaVI.Text}")
Dim FVF As String = If(txtFechaVF.Text = "", "", $"&emsp;<b>Fecha Venc. Final:</b>&nbsp;{txtFechaVF.Text}")
Dim Registro = If(DdlUsuario.SelectedValue = "-1", "", $"&emsp;<b>Registró:</b>&nbsp;{DdlUsuario.SelectedItem.Text}")
Dim Responsable = If(DdlResponsable.SelectedValue = "-1", "", $"&emsp;<b>Responsable:</b>&nbsp;{DdlResponsable.SelectedItem.Text}")
Dim EstatusCob = If(DdlCobranzaEstatusFiltro.SelectedValue = "-1", "", $"&emsp;<b>Estatus Cobranza:</b>&nbsp;{DdlCobranzaEstatusFiltro.SelectedItem.Text}")
'Dim CorteA As String = If(txtCorteA.Text = "31/12/2018", "", $"&emsp;<b>Corte A:</b>&nbsp;{txtCorteA.Text}")
Dim ClasificacionCli = If(DdlClienteClasificacion.SelectedValue = "-1", "", $"&emsp;<b>Clasificación Cliente:</b>&nbsp;{DdlClienteClasificacion.SelectedItem.Text}")
Dim TituloReporte As String = "REPORTE DE CUENTAS POR COBRAR DEL CLIENTE CON DETALLE"
'If UsuarioActual.CveEmpresa = 72 Then
' TituloReporte = "Antigüedad de Saldos de Clientes"
'End If
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)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("FechaInicio", FechaI))
params.Add(New ReportParameter("FechaFin", FechaF))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
params.Add(New ReportParameter("AgrupadoPor", $"{Cliente}{Sucursal}{Grupo}{Vendedor}{FechaIn}{FechaFn}{Registro}{Responsable}{TipoDocto}{EstatusCob}{FVI}{FVF}{ClasificacionCli}"))
params.Add(New ReportParameter("TituloReporte", TituloReporte))
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", logouri))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepCxCDetalle.rdlc", UsuarioActual.Empresa.Ruta))
If Archivo.Exists Then
ImprimirPDF(String.Format("{0}Formatos/RepCxCDetalle.rdlc", UsuarioActual.Empresa.Ruta), CargaDatos, params, "ReporteCxCDetalle", TipoImpresion)
Else
ImprimirPDF("Empresas/Grales/Formatos/RepCxCDetalle.rdlc", CargaDatos, params, "ReporteCxCDetalle", TipoImpresion)
End If
End Sub
Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click
GenerarImpresion("PDF")
End Sub
#End Region
#Region "TIPO DE CAMBIO"
Private Sub RblTipoCambio_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipoCambio.SelectedIndexChanged
If RblTipoCambio.SelectedValue.ToEntero = 3 Then
Dim TipoCambio As Double
LiEspecifico.Visible = True
TipoCambio = GlobalTipoCambio(Now)
TxtEspecifico.Text = TipoCambio.ToString
Else
LiEspecifico.Visible = False
End If
UpBodyTipoCambio.Update()
End Sub
Private Sub BtnTipoCambio_Click(sender As Object, e As EventArgs) Handles BtnTipoCambio.Click
CargaDatos()
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivTipoCambio"))
End Sub
#End Region
#Region "C O B R A N Z A "
Private Sub CargaAsignarCobranza()
Dim ObjVentas As New ClsVentas
DdlUsuarioCobranza.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
DdlUsuarioCobranza.DataBind()
DdlUsuarioCobranza.Items.Insert(0, New ListItem("Sin Cobrador", "-1"))
DdlCobranzaEstatus.DataSource = GlobalDTCobranzaEstatus(UsuarioActual.CveEmpresa)
DdlCobranzaEstatus.DataBind()
DdlCobranzaEstatus.Items.Insert(0, New ListItem("Sin Estatus", "-1"))
If ObjVentas.GetCobranzaTurnoEstatus(-1, UsuarioActual.CveEmpresa) Then
DdlTurnoCobranza.DataSource = ObjVentas.DtResultados
DdlTurnoCobranza.DataBind()
DdlTurnoCobranza.Items.Insert(0, New ListItem("Sin Turno", "-1"))
End If
ObjVentas.Dispose()
End Sub
Private Sub LkbHabilitarCobranza_Click(sender As Object, e As EventArgs) Handles LkbHabilitarCobranza.Click
GvDatos.Columns(32).Visible = True ' chk aplica
GvDatos.Columns(33).Visible = True : ChkEstatusCobranza.Checked = True
GvDatos.Columns(35).Visible = True : ChkObsCobranza.Checked = True
GvDatos.Columns(36).Visible = True : ChkFechaCobranza.Checked = True
GvDatos.Columns(37).Visible = True : ChkHorario.Checked = True
DivCobranza.Visible = True
CargaDatos()
UPPersonalizar.Update()
UpCobranza.Update()
End Sub
Private Sub BtnAsignaCobranza_Click(sender As Object, e As EventArgs) Handles BtnAsignaCobranza.Click
Dim ObjVentas As New ClsVentas
Dim time As DateTime
Dim TieneError = False
ObjVentas.IniciaTransacSQL()
For Each row As GridViewRow In GvDatos.Rows
If row.FCCheckBox("ChkCobranza").Checked Then
time = DateTime.Parse(String.Format("{0} {1}:{2} {3}", TxtFechaCobranza.Text, TimeSelector.Hour, TimeSelector.Minute, TimeSelector.AmPm))
If Not ObjVentas.UpdateAsignaVentaCobranza(row.DataKey("CveVenta").ToEntero, DdlCobranzaEstatus.SelectedValue.ToEntero, DdlUsuarioCobranza.SelectedValue.ToEntero, DdlTurnoCobranza.SelectedValue.ToEntero, TxtObservacionCobranza.Text.Trim, time) Then
TieneError = True
End If
End If
Next
If Not TieneError Then
ObjVentas.Commit()
Alert("Se asigno exitosamente datos de cobranza a la venta", TipoMensaje.MsgInformacion)
Else
ObjVentas.RollBack()
Alert("Hubo un error al asignar datos de cobranza", TipoMensaje.MsgInformacion)
End If
ObjVentas.Dispose()
CargaDatos()
End Sub
#End Region
#Region "SELECTED INDEX CHANGE"
Protected Sub DdlClienteClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaClientes()
End Sub
Private Sub CargaClientes()
If UsuarioActual.CveEmpresa <> 119 Then
DdlClientesWS.ddl.Items.Clear()
DdlClientesWS.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveClienteClasificacion = {DdlClienteClasificacion.SelectedValue.ToEntero} OR {DdlClienteClasificacion.SelectedValue.ToEntero} = -1")
DdlClientesWS.DataBind()
DdlClientesWS.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
End If
End Sub
#End Region
End Class