3469 lines
155 KiB
VB.net
3469 lines
155 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
'Imports DocumentFormat.OpenXml.Wordprocessing
|
|
|
|
Partial Class Inventarios_RecepcionUsados
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
|
|
Private _dtDatos As DataTable
|
|
|
|
Public Property DtMovimientos() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientos") = value
|
|
End Set
|
|
End Property
|
|
Private Property ConsecutivoVenta As Integer
|
|
Get
|
|
Return ViewState("ConsecutivoVenta").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("ConsecutivoVenta") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtTamaños() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtTamaños"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtTamaños") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DtMovimientosEntradaInvFisico() As DataTable
|
|
|
|
Get
|
|
Return CType(ViewState("DtMovimientosEntradaInvFisico"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientosEntradaInvFisico") = value
|
|
End Set
|
|
|
|
End Property
|
|
|
|
Public Property DtMovimientosSalidaInvFisico() As DataTable
|
|
|
|
Get
|
|
Return CType(ViewState("DtMovimientosSalidaInvFisico"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientosSalidaInvFisico") = value
|
|
End Set
|
|
|
|
End Property
|
|
|
|
Public Property CveMovimiento() As Integer
|
|
Get
|
|
Return ViewState("CveMovimiento").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMovimiento") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtMov As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMov"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMov") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveCompra() As Integer
|
|
Get
|
|
Return ViewState("CveCompra").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCompra") = value
|
|
End Set
|
|
End Property
|
|
'Public Property CveConcepto() As Integer
|
|
' Get
|
|
' Return ViewState("CveConcepto").ToString.ToEntero
|
|
' End Get
|
|
' Set(value As Integer)
|
|
' ViewState("CveConcepto") = value
|
|
' End Set
|
|
'End Property
|
|
Public Property Folio() As Integer
|
|
Get
|
|
Return ViewState("Folio").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("Folio") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveMovimientoRelacionado As Integer
|
|
Get
|
|
Return ViewState("CveMovimientoRelacionado").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMovimientoRelacionado") = value
|
|
End Set
|
|
End Property
|
|
Public Property ConceptoRelacionado As String
|
|
Get
|
|
Return ViewState("ConceptoRelacionado").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ConceptoRelacionado") = value
|
|
End Set
|
|
End Property
|
|
Public Property FolioRelacionado As Integer
|
|
Get
|
|
Return ViewState("FolioRelacionado").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("FolioRelacionado") = value
|
|
End Set
|
|
End Property
|
|
Public Property TieneRelacionado As Integer
|
|
Get
|
|
Return ViewState("TieneRelacionado").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TieneRelacionado") = value
|
|
End Set
|
|
End Property
|
|
Public Property EstatusAlmacenCompra As Integer
|
|
Get
|
|
Return ViewState("EstatusAlmacenCompra").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("EstatusAlmacenCompra") = value
|
|
End Set
|
|
End Property
|
|
Public Property TieneSalida As Boolean
|
|
Get
|
|
Return CBool(ViewState("TieneSalida").ToString)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("TieneSalida") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtBitacora As DataTable
|
|
Get
|
|
Return CType(ViewState("DtBitacora"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtBitacora") = value
|
|
End Set
|
|
End Property
|
|
Private Property CvePSSerieLote As Integer
|
|
Get
|
|
Return CType(ViewState("CvePSSerieLote"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePSSerieLote") = value
|
|
End Set
|
|
End Property
|
|
Private Property PSSerieLote As String
|
|
Get
|
|
Return CType(ViewState("PSSerieLote"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("PSSerieLote") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveUMSerieLote As Integer
|
|
Get
|
|
Return CType(ViewState("CveUMSerieLote"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUMSerieLote") = value
|
|
End Set
|
|
End Property
|
|
Private Property UMSerieLote As String
|
|
Get
|
|
Return CType(ViewState("UMSerieLote"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("UMSerieLote") = value
|
|
End Set
|
|
End Property
|
|
Private Property CostoPromedioSerieLote As Decimal
|
|
Get
|
|
Return CType(ViewState("CostoPromedioSerieLote"), Decimal)
|
|
End Get
|
|
Set(value As Decimal)
|
|
ViewState("CostoPromedioSerieLote") = value
|
|
End Set
|
|
End Property
|
|
Public Property EsConsumoInterno As Boolean
|
|
Get
|
|
Return CBool(ViewState("EsConsumoInterno").ToString)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsConsumoInterno") = value
|
|
End Set
|
|
End Property
|
|
Private Property FolioAsignado As Integer
|
|
Get
|
|
Return CType(ViewState("FolioAsignado"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("FolioAsignado") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveRemisionRecibida As Integer
|
|
Get
|
|
Return IfNull(ViewState("CveRemisionRecibida"), -1, CType(ViewState("CveRemisionRecibida"), Integer)).ToString().ToEntero()
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveRemisionRecibida") = value
|
|
End Set
|
|
End Property
|
|
Private Property EsDistribuidor As Boolean
|
|
Get
|
|
Return CBool(IfNull(ViewState("EsDistribuidor"), False, CBool(ViewState("EsDistribuidor"))))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsDistribuidor") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private ReadOnly Property CveConcepto As Integer
|
|
Get
|
|
Return RBLOpcion.SelectedValue.ToEntero
|
|
End Get
|
|
End Property
|
|
|
|
Public Property AgregarUsado As Boolean
|
|
Get
|
|
If ViewState("AgregarUsado") Is Nothing Then
|
|
Return True
|
|
Else
|
|
Return Boolean.Parse(ViewState("AgregarUsado").ToString)
|
|
End If
|
|
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("AgregarUsado") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property IndexDTUsado As Integer
|
|
Get
|
|
Return CType(ViewState("IndexDTUsado"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IndexDTUsado") = value
|
|
End Set
|
|
End Property
|
|
Private Property Correo As String
|
|
Get
|
|
Return CType(ViewState("Correo"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Correo") = value
|
|
End Set
|
|
End Property
|
|
Private Property FolioCorreo As String
|
|
Get
|
|
Return CType(ViewState("FolioCorreo"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("FolioCorreo") = value
|
|
End Set
|
|
End Property
|
|
Private Property ObjRemisionNC As Modelos.Factura
|
|
Get
|
|
Return CType(ViewState("ObjRemisionNC"), Modelos.Factura)
|
|
End Get
|
|
Set(value As Modelos.Factura)
|
|
ViewState("ObjRemisionNC") = value
|
|
End Set
|
|
End Property
|
|
Private Property ObjFactura As Modelos.Factura
|
|
Get
|
|
Return CType(ViewState("ObjFactura"), Modelos.Factura)
|
|
End Get
|
|
Set(value As Modelos.Factura)
|
|
ViewState("ObjFactura") = value
|
|
End Set
|
|
End Property
|
|
Private Property IndexAjuste As Integer
|
|
Get
|
|
Return ViewState("IndexAjuste").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IndexAjuste") = value
|
|
End Set
|
|
End Property
|
|
Private Property TmpDTAjustes As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("TmpDTAjustes")), Nothing, CType(ViewState("TmpDTAjustes"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDTAjustes") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtPorcentajeMarcas As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("DtPorcentajeMarcas")), Nothing, CType(ViewState("DtPorcentajeMarcas"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtPorcentajeMarcas") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property TmpDTPolizaVirtual As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("TmpDTPolizaVirtual")), Nothing, CType(ViewState("TmpDTPolizaVirtual"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDTPolizaVirtual") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
CargaInicial()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaInicial()
|
|
ConsecutivoVenta = 0
|
|
CveMovimiento = -1
|
|
CveMovimientoRelacionado = -1
|
|
TieneRelacionado = -1
|
|
TieneSalida = False
|
|
EstatusAlmacenCompra = -1
|
|
EsConsumoInterno = False
|
|
Correo = ""
|
|
FolioCorreo = ""
|
|
|
|
If IfNull(Request("Opc"), "").ToString = "S" Then
|
|
RBLOpcion.SelectedValue = "3"
|
|
DivCliente.Visible = False
|
|
End If
|
|
|
|
CreaDT()
|
|
CargaCombos()
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
TxtFechaPendientes.Text = Now.ToShortDateString
|
|
RVFecha.MaximumValue = Now.ToShortDateString
|
|
InicializaClientes(False)
|
|
|
|
'si viene una parámetro para cargar un movimiento lo hacemos dentro del procedimiento cargadatos
|
|
Select Case UsuarioActual.Empresa.Funcionalidad(103)
|
|
Case "1"
|
|
|
|
Case "2"
|
|
divMonedaSeccion.Visible = True
|
|
divGuia.Visible = True
|
|
End Select
|
|
|
|
'AsignacionOpcion()
|
|
SiguienteFolio()
|
|
|
|
'SI YA ES MOVIMIENTO REGISTRADO NO ESCONDE COLUMNA AF
|
|
If CveMovimiento > 0 Then
|
|
BloqueaEdicionEncabezado()
|
|
If UsuarioActual.CveEmpresa.Contiene(66, 13) Then
|
|
TrSubProyectoActivoFijo.Visible = True
|
|
VisualizaAF(True)
|
|
CargaSubProyectos()
|
|
End If
|
|
End If
|
|
|
|
CargaSubProyectosUsados()
|
|
InicializaBitacoraTemporal()
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
|
|
DivCodigoSeriePS.Visible = True
|
|
End If
|
|
|
|
'If IfNull(Request("CI"), -1).ToString.ToEntero > 0 Then
|
|
' ActivaConsumoInterno()
|
|
'End If
|
|
|
|
'BLOQUEA PERMISOS
|
|
BtnGuardar.Enabled = PermiteGuardar()
|
|
BtnEliminar.Enabled = PermiteEliminar()
|
|
BtnContabilizar.Enabled = PermiteContabilizar()
|
|
BtnNuevo.Enabled = PermiteCrearNuevo()
|
|
|
|
If CveMovimiento > 0 Then
|
|
PermisoVerImportes()
|
|
End If
|
|
|
|
CargaTamaños()
|
|
CargaMarcasFiltro()
|
|
'DdlProducto2.setEsWebService(True)
|
|
'DdlProducto2.Attributes.Add("data-metodo", "getpsusados")
|
|
End Sub
|
|
|
|
|
|
|
|
#Region " PERMISOS PAGINAS "
|
|
Private Function PermiteGuardar() As Boolean
|
|
Return True 'If(UsuarioActual.TienePermisoProceso(181) Or EsConsumoInterno, True, False)
|
|
End Function
|
|
''' <summary>
|
|
''' Este permiso solo habilita el Btn del GV. Debe ir en conjunto con el permiso 181 [PermiteGuardar]
|
|
''' </summary>
|
|
Private Function PermiteGuardarObservacionDetalle() As Boolean
|
|
Return UsuarioActual.TienePermisoProceso(225)
|
|
End Function
|
|
Private Function PermiteEliminar() As Boolean
|
|
Return If(UsuarioActual.TienePermisoProceso(182), True, False)
|
|
End Function
|
|
Private Function PermiteContabilizar() As Boolean
|
|
Return If(UsuarioActual.TienePermisoProceso(183), True, False)
|
|
End Function
|
|
Private Function PermiteCrearNuevo() As Boolean
|
|
Return If(UsuarioActual.TienePermisoProceso(184) Or EsConsumoInterno, True, False)
|
|
End Function
|
|
|
|
Private Sub PermisoVerImportes()
|
|
Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201)
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " VALORES INICIALES "
|
|
Protected Sub CreaDT()
|
|
Dim dt As New DataTable
|
|
|
|
Dim column As DataColumn = New DataColumn("No")
|
|
column.DataType = Type.GetType("System.Int32")
|
|
With column
|
|
.AutoIncrement = True
|
|
.AutoIncrementSeed = 1
|
|
.AutoIncrementStep = 1
|
|
End With
|
|
|
|
'dt.Columns.Add("No", Type.GetType("System.Int32"))
|
|
dt.Columns.Add(column)
|
|
dt.Columns.Add("CveMovimiento", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("CveMovimientoDetalle", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("Cantidad", Type.GetType("System.Double"))
|
|
dt.Columns.Add("CveUM", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("UnidadMedida")
|
|
dt.Columns.Add("CvePS", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("CodigoPS")
|
|
dt.Columns.Add("Codigo")
|
|
dt.Columns.Add("PS")
|
|
dt.Columns.Add("PU", Type.GetType("System.Double"))
|
|
dt.Columns.Add("PUExtranjero", Type.GetType("System.Double"))
|
|
dt.Columns.Add("Total", Type.GetType("System.Double"))
|
|
dt.Columns.Add("CveClasificacion", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("CveSeccionAlmacen", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("SeccionAlmacen")
|
|
dt.Columns.Add("Estatus")
|
|
|
|
dt.Columns.Add("CostoIndirecto", Type.GetType("System.Double"))
|
|
dt.Columns.Add("CodigoAF")
|
|
dt.Columns.Add("CveAF")
|
|
dt.Columns.Add("Serie", Type.GetType("System.String"))
|
|
dt.Columns.Add("Lote", Type.GetType("System.String"))
|
|
dt.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime"))
|
|
|
|
dt.Columns.Add("Observaciones")
|
|
dt.Columns.Add("CountMovimientoEntradaDetalle")
|
|
dt.Columns.Add("TotalExtranjero", Type.GetType("System.Double"))
|
|
dt.Columns.Add("CveTamaño", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("Tamaño", Type.GetType("System.String"))
|
|
CargaGVM(dt)
|
|
|
|
DtMovimientos = dt.Clone
|
|
DtMovimientosEntradaInvFisico = dt.Clone
|
|
DtMovimientosSalidaInvFisico = dt.Clone
|
|
|
|
End Sub
|
|
Private Sub CargaCombos()
|
|
|
|
'Llenar el dropdownlist de monedas
|
|
DdlMoneda.DataSource = GlobalDTMonedas
|
|
DdlMoneda.DataBind()
|
|
|
|
'Llenar el dropdownlist de almacén
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (22)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
DdlAlmacen.DataBind()
|
|
|
|
If IsNothing(Request("CveMovimiento")) Then
|
|
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
|
DdlAlmacen_SelectedIndexChanged(DdlAlmacen, EventArgs.Empty)
|
|
End If
|
|
|
|
CargaPS()
|
|
End Sub
|
|
Private Sub CargaPS()
|
|
Dim ObjAcum As New ClsAcumuladores
|
|
Dim lista As New List(Of String)
|
|
Dim Filtro As String = ""
|
|
|
|
If ObjAcum.TamañoGet(-1, UsuarioActual.CveEmpresa) Then
|
|
For Each drow As DataRow In ObjAcum.DtResultados.Rows
|
|
|
|
If drow("CvePSCargo").ToString.ToEntero > 0 Then
|
|
lista.Add(drow("CvePSCargo").ToString)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If lista.Count > 0 Then
|
|
|
|
Filtro = "CvePS in(" & String.Join(",", lista) & ")"
|
|
|
|
DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros(Filtro)
|
|
DdlProducto2.DataBind()
|
|
DdlProducto2.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
ObjAcum.Dispose()
|
|
End Sub
|
|
Private Sub CargaSubProyectos()
|
|
DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1))
|
|
DdlSubProyecto.DataBind()
|
|
|
|
'DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaSubProyectosUsados()
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
DivRecepcionUsados.Visible = True
|
|
|
|
If Not UsuarioActual.TienePermisoProceso(190) Then
|
|
'CARGA SOLO LAS SUCURSALES DE LOS ALMCENES QUE TIENE ASIGNADO EL USUARIO
|
|
Dim ObjInventarios As New ClsInventarios
|
|
If ObjInventarios.GetSucursalesAlmacenUsuario(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
DdlSubProyectos.DataSource = ObjInventarios.DtResultados
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
Else
|
|
DdlSubProyectos.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
End If
|
|
DdlSubProyectos.DataBind()
|
|
DdlSubProyectos.SelectedValueExist(UsuarioActual.CveSubProyecto.ToString)
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub CargaPersonal()
|
|
TrPersonal.Visible = True
|
|
Dim dt As DataTable = Nothing
|
|
|
|
Dim RH As New ClsRH
|
|
|
|
If RH.GetPersonal(-1, UsuarioActual.CveEmpresa) Then
|
|
dt = RH.DtResultados
|
|
End If
|
|
|
|
RH.Dispose()
|
|
|
|
DdlPersonal.DataSource = dt
|
|
DdlPersonal.DataBind()
|
|
'DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " CARGA DATOS "
|
|
|
|
|
|
Private Sub BloqueaEdicionEncabezado()
|
|
|
|
|
|
DdlAlmacen.Enabled = True
|
|
'DdlConcepto.Enabled = True
|
|
TxtFolio.Enabled = True
|
|
TxtFecha.Enabled = True
|
|
TxtResponsable.Enabled = True
|
|
TxtObservaciones.Enabled = True
|
|
DdlMoneda.Enabled = True
|
|
TxtGuia.Enabled = True
|
|
DdlSeccion.Enabled = True
|
|
|
|
If CveMovimiento > 0 Then
|
|
DdlAlmacen.Enabled = False
|
|
' DdlConcepto.Enabled = False
|
|
TxtFolio.Enabled = False
|
|
If Not PermiteGuardar() Then TxtFecha.Enabled = False
|
|
TxtResponsable.Enabled = False
|
|
TxtObservaciones.Enabled = False
|
|
DdlMoneda.Enabled = False
|
|
TxtGuia.Enabled = False
|
|
DdlSeccion.Enabled = False
|
|
End If
|
|
UppGrid.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " BOTONES: ELIMINAR, NUEVO "
|
|
Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs) Handles BtnNuevo.Click
|
|
'Response.Redirect("EntradasSalidas.aspx")
|
|
|
|
LimpiarMovimiento()
|
|
BloqueaEdicionEncabezado()
|
|
End Sub
|
|
Private Sub LimpiarMovimiento()
|
|
CveMovimiento = -1
|
|
|
|
If ObjFactura IsNot Nothing Then
|
|
ObjFactura.Dispose()
|
|
ObjFactura = Nothing
|
|
End If
|
|
|
|
If ObjRemisionNC IsNot Nothing Then
|
|
ObjRemisionNC.Dispose()
|
|
ObjRemisionNC = Nothing
|
|
End If
|
|
|
|
CveRemisionRecibida = -1
|
|
EsDistribuidor = False
|
|
DdlClientes.SelectedValueExist("-1")
|
|
DdlClientes_SelectedIndexChanged(DdlClientes, EventArgs.Empty)
|
|
|
|
SiguienteFolio()
|
|
|
|
HplCompra.Visible = False
|
|
HplPoliza.Visible = False
|
|
HplVenta.Visible = False
|
|
HplOrdenCompra.Visible = False
|
|
|
|
TrTipoCargado.Visible = False
|
|
TrPersonal.Visible = False
|
|
|
|
DtMovimientos.Clear()
|
|
GvM.EditIndex = -1
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
BtnGuardar.Visible = PermiteGuardar()
|
|
BtnEliminar.Visible = False
|
|
|
|
DivRegistro.Visible = False
|
|
DivTipoCambio.Visible = False
|
|
|
|
If Not DdlAlmacen.Items.Contains(New ListItem("Seleccione", "-1")) Then
|
|
DdlAlmacen.Items.Add(New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
If Not EsConsumoInterno Then
|
|
DdlAlmacen_SelectedIndexChanged(DdlAlmacen, EventArgs.Empty)
|
|
End If
|
|
DdlAlmacen.Enabled = True
|
|
|
|
TxtResponsable.Text = ""
|
|
TxtObservaciones.Text = ""
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
|
|
LblUsuarioRegistro.Text = ""
|
|
LblFechaRegistro.Text = ""
|
|
HplCompra.Visible = False
|
|
HplVenta.Visible = False
|
|
HplPoliza.Visible = False
|
|
HplOrdenCompra.Visible = False
|
|
|
|
LimpiarAgregar()
|
|
|
|
InicializaBitacoraTemporal()
|
|
DtBitacora.Clear()
|
|
CargaEventoBitacoraTemp()
|
|
|
|
TxtRemision.Text = ""
|
|
DivRemision.Visible = False
|
|
|
|
'CargaInicial()
|
|
|
|
UpRegistroTipoCambio.Update()
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub LimpiarAgregar()
|
|
'DdlClasificacion.SelectedValue = "-1"
|
|
txtCantidad.Text = ""
|
|
|
|
TxtObservacionesdetalle.Text = ""
|
|
|
|
UpModalAgregar.Update()
|
|
End Sub
|
|
|
|
Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
|
|
Dim Inv As New ClsInventarios
|
|
Dim Conta As New ClsContabilidad(Inv.IniciaTransacSQL())
|
|
|
|
Dim TieneError = False
|
|
|
|
Dim ObjConta As ClsContPAQi = Nothing
|
|
If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then
|
|
ObjConta = New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjConta.IniciaTransacSQL()
|
|
End If
|
|
|
|
|
|
If Inv.MovimientoRemove(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
If HdnIdPoliza.Value.ToEntero > 0 Then
|
|
If Not ObjConta.RemovePoliza(HdnIdPoliza.Value.ToEntero) Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
'If Not TieneError Then
|
|
' If Not Conta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
|
|
' TieneError = True
|
|
' End If
|
|
'End If
|
|
|
|
If Not TieneError Then
|
|
If ObjConta IsNot Nothing Then ObjConta.Commit()
|
|
Inv.Commit()
|
|
|
|
Alert("Movimientos Eliminado", TipoMensaje.MsgInformacion)
|
|
LimpiarMovimiento()
|
|
Else
|
|
If ObjConta IsNot Nothing Then ObjConta.RollBack()
|
|
Inv.RollBack()
|
|
|
|
Alert("Ocurrió un error al eliminar el movimiento. Por favor vuelva a intetar.", TipoMensaje.MsgError)
|
|
End If
|
|
CveMovimiento = 0
|
|
|
|
If ObjConta IsNot Nothing Then ObjConta.Dispose()
|
|
Inv.Dispose()
|
|
Conta.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "CORREO"
|
|
|
|
Private Function GeneraCorreo() As String
|
|
Dim ObjInv As New ClsInventarios
|
|
ObjInv.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa)
|
|
Dim strBody As New StringBuilder
|
|
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
|
|
strBody.Append("<head> ")
|
|
strBody.Append(" <style type=""text/css""> ")
|
|
strBody.Append(" body ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" margin:0px; ")
|
|
strBody.Append(" padding:0px 0px 0px 0px; ")
|
|
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
|
|
strBody.Append(" font-size: 10px; ")
|
|
strBody.Append(" background-color:#F0F0F0; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" a.Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" font-size:11px; ")
|
|
strBody.Append(" background-color:#F7F6F3; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .TextoAlterno ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .BarraIdentidad ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" color:#FFFFFF; ")
|
|
strBody.Append(" background:#F0F0F0; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" font-size:19px; ")
|
|
strBody.Append(" font-style:oblique; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Titulos ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: Gray;")
|
|
strBody.Append(" color:White; ")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Contenido2 ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: White;")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Verde {color: #00CC00;} ")
|
|
strBody.Append(" .Negro {color: #000000;} ")
|
|
strBody.Append(" .Rojo {color: #FF0000;} ")
|
|
strBody.Append(" </style> ")
|
|
strBody.Append("</head> ")
|
|
strBody.Append("<body> ")
|
|
strBody.Append("<div class='Contenido2' style='display: table!important'>")
|
|
strBody.AppendFormat(" <div id=""C_divOP"" style=""width: 550px""> <fieldset> <legend><b>Datos {0}</b></legend> ", "de la recepción de usados")
|
|
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%""> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td style=""width: 90px""> Folio:</td><td colspan=""3""> <a href=" + UrlSitio + "Inventarios/EntradasSalidas.aspx?CveMovimiento=" + CveMovimiento.ToString() + "> <b>" + ObjInv.DtResultados(0)("Folio").ToString() + "</b><a/></td>")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Almacen:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", ObjInv.DtResultados(0)("Almacen").ToString())
|
|
strBody.Append(" </tr> ")
|
|
strBody.AppendFormat(" <td style=""width: 90px""> Fecha:</td><td colspan=""3""><b>{0}</b></td> ", ObjInv.DtResultados(0)("FechaMovto").ToString().ToDate().ToShortDateString())
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Cliente:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", ObjInv.DtResultados(0)("Nombre").ToString())
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Recibe:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", ObjInv.DtResultados(0)("Recibio").ToString())
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Observaciones:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", ObjInv.DtResultados(0)("Observaciones").ToString())
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
strBody.Append(" <div style='width: 1000px'> ")
|
|
strBody.Append(" <fieldset> ")
|
|
strBody.Append(" <legend>Listado de Recepción</legend> ")
|
|
strBody.Append(" <table width=""1000px""> <tr style='background-color:gray;color:White;font-family:Verdana;font-size:10px;text-align:center;vertical-align:middle;font-weight:bold;height:20px;text-decoration:none;'><th scope='col' style='width: 50px'>Cantidad</th><th scope='col' style='width: 150px'>Producto</th><th scope='col' style='width: 150px'>Unidad</th><th scope='col' style='width: 150px'>Observaciones</th>")
|
|
strBody.Append(" </tr>")
|
|
FolioCorreo = ObjInv.DtResultados(0)("Folio").ToString()
|
|
Dim DtMovimientosDetalle As DataTable = Nothing
|
|
If ObjInv.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
DtMovimientosDetalle = ObjInv.DtResultados
|
|
End If
|
|
For Each dr As DataRow In DtMovimientosDetalle.Rows
|
|
strBody.AppendFormat("<tr class='Texto'><td style='width:50px;'>{0}</td><td style='width:100px;'>{1}</td><td align='left' style='width:100px;'>{2}</td><td align='left' style='width:100px;'>{3}</td></tr>", dr("Cantidad").ToString.FormatoNumero(0), dr("CodigoPS"), dr("UnidadMedida"), dr("Observaciones"))
|
|
Next
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
strBody.Append("</div>")
|
|
strBody.Append("</body></html>")
|
|
ObjInv.Dispose()
|
|
Return strBody.ToString
|
|
End Function
|
|
|
|
Private Sub MandaCorreo(Para As String, Asunto As String, Body As String)
|
|
|
|
Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para)
|
|
Dim Mail As New ClsSisMail()
|
|
Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body)
|
|
End Sub
|
|
|
|
Protected Sub EnvioCorreo()
|
|
Dim Body As String = GeneraCorreo()
|
|
Dim Asunto As String = $"SIG - Se Genero una Recepción de Usados con el folio: {FolioCorreo}"
|
|
Try
|
|
Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Correo, Asunto, Body))
|
|
Hilo.Start()
|
|
Catch ex As Exception
|
|
OnError("Ocurrió error al mandar MAIL", ex)
|
|
End Try
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " AGREGAR - GUARDAR "
|
|
Private Function GetExistencias(CvePS As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, CveAlmacen As Integer, Optional Serie As String = "-1", Optional Lote As String = "-1", Optional FechaCaducidad As Date = MinFecha) As Double
|
|
Dim Inv As New ClsInventarios
|
|
Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, -1, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad)
|
|
Inv.Dispose()
|
|
Return Existencia
|
|
End Function
|
|
|
|
|
|
Protected Sub BtnSerieAddNew_Click(sender As Object, e As EventArgs)
|
|
AgregarPS()
|
|
End Sub
|
|
Private Sub AgregarPS()
|
|
If Not DdlProducto2.SelectedValue.ToEntero > 0 Then
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim PU As Decimal = 0
|
|
If GlobalDTAcumTamaños.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CvePSCargo > 0 AND CvePSCargo={DdlProducto2.SelectedValue}").Rows.Count > 0 Then
|
|
PU = GlobalDTAcumTamaños.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CvePSCargo > 0 AND CvePSCargo={DdlProducto2.SelectedValue}").Rows(0)("Cargo").ToString.ToDecimal
|
|
End If
|
|
|
|
AddNew(DdlProducto2.SelectedValue.ToEntero, DdlProducto2.SelectedItem.Text, DdlUnidad.SelectedValue.ToEntero, DdlUnidad.SelectedItem.Text, txtCantidad.Text.ToDouble, PU,
|
|
"", "-1", "-1", "-1", TxtObservacionesdetalle.Text, "", -1, "", "", HdnCveTamaño.Value.ToEntero)
|
|
LimpiarAgregar()
|
|
|
|
txtCantidad.Text = ""
|
|
|
|
RegistraScript("CodigoAF = "";")
|
|
|
|
If Not UsuarioActual.Empresa.Funcionalidad(105).ToString = "1" Then
|
|
DdlProducto2.SelectedValue = "-1"
|
|
Else
|
|
DdlProducto2.SelectedIndex = 0
|
|
End If
|
|
|
|
txtCantidad.Focus()
|
|
End Sub
|
|
|
|
|
|
Protected Sub AddNew(CvePS As Integer, PS As String, CveUM As Integer, UM As String, Cantidad As Double, PU As Double, Serie As String, CodigoAF As String, Codigo As String,
|
|
CveAF As String, Observaciones As String, Lote As String, CveSeccionAlmacen As Integer, SeccionAlmacen As String, Tamaño As String, CveTamaño As Integer)
|
|
|
|
'If DdlAlmacen.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlProducto2.SelectedText = "" : Exit Sub
|
|
|
|
Dim Valido As Boolean = True
|
|
|
|
Dim CveClasificacion As Integer
|
|
Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS")
|
|
If dr IsNot Nothing Then CveClasificacion = dr("CveClasificacion").ToString.ToEntero
|
|
|
|
|
|
If Valido And AgregarUsado Then
|
|
|
|
If ObjFactura IsNot Nothing AndAlso Me.CveRemisionRecibida > 0 Then
|
|
Dim RowDetalle As DataRow = ObjFactura.DtDetalle.FiltroPrimero($"CvePS={CvePS}")
|
|
|
|
If RowDetalle IsNot Nothing Then
|
|
|
|
'If RowDetalle("PU").ToString.ToDecimal().RoundSQL <> PU.RoundSQL Then
|
|
' Alert($"Los importes no coinciden", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
'End If
|
|
|
|
Dim Puntos As Decimal = DtTamaños.FiltroPrimeroValor("Puntos", $"CvePSCargo={CvePS}").ToDecimal()
|
|
Dim CantidadPermitida As Double = Math.Ceiling(RowDetalle("Cantidad").ToString.ToDecimal() * Puntos)
|
|
|
|
If Cantidad > CantidadPermitida Then
|
|
Alert($"La cantidad es mayor a la permitida", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'Else
|
|
' Alert($"El producto no se encuentra en la factura", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
End If
|
|
End If
|
|
|
|
'VALIDA QUE LA SERIE NO SEA IGUAL AL CODIGO O CODIGOBARRAS
|
|
If Serie <> "" And (Serie.ToUpper = dr("Codigo").ToString.ToUpper Or Serie.ToUpper = dr("CodigoBarras").ToString.ToUpper) Then
|
|
Alert($"La serie indicada <b>{Serie}</b> coincide con el codigo o codigo de barras del producto. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim registro As DataRow = DtMovimientos.NewRow
|
|
registro.Item("Cantidad") = Cantidad
|
|
registro.Item("CveUM") = CveUM
|
|
registro.Item("UnidadMedida") = UM
|
|
registro.Item("CvePS") = CvePS
|
|
registro.Item("CodigoPS") = PS
|
|
registro.Item("PS") = PS
|
|
registro.Item("PU") = PU
|
|
'registro.Item("PUExtranjero") = PU
|
|
registro.Item("Total") = Cantidad * PU
|
|
registro.Item("CveClasificacion") = CveClasificacion
|
|
registro.Item("Estatus") = ""
|
|
registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen
|
|
registro.Item("SeccionAlmacen") = SeccionAlmacen
|
|
|
|
|
|
registro.Item("CodigoAF") = CodigoAF
|
|
registro.Item("Codigo") = Codigo
|
|
registro.Item("CveAF") = CveAF
|
|
registro.Item("Serie") = If(Serie <> "", Serie, "")
|
|
registro.Item("Lote") = If(Lote <> "", Lote, "")
|
|
registro.Item("Observaciones") = Observaciones
|
|
|
|
registro.Item("CveTamaño") = CveTamaño
|
|
registro.Item("Tamaño") = Tamaño
|
|
|
|
DtMovimientos.Rows.Add(registro)
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
' RegistraScript("playsonidito('beep-07.wav')")
|
|
|
|
'asdasdasdasdasdad
|
|
If Not ChkSeguirAgregando.Checked Then
|
|
RegistraScript("$('#DivModalAgregar').modal('hide')", "hidemodal")
|
|
End If
|
|
Else
|
|
|
|
|
|
DtMovimientos.Rows(IndexDTUsado)("Cantidad") = Cantidad
|
|
DtMovimientos.Rows(IndexDTUsado)("CveUM") = CveUM
|
|
DtMovimientos.Rows(IndexDTUsado)("UnidadMedida") = UM
|
|
DtMovimientos.Rows(IndexDTUsado)("CvePS") = CvePS
|
|
DtMovimientos.Rows(IndexDTUsado)("CodigoPS") = PS
|
|
DtMovimientos.Rows(IndexDTUsado)("PS") = PS
|
|
DtMovimientos.Rows(IndexDTUsado)("PU") = PU
|
|
'registro.Item("PUExtranjero") = PU
|
|
DtMovimientos.Rows(IndexDTUsado)("Total") = Cantidad * PU
|
|
DtMovimientos.Rows(IndexDTUsado)("CveClasificacion") = CveClasificacion
|
|
DtMovimientos.Rows(IndexDTUsado)("Estatus") = ""
|
|
DtMovimientos.Rows(IndexDTUsado)("CveSeccionAlmacen") = CveSeccionAlmacen
|
|
DtMovimientos.Rows(IndexDTUsado)("SeccionAlmacen") = SeccionAlmacen
|
|
DtMovimientos.Rows(IndexDTUsado)("FechaCaducidad") = "1900/01/01"
|
|
|
|
|
|
DtMovimientos.Rows(IndexDTUsado)("CodigoAF") = CodigoAF
|
|
DtMovimientos.Rows(IndexDTUsado)("Codigo") = Codigo
|
|
DtMovimientos.Rows(IndexDTUsado)("CveAF") = CveAF
|
|
DtMovimientos.Rows(IndexDTUsado)("Serie") = If(Serie <> "", Serie, "")
|
|
DtMovimientos.Rows(IndexDTUsado)("Lote") = If(Lote <> "", Lote, "")
|
|
DtMovimientos.Rows(IndexDTUsado)("Observaciones") = Observaciones
|
|
|
|
DtMovimientos.Rows(IndexDTUsado)("CveTamaño") = CveTamaño
|
|
DtMovimientos.Rows(IndexDTUsado)("Tamaño") = Tamaño
|
|
|
|
DtMovimientos.AcceptChanges()
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
If Not ChkSeguirAgregando.Checked Then
|
|
RegistraScript("$('#DivModalAgregar').modal('hide')", "hidemodal")
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
|
If DdlClientes.SelectedValue.ToEntero <= 0 Then
|
|
Alert("No se ha especificado el cliente", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim GenerarRNC As Boolean = False
|
|
'SI ES DISTRIBUIDOR Y NO VIENE DE REMISION, GENERA UNA REMISION DE NOTA DE CREDITO
|
|
If Me.CveRemisionRecibida <= 0 Then 'EsDistribuidor AndAlso , comentado, 2020.04.21 RMF
|
|
GenerarRNC = True
|
|
Dim CveCliente As Integer = DdlClientes.SelectedValue.ToEntero()
|
|
Dim CveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue}").ToEntero
|
|
|
|
CreaRemisionNC(CveCliente, CveSubProyecto, 1)
|
|
End If
|
|
|
|
If GenerarRNC AndAlso Me.ObjRemisionNC IsNot Nothing Then
|
|
Dim sb As New StringBuilder()
|
|
sb.Append($"Se va a generar un documento de tipo 'Remisión de nota de crédito'.<br> ¿Esta seguro que desea guardar?:<br/>")
|
|
|
|
Alert(sb.ToString(), TipoMensaje.MsgConfirmacion, JSBtnAceptar:="GenerarRNC();", TextoConfirmacion:=" Si ", TextoCancelacion:=" No ")
|
|
Else
|
|
Guardar()
|
|
End If
|
|
End Sub
|
|
Private Sub BtnGenerarRNC_Click(sender As Object, e As EventArgs) Handles BtnGenerarRNC.Click
|
|
Guardar(True)
|
|
End Sub
|
|
|
|
Protected Sub Guardar(Optional GenerarRNC As Boolean = False)
|
|
If GvM.Rows.Count > 0 Then
|
|
Dim Msg As New StringBuilder()
|
|
Dim Resp As Modelos.Factura.MMensajeFactura = Nothing
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ObjAcum As New ClsAcumuladores(ObjInventario.IniciaTransacSQL())
|
|
Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL())
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim ErrorAC As Boolean = False
|
|
Dim IDPoliza As Integer = 0
|
|
Dim ImporteConcepto As Decimal = 0
|
|
|
|
Try
|
|
Dim CveSubProyecto = -1
|
|
Dim ActivoFijo = -1
|
|
|
|
If CveMovimiento > 0 Then
|
|
Else
|
|
|
|
Dim Fecha = String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime).ToDate
|
|
Dim CveCliente As Integer = CInt(IIf((DdlClientes.SelectedValue.ToEntero <= 0), -1, DdlClientes.SelectedValue.ToEntero))
|
|
Dim CveClienteSucursal As Integer = CInt(IIf((DdlClientesSucursales.SelectedValue.ToEntero <= 0), -1, DdlClientesSucursales.SelectedValue.ToEntero))
|
|
|
|
'cuando es APH
|
|
Dim tFolio As Integer = -1
|
|
If UsuarioActual.CveEmpresa = 48 And EsConsumoInterno = False Then tFolio = TxtFolio.Text.ToEntero
|
|
If Not tFolio > 0 Then
|
|
tFolio = If(TxtFolio.Text.ToEntero <> FolioAsignado, TxtFolio.Text.ToEntero, -1)
|
|
End If
|
|
Dim tCveProveedor As Integer = -1
|
|
If DdlProveedor.SelectedValue.ToEntero > 0 Then tCveProveedor = DdlProveedor.SelectedValue.ToEntero
|
|
Dim CveVenta As Integer = -1
|
|
|
|
If CveRemisionRecibida > 0 Then
|
|
CveVenta = CveRemisionRecibida
|
|
Else
|
|
CveVenta = -1
|
|
End If
|
|
|
|
|
|
If Not ErrorMovInv AndAlso GenerarRNC AndAlso ObjRemisionNC IsNot Nothing Then
|
|
|
|
CargaDTDetalleRNC()
|
|
|
|
Resp = ObjRemisionNC.EmitirFactura(False, ObjInventario.IniciaTransacSQL)
|
|
'For Each mensaje2 As String In Resp.Mensajes
|
|
' Msg.AppendFormat("<br>{0}", mensaje2)
|
|
'Next
|
|
If Resp.TieneError Then ErrorMovInv = True
|
|
'Alert(Msg.ToString, If(Resp.CveVenta > 0, TipoMensaje.MsgInformacion, TipoMensaje.MsgAdvertencia))
|
|
CveVenta = Resp.CveVenta
|
|
|
|
End If
|
|
|
|
Dim Mensaje As String = ""
|
|
Dim FolioInv As String = ""
|
|
|
|
If GenerarRNC Then
|
|
CveMovimiento = Resp.CveMovimientoUsado
|
|
FolioInv = Resp.FolioUsado
|
|
Else
|
|
|
|
Dim tCveConcepto As Integer = CveConcepto
|
|
If RblUsadosAjuste.SelectedValue = "1" Then 'cuando es garantia, el concepto es de entrada
|
|
tCveConcepto = 2
|
|
End If
|
|
|
|
CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, tCveConcepto, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta,
|
|
CveSubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text, CvePersonal:=DdlPersonal.SelectedValue.ToEntero,
|
|
Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text,
|
|
PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor, Modulo:="RU/G")
|
|
If CveMovimiento <= 0 Then
|
|
Mensaje = "Error al guardar los movimientos"
|
|
ErrorMovInv = True
|
|
Else
|
|
FolioInv = ObjInventario.Folio.ToString()
|
|
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
|
|
If CveConcepto = 42 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then
|
|
ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
|
|
Else
|
|
ImporteConcepto = Dr("PU").ToString.ToDecimal
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
Mensaje = "Error al guardar los movimientos"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
If CveVenta > 0 AndAlso Not ObjVentas.UpdateVentaUsadoRecibido(CveVenta, Dr("CvePS").ToString.ToEntero, True, CveMovimiento) Then
|
|
Mensaje = "Error al actualizar el recibo de los usados"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
'si es selectedvalue = 42, es entrada ,3 -salida
|
|
Dim CveConceptoUsados As Integer = If(RBLOpcion.SelectedValue.ToEntero = 42, 1, 2)
|
|
|
|
If EsDistribuidor AndAlso RBLOpcion.SelectedValue.ToEntero = 42 AndAlso Dr("CveTamaño").ToString.ToEntero > 0 Then
|
|
|
|
If Not ObjAcum.DistribuidorMovtosAdd(DdlClientes.SelectedValue.ToEntero, Dr("Cantidad").ToString.ToEntero(), Dr("CveTamaño").ToString.ToEntero, CveConceptoUsados, CveVenta, UsuarioActual.CveUsuario,
|
|
UsuarioActual.CveEmpresa, 0, Dr("Observaciones").ToString, CveMovimiento:=CveMovimiento) Then
|
|
Mensaje = "Error al guardar Movimientos de distribuidor"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
'ACTUALIZA LA POLIZA VIRTUAL DEL LA REMISION
|
|
'If Not ErrorMovInv AndAlso ObjFactura.TipoDocto = "Rem" Then
|
|
' If ObjAcum.GetPolizasVirtuales(ObjFactura.CveVenta) Then
|
|
' Dim DtPoliza As DataTable = ObjAcum.DtResultados.Copy()
|
|
' For Each RowPoliza As DataRow In DtPoliza.Rows
|
|
' If Not ObjAcum.UpdatePolizaVirtual(RowPoliza("CvePolizaVirtual").ToString().ToEntero, DdlMarcaRem.SelectedValue.ToEntero(), TxtFechaVigencia.Text.ToDateTime()) Then
|
|
' Mensaje = "Error al guardar la póliza virtual"
|
|
' ErrorMovInv = True
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
|
|
' DtPoliza.Dispose()
|
|
' Else
|
|
' Mensaje = "Error al obtener la póliza virtual"
|
|
' ErrorMovInv = True
|
|
' End If
|
|
'End If
|
|
|
|
'GENERA LA PREPOLIZA DE ALMACEN VS EL CONCEPTO DE RNC
|
|
'If Not ErrorMovInv Then
|
|
' ErrorMovInv = Not GeneraPrePoliza(CveMovimiento, ObjInventario, ObjConta, True)
|
|
'End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If Not ErrorMovInv Then
|
|
If Resp IsNot Nothing Then
|
|
For Each mensaje2 As String In Resp.Mensajes
|
|
Msg.AppendFormat("<br>{0}", mensaje2)
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
|
|
Msg.AppendFormat("<br/>El Movimiento se registro con el Folio: <b><a href='/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}' target='_blank'>{0}</a></b>", FolioInv, CveMovimiento)
|
|
Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
|
|
|
|
If IDPoliza > 0 Then Msg = Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IDPoliza)
|
|
|
|
ObjInventario.Commit() ' aplica los movimientos insertados
|
|
|
|
'Limpia Valores cuando inserta de campos especiales
|
|
If UsuarioActual.CveEmpresa = 66 Then
|
|
DdlSubProyecto.SelectedValueExist("-1")
|
|
End If
|
|
|
|
' EnvioCorreo()
|
|
|
|
CargaPendientesRecibir()
|
|
UPDatos.Update()
|
|
|
|
Else
|
|
ObjInventario.RollBack() 'deshace lo insertado
|
|
CveMovimiento = 0
|
|
Alert("ocurrió un Error al registrar los movimientos", TipoMensaje.MsgError)
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
ObjInventario.RollBack() 'deshace lo insertado
|
|
CveMovimiento = 0
|
|
Alert("Ocurrió un Error inesperado en el registro" & ex.Message, TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End Try
|
|
|
|
ObjInventario.Dispose()
|
|
ObjAcum.Dispose()
|
|
ObjVentas.Dispose()
|
|
|
|
If Not ErrorMovInv Then
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
Else
|
|
Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
|
|
LimpiarMovimiento()
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
End Sub
|
|
|
|
Private Function GeneraPrePoliza(CveMovimiento As Integer, ByRef ObjInventario As ClsInventarios, ByRef ObjConta As ClsContabilidad, EsContabilizable As Boolean) As Boolean
|
|
Dim Correcto As Boolean = True
|
|
Try
|
|
Dim DtCostos As DataTable = Nothing
|
|
Dim ValorInventario As Decimal = 0
|
|
Dim ValorInventarioME As Decimal = 0
|
|
|
|
|
|
ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa)
|
|
Dim CveVenta As Integer = ObjInventario.CveVenta
|
|
Dim CveAlmacen As Integer = ObjInventario.CveAlmacen
|
|
Dim SerieFolio As String = ObjInventario.DtResultados.Rows(0)("SerieFolioVenta").ToString
|
|
Dim MovAlmacen As Boolean = True
|
|
Dim CveConcepto As Integer = ObjInventario.DtResultados.Rows(0)("CveConcepto").ToString().ToEntero()
|
|
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & CveConcepto).ToEntero
|
|
If OrigenMov = 1 Then MovAlmacen = False Else MovAlmacen = True
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
DtCostos = ObjInventario.DtResultados
|
|
Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
|
|
Dim IdCtaContable As Integer = 0
|
|
Dim ConceptoPoliza As String = String.Format("{0}-{1}", "Salida de Almacen", SerieFolio)
|
|
|
|
If tmpCostos.Rows.Count > 0 Then
|
|
Dim Concepto As String = ConceptoPoliza
|
|
Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv_EntradaSalida", 74, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
Dim tCveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={CveAlmacen}").ToEntero
|
|
Dim tCveConcepto As Integer = 278
|
|
|
|
For Each RowInv As DataRow In tmpCostos.Rows
|
|
ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal.RoundSQL
|
|
If tCveConcepto = 69 Then
|
|
IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
|
|
End If
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ValorInventario, Concepto, tCveConcepto, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, CveSubProyecto:=tCveSubProyecto, Contabilizable:=EsContabilizable) Then
|
|
Correcto = False
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={CveAlmacen}").ToEntero
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, DtCostos.SUMD("Total").RoundSQL, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total").RoundSQL, Contabilizable:=EsContabilizable) Then
|
|
Correcto = False
|
|
End If
|
|
|
|
|
|
If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
GuardaLogAD($"Inventarios/RecepcionAlmacen-PPCompOC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
|
Correcto = False
|
|
End If
|
|
End If
|
|
|
|
'CONTABILIZAR - SIMPLIFICAR
|
|
If Correcto Then
|
|
If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
|
|
If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
|
Correcto = False
|
|
End If
|
|
End If
|
|
|
|
'If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
|
|
' If ObjContaContPAQ Is Nothing Then
|
|
' ObjContaContPAQ = New ClsContPAQi(UsuarioActual.Empresa)
|
|
' ObjContaContPAQ.IniciaTransacSQL()
|
|
' End If
|
|
|
|
' If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaContPAQ) Then
|
|
' Retorno = False
|
|
' End If
|
|
'End If
|
|
|
|
End If
|
|
Else
|
|
Correcto = False
|
|
End If
|
|
Else
|
|
Correcto = False
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al guadar la prepoliza", ex)
|
|
Correcto = False
|
|
End Try
|
|
|
|
Return Correcto
|
|
End Function
|
|
#End Region
|
|
|
|
#Region " ADD INVENTARIO INICIAL "
|
|
Protected Sub BtnCodigoBarras_Click(sender As Object, e As EventArgs)
|
|
|
|
If TxtCodigoBarras.Text = "" Then
|
|
Exit Sub
|
|
End If
|
|
|
|
TdSeriePS.Visible = False
|
|
|
|
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras= '{TxtCodigoBarras.Text}'")
|
|
If DrPS Is Nothing Then
|
|
Alert($"No se ha encontrado un producto del Codigo ""<b>{TxtCodigoBarras.Text}</b>"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
TxtCodigoBarras.Text = ""
|
|
Exit Sub
|
|
End If
|
|
|
|
If DrPS("Inv_CveMetodoInventario").ToString.ToEntero = 5 Then
|
|
TdSeriePS.Visible = True
|
|
TxtCodigoSerie.Focus()
|
|
CvePSSerieLote = DrPS("CvePS").ToString.ToEntero
|
|
CveUMSerieLote = DrPS("CveUnidadMedida").ToString.ToEntero
|
|
CostoPromedioSerieLote = DrPS("CostoPromedio").ToString.ToDecimal
|
|
Exit Sub
|
|
End If
|
|
|
|
GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero, DrPS("CostoPromedio").ToString.ToDecimal)
|
|
|
|
TxtCodigoBarras.Text = ""
|
|
TxtCodigoBarras.Focus()
|
|
End Sub
|
|
Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs)
|
|
If TxtCodigoSerie.Text.Trim = "" Then TxtCodigoSerie.Focus() : Exit Sub
|
|
|
|
GuardaCodigoSerie(1, CvePSSerieLote, CveUMSerieLote, CostoPromedioSerieLote, TxtCodigoSerie.Text.Trim)
|
|
|
|
TdSeriePS.Visible = False
|
|
End Sub
|
|
Private Sub BtnAddCodigo_Click(sender As Object, e As EventArgs) Handles BtnAddCodigo.Click
|
|
If TxtCodigo.Text.Trim = "" Then Exit Sub
|
|
|
|
Dim DrP = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo= '{TxtCodigo.Text.Trim}'")
|
|
|
|
If DrP IsNot Nothing AndAlso DrP("CvePS").ToString.ToEntero > 0 Then
|
|
GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrP("CvePS").ToString.ToEntero, DrP("CveUnidadMedida").ToString.ToEntero, DrP("CostoPromedio").ToString.ToDecimal)
|
|
Else
|
|
Alert("No se encontró el producto. Favor de verificar y volver a intentar.", TipoMensaje.MsgError, "window.setTimeout(Focus2,200);")
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub GuardaCodigoSerie(Cantidad As Double, CvePS As Integer, CveUM As Integer, CostoPromedio As Decimal, Optional Serie As String = "-1")
|
|
Dim ObjInv As New ClsInventarios
|
|
|
|
If CveMovimiento <= 0 Then
|
|
CveMovimiento = ObjInv.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, CveConcepto, 1, TxtFecha.Text.ToDate, TxtFolio.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
|
|
-1, -1, -1, -1, Modulo:="RU/G")
|
|
End If
|
|
|
|
ObjInv.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, CostoPromedio, -1, Serie:=Serie)
|
|
ObjInv.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa)
|
|
DtMovimientos = ObjInv.DtResultados.FiltraParametros("", "CveMovimientoDetalle DESC").AsEnumerable.Take(25).CopyToDataTable
|
|
ObjInv.Dispose()
|
|
|
|
CargaGVM(DtMovimientos)
|
|
|
|
TxtCodigoBarras.Text = ""
|
|
TxtCodigo.Text = ""
|
|
TxtCodigoSerie.Text = ""
|
|
TxtCantidadProducto.Text = "1"
|
|
|
|
txtCantidad.Text = ""
|
|
|
|
|
|
TxtCodigoBarras.Focus()
|
|
RegistraScript("beep-07.wav')")
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " DdlConcepto, DdlClasificacion, DdlAlmacen | Index CHANGED "
|
|
|
|
Protected Sub DdlAlmacen_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
If EsConsumoInterno Then
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
|
|
Dim filtro As String = ""
|
|
Dim CveTipoAlmacen = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero
|
|
|
|
filtro = If(UsuarioActual.TienePermisoProceso(144), "CveConcepto NOT IN (1,4,5,8,9,10,12,26,27,29)", "CveConcepto NOT IN (1,2,4,5,8,9,10,12,26,27,29)")
|
|
|
|
If DdlAlmacen.SelectedValue = "-1" Then
|
|
filtro = IIf(UsuarioActual.CveEmpresa.Contiene(72, 1, 80), "CveConcepto NOT IN (4,5,10)", filtro).ToString
|
|
Else
|
|
filtro = String.Format("{0} AND CveTipoAlmacen = {1}", IIf(UsuarioActual.CveEmpresa.Contiene(72, 1, 80, 4, 7, 11, 12), "CveConcepto NOT IN (4,5,10)", filtro).ToString, CveTipoAlmacen)
|
|
End If
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub VisualizaPU(Opcion As Boolean)
|
|
txtPrecio.Visible = Opcion
|
|
End Sub
|
|
Private Sub VisualizaPUExtranjero(Opcion As Boolean)
|
|
|
|
End Sub
|
|
Private Sub VisualizaAF(Opcion As Boolean)
|
|
|
|
End Sub
|
|
Private Sub SiguienteFolio()
|
|
Dim Inv As New ClsInventarios
|
|
Dim Folio As Integer = Inv.GetFolioSiguiente(CveConcepto, UsuarioActual.CveEmpresa)
|
|
Inv.Dispose()
|
|
|
|
TxtFolio.Text = Folio.ToString
|
|
FolioAsignado = Folio
|
|
|
|
End Sub
|
|
Protected Sub DdlProducto2_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CambiarProducto()
|
|
End Sub
|
|
Private Sub CambiarProducto()
|
|
EscondeColumnasGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
DdlUnidad.Items.Clear()
|
|
DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
DdlUnidad.DataBind()
|
|
|
|
HdnCveTamaño.Value = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTamaño", $"CvePS = { DdlProducto2.SelectedValue.ToEntero }")
|
|
|
|
Dim ObjAcum As New ClsAcumuladores
|
|
If ObjAcum.TamañoGet(-1, UsuarioActual.CveEmpresa) Then
|
|
HdnCveTamaño.Value = ObjAcum.DtResultados.FiltroPrimeroValor("CveTamaño", $"CvePSCargo = { DdlProducto2.SelectedValue }")
|
|
End If
|
|
ObjAcum.Dispose()
|
|
|
|
UPDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " GVM "
|
|
Private Sub CargaGVM(DtTemp As DataTable)
|
|
GvM.DataSource = DtTemp
|
|
GvM.DataBind()
|
|
|
|
'If TmpDTPolizaVirtual IsNot Nothing AndAlso RblUsadosAjuste.SelectedValue = "2" Then
|
|
' TmpDTPolizaVirtual.Clear()
|
|
' For Each Row As DataRow In DtTemp.Rows
|
|
' AddPolizaVirtual(Row("CvePS").ToString().ToEntero())
|
|
' Next
|
|
'End If
|
|
|
|
EscondeColumnasGVM(DtTemp)
|
|
End Sub
|
|
Private Sub EscondeColumnasGVM(DtTemp As DataTable)
|
|
|
|
'Dim TienePermisoImportes = UsuarioActual.TienePermisoProceso(201)
|
|
|
|
If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then
|
|
If DtTemp.MAX("Serie").ToString <> "" Then
|
|
End If
|
|
|
|
If DtTemp.MAX("Lote").ToString <> "" Then
|
|
GvM.Columns(11).Visible = True
|
|
End If
|
|
|
|
If DtTemp.SUM("PUExtranjero") > 0 Then
|
|
|
|
End If
|
|
|
|
If DtTemp.SUM("CostoIndirecto") > 0 Then
|
|
|
|
End If
|
|
|
|
Dim Total = DtTemp.SUM("Total")
|
|
|
|
TxtTotal.Text = Total.FormatoNumero(2)
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub GvM_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
|
|
|
|
End Sub
|
|
Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvM.RowEditing
|
|
GvM.EditIndex = e.NewEditIndex
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
End Sub
|
|
Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvM.RowCancelingEdit
|
|
GvM.EditIndex = -1
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
End Sub
|
|
Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvM.RowUpdating
|
|
|
|
Dim Precio As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDouble
|
|
Dim No As Integer = GvM.Rows(e.RowIndex).DataKey("No").ToEntero
|
|
Dim serie As String = GvM.Rows(e.RowIndex).FCTextBox("TxtSerie").Text.Replace(" ", String.Empty)
|
|
Dim Observaciones As String = GvM.Rows(e.RowIndex).FCTextBox("TxtObservaciones").Text
|
|
Dim CveSeccionAlmacen As Integer = GvM.Rows(e.RowIndex).FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero
|
|
Dim SeccionAlmacen As String = GvM.Rows(e.RowIndex).FCDropDownList("DdlSeccionAlmacen").SelectedItem.Text
|
|
Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", No))
|
|
|
|
If Drs.Count > 0 Then
|
|
Drs(0)("PU") = Precio
|
|
Drs(0)("Total") = Drs(0)("Cantidad").ToString.ToDouble * Precio
|
|
Drs(0)("Estatus") = "U"
|
|
Drs(0)("Serie") = serie
|
|
Drs(0)("Observaciones") = Observaciones
|
|
Drs(0)("CveSeccionAlmacen") = CveSeccionAlmacen
|
|
Drs(0)("SeccionAlmacen") = SeccionAlmacen
|
|
End If
|
|
|
|
DtMovimientos.AcceptChanges()
|
|
GvM.EditIndex = -1
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
End Sub
|
|
Protected Sub DeleteRow(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
|
|
|
|
|
|
If DtMovimientos.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then
|
|
Dim i As Integer
|
|
i = lnkRemove.CommandArgument.ToString.ToEntero
|
|
Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", i))
|
|
If Drs.Count > 0 Then
|
|
If CveMovimiento > 0 AndAlso Drs(0)("CveMovimientoDetalle").ToString.ToEntero > 0 Then
|
|
Drs(0)("Estatus") = "E"
|
|
Else
|
|
Drs(0).Delete()
|
|
End If
|
|
|
|
End If
|
|
DtMovimientos.AcceptChanges()
|
|
End If
|
|
|
|
GvM.EditIndex = -1
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " TIPO DE CAMBIO "
|
|
Protected Sub DdlMonedaTC_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
Select Case DdlMonedaTC.SelectedValue.ToEntero
|
|
Case 1
|
|
TrTC1.Visible = False
|
|
TrTC2.Visible = False
|
|
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
Dr("PU") = Dr("PUExtranjero")
|
|
Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble
|
|
Next
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
'LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero
|
|
|
|
UPDatos.Update()
|
|
|
|
Case 2
|
|
TrTC1.Visible = True
|
|
TrTC2.Visible = True
|
|
End Select
|
|
End Sub
|
|
Protected Sub BtnAplicarTC_Click(sender As Object, e As EventArgs)
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
Dr("PU") = Dr("PUExtranjero").ToString.ToDouble * TxtTipoCambio.Text.ToDouble
|
|
Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble
|
|
Next
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
'LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero
|
|
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " BITACORA "
|
|
Private Sub InicializaBitacoraTemporal()
|
|
|
|
DivBitacora.Visible = True
|
|
If CveMovimiento > 0 Then
|
|
CargaEventoBitacora()
|
|
Else
|
|
DtBitacora = New DataTable
|
|
DtBitacora.Columns.Add("FechaIng", GetType(String))
|
|
DtBitacora.Columns.Add("FechaInicio", GetType(String))
|
|
DtBitacora.Columns.Add("Usuario", GetType(String))
|
|
DtBitacora.Columns.Add("CveUsuario", GetType(String))
|
|
DtBitacora.Columns.Add("Descripcion", GetType(String))
|
|
DtBitacora.Columns.Add("Prioridad", GetType(String))
|
|
DtBitacora.Columns.Add("FileExtension", GetType(String))
|
|
DtBitacora.Columns.Add("Archivo", GetType(String))
|
|
DtBitacora.Columns.Add("CveOrdenCompra", GetType(String))
|
|
DtBitacora.Columns.Add("CveEmpresa", GetType(String))
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub CargaEventoBitacora()
|
|
Dim ObjEventoBitacora As New ClsOIEventos()
|
|
|
|
If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then
|
|
GvBitacora.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento IN (6,2)")
|
|
Else
|
|
GvBitacora.DataSource = Nothing
|
|
End If
|
|
|
|
ObjEventoBitacora.Dispose()
|
|
|
|
GvBitacora.DataBind()
|
|
UPEventoBitacora.Update()
|
|
End Sub
|
|
Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click
|
|
If CveMovimiento > 0 Then
|
|
GuardaBitacora()
|
|
Else
|
|
AgregaBitacoraTemporal()
|
|
End If
|
|
End Sub
|
|
|
|
#Region " GUARDA TEMPORAL "
|
|
Private Sub AgregaBitacoraTemporal()
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
|
|
'Archivo
|
|
Dim FileExtension As String = ""
|
|
Dim Filename As String = ""
|
|
Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
Filename = fileItem.filename
|
|
Next
|
|
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}OI\Temp\OI{1}{2}.{3}", UsuarioActual.Empresa.Ruta, UsuarioActual.CveUsuario, Now.ToString("HH-mm"), FileExtension))
|
|
If Archivo.Exists() Then
|
|
Archivo.Delete()
|
|
|
|
End If
|
|
|
|
If Filename <> "" Then
|
|
Filename.FilesMove(String.Format("OI{0}{1}", UsuarioActual.CveUsuario, Now.ToString("HH-mm")), String.Format("{0}OI\Temp", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
|
|
|
|
'AGREGA
|
|
Dim Dr = DtBitacora.NewRow
|
|
Dr("FechaIng") = Now
|
|
Dr("FechaInicio") = ""
|
|
Dr("Usuario") = UsuarioActual.Usuario
|
|
Dr("CveUsuario") = UsuarioActual.CveUsuario
|
|
Dr("Descripcion") = TxtEventoDescripcion.Text.Trim
|
|
Dr("Prioridad") = 1
|
|
Dr("Archivo") = If(FileExtension = "", "", $"{UsuarioActual.Empresa.Ruta}OI\Temp\OI{UsuarioActual.CveUsuario}{Now.ToString("HH-mm")}.{FileExtension}")
|
|
Dr("FileExtension") = String.Format(".{0}", FileExtension)
|
|
Dr("CveOrdenCompra") = -1
|
|
Dr("CveEmpresa") = UsuarioActual.CveEmpresa
|
|
DtBitacora.Rows.Add(Dr)
|
|
|
|
|
|
'LIMPIA
|
|
TxtEventoDescripcion.Text = ""
|
|
'ChkEventoPrioridad.Checked = False
|
|
RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal")
|
|
|
|
CargaEventoBitacoraTemp()
|
|
|
|
|
|
End Sub
|
|
Private Sub CargaEventoBitacoraTemp()
|
|
GvBitacora.DataSource = DtBitacora
|
|
GvBitacora.DataBind()
|
|
UPAddEventoBitacora.Update()
|
|
UPEventoBitacora.Update()
|
|
End Sub
|
|
Private Function GuardaBitacoraTemporal(ObjEventoBitacora As ClsOIEventos, CveMovimiento As Integer) As Boolean
|
|
Dim Retorno = False
|
|
Dim Archivo As System.IO.FileInfo = Nothing
|
|
|
|
For Each Dr As DataRow In DtBitacora.Rows
|
|
If ObjEventoBitacora.AddEventoBitacora(Dr("Descripcion").ToString, Dr("FileExtension").ToString, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then
|
|
Try
|
|
If Dr("Archivo").ToString <> "" Then
|
|
Archivo = New System.IO.FileInfo(Dr("Archivo").ToString)
|
|
If Archivo.Exists() Then
|
|
File.Move(Archivo.ToString, String.Format("{0}OI\OI{1}{2}", UsuarioActual.Empresa.Ruta, ObjEventoBitacora.CveEvento.ToString, Archivo.Extension))
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
Retorno = True
|
|
Alert("Ocurrió un error al guardar los datos adjuntos de la Bitácora.", TipoMensaje.MsgError)
|
|
Exit For
|
|
End Try
|
|
|
|
Else
|
|
Retorno = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Return Retorno
|
|
End Function
|
|
#End Region
|
|
|
|
|
|
#Region " GUARDA DIRECTO "
|
|
Private Sub GuardaBitacora()
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
|
|
Dim FileExtension As String = ""
|
|
Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)) '.Replace(".", "")
|
|
Filename = fileItem.filename
|
|
Next
|
|
|
|
Dim descripcion As String = TxtEventoDescripcion.Text.Trim
|
|
|
|
|
|
If ObjEventoBitacora.AddEventoBitacora(descripcion, String.Format("{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMovimientoAlmacen:=CveMovimiento) Then
|
|
|
|
If Filename <> "" Then
|
|
Filename.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("{0}OI", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
End If
|
|
|
|
GvBitacora.DataSource = ObjEventoBitacora.DtResultados
|
|
TxtEventoDescripcion.Text = ""
|
|
Anexo.Text = "[]"
|
|
|
|
Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion)
|
|
RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal")
|
|
|
|
|
|
End If
|
|
|
|
ObjEventoBitacora.Dispose()
|
|
GvBitacora.DataBind()
|
|
|
|
UPEventoBitacora.Update()
|
|
CargaEventoBitacora()
|
|
UPAddEventoBitacora.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvBitacora.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DBCampo("Archivo").ToString.Trim <> "" AndAlso CveMovimiento > 0 Then
|
|
e.Row.FCLinkButton("LinkArchivo").Visible = True
|
|
e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString)
|
|
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione
|
|
Else
|
|
e.Row.Cells(4).Text = "NO"
|
|
End If
|
|
End If
|
|
End Sub
|
|
Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument)
|
|
If IO.File.Exists(filePath) Then
|
|
Dim Archivo As New System.IO.FileInfo(filePath)
|
|
|
|
HttpContext.Current.Response.Clear()
|
|
HttpContext.Current.Response.ClearContent()
|
|
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
|
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath))
|
|
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
HttpContext.Current.Response.TransmitFile(filePath)
|
|
HttpContext.Current.Response.Flush()
|
|
HttpContext.Current.Response.End()
|
|
|
|
Archivo = Nothing
|
|
Else
|
|
UPEventoBitacora.Update()
|
|
End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
#Region "DDL CLIENTE / CLIENTE SUCURSAL - SELECTED INDEX CHANGED"
|
|
Private Sub InicializaClientes(Todos As Boolean)
|
|
|
|
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(If(Todos, "", "EsDistribuidor = 1"))
|
|
DdlClientes.DataBind()
|
|
DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlClientes.SelectedValue = "-1"
|
|
|
|
End Sub
|
|
'Protected Sub ActivaClientes()
|
|
' If UsuarioActual.CveEmpresa.Contiene(72, 80) Then
|
|
' DivCliente.Visible = True
|
|
' DivDepartamentoEntrega.Visible = True
|
|
' 'TxtDepartamentoEntrega.Text = ""
|
|
' End If
|
|
|
|
|
|
|
|
'End Sub
|
|
Protected Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CambiaCliente()
|
|
End Sub
|
|
Private Sub CambiaCliente()
|
|
DivClienteSucursal.Visible = False
|
|
DdlClientesSucursales.Items.Clear()
|
|
|
|
If DdlClientes.SelectedValue.ToEntero > 0 Then
|
|
Me.EsDistribuidor = CBool(GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=DdlClientes.SelectedValue.ToEntero()).FiltroPrimeroValor("EsDistribuidor", ""))
|
|
|
|
CargaSucursalesCliente()
|
|
CargaFacturasCliente()
|
|
End If
|
|
UpGenerales.Update()
|
|
End Sub
|
|
Private Sub CargaFacturasCliente()
|
|
'DivFactura.Visible = True
|
|
Dim CveCliente As Integer = DdlClientes.SelectedValue.ToEntero()
|
|
If CveCliente > 0 Then
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "Ing", "-1", -1, "-1", CveCliente, -1, -1, -1, "-1", "-1", "-1", CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
|
|
DdlFactura.DataSource = ObjVentas.DtResultados.FiltraParametros("", "", {"CveVenta", "SerieFolio"})
|
|
End If
|
|
ObjVentas.Dispose()
|
|
|
|
DdlFactura.DataBind()
|
|
DdlFactura.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub CargaSucursalesCliente()
|
|
DdlClientesSucursales.Enabled = True
|
|
Dim ObjCliente As New ClsClientes
|
|
If ObjCliente.GetSucursales(DdlClientes.SelectedValue.ToEntero) Then
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
|
|
DivClienteSucursal.Visible = True
|
|
UpGenerales.Update()
|
|
|
|
DdlClientesSucursales.DataSource = ObjCliente.DtResultados
|
|
DdlClientesSucursales.DataBind()
|
|
|
|
DdlClientesSucursales.Items.Insert(0, New ListItem("-", "-1"))
|
|
DdlClientesSucursales.SelectedValue = "-1"
|
|
|
|
UpGenerales.Update()
|
|
End If
|
|
End If
|
|
If DdlClientes.SelectedValue.ToEntero > 0 AndAlso GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros($"CveCliente = {DdlClientes.SelectedValue}").Rows.Count > 0 Then
|
|
Correo = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros($"CveCliente = {DdlClientes.SelectedValue}").Rows(0)("Mail").ToString
|
|
End If
|
|
|
|
ObjCliente.Dispose()
|
|
End Sub
|
|
|
|
Private Sub BtnGeneraPrepoliza_Click(sender As Object, e As EventArgs) Handles BtnGeneraPrepoliza.Click
|
|
''PREPOLIZA - SE CAMBIO DE LUGAR EL USO DE ESTA PARTE
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
|
|
|
|
Dim DtCostos As DataTable = Nothing
|
|
Dim ValorInventario As Decimal = 0
|
|
Dim ValorInventarioME As Decimal = 0
|
|
|
|
ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa)
|
|
Dim CveVenta As Integer = ObjInventario.CveVenta
|
|
Dim MovAlmacen As Boolean = True
|
|
|
|
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & CveConcepto).ToEntero
|
|
If OrigenMov = 1 Then MovAlmacen = False Else MovAlmacen = True
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
DtCostos = ObjInventario.DtResultados
|
|
Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
|
|
Dim DTOCs As DataTable = DtCostos.FiltraParametros("", "", {"CveOrdenCompraDetalle"})
|
|
Dim IdCtaContable As Integer = 0
|
|
|
|
If tmpCostos.Rows.Count > 0 Then
|
|
Dim Concepto As String = $" {TxtObservaciones.Text}"
|
|
Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv_EntradaSalida", 74, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, $"F: {HplVenta.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If HdnCveOrdenCompra.Value.ToEntero > 0 Then
|
|
MovAlmacen = False
|
|
For Each RowOC As DataRow In DTOCs.Rows
|
|
ValorInventario = DtCostos.SUM("Total", $"CveOrdenCompraDetalle = {RowOC("CveOrdenCompraDetalle")}").ToString.ToDecimal
|
|
ValorInventarioME = DtCostos.SUM("TotalExtranjero", $"CveOrdenCompraDetalle = {RowOC("CveOrdenCompraDetalle")}").ToString.ToDecimal
|
|
If ValorInventarioME > 0 Then
|
|
If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventarioME, Concepto, 228, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventarioME, ImporteME:=ValorInventarioME, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=LbTipoCambio.Text.ToDecimal) Then
|
|
ValorInventario = ValorInventario - ValorInventarioME
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventario, Concepto, 229, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, ImporteME:=ValorInventarioME, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=LbTipoCambio.Text.ToDecimal) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventario, Concepto, 176, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
Else
|
|
For Each RowInv As DataRow In tmpCostos.Rows
|
|
ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal
|
|
IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ValorInventario, Concepto, 69, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
End If
|
|
|
|
|
|
|
|
IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, DtCostos.SUMD("Total"), Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total")) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If ErrorMovInv = False Then
|
|
ObjInventario.Commit()
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
Protected Sub LnkAgregarUsado_Click(sender As Object, e As EventArgs)
|
|
AgregarUsado = True
|
|
ResetModalUsados()
|
|
RegistraScript("$('#DivModalAgregar').modal()", "showmodal")
|
|
LnkModalAgregarUsado.Text = "Agregar"
|
|
UpModalAgregar.Update()
|
|
End Sub
|
|
|
|
Protected Sub LnkModalAgregarUsado_Click(sender As Object, e As EventArgs)
|
|
AgregarPS()
|
|
End Sub
|
|
|
|
Protected Sub LnkActuallizarUsado_Click(sender As Object, e As EventArgs)
|
|
ResetModalUsados()
|
|
AgregarUsado = False
|
|
|
|
LnkModalAgregarUsado.Text = "Actualizar"
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
Dim CveTamaño As Integer = DtMovimientos.Rows(GvRow.RowIndex)("CveTamaño").ToString.ToEntero
|
|
IndexDTUsado = GvRow.RowIndex
|
|
|
|
txtCantidad.Text = DtMovimientos.Rows(GvRow.RowIndex)("Cantidad").ToString
|
|
|
|
'DdlClasificacion.SelectedValueExist(DtMovimientos.Rows(GvRow.RowIndex)("CveClasificacion").ToString)
|
|
DdlProducto2.SelectedValueExist(DtMovimientos.Rows(GvRow.RowIndex)("CvePS").ToString)
|
|
|
|
CambiarProducto()
|
|
|
|
'LblMoldalTamanio.Text = DtMovimientos.Rows(GvRow.RowIndex)("Tamaño").ToString
|
|
DdlUnidad.SelectedValueExist(DtMovimientos.Rows(GvRow.RowIndex)("UnidadMedida").ToString)
|
|
txtPrecio.Text = DtMovimientos.Rows(GvRow.RowIndex)("PU").ToString
|
|
TxtObservacionesdetalle.Text = DtMovimientos.Rows(GvRow.RowIndex)("Observaciones").ToString
|
|
|
|
RegistraScript("$('#DivModalAgregar').modal()", "showmodal")
|
|
UpModalAgregar.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub ResetModalUsados()
|
|
txtCantidad.Text = ""
|
|
' DdlClasificacion.SelectedIndex = 0
|
|
DdlProducto2.SelectedIndex = 0
|
|
' LblMoldalTamanio.Text = ""
|
|
Try
|
|
DdlUnidad.SelectedIndex = 0
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
DdlUnidad.Items.Clear()
|
|
|
|
txtPrecio.Text = ""
|
|
TxtObservacionesdetalle.Text = ""
|
|
|
|
UpModalAgregar.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub RBLOpcion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLOpcion.SelectedIndexChanged
|
|
If RBLOpcion.SelectedValue.ToEntero = 3 Then
|
|
DivCliente.Visible = False
|
|
Else
|
|
DivCliente.Visible = True
|
|
End If
|
|
SiguienteFolio()
|
|
UpGenerales.Update()
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultarPendientes_Click(sender As Object, e As EventArgs)
|
|
CargaPendientesRecibir()
|
|
End Sub
|
|
|
|
Private Sub CargaPendientesRecibir()
|
|
Dim ObjVentas As New ClsVentas
|
|
If ObjVentas.GetVentasUsados(-1, DdlSubProyectos.SelectedValue.ToEntero(), TxtFechaPendientes.Text.ToDateTime(), UsuarioActual.CveEmpresa, ServicioDomicilio:=ChkServicioDomicilio.Checked) Then
|
|
GVPendientes.DataSource = ObjVentas.DtResultados
|
|
End If
|
|
ObjVentas.Dispose()
|
|
GVPendientes.DataBind()
|
|
|
|
UpGenerales.Update()
|
|
End Sub
|
|
Protected Sub BtnRecibir_Click(sender As Object, e As EventArgs)
|
|
DtMovimientos.Rows.Clear()
|
|
|
|
Me.CveRemisionRecibida = -1
|
|
Me.CveRemisionRecibida = CType(CType(sender, LinkButton).NamingContainer, GridViewRow).DataKey("CveVenta").ToEntero()
|
|
|
|
Dim DtUsados As DataTable = Nothing
|
|
Dim CveCliente As Integer = -1
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
If ObjVentas.GetVenta(CveRemisionRecibida, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
|
EsDistribuidor = CBool(ObjVentas.DtResultados.Rows(0)("EsDistribuidor").ToString())
|
|
CveCliente = ObjVentas.DtResultados.Rows(0)("CveCliente").ToString().ToEntero()
|
|
|
|
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveCliente = {0}", CveCliente))
|
|
DdlClientes.DataBind()
|
|
DdlClientes.SelectedValueExist(CveCliente)
|
|
End If
|
|
|
|
If Me.ObjFactura IsNot Nothing Then
|
|
Me.ObjFactura.Dispose()
|
|
Me.ObjFactura = Nothing
|
|
End If
|
|
|
|
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas)
|
|
|
|
|
|
'SI ES DISTRIBUIDOR VAMOS A GENERAR LA REMISION DE NOTA DE CREDITO
|
|
If EsDistribuidor Then
|
|
DivCliente.Visible = True
|
|
DdlClientes.SelectedValueExist(CveCliente)
|
|
DdlClientes_SelectedIndexChanged(DdlClientes, EventArgs.Empty)
|
|
|
|
If Me.ObjRemisionNC IsNot Nothing Then
|
|
Me.ObjRemisionNC.Dispose()
|
|
Me.ObjRemisionNC = Nothing
|
|
End If
|
|
|
|
If Me.ObjFactura IsNot Nothing Then
|
|
'CreaRemisionNC(ObjFactura.CveCliente, ObjFactura.CveSubProyecto, ObjFactura.CveMoneda)
|
|
DivTotal.Visible = True
|
|
End If
|
|
Else
|
|
'DivCliente.Visible = False
|
|
'DivFactura.Visible = False
|
|
End If
|
|
|
|
If ObjVentas.GetVentasUsadosDetalle(CveRemisionRecibida) Then
|
|
DtUsados = ObjVentas.DtResultados.Copy()
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
If DtUsados IsNot Nothing Then
|
|
|
|
'DivRecepcionApartado.Visible = True
|
|
|
|
For Each RowUsado As DataRow In DtUsados.Rows
|
|
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
|
|
|
|
Dim RowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).Rows(0)
|
|
Dim CveTamaño As Integer = RowPS("CveTamaño").ToString().ToEntero()
|
|
|
|
Dim PS As String = RowPS("PS").ToString()
|
|
Dim CveUM As Integer = RowPS("CveUnidadMedida").ToString().ToEntero()
|
|
Dim UM As String = RowPS("UnidadMedida").ToString()
|
|
Dim Cantidad As Double = RowUsado("Cantidad").ToString().ToEntero()
|
|
Dim PU As Double = RowUsado("PU").ToString().ToDouble()
|
|
|
|
AddNew(CvePS, PS, CveUM, UM, Cantidad, PU, "", "-1", "-1", "-1", "", "", DdlAlmacen.SelectedValue.ToEntero, DdlAlmacen.SelectedItem.Text, "", CveTamaño)
|
|
|
|
Next
|
|
End If
|
|
|
|
UpGenerales.Update()
|
|
End Sub
|
|
|
|
'Protected Sub DdlFactura_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
' If EsDistribuidor AndAlso Me.CveRemisionRecibida <= 0 Then
|
|
|
|
' If Me.ObjRemisionNC IsNot Nothing Then
|
|
' Me.ObjRemisionNC.Dispose()
|
|
' Me.ObjRemisionNC = Nothing
|
|
' End If
|
|
|
|
' If Me.ObjFactura IsNot Nothing Then
|
|
' Me.ObjFactura.Dispose()
|
|
' Me.ObjFactura = Nothing
|
|
' End If
|
|
|
|
' 'Dim CveVenta As Integer = DdlFactura.SelectedValue.ToEntero()
|
|
|
|
' 'ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas)
|
|
|
|
' If Me.ObjFactura IsNot Nothing Then
|
|
' CreaRemisionNC(ObjFactura.CveCliente, ObjFactura.CveSubProyecto, ObjFactura.CveMoneda)
|
|
' DivTotal.Visible = True
|
|
' End If
|
|
' End If
|
|
|
|
' UPDatos.Update()
|
|
|
|
'End Sub
|
|
|
|
Private Sub CreaRemisionNC(CveCliente As Integer, CveSubProyecto As Integer, CveMoneda As Integer)
|
|
If ObjRemisionNC IsNot Nothing Then
|
|
ObjRemisionNC.Dispose()
|
|
ObjRemisionNC = Nothing
|
|
End If
|
|
Me.ObjRemisionNC = New Modelos.Factura(UsuarioActual)
|
|
|
|
Me.ObjRemisionNC.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.HTML
|
|
Me.ObjRemisionNC.Serie = "-1"
|
|
Me.ObjRemisionNC.Folio = -1 'Folio.ToEntero()
|
|
Me.ObjRemisionNC.Version = "3.3"
|
|
Me.ObjRemisionNC.FolioFiscal = ""
|
|
Me.ObjRemisionNC.CveUsuario = UsuarioActual.CveUsuario
|
|
Me.ObjRemisionNC.CveEmpresa = UsuarioActual.CveEmpresa
|
|
Me.ObjRemisionNC.TipoCambio = 1
|
|
Me.ObjRemisionNC.ConvertirPesos = False
|
|
Me.ObjRemisionNC.CveMoneda = CveMoneda
|
|
Me.ObjRemisionNC.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", String.Format("CveMoneda = {0} ", CveMoneda))
|
|
Me.ObjRemisionNC.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", String.Format("CveMoneda = {0} ", CveMoneda))
|
|
Me.ObjRemisionNC.TipoDocto = "RNC"
|
|
Me.ObjRemisionNC.RefDocto = ""
|
|
Me.ObjRemisionNC.CveMesa = -1
|
|
Me.ObjRemisionNC.Fecha = Now
|
|
Me.ObjRemisionNC.CvePrePoliza = -1
|
|
Me.ObjRemisionNC.FechaPago = Now
|
|
Me.ObjRemisionNC.MotivoDescuento = ""
|
|
Me.ObjRemisionNC.FechaEjecucion = Now
|
|
Me.ObjRemisionNC.UsuarioCreo = UsuarioActual.Usuario
|
|
Me.ObjRemisionNC.CveCondicionEntrega = -1
|
|
Me.ObjRemisionNC.CondicionEntrega = ""
|
|
Me.ObjRemisionNC.NumeroCuenta = ""
|
|
Me.ObjRemisionNC.CondicionesPago = 0
|
|
Me.ObjRemisionNC.FormaPago = 0
|
|
Me.ObjRemisionNC.PedidoContrato = ""
|
|
Me.ObjRemisionNC.NumeroContrato = ""
|
|
Me.ObjRemisionNC.DescripcionContrato = ""
|
|
Me.ObjRemisionNC.CveCorte = -1
|
|
Me.ObjRemisionNC.TipoDocumento = "Remisión"
|
|
'NUM 1- CARGO 2- BONIFICACION
|
|
Me.ObjRemisionNC.Num1 = 1
|
|
'NUM 0- USADO 1- AJUSTE/GARANTIA
|
|
Me.ObjRemisionNC.Num2 = RblUsadosAjuste.SelectedValue.ToEntero()
|
|
Me.ObjRemisionNC.Alfa1 = ""
|
|
Me.ObjRemisionNC.Alfa2 = ""
|
|
Me.ObjRemisionNC.Alfa3 = ""
|
|
Me.ObjRemisionNC.CveContrato = -1
|
|
Me.ObjRemisionNC.ConvertirPesos = False
|
|
Me.ObjRemisionNC.CveSubProyecto = CveSubProyecto
|
|
Me.ObjRemisionNC.CveSubProyectoCobranza = CveSubProyecto
|
|
Me.ObjRemisionNC.CveSubProyectoEjecucion = CveSubProyecto
|
|
Me.ObjRemisionNC.SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero(String.Format("CveSubProyecto = {0}", CveSubProyecto)))
|
|
Me.ObjRemisionNC.SubProyectoMatriz = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1"))
|
|
|
|
'CLIENTE
|
|
Me.ObjRemisionNC.CveCliente = CveCliente
|
|
Me.ObjRemisionNC.SetCliente()
|
|
Me.ObjRemisionNC.CveAlmacen = -1
|
|
|
|
Dim ObjCliente As New ClsClientes
|
|
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
Me.ObjRemisionNC.CveFormaPago33 = ObjCliente.CveFormaPago33
|
|
Me.ObjRemisionNC.FormaPago33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("FormaPago", String.Format("CveFormaPago = {0}", ObjCliente.CveFormaPago33))
|
|
Me.ObjRemisionNC.FormaPagoSAT33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", String.Format("CveFormaPago = {0}", ObjCliente.CveFormaPago33))
|
|
|
|
Me.ObjRemisionNC.CveMetodoPago33 = ObjCliente.CveMetodoPago33
|
|
Me.ObjRemisionNC.MetodoPago33 = GlobalDTVtaMetodoPago.FiltroPrimeroValor("MetodoPago", String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33))
|
|
Me.ObjRemisionNC.ClaveMetodoPagoSAT = GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33))
|
|
|
|
Me.ObjRemisionNC.CveUsoCFDI = ObjCliente.CveUsoCFDI
|
|
Me.ObjRemisionNC.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
|
|
Me.ObjRemisionNC.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
|
|
|
|
Me.ObjRemisionNC.CveMetodoPago = ObjCliente.CveMetodoPago33
|
|
|
|
If GlobalDTMetodosPago IsNot Nothing Then
|
|
Dim DtMetodoPago = GlobalDTMetodosPago.FiltraParametros(String.Format("CveMetodoPago = {0}", ObjCliente.CveMetodoPago33))
|
|
|
|
If DtMetodoPago IsNot Nothing Then
|
|
|
|
If DtMetodoPago.Rows.Count > 0 Then
|
|
Me.ObjRemisionNC.MetodoPago = DtMetodoPago.Rows(0)("MetodoPago").ToString
|
|
Else
|
|
Me.ObjRemisionNC.CveMetodoPago = 1
|
|
Me.ObjRemisionNC.MetodoPago = "Efectivo"
|
|
End If
|
|
|
|
DtMetodoPago.Dispose()
|
|
DtMetodoPago = Nothing
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
If ObjCliente.GetSucursales(CveCliente) Then
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
Me.ObjRemisionNC.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero())
|
|
Else
|
|
Me.ObjRemisionNC.CveClienteSucursal = -1
|
|
End If
|
|
End If
|
|
ObjCliente.Dispose()
|
|
|
|
'DETALLES
|
|
Me.ObjRemisionNC.DtDetalle = CreaDTDetalleRNC()
|
|
|
|
'GUARDAR AJUSTES
|
|
Me.ObjRemisionNC.DtAjustes = TmpDTAjustes
|
|
|
|
'VALIDA PROMOCIONES Y EXISTENCIAS
|
|
Dim ObjVentas As New ClsVentas
|
|
If ObjVentas.GetPromocionesPS(-1, Now, CveSubProyecto, Me.ObjRemisionNC.CveCliente, Me.ObjRemisionNC.CveVendedor, 1, UsuarioActual.CveEmpresa) Then
|
|
Me.ObjRemisionNC.DtPromociones = ObjVentas.DtResultados.Copy()
|
|
End If
|
|
ObjVentas.Dispose()
|
|
|
|
If RblUsadosAjuste.SelectedValue = "1" Then
|
|
Me.ObjRemisionNC.Observaciones = "Descuento por garantía"
|
|
Else
|
|
Me.ObjRemisionNC.Observaciones = "Devolución por usado"
|
|
End If
|
|
Me.ObjRemisionNC.OrdenCompra = ""
|
|
Me.ObjRemisionNC.PedidoContrato = ""
|
|
Me.ObjRemisionNC.ObservacionesAlmacen = ""
|
|
|
|
'If TmpDTPolizaVirtual IsNot Nothing Then
|
|
' Me.ObjRemisionNC.DtPolizasVirtuales = TmpDTPolizaVirtual
|
|
'End If
|
|
|
|
End Sub
|
|
|
|
Private Function AddPSRNC(ByRef TmpDT As DataTable, Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
|
|
PU As Decimal, Descuento As Decimal,
|
|
CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String,
|
|
Optional Serie As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0,
|
|
Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0,
|
|
Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0,
|
|
Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional EsCargo As Boolean = False, Optional PorcentajeIVA As Decimal = 0D, Optional CveTamaño As Integer = 0) As Boolean
|
|
|
|
Dim Retorno As Boolean = False
|
|
If Not CvePS > 0 Then
|
|
Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Return False
|
|
End If
|
|
|
|
If (Obs.Length + PS.Length > 1000) Then
|
|
Alert(String.Format("El Nombre y observación del producto tiene longitud de {0} caracteres y excede los 1000 caracteres permitidos.", Obs.Length + PS.Length), TipoMensaje.MsgAdvertencia)
|
|
Return False
|
|
End If
|
|
|
|
|
|
Dim Row As DataRow = Nothing
|
|
Dim TotalCalculableImpuestos As Decimal = 0
|
|
PU = Math.Round(PU, 6) ' el precio unitario puede llevar hasta 6 decimales permitidos
|
|
|
|
Row = TmpDT.NewRow()
|
|
Row("CveProyecto") = CveProyecto
|
|
Row("Proyecto") = Proyecto
|
|
Row("CveSubProyecto") = CveSubProyecto
|
|
Row("SubProyecto") = SubProyecto
|
|
Row("Serie") = Serie
|
|
Row("TiempoEntrega") = TiempoEntrega
|
|
Row("Orden") = TmpDT.Rows.Count + 1
|
|
Row("Cantidad") = Cantidad
|
|
Row("CveUM") = CveUM
|
|
Row("UM") = UM
|
|
Row("CveClasificacion") = CveClasificacion
|
|
Row("Clasificacion") = Clasificacion
|
|
Row("CvePS") = CvePS
|
|
Row("Obs") = Obs
|
|
|
|
|
|
|
|
Dim DrPS As DataRow = Nothing
|
|
|
|
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1
|
|
|
|
If DrPS Is Nothing Then
|
|
Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Return False
|
|
End If
|
|
|
|
|
|
DrPS("IEPSPorcentaje") = 0
|
|
|
|
'verifica si tiene ventaminima
|
|
If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then
|
|
'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
|
|
If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then
|
|
Alert(String.Format("El producto se vende solo en cantidades de {0}", DrPS("VentaMinima").ToString))
|
|
Return False
|
|
End If
|
|
End If
|
|
|
|
TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento
|
|
|
|
Row("PU") = PU
|
|
Row("Codigo") = DrPS("Codigo")
|
|
Row("NoIdentificacion") = DrPS("Codigo")
|
|
Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria")
|
|
Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana")
|
|
Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion")
|
|
Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion")
|
|
Row("Consec") = TmpDT.Rows.Count + 1
|
|
|
|
Row("PS") = DrPS("PS")
|
|
Row("CodigoPS") = DrPS("PSCodigo").ToString
|
|
Row("CveTipoPS") = DrPS("CveTipoPS")
|
|
Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario")
|
|
Row("CveTamaño") = DrPS("CveTamaño")
|
|
|
|
If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion")
|
|
If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion")
|
|
|
|
Row("PorcentajeIVA") = PorcentajeIVA
|
|
|
|
Row("IVA") = Row("PorcentajeIVA")
|
|
Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, 2)
|
|
|
|
|
|
Row("ImporteRetIVA") = 0
|
|
Row("ImporteRetISR") = 0
|
|
Row("PorcentajeRetIVA") = 0
|
|
Row("PorcentajeRetISR") = 0
|
|
Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje")
|
|
Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, 2)
|
|
Row("IEPS") = Row("ImporteIEPS")
|
|
Row("Descuento") = Math.Round(Descuento, 2)
|
|
Row("TipoDescuento") = 0
|
|
Row("Total") = (Cantidad * PU)
|
|
Row("TotalImporte") = Math.Round(Cantidad * PU, 2)
|
|
'Row("AsientoContableVentas") = DrPS("AsientoContableVentas")
|
|
' Row("IdCtaContVentas") = IdCtaContable
|
|
' Row("AplicaParaConcepto") = AplicaParaConcepto
|
|
|
|
Row("SATClaveProdServ") = DrPS("SATClavePS")
|
|
Row("SATClaveUM") = DrPS("SATClaveUnidadMedida")
|
|
|
|
|
|
Row("EntregaDirecta") = EntregaDirecta
|
|
'Contratos
|
|
Row("CveContratoDetalle") = CveContratoDetalle
|
|
Row("CveVentaDetalle") = CveVentaDetalle
|
|
Row("CveMovimientoDetallePedido") = CveVentaDetalle
|
|
Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
|
|
Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
|
|
Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
|
|
Row("CveVentaDetallePedido2") = CveVentaDetallePedido2
|
|
Row("CuentaPredial") = CuentaPredial
|
|
Row("EsCargo") = EsCargo
|
|
Row("CveTamaño") = CveTamaño
|
|
|
|
'RECARGAR GV
|
|
TmpDT.Rows.Add(Row)
|
|
TmpDT.AcceptChanges()
|
|
Retorno = True
|
|
Return Retorno
|
|
|
|
End Function
|
|
Protected Function CreaDTDetalleRNC() As DataTable
|
|
Dim TmpDT = New DataTable
|
|
TmpDT.Columns.Add("CveVenta", GetType(Integer))
|
|
TmpDT.Columns.Add("Consec", GetType(Integer))
|
|
TmpDT.Columns.Add("Cantidad", GetType(Decimal))
|
|
TmpDT.Columns.Add("Codigo", GetType(String))
|
|
TmpDT.Columns.Add("CveUM", GetType(Integer))
|
|
TmpDT.Columns.Add("UM", GetType(String))
|
|
TmpDT.Columns.Add("SATClaveUM", GetType(String))
|
|
TmpDT.Columns.Add("CveClasificacion", GetType(Integer))
|
|
TmpDT.Columns.Add("Clasificacion", GetType(String))
|
|
TmpDT.Columns.Add("CvePS", GetType(Integer))
|
|
TmpDT.Columns.Add("PS", GetType(String))
|
|
TmpDT.Columns.Add("CodigoPS", GetType(String))
|
|
TmpDT.Columns.Add("SATClaveProdServ", GetType(String))
|
|
TmpDT.Columns.Add("NoIdentificacion", GetType(String))
|
|
TmpDT.Columns.Add("CveTipoPS", GetType(Integer))
|
|
TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer))
|
|
TmpDT.Columns.Add("Serie", GetType(String))
|
|
TmpDT.Columns.Add("CuentaPredial", GetType(String))
|
|
TmpDT.Columns.Add("Obs", GetType(String))
|
|
TmpDT.Columns.Add("TiempoEntrega", GetType(String))
|
|
TmpDT.Columns.Add("PU", GetType(Decimal))
|
|
TmpDT.Columns.Add("IVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("ImporteIVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal))
|
|
TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
|
|
TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal))
|
|
TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal))
|
|
TmpDT.Columns.Add("IEPS", GetType(Decimal))
|
|
TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal))
|
|
TmpDT.Columns.Add("Descuento", GetType(Decimal))
|
|
TmpDT.Columns.Add("TipoDescuento", GetType(Integer))
|
|
TmpDT.Columns.Add("TotalImporte", GetType(Decimal))
|
|
TmpDT.Columns.Add("Total", GetType(Decimal))
|
|
'Para uso del módulo contable
|
|
TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer))
|
|
TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer))
|
|
TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean))
|
|
TmpDT.Columns.Add("CveProyecto", GetType(Integer))
|
|
TmpDT.Columns.Add("Proyecto", GetType(String))
|
|
TmpDT.Columns.Add("CveSubProyecto", GetType(Integer))
|
|
TmpDT.Columns.Add("SubProyecto", GetType(String))
|
|
TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer))
|
|
|
|
'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto
|
|
TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer))
|
|
TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer))
|
|
'Contratos
|
|
TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
|
|
'Remisiones a Facturas
|
|
TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer))
|
|
TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer))
|
|
|
|
'Pedido2 a Facturas
|
|
TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer))
|
|
|
|
TmpDT.Columns.Add("Origen", GetType(Integer))
|
|
'Ordenes Servicio
|
|
TmpDT.Columns.Add("CveOS", GetType(Integer))
|
|
TmpDT.Columns.Add("CveOSDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("SeFacturara", GetType(Integer))
|
|
TmpDT.Columns.Add("Folio", GetType(Integer))
|
|
TmpDT.Columns.Add("Estatus", GetType(String))
|
|
'Ordenamiento
|
|
TmpDT.Columns.Add("Orden", GetType(Integer))
|
|
TmpDT.Columns.Add("TipoDocto", GetType(String))
|
|
'OC
|
|
TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
|
|
|
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
|
TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal))
|
|
TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal))
|
|
TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal))
|
|
TmpDT.Columns.Add("CantidadInventario", GetType(Decimal))
|
|
|
|
TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String))
|
|
TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String))
|
|
TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String))
|
|
TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String))
|
|
|
|
TmpDT.Columns.Add("CveTamaño", GetType(Integer))
|
|
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
|
|
|
|
Return TmpDT
|
|
End Function
|
|
Protected Sub CargaDTDetalleRNC()
|
|
|
|
For Each Row As GridViewRow In GvM.Rows
|
|
If Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
Dim Cantidad As Decimal = Row.DataKey("Cantidad").ToDecimal()
|
|
Dim PU As Decimal = Row.DataKey("PU").ToDecimal()
|
|
Dim CveTamaño As Integer = Row.DataKey("CveTamaño").ToEntero()
|
|
Dim SubTotal As Decimal = Cantidad * PU
|
|
|
|
Dim CveUnidadMedida As Integer = 0
|
|
Dim CveClasificacion As Integer = 0
|
|
Dim UnidadMedida As String = ""
|
|
Dim Clasificacion As String = ""
|
|
Dim PS As String = ""
|
|
Dim PorcentajeIVA As Decimal = 0D
|
|
Dim IVA As Decimal = 0D
|
|
|
|
Dim CvePS As Integer = 0
|
|
|
|
Select Case RblUsadosAjuste.SelectedValue
|
|
Case "0" ' USADOS
|
|
CvePS = Row.DataKey("CvePS").ToEntero()
|
|
Case "1" ' AJUSTE/GARANTIA
|
|
CvePS = Row.DataKey("CvePS").ToEntero()
|
|
'Dim drDatos As DataRow = GlobalDTAcumTamaños().FiltroPrimero(String.Format("CveTamaño = {0} AND CveEmpresa = {1}", CveTamaño, UsuarioActual.CveEmpresa))
|
|
|
|
'If drDatos IsNot Nothing Then
|
|
' CvePS = drDatos.Item("CvePSCargo").ToString.ToEntero
|
|
'End If
|
|
End Select
|
|
|
|
If CvePS > 0 Then
|
|
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0)
|
|
If Dr IsNot Nothing Then
|
|
CveUnidadMedida = Dr("CveUnidadMedida").ToString.ToEntero
|
|
CveClasificacion = Dr("CveClasificacion").ToString.ToEntero
|
|
PS = Dr("PSCodigo").ToString
|
|
UnidadMedida = Dr("UnidadMedida").ToString
|
|
Clasificacion = Dr("Clasificacion").ToString
|
|
End If
|
|
PorcentajeIVA = 0.16D
|
|
IVA = SubTotal * PorcentajeIVA
|
|
|
|
AddPSRNC(ObjRemisionNC.DtDetalle, Cantidad, CveUnidadMedida, UnidadMedida, CveClasificacion, Clasificacion, CvePS, PS, "", PU, 0, -1, "",
|
|
ObjRemisionNC.CveSubProyecto, ObjRemisionNC.SubProyecto.SubProyecto, PorcentajeIVA:=PorcentajeIVA, CveTamaño:=CveTamaño)
|
|
Else
|
|
Alert("No se pudo cargar el producto", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
'SI ES AJUSTE/GARANTIA
|
|
If RblUsadosAjuste.SelectedValue = "1" Then
|
|
'agrego un registro extra del importe de ajuste
|
|
Dim PU As Decimal = TmpDTAjustes.SUMD("Importe")
|
|
'CONSULTA EL CONCEPTO DE NC
|
|
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
|
|
Dim NCAjuste As Integer = -1
|
|
If ArrayNC.Length > 5 Then
|
|
NCAjuste = ArrayNC(5).ToEntero()
|
|
End If
|
|
|
|
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCAjuste, AplicaParaVenta:=1).FiltroPrimero("")
|
|
|
|
If Dr IsNot Nothing Then
|
|
Dim CveUnidadMedida, CveClasificacion, CvePS As Integer
|
|
CveUnidadMedida = Dr("CveUnidadMedida").ToString.ToEntero
|
|
CveClasificacion = Dr("CveClasificacion").ToString.ToEntero
|
|
CvePS = Dr("CvePS").ToString.ToEntero
|
|
Dim PorcentajeIVA As Decimal = 0.16D
|
|
|
|
Dim SbBCI As New StringBuilder()
|
|
SbBCI.Append("BCI: ")
|
|
'AGREGA LOS PRODUCTOS COMO OBSERVACION
|
|
For Each GvRow As GridViewRow In GvM.Rows
|
|
If GvRow.RowType = DataControlRowType.DataRow Then
|
|
SbBCI.AppendFormat("{0},", GvRow.DataKey("CodigoPS"))
|
|
End If
|
|
Next
|
|
SbBCI.Remove(SbBCI.Length - 1, 1)
|
|
|
|
Dim Obs As String = SbBCI.ToString()
|
|
|
|
If AddPSRNC(ObjRemisionNC.DtDetalle, 1, CveUnidadMedida, "", CveClasificacion, "", CvePS, "", Obs, PU, 0, -1, "",
|
|
ObjRemisionNC.CveSubProyecto, ObjRemisionNC.SubProyecto.SubProyecto, PorcentajeIVA:=PorcentajeIVA) Then
|
|
ConsecutivoVenta += 1
|
|
End If
|
|
|
|
Else
|
|
|
|
End If
|
|
End If
|
|
|
|
Dim TotalImporte As Decimal = ObjRemisionNC.DtDetalle.SUM("TotalImporte").ToDecimal()
|
|
Dim ImporteIVA As Decimal = ObjRemisionNC.DtDetalle.SUM("ImporteIVA").ToDecimal()
|
|
Dim ImporteRetIVA As Decimal = ObjRemisionNC.DtDetalle.SUM("ImporteRetIVA").ToDecimal()
|
|
Dim ImporteRetISR As Decimal = ObjRemisionNC.DtDetalle.SUM("ImporteRetISR").ToDecimal()
|
|
Dim ImporteIEPS As Decimal = ObjRemisionNC.DtDetalle.SUM("ImporteIEPS").ToDecimal()
|
|
Dim Descuento As Decimal = ObjRemisionNC.DtDetalle.SUM("Descuento").ToDecimal()
|
|
Dim Amortizacion As Decimal = 0
|
|
|
|
Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion)
|
|
|
|
'DETALLES
|
|
ObjRemisionNC.SubTotal = TotalImporte
|
|
ObjRemisionNC.Descuento = Descuento
|
|
ObjRemisionNC.Amortizacion = Amortizacion
|
|
ObjRemisionNC.IVA = ImporteIVA
|
|
ObjRemisionNC.RetIVA = ImporteRetIVA
|
|
ObjRemisionNC.RetISR = ImporteRetISR
|
|
ObjRemisionNC.IEPS = ImporteIEPS
|
|
ObjRemisionNC.Total = Total
|
|
ObjRemisionNC.TotalOtrosConceptos = 0
|
|
|
|
ObjRemisionNC.DtMovimientosUsados = DtMovimientos
|
|
ObjRemisionNC.CveAlmacen = DdlAlmacen.SelectedValue.ToEntero()
|
|
ObjRemisionNC.ObservacionesMovimiento = TxtObservaciones.Text
|
|
ObjRemisionNC.CveConceptoMovimiento = CveConcepto
|
|
End Sub
|
|
|
|
Protected Sub CargaTamaños()
|
|
Dim objAcum As New ClsAcumuladores
|
|
If objAcum.TamañoGet(-1, UsuarioActual.Empresa.CveEmpresa) Then
|
|
DtTamaños = objAcum.DtResultados.Copy()
|
|
End If
|
|
objAcum.Dispose()
|
|
End Sub
|
|
|
|
#Region "Ajustes"
|
|
Public Sub OnRblUsadosAjuste_Change(sender As Object, e As EventArgs)
|
|
DdlAlmacen.Items.Clear()
|
|
If RblUsadosAjuste.SelectedValue = "1" Then
|
|
If DdlClientes.SelectedValue <> "-1" Then
|
|
CargaAjuste()
|
|
DivAjuste.Visible = True
|
|
'Llenar el dropdownlist de almacén
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6)
|
|
CargarDescuento()
|
|
LnkAgregarUsado.Visible = False
|
|
UppAcciones.Update()
|
|
Else
|
|
Alert("hace falta seleccionar un cliente")
|
|
RblUsadosAjuste.SelectedValue = "0"
|
|
End If
|
|
Else
|
|
DivAjuste.Visible = False
|
|
'Llenar el dropdownlist de almacén
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 22)
|
|
LnkAgregarUsado.Visible = True
|
|
UppAcciones.Update()
|
|
End If
|
|
DdlAlmacen.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaAjuste()
|
|
CreaDTmpDTAjustes()
|
|
CargaPSAjuste()
|
|
CargaBCIAjuste()
|
|
CargaFolioAjuste()
|
|
CargaTipoDefecto()
|
|
CargaTipoDeUso()
|
|
TxtFechaAjuste.Attributes.Add("onchange", "CalculaMesesUso();")
|
|
TxtFechaAjuste.Text = Today.ToString("d")
|
|
End Sub
|
|
Private Sub CreaDTmpDTAjustes()
|
|
TmpDTAjustes = New DataTable
|
|
TmpDTAjustes.Columns.Add("CveFolioGarantia", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("CveTipoUso", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("CveTipoDefecto", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("CodigoTD", GetType(String))
|
|
TmpDTAjustes.Columns.Add("CodigoEnsamble", GetType(String))
|
|
TmpDTAjustes.Columns.Add("CodigoLinea", GetType(String))
|
|
TmpDTAjustes.Columns.Add("CodigoInspeccion", GetType(String))
|
|
TmpDTAjustes.Columns.Add("Consecutivo", GetType(String))
|
|
TmpDTAjustes.Columns.Add("ConsecutivoVenta", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("FechaAjuste", GetType(Date))
|
|
TmpDTAjustes.Columns.Add("Meses", GetType(String))
|
|
TmpDTAjustes.Columns.Add("PorcentajeAjuste", GetType(Double))
|
|
TmpDTAjustes.Columns.Add("TipoComprobante", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("Comprobante", GetType(String))
|
|
TmpDTAjustes.Columns.Add("Importe", GetType(Double))
|
|
TmpDTAjustes.Columns.Add("CvePS", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("PS", GetType(String))
|
|
TmpDTAjustes.Columns.Add("Cantidad", GetType(Decimal))
|
|
TmpDTAjustes.Columns.Add("CveUM", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("CveVenta", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("PUFactura", GetType(Double))
|
|
TmpDTAjustes.Columns.Add("CveBCIAjuste", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("Etiqueta", GetType(String))
|
|
TmpDTAjustes.Columns.Add("CveClienteDistribuidor", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("CveModeloAuto", GetType(Integer))
|
|
TmpDTAjustes.Columns.Add("Año", GetType(String))
|
|
End Sub
|
|
Private Sub CargaPSAjuste()
|
|
DdlPSAjuste.setEsWebService(True)
|
|
DdlPSAjuste.Attributes.Add("data-cvesubproyecto", "-1")
|
|
DdlPSAjuste.ddlWS.Attributes.Add("data-cveclasificacion", "-1")
|
|
DdlPSAjuste.ddlWS.Attributes.Add("data-pagina", "ventas/ventas")
|
|
DdlPSAjuste.ddlWS.Attributes.Add("data-Estatus", "1")
|
|
DdlPSAjuste.ddlWS.Attributes.Add("data-aplicaparaventa", "1")
|
|
End Sub
|
|
|
|
Protected Sub DdlPSAjuste_selectedindexchange(sender As Object, e As EventArgs)
|
|
If DdlPSAjuste.SelectedValue.ToEntero > 0 Then
|
|
Dim CvePSParametro As Integer = DdlPSAjuste.SelectedValue.ToEntero
|
|
Dim CveMarca As Integer = -1
|
|
Dim CveClasificacion As Integer = -1
|
|
Dim PrecioSugerido As Decimal = 0
|
|
Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("")
|
|
|
|
If drPS IsNot Nothing Then
|
|
Dim CvePrecioListaPS As Integer = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=DdlClientes.SelectedValue.ToEntero).FiltroPrimeroValor("CvePrecioLista").ToEntero()
|
|
If CvePrecioListaPS > 0 Then
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioListaPS, CvePS:=CvePSParametro) Then
|
|
PrecioSugerido = ObjPS.DtResultados.FiltroPrimeroValor("PrecioLista").ToDecimal
|
|
End If
|
|
ObjPS.Dispose()
|
|
End If
|
|
Dim PS As String = drPS("PS").ToString
|
|
CveMarca = drPS("CveMarca").ToString.ToEntero
|
|
CveClasificacion = drPS("CveClasificacion").ToString.ToEntero
|
|
|
|
Dim Arr = PS.Split("-"c)
|
|
If Arr.Count > 1 Then
|
|
If (DdlBCIAjuste.Items.FindByText(Arr(1).ToString) IsNot Nothing) Then
|
|
DdlBCIAjuste.SelectedValueExist(DdlBCIAjuste.Items.FindByText(Arr(1).ToString).Value)
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
HdnPSAjusteMarca.Value = CveMarca.ToString()
|
|
HdnPSAjusteClasificacion.Value = CveClasificacion.ToString()
|
|
|
|
If DdlAlmacen.SelectedValue.ToEntero() <= 0 Then
|
|
Alert("Debe seleccionar un almacen de tipo garantía", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim CveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue}").ToEntero
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(404).ToEntero > 0 Then 'cuando el valor es 10.- secuencia Cliente/Sucursal, 20 - sucursal/cliente
|
|
Dim TipoPrecioLista As Integer = UsuarioActual.Empresa.Funcionalidad(404).ToEntero
|
|
' si es 10. primero el cliente
|
|
Dim CvePrecioListaPS As Integer
|
|
Dim PorcentajePrecio As Decimal = 0
|
|
|
|
If TipoPrecioLista = 10 Then
|
|
CvePrecioListaPS = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=DdlClientes.SelectedValue.ToEntero()).FiltroPrimeroValor("CvePrecioLista").ToEntero()
|
|
If CvePrecioListaPS <= 0 Then
|
|
CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero()
|
|
End If
|
|
Else
|
|
CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=CveSubProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero()
|
|
If CvePrecioListaPS <= 0 Then
|
|
CvePrecioListaPS = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=DdlClientes.SelectedValue.ToEntero()).FiltroPrimeroValor("CvePrecioLista").ToEntero()
|
|
End If
|
|
End If
|
|
|
|
If CvePrecioListaPS > 0 Then
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioListaPS, CvePS:=CvePSParametro) Then
|
|
PrecioSugerido = ObjPS.DtResultados.FiltroPrimeroValor("PrecioLista").ToDecimal
|
|
PorcentajePrecio = ObjPS.DtResultados.FiltroPrimeroValor("Porcentaje").ToDecimal
|
|
End If
|
|
ObjPS.Dispose()
|
|
End If
|
|
|
|
If PrecioSugerido = 0 Then
|
|
Dim ObjInventarios As New ClsInventarios
|
|
Dim CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, txtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, CveSubProyecto, CveTipoAlmacen:=1)
|
|
'si el costo es cero, puede ser que no halla movimientos del producto, en esa sucursal. y se volverá a sacar sin especificar sucursal
|
|
If CostoPS = 0 Then CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, txtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1)
|
|
ObjInventarios.Dispose()
|
|
If CostoPS > 0 And PorcentajePrecio > 0 Then
|
|
PrecioSugerido = ((PorcentajePrecio / 100) + 1) * CostoPS
|
|
End If
|
|
End If
|
|
'CvePrecioLista = CvePrecioListaPS
|
|
End If
|
|
|
|
Dim MarcaPorcentaje As DataRow = DtPorcentajeMarcas.FiltroPrimero(String.Format("CveMarca = {0}", drPS("CveMarca").ToString))
|
|
If MarcaPorcentaje IsNot Nothing Then
|
|
Dim PorcentajeProducto As Decimal = MarcaPorcentaje("PorcentajeProducto").ToString.ToDecimal / 100
|
|
Dim PorcentajeProducto2 As Decimal = MarcaPorcentaje("PorcentajeProducto2").ToString.ToDecimal / 100
|
|
Dim PorcentajeProducto3 As Decimal = MarcaPorcentaje("PorcentajeProducto3").ToString.ToDecimal / 100
|
|
|
|
If PorcentajeProducto > 0 Then
|
|
|
|
Dim MontoDescuento As Decimal = PrecioSugerido * PorcentajeProducto
|
|
PrecioSugerido -= MontoDescuento
|
|
|
|
If PorcentajeProducto2 > 0 Then
|
|
|
|
MontoDescuento = PrecioSugerido * PorcentajeProducto2
|
|
PrecioSugerido -= MontoDescuento
|
|
|
|
If PorcentajeProducto3 > 0 Then
|
|
MontoDescuento = PrecioSugerido * PorcentajeProducto3
|
|
PrecioSugerido -= MontoDescuento
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
txtPrecio.Text = PrecioSugerido.FormatoNumero(2)
|
|
TxtPUFactura.Text = PrecioSugerido.FormatoNumero(2)
|
|
End If
|
|
UpModalAgregar.Update()
|
|
UpAjuste.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaBCIAjuste()
|
|
DdlBCIAjuste.Items.Clear()
|
|
Dim ObjGral As New ClsGenerales
|
|
If ObjGral.BCIUsadoGet(UsuarioActual.CveEmpresa) Then
|
|
DdlBCIAjuste.DataSource = ObjGral.DtResultados
|
|
DdlBCIAjuste.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
ObjGral.Dispose()
|
|
DdlBCIAjuste.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaFolioAjuste()
|
|
DdlFolioGarantia.Items.Clear()
|
|
Dim ObjAcum As New ClsAcumuladores
|
|
If ObjAcum.FoliosGarantiaGet(-1, UsuarioActual.CveEmpresa, Estatus:=1, Area:=2) Then
|
|
DdlFolioGarantia.DataSource = ObjAcum.DtResultados
|
|
DdlFolioGarantia.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
ObjAcum.Dispose()
|
|
DdlFolioGarantia.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub DdlFolioGarantia_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFolioGarantia.SelectedIndexChanged
|
|
Dim ObjAcumuladores As New ClsAcumuladores
|
|
If ObjAcumuladores.GetNuevoConsecutivoFolio(DdlFolioGarantia.SelectedValue.ToEntero) Then
|
|
Dim resultado As String = ObjAcumuladores.DtResultados.FiltroPrimeroValor("NuevoConsecutivo")
|
|
TxtConsecutivoAjuste.Text = (resultado.ToEntero + 1).ToString
|
|
End If
|
|
ObjAcumuladores.Dispose()
|
|
|
|
Dim FolioGarantia As MFolioGarantiaMensaje = ValidaFolioGarantia(DdlPSAjuste.SelectedValue.ToEntero(), DdlFolioGarantia.SelectedValue.ToEntero())
|
|
|
|
If Not FolioGarantia.Valido Then
|
|
Alert($"El folio de garantía no es valido.<br/> Clasificacion del Producto:{FolioGarantia.ClasificacionPS}.<br/>Tipo Folio:{FolioGarantia.TipoFolio}", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function ValidaFolioGarantia(CvePS As Integer, CveFolioGarantia As Integer) As MFolioGarantiaMensaje
|
|
Dim Retorno As New MFolioGarantiaMensaje
|
|
|
|
Dim Valido As Boolean = False
|
|
Dim TipoFolio As String = ""
|
|
Dim ListaClasificacionesPermitidas As New List(Of Integer)
|
|
|
|
Dim ObjAcumuladores As New ClsAcumuladores
|
|
If ObjAcumuladores.FoliosGarantiaGet(CveFolioGarantia, UsuarioActual.CveEmpresa, Area:=-1) AndAlso ObjAcumuladores.DtResultados.Rows.Count > 0 Then
|
|
Dim Row As DataRow = ObjAcumuladores.DtResultados.Rows(0)
|
|
TipoFolio = Row("tipoFolio").ToString().ToUpper()
|
|
End If
|
|
ObjAcumuladores.Dispose()
|
|
|
|
Dim CveClasificacionPS As Integer = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveClasificacion").ToEntero()
|
|
Dim ClasificacionPS As String = GlobalDTClasificaciones(CveEmpresa:=UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionPS).FiltroPrimeroValor("Clasificacion").ToString()
|
|
Select Case TipoFolio
|
|
Case "GENERAL"
|
|
ListaClasificacionesPermitidas.Add(20520) 'ACUM. AUTOMOTRIZ
|
|
ListaClasificacionesPermitidas.Add(20522) 'ACUM. ESPECIALES
|
|
ListaClasificacionesPermitidas.Add(20513) 'ACUM. ESTANDAR
|
|
ListaClasificacionesPermitidas.Add(20521) 'ACUM. PESADO
|
|
ListaClasificacionesPermitidas.Add(20512) 'ACUM. PREMIUM
|
|
ListaClasificacionesPermitidas.Add(20514) 'ACUM. VALUE
|
|
ListaClasificacionesPermitidas.Add(20229) 'Acumulador
|
|
Case "OPTIMA"
|
|
'20511 ACUM. OPTIMA
|
|
ListaClasificacionesPermitidas.Add(20511) 'ACUM. OPTIMA
|
|
Case "MOTOBATERIA"
|
|
'20517 MOTOBATERIAS
|
|
ListaClasificacionesPermitidas.Add(20517) 'MOTOBATERIAS
|
|
End Select
|
|
|
|
If ListaClasificacionesPermitidas.Contains(CveClasificacionPS) Then
|
|
Valido = True
|
|
End If
|
|
|
|
Retorno.CvePS = CvePS
|
|
Retorno.CveFolioGarantia = CveFolioGarantia
|
|
Retorno.CveClasificacionPS = CveClasificacionPS
|
|
Retorno.ClasificacionPS = ClasificacionPS
|
|
Retorno.TipoFolio = TipoFolio
|
|
Retorno.Valido = Valido
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
Protected Sub CargaTipoDeUso()
|
|
DdlTipoUso.Items.Clear()
|
|
DdlTipoUso.DataSource = GlobalDTAcumTiposUso.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}")
|
|
DdlTipoUso.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlTipoUso.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub DdlTipoUso_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CalculaPorcentajeAjuste()
|
|
End Sub
|
|
|
|
Protected Sub CargaTipoDefecto()
|
|
DdlTipoDefecto.DataSource = GlobalDTAcumTiposDefecto.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}")
|
|
DdlTipoDefecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlTipoDefecto.DataBind()
|
|
End Sub
|
|
Private Sub CalculaPorcentajeAjuste()
|
|
Try
|
|
|
|
If DdlAlmacen.SelectedValue.ToEntero() <= 0 Then
|
|
Alert("Debe seleccionar un almacen de tipo garantía", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlTipoUso.SelectedValue.ToEntero > 0 AndAlso DdlPSAjuste.SelectedValue.ToEntero > 0 AndAlso TxtMesesUso.Text <> "" Then
|
|
Dim CveMarca As Integer = -1
|
|
|
|
CveMarca = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).FiltroPrimeroValor("CveMarca", "").ToEntero
|
|
|
|
Dim ObjAcum As New ClsAcumuladores
|
|
If ObjAcum.GarantiasMesesGet(-1, UsuarioActual.CveEmpresa, CveMarca, DdlTipoUso.SelectedValue.ToEntero, TxtMesesUso.Text.ToEntero) Then
|
|
If ObjAcum.DtResultados.Rows.Count > 0 Then
|
|
TxtPorcentajeAjuste.Text = (ObjAcum.DtResultados.Rows(0)("Valor").ToString.ToDouble / 100.0).FormatoNumero
|
|
|
|
TxtImporteAjuste.Text = (TxtPorcentajeAjuste.Text.ToDecimal * TxtPUFactura.Text.ToDecimal).FormatoNumero
|
|
|
|
Dim CargoVendido As Decimal = 0
|
|
Dim CargoGarantia As Decimal = 0
|
|
Dim CveTamaño As Integer = 0
|
|
|
|
If DdlPSAjuste.SelectedValue.ToEntero > 0 Then
|
|
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).FiltroPrimero("")
|
|
If Dr IsNot Nothing Then
|
|
CargoGarantia = Dr("Cargo").ToString.ToDecimal
|
|
End If
|
|
End If
|
|
|
|
If DdlPSAjuste.SelectedValue.ToEntero > 0 Then
|
|
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).FiltroPrimero("")
|
|
If Dr IsNot Nothing Then
|
|
CveTamaño = Dr("CveTamaño").ToString.ToEntero
|
|
End If
|
|
End If
|
|
|
|
Dim DrCargo As DataRow = GlobalDTAcumTamaños.FiltroPrimero($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTamaño = {CveTamaño}")
|
|
If DrCargo IsNot Nothing Then
|
|
|
|
CargoVendido = DrCargo("Cargo").ToString.ToDecimal
|
|
|
|
End If
|
|
|
|
'el ajuste no puede ser mayor al precio de lo vendido de nuevo
|
|
If (txtPrecio.Text.ToDouble - ((TxtPUFactura.Text.ToDouble - TxtImporteAjuste.Text.ToDouble) - (CargoVendido - CargoGarantia))) < 0 Then
|
|
|
|
TxtImporteAjuste.Text = "0.00"
|
|
CargoGarantia = CargoVendido
|
|
End If
|
|
TxtImporteAjuste.ToolTip = $"La diferencia de ajuste fue: {(txtPrecio.Text.ToDouble - TxtImporteAjuste.Text.ToDouble).FormatoNumero()}. La diferencia de tamaños fue: {(CargoVendido - CargoGarantia).FormatoNumero}."
|
|
TxtImporteAjuste.Text = ((TxtPUFactura.Text.ToDouble - TxtImporteAjuste.Text.ToDouble) - (CargoVendido - CargoGarantia)).FormatoNumero
|
|
|
|
Else
|
|
'cuando no está registrada, no da ajuste
|
|
TxtImporteAjuste.ToolTip = "El producto no tiene ajuste en ese periodo"
|
|
TxtImporteAjuste.Text = "0.00"
|
|
End If
|
|
End If
|
|
ObjAcum.Dispose()
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al recalcular el costo", ex)
|
|
End Try
|
|
|
|
UpAjuste.Update()
|
|
End Sub
|
|
Private Sub GuardaAjuste()
|
|
|
|
Dim CargoAnterior As Double = 0
|
|
Dim CargoActual As Double = 0
|
|
|
|
Dim Row As DataRow = Nothing
|
|
|
|
ConsecutivoVenta += 1
|
|
|
|
Row = TmpDTAjustes.NewRow
|
|
Row("CveFolioGarantia") = DdlFolioGarantia.SelectedValue.ToEntero
|
|
Row("CveTipoUso") = DdlTipoUso.SelectedValue.ToEntero
|
|
Row("CveTipoDefecto") = DdlTipoDefecto.SelectedValue.ToEntero
|
|
Row("CodigoTD") = TxtCodigoTD.Text
|
|
Row("CodigoEnsamble") = TxtCodEnsamble.Text
|
|
Row("CodigoLinea") = TxtCodLinea.Text
|
|
Row("CodigoInspeccion") = TxtCodInspeccion.Text
|
|
Row("Consecutivo") = TxtConsecutivoAjuste.Text
|
|
Row("FechaAjuste") = TxtFechaAjuste.Text.ToDate
|
|
Row("Meses") = TxtMesesUso.Text.ToEntero
|
|
Row("PorcentajeAjuste") = TxtPorcentajeAjuste.Text.ToDouble
|
|
Row("TipoComprobante") = 1
|
|
Row("Comprobante") = TxtPoliza.Text
|
|
Row("Importe") = TxtImporteAjuste.Text.ToDouble
|
|
Row("ConsecutivoVenta") = ConsecutivoVenta
|
|
Row("CvePS") = DdlPSAjuste.SelectedValue
|
|
Row("PS") = DdlPSAjuste.SelectedText
|
|
Row("CveVenta") = -1
|
|
Row("PUFactura") = TxtPUFactura.Text.ToDouble
|
|
Row("Cantidad") = 1
|
|
Dim CveUM As Integer = -1
|
|
If DdlPSAjuste.SelectedValue.ToEntero > 0 Then
|
|
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlPSAjuste.SelectedValue.ToEntero).Rows(0)
|
|
If Dr IsNot Nothing Then
|
|
CveUM = Dr("CveUnidadMedida").ToString.ToEntero
|
|
CargoAnterior = Dr("Cargo").ToString.ToDouble
|
|
End If
|
|
End If
|
|
Row("CveUM") = CveUM
|
|
Row("CveVentaDetalle") = -1
|
|
Row("CveBCIAjuste") = DdlBCIAjuste.SelectedValue.ToEntero()
|
|
Row("Etiqueta") = TxtEtiqueta.Text.TrimStart.TrimEnd
|
|
Row("CveClienteDistribuidor") = -1
|
|
Row("CveModeloAuto") = -1
|
|
Row("Año") = ""
|
|
TmpDTAjustes.Rows.Add(Row)
|
|
|
|
|
|
End Sub
|
|
Protected Sub BtnCalculaMesesUso_Click(sender As Object, e As EventArgs)
|
|
CalculaMesesUso()
|
|
End Sub
|
|
Protected Sub BtnCalcularImporteAjuste_Click(sender As Object, e As EventArgs)
|
|
CalculaPorcentajeAjuste()
|
|
End Sub
|
|
|
|
Private Sub CalculaMesesUso()
|
|
Dim FechaI As Date = TxtFechaAjuste.Text.ToDate.AddDays(1)
|
|
Dim FechaF As Date = Now
|
|
Dim Dia As Integer = FechaI.Day
|
|
'validación adicional, para saber si el mes tiene 31 días y el actua es menor.
|
|
If FechaI.Day > Today.LastDayOfMonth.Day Then Dia = Today.LastDayOfMonth.Day
|
|
Dim FechaT As Date = String.Format("{0}/{1}/{2}", Dia, FechaF.Month, FechaF.Year).ToDate 'armo la fecha con el día del mes actual
|
|
|
|
Dim MesesTrascurridos As Integer = Math.Round(DateDiff(DateInterval.Day, FechaI, FechaT) / 30.4, 2).ToEntero 'saco los meses y lo redondeo
|
|
|
|
If FechaT > FechaF Then
|
|
'todavía está en el mes actual.
|
|
MesesTrascurridos = MesesTrascurridos
|
|
Else
|
|
MesesTrascurridos = MesesTrascurridos + 1
|
|
End If
|
|
TxtMesesUso.Text = MesesTrascurridos.ToString
|
|
CalculaPorcentajeAjuste()
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarProductoAjuste_Click(sender As Object, e As EventArgs)
|
|
Dim CvePS As Integer = DdlPSAjuste.SelectedValue.ToEntero
|
|
|
|
Dim FolioGarantia As MFolioGarantiaMensaje = ValidaFolioGarantia(CvePS, DdlFolioGarantia.SelectedValue.ToEntero())
|
|
|
|
If Not FolioGarantia.Valido Then
|
|
Alert($"El folio de garantía no es valido.<br/> Clasificacion del Producto:{FolioGarantia.ClasificacionPS}.<br/>Tipo Folio:{FolioGarantia.TipoFolio}", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
Try
|
|
Dim CveTamaño As Integer = -1
|
|
If ObjPS.GetPS(CvePS, -1, UsuarioActual.CveEmpresa) Then
|
|
CveTamaño = ObjPS.DtResultados.FiltroPrimeroValor("CveTamaño").ToEntero
|
|
End If
|
|
Dim drDatos As DataRow = GlobalDTAcumTamaños().FiltroPrimero(String.Format("CveTamaño = {0} AND CveEmpresa = {1}", CveTamaño, UsuarioActual.CveEmpresa))
|
|
|
|
Dim Importe As Decimal = 0
|
|
Dim drTamañoPS As DataRow = Nothing
|
|
|
|
DtMovimientos.Rows.Clear()
|
|
|
|
' USADOS
|
|
If drDatos IsNot Nothing Then
|
|
If RblUsadosAjuste.SelectedValue = "0" Then
|
|
CvePS = drDatos.Item("CvePSCargo").ToString.ToEntero
|
|
End If
|
|
Importe = drDatos("Cargo").ToString.ToDecimal
|
|
Else
|
|
Importe = TxtImporteAjuste.Text.ToDecimal
|
|
End If
|
|
|
|
'AJUSTE/GARANTIA
|
|
If RblUsadosAjuste.SelectedValue = "1" Then
|
|
CvePS = DdlPSAjuste.SelectedValue.ToEntero
|
|
End If
|
|
|
|
If CvePS > 0 Then
|
|
If ObjPS.GetPS(CvePS, -1, UsuarioActual.CveEmpresa) Then
|
|
drTamañoPS = ObjPS.DtResultados.FiltroPrimero("")
|
|
'CveTamaño = -1 'limpio esta variable para que no se registre dos veces en la clase Modelos
|
|
AddNew(drTamañoPS.Item("CvePS").ToString.ToEntero, drTamañoPS.Item("PSCodigo").ToString, drTamañoPS.Item("CveUM").ToString.ToEntero, drTamañoPS.Item("UnidadMedida").ToString, 1.0, Importe,
|
|
"", "-1", "-1", "-1", "", "", -1, "", "", CveTamaño)
|
|
End If
|
|
Else
|
|
Alert("No se pudo cargar el producto", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al agregar el producto", ex)
|
|
End Try
|
|
ObjPS.Dispose()
|
|
|
|
GuardaAjuste()
|
|
|
|
'If TmpDTPolizaVirtual Is Nothing Then
|
|
' CreaDTmpDTPolizaVirtual()
|
|
'End If
|
|
End Sub
|
|
|
|
Protected Sub CargarDescuento()
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPorcentajeMarcas(DdlClientes.SelectedValue.ToEntero) Then
|
|
DtPorcentajeMarcas = ObjPS.DtResultados.Copy()
|
|
End If
|
|
ObjPS.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
Protected Sub SeleccionarTipoDeClientes(sender As Object, e As EventArgs)
|
|
DdlClientes.Items.Clear()
|
|
InicializaClientes(ChkClientesTodos.Checked)
|
|
End Sub
|
|
|
|
Protected Sub DdlTipoDefecto_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlTipoDefecto.SelectedIndexChanged
|
|
If DdlTipoDefecto.SelectedValue.ToEntero = 17 Then
|
|
DivCodigoTD.Visible = True
|
|
DdlTipoDefecto.Width = New Unit(140%)
|
|
Else
|
|
DivCodigoTD.Visible = False
|
|
DdlTipoDefecto.Width = New Unit(200%)
|
|
End If
|
|
End Sub
|
|
Protected Sub DdlMarcaPSAjuste_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaPSAjuste(-1, DdlPSAjuste, CveMarca:=DdlMarcaPSAjuste.SelectedValue.ToEntero())
|
|
UpAjuste.Update()
|
|
End Sub
|
|
Private Sub CargaPSAjuste(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost, Optional AplicaAlmacen As Boolean = True, Optional CveMarca As Integer = -1)
|
|
Objeto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(141).ToString = "1")
|
|
If Not UsuarioActual.Empresa.Funcionalidad(141).ToString = "1" Then
|
|
Objeto.ddl.Items.Clear()
|
|
Objeto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, Estatus:=1, AplicaParaVenta:=1)
|
|
Objeto.ddl.DataBind()
|
|
Objeto.ddl.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2"))
|
|
Objeto.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
|
|
Else
|
|
Dim CveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue}")
|
|
|
|
Objeto.Attributes.Add("data-cvesubproyecto", CveSubProyecto)
|
|
'Objeto.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString)
|
|
Objeto.ddlWS.Attributes.Add("data-cveclasificacion", "-1")
|
|
Objeto.ddlWS.Attributes.Add("data-aplicaparaventa", "1")
|
|
|
|
If AplicaAlmacen Then
|
|
Objeto.ddlWS.Attributes.Add("data-pagina", "ventas/ventas")
|
|
Else
|
|
Objeto.ddlWS.Attributes.Add("data-pagina", "-1")
|
|
End If
|
|
Objeto.ddlWS.Attributes.Add("data-aplicaparaventa", "1")
|
|
Objeto.ddlWS.Attributes.Add("data-cvemarca", CveMarca.ToString)
|
|
Objeto.ddlWS.Attributes.Add("data-Estatus", "1")
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnPDFHistorial_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
Dim MarcaPS As String = ""
|
|
If ObjPS.GetPS(DdlPSAjuste.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then
|
|
MarcaPS = ObjPS.DtResultados.FiltroPrimeroValor("Marca", String.Format("CvePS = {0}", DdlPSAjuste.SelectedValue.ToEntero))
|
|
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 DtDatos As New DataTable
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
|
|
|
|
'Informacion Distribuidor
|
|
If (DdlClientes.SelectedValue.ToEntero > 0) Then
|
|
|
|
Dim DatosClienteSeleccionado As DataRow = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCliente = {0}", DdlClientes.SelectedValue))
|
|
Dim CiudadEstado As String = ""
|
|
Dim Telefono As String = ""
|
|
Dim Nombre As String = ""
|
|
|
|
If DatosClienteSeleccionado IsNot Nothing Then
|
|
CiudadEstado = String.Format("{0}, {1}", DatosClienteSeleccionado("Ciudad"), DatosClienteSeleccionado("Estado"))
|
|
Telefono = DatosClienteSeleccionado("Telefono").ToString
|
|
Nombre = DatosClienteSeleccionado("Nombre").ToString
|
|
End If
|
|
|
|
params.Add(New ReportParameter("NombreDistribuidor", Nombre))
|
|
params.Add(New ReportParameter("CiudadEstado", CiudadEstado))
|
|
params.Add(New ReportParameter("TelCliente", Telefono))
|
|
|
|
End If
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("Consec", TxtConsecutivoAjuste.Text.Trim))
|
|
params.Add(New ReportParameter("FolioAcuse", If(DdlFolioGarantia.SelectedValue.ToEntero = -1, "", DdlFolioGarantia.SelectedItem.Text)))
|
|
|
|
'Informacion de Garantia o ajuste
|
|
params.Add(New ReportParameter("FechaInst", TxtFechaAjuste.Text.Trim))
|
|
params.Add(New ReportParameter("Fecha", Now.ToShortDateString))
|
|
params.Add(New ReportParameter("Defecto", If(DdlTipoDefecto.SelectedValue.ToEntero = -1, "", DdlTipoDefecto.SelectedItem.Text)))
|
|
params.Add(New ReportParameter("MesesUso", TxtMesesUso.Text.Trim))
|
|
params.Add(New ReportParameter("PorcentajeAjuste", TxtPorcentajeAjuste.Text.Trim))
|
|
|
|
'Informacion Acumulador
|
|
params.Add(New ReportParameter("CodEnsamble", TxtCodEnsamble.Text.Trim))
|
|
params.Add(New ReportParameter("CodLinea", TxtCodLinea.Text.Trim))
|
|
params.Add(New ReportParameter("CodInspeccion", TxtCodInspeccion.Text.Trim))
|
|
params.Add(New ReportParameter("Tipo", DdlBCIAjuste.SelectedItem.Text))
|
|
params.Add(New ReportParameter("Marca", MarcaPS))
|
|
params.Add(New ReportParameter("Etiqueta", TxtEtiqueta.Text))
|
|
|
|
'Informacion Vehiculo
|
|
params.Add(New ReportParameter("MarcaAuto", ""))
|
|
params.Add(New ReportParameter("TipoAuto", ""))
|
|
|
|
'Informacion Consumidor
|
|
'Informacion Distribuidor
|
|
'If (CveCliente > 0) Then
|
|
|
|
' Dim DatosClienteSeleccionado As DataRow = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCliente = {0}", DdlDistribuidor.SelectedValue.ToEntero))
|
|
' Dim Nombre As String = ""
|
|
' Dim Ciudad As String = ""
|
|
' Dim Estado As String = ""
|
|
' Dim Direccion As String = ""
|
|
' Dim Telefono As String = ""
|
|
|
|
' If DatosClienteSeleccionado IsNot Nothing Then
|
|
' Nombre = DatosClienteSeleccionado("Nombre").ToString
|
|
' Ciudad = DatosClienteSeleccionado("Ciudad").ToString
|
|
' Estado = DatosClienteSeleccionado("Estado").ToString
|
|
' Direccion = DatosClienteSeleccionado("Direccion").ToString
|
|
' Telefono = DatosClienteSeleccionado("Telefono").ToString
|
|
' End If
|
|
|
|
' params.Add(New ReportParameter("NombreCliente", Nombre))
|
|
' params.Add(New ReportParameter("Direccion", Direccion))
|
|
' params.Add(New ReportParameter("CiudadEstadoConsumidor", String.Format("{0}, {1}", Ciudad, Estado)))
|
|
' params.Add(New ReportParameter("TelConsumidor", Telefono))
|
|
'End If
|
|
|
|
|
|
params.Add(New ReportParameter("NombreCliente", ""))
|
|
params.Add(New ReportParameter("Direccion", ""))
|
|
params.Add(New ReportParameter("CiudadEstadoConsumidor", ""))
|
|
params.Add(New ReportParameter("TelConsumidor", ""))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
params.Add(New ReportParameter("Anio", ""))
|
|
params.Add(New ReportParameter("Comprobante", TxtPoliza.Text))
|
|
params.Add(New ReportParameter("CodigoTD", TxtCodigoTD.Text))
|
|
|
|
ImprimirPDF("Empresas/Grales/Formatos/Ajuste.rdlc", DtDatos, params, "Reporte de Ajuste", "PDF")
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaMarcasFiltro()
|
|
|
|
Using ObjMarcas As New ClsProductosServicios
|
|
If ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa) Then
|
|
DdlMarcaPSAjuste.DataSource = ObjMarcas.DtResultados
|
|
DdlMarcaRem.DataSource = ObjMarcas.DtResultados
|
|
End If
|
|
End Using
|
|
|
|
DdlMarcaPSAjuste.DataBind()
|
|
DdlMarcaRem.DataBind()
|
|
|
|
DdlMarcaPSAjuste.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
DdlMarcaRem.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
|
|
UpAjuste.Update()
|
|
End Sub
|
|
|
|
#Region "P O L I Z A - V I R T U A L"
|
|
Private Sub CreaDTmpDTPolizaVirtual()
|
|
TmpDTPolizaVirtual = New DataTable
|
|
TmpDTPolizaVirtual.Columns.Add("CvePS", GetType(Integer))
|
|
TmpDTPolizaVirtual.Columns.Add("Cantidad", GetType(Decimal))
|
|
TmpDTPolizaVirtual.Columns.Add("PU", GetType(Decimal))
|
|
TmpDTPolizaVirtual.Columns.Add("Descuento", GetType(Decimal))
|
|
TmpDTPolizaVirtual.Columns.Add("Total", GetType(Decimal))
|
|
TmpDTPolizaVirtual.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
TmpDTPolizaVirtual.Columns.Add("TipoServicio", GetType(Integer))
|
|
TmpDTPolizaVirtual.Columns.Add("TipoPoliza", GetType(Integer))
|
|
TmpDTPolizaVirtual.Columns.Add("CveModeloAuto", GetType(Integer))
|
|
TmpDTPolizaVirtual.Columns.Add("AnioVehiculo", GetType(Integer))
|
|
TmpDTPolizaVirtual.Columns.Add("TieneUsado", GetType(Boolean))
|
|
TmpDTPolizaVirtual.Columns.Add("FechaUsado", GetType(DateTime))
|
|
TmpDTPolizaVirtual.Columns.Add("CvePSUsado", GetType(Integer))
|
|
TmpDTPolizaVirtual.Columns.Add("CveBCIUsado", GetType(Integer))
|
|
End Sub
|
|
Private Function AddPolizaVirtual(CvePS As Integer) As Boolean
|
|
|
|
Dim Retorno As Boolean = True
|
|
|
|
'If Modalidad = "U" Then
|
|
' If TmpDTPolizaVirtual.Rows.Count > 0 Then
|
|
' Dim Elimino As Boolean = False
|
|
' For Each RowPoliza As DataRow In TmpDTPolizaVirtual.Rows
|
|
' If RowPoliza("CvePS").ToString().ToEntero() = CvePS Then
|
|
' RowPoliza.Delete()
|
|
' Elimino = True
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
' If Elimino Then
|
|
' TmpDTRecepcionUsados.AcceptChanges()
|
|
' End If
|
|
' End If
|
|
'End If
|
|
|
|
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
|
|
|
If DrPS IsNot Nothing Then
|
|
'SOLO DEBE AGREGAR POLIZA VIRTUAL SI ES ACUMULADOR
|
|
If Not DrPS("CveClasificacion").ToString().ToEntero().Contiene(20520, 20522, 20513, 20511, 20521, 20512, 20514, 20229) Then
|
|
Return Retorno
|
|
End If
|
|
Else
|
|
Retorno = False
|
|
Return Retorno
|
|
End If
|
|
|
|
Dim Cantidad As Decimal = 1
|
|
Dim PU As Decimal = txtPrecio.Text.ToDecimal()
|
|
Dim Descuento As Decimal = 0
|
|
Dim ImporteAjuste As Decimal = TxtImporteAjuste.Text.ToDecimal().RoundSQL(2)
|
|
|
|
Dim Total As Decimal = ((Cantidad * PU) - Descuento).RoundSQL(2)
|
|
Dim TipoServicio As Integer = -1
|
|
Dim FechaUsado As DateTime = If(TxtFechaAjuste.Text.ToDateTime() < MinFecha, Now, TxtFechaAjuste.Text.ToDateTime())
|
|
Dim CveModeloAuto As Integer = -1
|
|
Dim AnioVehiculo As Integer = 0
|
|
Dim TipoPoliza As Integer = 1 'VENTA
|
|
|
|
If Total = ImporteAjuste Then
|
|
TipoPoliza = 3 'GARANTIA
|
|
Else
|
|
TipoPoliza = 2 'AJUSTE
|
|
End If
|
|
|
|
'Dim TieneUsado As Boolean = GvRecepcionUsados.Rows.Cast(Of GridViewRow).Any(Function(GvRow) GvRow.RowType = DataControlRowType.DataRow AndAlso GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() > 0)
|
|
Dim CvePSUsado As Integer = -1
|
|
Dim CveBCIUsado As Integer = -1
|
|
|
|
'If TieneUsado Then
|
|
' For Each GvRow As GridViewRow In GvRecepcionUsados.Rows
|
|
' If GvRow.RowType = DataControlRowType.DataRow Then
|
|
' If GvRow.FCTextBox("TxtCantidad").Text.ToDecimal() > 0 Then
|
|
' CvePSUsado = GvRow.DataKey("CvePSCargo").ToEntero()
|
|
' CveBCIUsado = GvRow.FCDropDownList("DdlBCIUsado").SelectedValue.ToEntero()
|
|
|
|
' Exit For
|
|
' End If
|
|
' End If
|
|
' Next
|
|
'End If
|
|
|
|
Dim Row As DataRow = TmpDTPolizaVirtual.NewRow()
|
|
Row("CvePS") = CvePS
|
|
Row("Cantidad") = Cantidad
|
|
Row("PU") = PU
|
|
Row("Descuento") = Descuento
|
|
Row("Total") = Total
|
|
Row("CveVentaDetalle") = -1
|
|
Row("TipoServicio") = TipoServicio
|
|
Row("TipoPoliza") = TipoPoliza
|
|
Row("CveModeloAuto") = CveModeloAuto
|
|
Row("AnioVehiculo") = AnioVehiculo
|
|
Row("TieneUsado") = 1
|
|
Row("FechaUsado") = FechaUsado
|
|
Row("CvePSUsado") = CvePSUsado
|
|
Row("CveBCIUsado") = CveBCIUsado
|
|
|
|
TmpDTPolizaVirtual.Rows.Add(Row)
|
|
|
|
Return Retorno
|
|
End Function
|
|
#End Region
|
|
|
|
|
|
Partial Class MFolioGarantiaMensaje
|
|
Public Property CvePS As Integer
|
|
Public Property CveClasificacionPS As Integer
|
|
Public Property ClasificacionPS As String
|
|
Public Property CveFolioGarantia As Integer
|
|
Public Property TipoFolio As String
|
|
|
|
Public Property Valido As Boolean
|
|
End Class
|
|
|
|
End Class
|