5518 lines
264 KiB
VB.net
5518 lines
264 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.IO
|
|
Imports Extensiones
|
|
|
|
'Imports DocumentFormat.OpenXml.Wordprocessing
|
|
|
|
Partial Class Inventarios_EntradasSalidas
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
|
|
Private _dtDatos As DataTable
|
|
Private Property NumRow As Integer
|
|
|
|
Public Property DtMovimientos() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientos") = 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 DtMovimientosEntradaCambioVigencias() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientosEntradaCambioVigencias"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientosEntradaCambioVigencias") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DtMovimientosCambioVigencias() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientosCambioVigencias"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientosCambioVigencias") = 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
|
|
Public Property EsNuevoMov As Boolean
|
|
Get
|
|
Return CBool(ViewState("EsNuevoMov").ToString)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsNuevoMov") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property IndexSeccionAlmacen As Integer
|
|
Get
|
|
Return CType(ViewState("IndexSeccionAlmacen"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IndexSeccionAlmacen") = value
|
|
End Set
|
|
End Property
|
|
Private Property CantidadTotal As Decimal
|
|
Get
|
|
Return CType(ViewState("CantidadTotal"), Decimal)
|
|
End Get
|
|
Set(value As Decimal)
|
|
ViewState("CantidadTotal") = value
|
|
End Set
|
|
End Property
|
|
Private Property CvePS As Integer
|
|
Get
|
|
Return CType(ViewState("CvePS"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePS") = value
|
|
End Set
|
|
End Property
|
|
Private Property Tipo As Integer
|
|
Get
|
|
Return CType(ViewState("Tipo"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("Tipo") = value
|
|
End Set
|
|
End Property
|
|
Private Property CvePrePoliza As Integer
|
|
Get
|
|
Return CType(ViewState("CvePrePoliza"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePrePoliza") = value
|
|
End Set
|
|
End Property
|
|
Private Property DescripcionDetalladaEliminar As String
|
|
Get
|
|
Return CType(ViewState("DescripcionDetalladaEliminar"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("DescripcionDetalladaEliminar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property CveMovimientoDetalleEdit() As Integer
|
|
Get
|
|
Return IfNull(ViewState("CveMovimientoDetalleEdit"), 0).ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMovimientoDetalleEdit") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveAFEdit() As Integer
|
|
Get
|
|
Return ViewState("CveAFEdit").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAFEdit") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property AplicaVigenciaCambioVigencia() As Boolean
|
|
Get
|
|
If ViewState("CveAFEdit") Is Nothing Then
|
|
ViewState("CveAFEdit") = False
|
|
End If
|
|
Return Boolean.Parse(ViewState("CveAFEdit").ToString)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("CveAFEdit") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
|
|
If Not IsPostBack Then
|
|
|
|
If UsuarioActual.CveUsuario = 100 AndAlso IfNull(Request("Regenera"), "").ToString = "1" Then
|
|
RegeneraRM(Request("CveMovimiento").ToString.ToEntero, 119)
|
|
Exit Sub
|
|
End If
|
|
|
|
CveMovimiento = -1
|
|
CveMovimientoRelacionado = -1
|
|
TieneRelacionado = -1
|
|
TieneSalida = False
|
|
EstatusAlmacenCompra = -1
|
|
EsConsumoInterno = False
|
|
EsNuevoMov = False
|
|
CvePrePoliza = -1
|
|
|
|
CreaDT()
|
|
CargaCombos()
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
TxtFechaInvFisico.Text = Now.ToShortDateString
|
|
RVFecha.MaximumValue = Now.ToShortDateString
|
|
|
|
If Not UsuarioActual.CveEmpresa = 48 Then
|
|
TxtFecha.Enabled = False
|
|
ImgFecha.Visible = False
|
|
End If
|
|
|
|
|
|
CantidadTotal = 0
|
|
IndexSeccionAlmacen = 0
|
|
Tipo = 0
|
|
|
|
'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
|
|
|
|
If Request("CveMovimiento") IsNot Nothing AndAlso Request("CveMovimiento").ToString.ToEntero > 0 Then
|
|
If UsuarioActual.CveRol = 1 AndAlso UsuarioActual.CveEmpresa = 140 Then
|
|
LnkGenerarVirtual.Visible = True
|
|
End If
|
|
|
|
CargaDatos(Request("CveMovimiento").ToString.ToEntero)
|
|
'CargaGvPaqueteria()
|
|
Else
|
|
AsignacionOpcion()
|
|
SiguienteFolio()
|
|
End If
|
|
|
|
'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
|
|
|
|
InicializaClientes()
|
|
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
|
|
|
|
If Request("CveEntregaAlmacen") IsNot Nothing AndAlso Request("CveEntregaAlmacen").ToString.ToEntero > 0 Then
|
|
CargaDatosEntregaAlmacen(Request("CveEntregaAlmacen").ToString.ToEntero)
|
|
End If
|
|
|
|
|
|
'BLOQUEA PERMISOS
|
|
BtnGuardar.Enabled = PermiteGuardar()
|
|
BtnEliminar.Enabled = PermiteEliminar()
|
|
BtnContabilizar.Enabled = PermiteContabilizar()
|
|
BtnNuevo.Enabled = PermiteCrearNuevo()
|
|
LnkCambioInventarioFisico.Visible = UsuarioActual.TienePermisoProceso(312)
|
|
|
|
If CveMovimiento > 0 Then
|
|
PermisoVerImportes()
|
|
End If
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(281).ToEntero = 1 Then
|
|
|
|
TxtFecha.Enabled = False
|
|
ImgFecha.Visible = False
|
|
|
|
TxtFechaInvFisico.Enabled = False
|
|
ImgFechaInvFisico.Visible = False
|
|
|
|
UpGenerales.Update()
|
|
UpModalInventarioFisico.Update()
|
|
|
|
End If
|
|
|
|
'HABILITA EL CAMBIO DE VIGENCIAS
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
LnkCambioVigencia.Visible = True
|
|
End If
|
|
|
|
If EsConsumoInterno AndAlso UsuarioActual.TienePermisoProceso(340) Then
|
|
TxtFecha.Enabled = True
|
|
ImgFecha.Visible = True
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#Region " PERMISOS PAGINAS "
|
|
Private Function PermiteGuardar() As Boolean
|
|
Return 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)
|
|
' tdPU.Visible = TienePermisoImportes
|
|
' tdTxtPU.Visible = TienePermisoImportes
|
|
GvM.Columns(4).Visible = TienePermisoImportes
|
|
|
|
ThTotal.Visible = TienePermisoImportes
|
|
TdTotal.Visible = TienePermisoImportes
|
|
GvM.Columns(5).Visible = TienePermisoImportes
|
|
End Sub
|
|
|
|
Private Sub CargaDdlPaqueteria()
|
|
'DdlPaqueteria.DataSource = GlobalDTPaqueterias
|
|
'DdlPaqueteria.DataBind()
|
|
'DdlPaqueteria.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
End Sub
|
|
#End Region
|
|
|
|
Sub AsignacionOpcion()
|
|
DdlConcepto.SelectedValueExist("-1")
|
|
If UsuarioActual.CveEmpresa.Contiene(66, 13) Then
|
|
TrSubProyectoActivoFijo.Visible = True
|
|
VisualizaAF(True)
|
|
CargaSubProyectos()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function isWhitFamily() As Boolean
|
|
Return (UsuarioActual.CveEmpresa = 66)
|
|
End Function
|
|
|
|
#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("AplicaCaducidad", Type.GetType("System.String"))
|
|
|
|
dt.Columns.Add("Observaciones")
|
|
dt.Columns.Add("CountMovimientoEntradaDetalle")
|
|
dt.Columns.Add("TotalExtranjero", Type.GetType("System.Double"))
|
|
dt.Columns.Add("CveCultivoCuadroDetalle", Type.GetType("System.Int32"))
|
|
|
|
CargaGVM(dt)
|
|
|
|
DtMovimientos = dt.Clone
|
|
|
|
DtMovimientosEntradaInvFisico = dt.Clone
|
|
DtMovimientosSalidaInvFisico = dt.Clone
|
|
|
|
DtMovimientosCambioVigencias = dt.Clone
|
|
DtMovimientosCambioVigencias.Columns.Add("CvePSVigencia", Type.GetType("System.Int32"))
|
|
DtMovimientosCambioVigencias.Columns.Add("CodigoPSVigencia", Type.GetType("System.String"))
|
|
DtMovimientosCambioVigencias.Columns.Add("CveUMVigencia", Type.GetType("System.Int32"))
|
|
|
|
|
|
End Sub
|
|
Private Sub CargaCombos()
|
|
'Llenar el dropdownlist de Secciones
|
|
If UsuarioActual.CveEmpresa = 66 Then
|
|
DdlClasificacion.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion")
|
|
Else
|
|
Dim ObjClasificaciones As New ClsClasificaciones
|
|
If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then
|
|
DdlClasificacion.DataSource = ObjClasificaciones.DtResultados
|
|
End If
|
|
ObjClasificaciones.Dispose()
|
|
End If
|
|
DdlClasificacion.DataBind()
|
|
|
|
'DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1)
|
|
'DdlSeccionAlmacen.DataBind()
|
|
|
|
DdlSeccionAlmacenEntrada.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1)
|
|
DdlSeccionAlmacenEntrada.DataBind()
|
|
|
|
DdlSeccionAlmacenSalida.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1)
|
|
DdlSeccionAlmacenSalida.DataBind()
|
|
|
|
'Llenar el dropdownlist de monedas
|
|
DdlMoneda.DataSource = GlobalDTMonedas
|
|
DdlMoneda.DataBind()
|
|
|
|
'MOVIMIENTO
|
|
DdlConcepto.DataSource = GlobalDTInvConceptos.FiltraParametros(IIf(UsuarioActual.CveEmpresa.Contiene(72, 80, 1), "CveConcepto NOT IN (4,5,10)", "CveConcepto NOT IN (1,2,4,5,8,9,10,12,26,27,29)").ToString)
|
|
DdlConcepto.DataBind()
|
|
|
|
'FILTRO
|
|
DdlCConcepto.DataSource = GlobalDTInvConceptos.FiltraParametros("CveConcepto NOT IN (4,5)")
|
|
DdlCConcepto.DataBind()
|
|
|
|
|
|
'Llenar el dropdownlist de almacén
|
|
If Not IfNull(Request("CI"), -1).ToString.ToEntero > 0 AndAlso Not IfNull(Request("CveEntregaAlmacen"), -1).ToString.ToEntero > 0 Then
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
'ElseIf UsuarioActual.CveUsuario.Contiene(1) Then
|
|
' DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11) or CveAlmacen = 651e") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
|
|
End If
|
|
|
|
If IfNull(Request("CI"), -1).ToString.ToEntero > 0 And UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)")
|
|
End If
|
|
|
|
DdlAlmacenInventarioFisico.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlAlmacenCambioVigencias.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)")
|
|
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlAlmacenInventarioFisico.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlAlmacenCambioVigencias.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
DdlAlmacenInventarioFisico.SelectedValue = "-1"
|
|
DdlAlmacenCambioVigencias.SelectedValue = "-1"
|
|
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacenInventarioFisico.DataBind()
|
|
DdlAlmacenCambioVigencias.DataBind()
|
|
|
|
If IsNothing(Request("CveMovimiento")) And IsNothing(Request("CveEntregaAlmacen")) Then
|
|
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
|
DdlAlmacen_SelectedIndexChanged(DdlAlmacen, EventArgs.Empty)
|
|
End If
|
|
|
|
If DdlAlmacen.SelectedValue.ToEntero = -1 Then
|
|
DdlConcepto.Items.Clear()
|
|
DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
|
|
|
|
CargaPS()
|
|
|
|
' CargaDdlPaqueteria()
|
|
|
|
End Sub
|
|
Private Sub CargaPS()
|
|
DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
DdlPSSalida.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
DdlPSCambioSalida.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
If UsuarioActual.CveEmpresa = 66 Then
|
|
DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios")
|
|
End If
|
|
|
|
If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then
|
|
DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2")
|
|
DdlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2")
|
|
DdlPSSalida.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2")
|
|
DdlPSCambioSalida.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2")
|
|
|
|
DdlProducto2.DataBind()
|
|
DdlPS.DataBind()
|
|
DdlPSSalida.DataBind()
|
|
DdlPSCambioSalida.DataBind()
|
|
|
|
DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlPSSalida.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlPSCambioSalida.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub CargaSubProyectos()
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto)
|
|
'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 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 "
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
|
|
GvM.EditIndex = -1
|
|
LimpiarMovimiento()
|
|
CargaDatos(-1, DdlCConcepto.SelectedValue.ToEntero(), TxtCFolio.Text.ToEntero)
|
|
End Sub
|
|
Private Sub CargaDatos(tCveMovimiento As Integer, Optional pCveConcepto As Integer = -1, Optional pFolio As Integer = -1)
|
|
Dim Mov As New ClsInventarios
|
|
DtMovimientos.Clear()
|
|
TieneSalida = False
|
|
EstatusAlmacenCompra = -1
|
|
|
|
If UsuarioActual.CveEmpresa = 48 Then
|
|
GvM.Columns(8).Visible = False
|
|
End If
|
|
|
|
If Mov.GetMovimientos(tCveMovimiento, pCveConcepto, pFolio, UsuarioActual.CveEmpresa) AndAlso Mov.DtResultados.Rows.Count = 1 Then
|
|
|
|
CveMovimiento = Mov.CveMovimiento
|
|
DtMov = Mov.DtResultados
|
|
TxtFecha.Text = Mov.Fecha.ToShortDateString
|
|
TxtHoraInicio.SelectedTime = Mov.Fecha
|
|
EstatusAlmacenCompra = Mov.EstatusAlmacenCompra
|
|
Folio = Mov.Folio
|
|
Dim drM As DataRow = DtMov.Rows(0)
|
|
|
|
If DtMov.Rows(0)("CveConcepto").ToString.ToEntero = 2 Then
|
|
HplTraspaso.Visible = True
|
|
HplTraspaso.NavigateUrl = $"/Inventarios/TraspasoAlmacen.aspx?CveEntrada={DtMov.Rows(0)("CveMovimiento").ToString}"
|
|
End If
|
|
'DATOS DE REGISTRO
|
|
DivRegistro.Visible = True
|
|
LnkAgregarNuevoMov.Visible = True
|
|
LblUsuarioRegistro.Text = Mov.NombreCapturo
|
|
LblFechaRegistro.Text = Mov.FechaRegistro.ToShortDateString
|
|
|
|
If DtMov.Rows(0)("CvePrePoliza").ToString.ToEntero > 0 Then
|
|
HplPrePoliza.Visible = True
|
|
HplPrePoliza.NavigateUrl = String.Format("/Contabilidad/RegPrePoliza.aspx?CvePrePoliza={0}", DtMov.Rows(0)("CvePrePoliza"))
|
|
CvePrePoliza = DtMov.Rows(0)("CvePrePoliza").ToString.ToEntero
|
|
Else
|
|
If UsuarioActual.CveRol = 1 Then
|
|
BtnGeneraPrepoliza.Visible = True
|
|
End If
|
|
End If
|
|
|
|
'DATOS DE CONSIGNACION
|
|
If DtMov.Rows(0)("SerieFolio").ToString.Length > 0 Then
|
|
RowConsignacion.Visible = True
|
|
'LbConsignacion.Text = DtMov.Rows(0)("SerieFolio").ToString
|
|
HLConsignacion.Text = DtMov.Rows(0)("SerieFolio").ToString
|
|
HLConsignacion.NavigateUrl = String.Format("/Inventarios/Consignaciones.aspx?CveConsignacion={0}", DtMov.Rows(0)("CveConsignacion").ToString)
|
|
End If
|
|
|
|
'TIPO CAMBIO
|
|
If DtMov.Rows(0)("TipoCambio").ToString.Length > 0 Then
|
|
RowTipoCambio.Visible = True
|
|
LbTipoCambio.Text = DtMov.Rows(0)("TipoCambio").ToString
|
|
End If
|
|
Dim TMDsTR = DtMov.Rows(0)("CveMtoRel").ToString
|
|
If DtMov.Rows(0)("CveMtoRel").ToString.Length > 0 Then
|
|
RowMtoRel.Visible = True
|
|
|
|
lnkMtoRelaioando.NavigateUrl = "./EntradasSalidas.aspx?CveMovimiento=" & DtMov.Rows(0)("CveMtoRel").ToString
|
|
'lnkMtoRelaioando.Attributes.Add("hreh", "./EntradasSalidas.aspx?CveMoviento=" & DtMov.Rows(0)("CveMtoRel").ToString)
|
|
'lnkMtoRelaioando.Attributes.Add("target", "_blank")
|
|
Else
|
|
RowMtoRel.Visible = False
|
|
End If
|
|
|
|
If (DdlAlmacen.Items.FindByValue(Mov.CveAlmacen.ToString()) Is Nothing) Then
|
|
Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveEstatus:=-1).FiltroPrimero(String.Format("CveAlmacen = {0}", Mov.CveAlmacen))
|
|
If dr IsNot Nothing Then
|
|
DdlAlmacen.Items.Insert(0, New ListItem(dr("Almacen").ToString, dr("CveAlmacen").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString
|
|
DdlAlmacen.Enabled = False
|
|
End If
|
|
End If
|
|
|
|
DdlAlmacen.SelectedValue = Mov.CveAlmacen.ToString
|
|
|
|
DdlMoneda.SelectedValue = Mov.CveMoneda.ToString
|
|
|
|
'DATOS MONEDA EXTRANJERA
|
|
DdlMonedaTC.SelectedValue = Mov.CveMoneda.ToString
|
|
If DdlMonedaTC.SelectedValue.ToEntero = 2 Then
|
|
DivTipoCambio.Visible = True
|
|
TxtTipoCambio.Text = Mov.TipoCambio.ToString.FormatoNumero
|
|
DdlMonedaTC_SelectedIndexChanged(DdlMonedaTC, EventArgs.Empty)
|
|
|
|
DdlMonedaTC.Enabled = False
|
|
TxtTipoCambio.Enabled = False
|
|
|
|
VisualizaPUExtranjero(UsuarioActual.TienePermisoProceso(201))
|
|
Else
|
|
DivTipoCambio.Visible = False
|
|
VisualizaPUExtranjero(False)
|
|
End If
|
|
|
|
TxtGuia.Text = Mov.Guia
|
|
TxtObservaciones.Text = Mov.Observaciones
|
|
TxtResponsable.Text = Mov.Recibio
|
|
|
|
If Mov.CveAlmacenDestino > 0 Then
|
|
divDestino.Visible = True
|
|
LtlAlmacenDestino.Text = Mov.AlmacenDestino
|
|
If DtMov.Rows(0)("Origen").ToString = "1" Then
|
|
LblDestino.Text = "Origen:"
|
|
End If
|
|
End If
|
|
|
|
CveMovimientoRelacionado = Mov.CveMovimientoRelacionado
|
|
FolioRelacionado = Mov.FolioRelacionado
|
|
TieneRelacionado = Mov.TieneRelacionado
|
|
ConceptoRelacionado = Mov.ConceptoRelacionado
|
|
|
|
'sino existe el movimiento
|
|
If (DdlConcepto.Items.FindByValue(Mov.CveConcepto.ToString()) Is Nothing) Then
|
|
Dim dr As DataRow = GlobalDTInvConceptos.FiltroPrimero(String.Format("CveConcepto = {0}", Mov.CveConcepto))
|
|
DdlConcepto.Items.Insert(0, New ListItem(dr("Concepto").ToString, dr("CveConcepto").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString
|
|
End If
|
|
|
|
DdlConcepto.SelectedValue = Mov.CveConcepto.ToString
|
|
ddlConcepto_SelectedIndexChanged(DdlConcepto, EventArgs.Empty)
|
|
|
|
TxtFolio.Text = Mov.Folio.ToString
|
|
HdnIdPoliza.Value = Mov.IDPoliza.ToString
|
|
HplImprimir.Visible = True
|
|
HplImprimir.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
|
|
|
|
HplImprimirResumen.Visible = True
|
|
HplImprimirResumen.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=Almr&CveMovimiento={0}", CveMovimiento)))
|
|
|
|
CveCompra = Mov.CveCompra
|
|
CveConcepto = Mov.CveConcepto
|
|
|
|
If drM("CveEstatusTimbrado").ToString.ToEntero > 0 Then
|
|
HplDescargaXml.Visible = True
|
|
HplDescargaXml.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimiento, "XML", drM("TimbreSerieFolio"), "Tra")))
|
|
|
|
If drM("AplicaCP").ToString = "True" Then
|
|
HplCartaPorteTimbre.Visible = True
|
|
HplCartaPorteTimbre.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CARPOTIMBRE&CVEMOV={0}&CVETIMBRE={1}", CveMovimiento, drM("CveTimbre"))))
|
|
Else
|
|
HplDescargaPdf.Visible = True
|
|
HplDescargaPdf.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}&CVETIMBRE={4}", CveMovimiento, "PDF", drM("TimbreSerieFolio"), "Tra", drM("CveTimbre"))))
|
|
|
|
HplCartaPorte.Visible = True
|
|
HplCartaPorte.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimiento)))
|
|
End If
|
|
|
|
|
|
If UsuarioActual.CveRol = 1 Then
|
|
LnkGenerarPDF.Visible = True
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If CveConcepto.Contiene(3, 8) Then
|
|
LiLnkGuias.Visible = True
|
|
End If
|
|
|
|
|
|
If Mov.IDPoliza > 0 Then HplPoliza.Visible = True : HplPoliza.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", Mov.IDPoliza)
|
|
|
|
If CveConcepto = 6 Or CveConcepto = 7 Then
|
|
If Mov.DtResultados(0)("Nombre").ToString() <> "" Then
|
|
LtTipo.Text = Mov.DtResultados(0)("Nombre").ToString()
|
|
LblTipo.InnerText = "Cliente:"
|
|
ElseIf Mov.DtResultados(0)("RazonSocial").ToString() <> "" Then
|
|
LtTipo.Text = Mov.DtResultados(0)("RazonSocial").ToString()
|
|
LblTipo.InnerText = "Proveedor:"
|
|
Else
|
|
LtTipo.Text = Mov.NombreCompleto
|
|
LblTipo.InnerText = "Personal"
|
|
End If
|
|
TrTipoCargado.Visible = True
|
|
TrPersonal.Visible = False
|
|
End If
|
|
|
|
|
|
|
|
If Mov.CveSubProyecto > 0 Then
|
|
|
|
'verifico si existe
|
|
If (DdlSubProyecto.Items.FindByValue(Mov.CveSubProyecto.ToString()) Is Nothing) Then
|
|
Dim dr As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=Mov.CveSubProyecto, Estatus:=-1).FiltroPrimero("")
|
|
DdlSubProyecto.Items.Insert(0, New ListItem(dr("SubProyecto").ToString, dr("CveSubProyecto").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString
|
|
End If
|
|
|
|
DdlSubProyecto.SelectedValue = Mov.CveSubProyecto.ToString
|
|
TrSubProyectoActivoFijo.Visible = True
|
|
End If
|
|
|
|
'LblCodigo.Text = If(Mov.CodigoAF = 0, "-1", Mov.CodigoAF.ToString)
|
|
'HdnCveActivoFijo.Value = If(Mov.CveActivoFijo = 0, "-1", Mov.CveActivoFijo.ToString)
|
|
|
|
If Mov.CveCompra > 0 Then
|
|
HplCompra.Visible = True
|
|
HplCompra.Text = DtMov.Rows(0)("SerieFolioCompra").ToString
|
|
If UsuarioActual.TienePermisoProceso(201) Then
|
|
HplCompra.NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", Mov.CveCompra)
|
|
End If
|
|
End If
|
|
|
|
If Mov.CveVenta > 0 Then
|
|
HplVenta.Visible = True
|
|
HplVenta.Text = DtMov.Rows(0)("FolioVenta").ToString
|
|
If UsuarioActual.TienePermisoProceso(201) Then
|
|
HplVenta.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", Mov.CveVenta)
|
|
End If
|
|
End If
|
|
|
|
If Mov.CveOrdenCompraLiga > 0 Then
|
|
HplOrdenCompra.Visible = True
|
|
HdnCveOrdenCompra.Value = Mov.CveOrdenCompraLiga.ToString
|
|
HplOrdenCompra.Text = DtMov.Rows(0)("FolioOC").ToString
|
|
If UsuarioActual.TienePermisoProceso(201) Then
|
|
HplOrdenCompra.NavigateUrl = String.Format("/OC/OC.aspx?OC={0}", Mov.CveOrdenCompraLiga)
|
|
End If
|
|
End If
|
|
|
|
If Mov.IDPoliza = 0 AndAlso UsuarioActual.Empresa.UsaAC Then
|
|
BtnContabilizar.Visible = PermiteContabilizar()
|
|
Else
|
|
BtnContabilizar.Visible = False
|
|
End If
|
|
|
|
VisualizaPU(True)
|
|
|
|
If DtMov.Rows(0)("Remision").ToString.Length > 0 Then
|
|
TxtRemision.Text = DtMov.Rows(0)("Remision").ToString
|
|
DivRemision.Visible = True
|
|
End If
|
|
|
|
'Carga Cliente y ClienteSucursal
|
|
If Mov.CveCliente > 0 Then
|
|
If DdlClientes.Items.FindByValue(Mov.CveCliente.ToString()) Is Nothing Then
|
|
Dim dr As DataRow = GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=Mov.CveCliente, Estatus:=-1).FiltroPrimero("")
|
|
If dr IsNot Nothing Then
|
|
DdlClientes.Items.Insert(0, New ListItem(dr("NombreComercial").ToString, dr("CveCliente").ToString))
|
|
End If
|
|
End If
|
|
DivCliente.Visible = True
|
|
DdlClientes.Enabled = False
|
|
DdlClientes.SelectedValueExist(Mov.CveCliente.ToString)
|
|
|
|
End If
|
|
|
|
If Mov.CveVendedor > 0 Then
|
|
LblVendedor.Text = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Mov.CveVendedor))
|
|
DivVendedor.Visible = True
|
|
End If
|
|
|
|
|
|
'carga personal
|
|
If Mov.CvePersonal > 0 Then
|
|
DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa, CvePersonal:=Mov.CvePersonal)
|
|
DdlPersonal.DataBind()
|
|
DdlPersonal.SelectedValueExist(Mov.CvePersonal)
|
|
DdlPersonal.Enabled = False
|
|
TrPersonal.Visible = True
|
|
End If
|
|
|
|
If Mov.CveClienteSucursal > 0 Then
|
|
CambiaCliente()
|
|
|
|
'INSERTA SUCURSAL
|
|
If (DdlClientesSucursales.Items.FindByValue(Mov.CveClienteSucursal.ToString()) Is Nothing) Then
|
|
Dim ObjCliente As New ClsClientes
|
|
If ObjCliente.GetSucursales(Mov.CveCliente.ToString().ToEntero, Mov.CveClienteSucursal) Then
|
|
Dim dr As DataRow = ObjCliente.DtResultados.FiltroPrimero(String.Format("CveClienteSucursal = {0}", Mov.CveClienteSucursal))
|
|
If dr IsNot Nothing Then
|
|
DdlClientesSucursales.Items.Insert(0, New ListItem(dr("SucursalCliente").ToString, dr("CveClienteSucursal").ToString))
|
|
End If
|
|
End If
|
|
ObjCliente.Dispose()
|
|
End If
|
|
DdlClientesSucursales.Enabled = False
|
|
DdlClientesSucursales.SelectedValueExist(Mov.CveClienteSucursal.ToString)
|
|
End If
|
|
|
|
|
|
DivDepartamentoEntrega.Visible = True
|
|
TxtDepartamentoEntrega.Enabled = False
|
|
TxtDepartamentoEntrega.Text = Mov.DepartamentoEntrega
|
|
|
|
TxtPedidoContrato.Enabled = False
|
|
TxtPedidoContrato.Text = Mov.PedidoContrato
|
|
|
|
If Mov.CveProveedor > 0 Then
|
|
DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa, Mov.CveProveedor)
|
|
DdlProveedor.DataBind()
|
|
DdlProveedor.SelectedValueExist(Mov.CveProveedor)
|
|
DdlProveedor.Enabled = False
|
|
TrProveedor.Visible = True
|
|
End If
|
|
|
|
'cargar también los movimentos detalle
|
|
If Mov.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
|
|
DtMovimientos = Mov.DtResultados
|
|
|
|
DtMovimientos.Columns("No").AutoIncrement = True
|
|
DtMovimientos.Columns("No").AutoIncrementSeed = DtMovimientos.Rows.Count + 1
|
|
DtMovimientos.Columns("No").AutoIncrementStep = 1
|
|
|
|
Dim keys(1) As DataColumn
|
|
keys(0) = DtMovimientos.Columns("No")
|
|
DtMovimientos.PrimaryKey = keys
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
End If
|
|
|
|
PermisoVerImportes()
|
|
|
|
If IfNull(Request("Conta"), "0").ToString = "1" Then
|
|
Contabilizar()
|
|
End If
|
|
|
|
|
|
Else
|
|
Alert("Movimiento No encontrado", TipoMensaje.MsgError)
|
|
|
|
TxtObservaciones.Text = ""
|
|
TxtFolio.Text = ""
|
|
BtnGuardar.Visible = False
|
|
BtnEliminar.Visible = False
|
|
BtnContabilizar.Visible = False
|
|
|
|
DivRegistro.Visible = False
|
|
DivTipoCambio.Visible = False
|
|
|
|
CargaGVM(Nothing)
|
|
GvM.Columns(8).Visible = False
|
|
GvM.DataBind()
|
|
CveMovimiento = 0
|
|
End If
|
|
|
|
BtnGuardar.Visible = PermiteGuardar()
|
|
If UsuarioActual.TienePermisoProceso(182) Then
|
|
If TieneSalida Or TieneRelacionado > 0 Or EstatusAlmacenCompra = 2 Then
|
|
DivMensaje.Visible = True
|
|
BtnEliminar.Enabled = False
|
|
BtnEliminar.Visible = False
|
|
LtMensaje.Text = "El movimiento no se puede eliminar porque uno de sus conceptos ya tiene salida y/o el movimiento esta relacionado con otro."
|
|
Else
|
|
BtnEliminar.Visible = True
|
|
BtnEliminar.Enabled = True
|
|
If CveMovimientoRelacionado > 0 Then
|
|
BtnEliminar.ToolTip = $"El movimiento esta relacionado con el Folio de <b>{ConceptoRelacionado}</b> No. <b><a href = ""/Inventarios/EntradasSalidas.aspx?CveMovimiento={CveMovimientoRelacionado}"" target=""_blank"">{FolioRelacionado}</a></b> <br/><br/> ¿Esta seguro de eliminar los dos movimientos?"
|
|
End If
|
|
LtMensaje.Text = ""
|
|
End If
|
|
Else
|
|
BtnEliminar.Visible = False
|
|
End If
|
|
|
|
'BLOQUEA FECHA CUANDO YA SE TIENE POLIZA
|
|
If HdnIdPoliza.Value.ToEntero > 0 And Not PermiteGuardar() Then
|
|
TxtFecha.Enabled = False
|
|
ImgFecha.Enabled = False
|
|
Else
|
|
TxtFecha.Enabled = True
|
|
ImgFecha.Enabled = True
|
|
TxtObservaciones.Enabled = True
|
|
End If
|
|
|
|
Dim ObjContabilidad As New ClsContabilidad
|
|
If ObjContabilidad.GetPrePoliza(CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
|
Dim dr As DataRow = ObjContabilidad.DtResultados.FiltroPrimero("")
|
|
If dr IsNot Nothing Then
|
|
If dr("IdPoliza").ToString.ToEntero > 0 Then
|
|
BtnEliminar.Visible = False
|
|
End If
|
|
End If
|
|
End If
|
|
ObjContabilidad.Dispose()
|
|
|
|
'SI TIENE PREPOLIZA NO SE DEBE PODER EDITAR
|
|
If Mov.TienePrePoliza > 0 Then
|
|
'[IPP] Se invalida por necesidad de JAM de modificar fechas para cuadrar con CIFRA - 19Abril2018
|
|
'BtnGuardar.Visible = False
|
|
End If
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(281).ToEntero = 1 Then
|
|
|
|
TxtFecha.Enabled = False
|
|
ImgFecha.Visible = False
|
|
|
|
TxtFechaInvFisico.Enabled = False
|
|
ImgFechaInvFisico.Visible = False
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
UpModalInventarioFisico.Update()
|
|
BloqueaEdicionEncabezado()
|
|
Mov.Dispose()
|
|
UpGenerales.Update()
|
|
UPDatos.Update()
|
|
UppGrid.Update()
|
|
UPEncabezado.Update()
|
|
UpRegistroTipoCambio.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaDatosEntregaAlmacen(CveEntregaAlmacen As Integer)
|
|
'RECARGA ALMACENES SOLO DE recepcion de usados
|
|
DdlAlmacen.Items.Clear()
|
|
DdlAlmacen.DataBind()
|
|
Dim dttA As DataTable = Nothing
|
|
dttA = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,22,27)")
|
|
|
|
DdlAlmacen.DataSource = dttA
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.SelectedIndex = 1 'toma el primer renglón
|
|
|
|
Dim ObjGenerales As New ClsGenerales()
|
|
|
|
If (ObjGenerales.GetEntregaAlmacenRutaDetalle(CveEntregaAlmacen)) Then
|
|
|
|
For Each dr As DataRow In ObjGenerales.DtResultados.Rows
|
|
AddNew(dr("CvePS").ToString.ToEntero, dr("CodigoPS").ToString, dr("CveUnidadMedida").ToString.ToEntero, dr("Abreviatura").ToString, dr("Cantidad").ToString.ToDecimal,
|
|
0, "", "", "", "", "E", "", MinFecha, 0, "")
|
|
Next
|
|
End If
|
|
ObjGenerales.Dispose()
|
|
End Sub
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
End If
|
|
UppGrid.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaCodigoBarras()
|
|
If DdlCConcepto.SelectedValue.ToEntero = 1 Then
|
|
DivCodigoBarras.Visible = True
|
|
End If
|
|
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
|
|
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
|
|
|
|
UpRegistroTipoCambio.Update()
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub LimpiarAgregar()
|
|
DdlClasificacion.SelectedValue = "-1"
|
|
txtCantidad.Text = ""
|
|
TxtnLote.Text = ""
|
|
TxtObservacionesdetalle.Text = ""
|
|
End Sub
|
|
|
|
Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
|
|
|
|
RegistraScript("$('#divDescripcion').modal()")
|
|
|
|
Dim Description As String = String.Format("Movimiento con Concepto: {0}, Almacen: {1}, Fecha: {2}, Folio: {3}, Usuario: {4}, Observaciones adicionales: {5}, Productos Información:<br/>",
|
|
DdlConcepto.SelectedItem, DdlAlmacen.SelectedItem, TxtFecha.Text, TxtFolio.Text, LblUsuarioRegistro.Text, TxtObservaciones.Text)
|
|
For Each dr As DataRow In DtMovimientos.Rows
|
|
Dim detalleDescripcion As String = String.Format("- Cant: {0}, PS: {1}, PU: {2}, UM: {3}<br/>", dr("Cantidad").ToString.ToEntero, dr("CodigoPS"), dr("PU"), dr("UnidadMedida"))
|
|
Description = String.Format("{0}{1}", Description, detalleDescripcion)
|
|
Next
|
|
DescripcionDetalladaEliminar = Description
|
|
UpDescripcion.Update()
|
|
|
|
'Dim Inv As New ClsInventarios
|
|
'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 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()
|
|
End Sub
|
|
Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click
|
|
Dim Borrar As Boolean = False
|
|
If Not TxtDescripcion.Text = "" Then
|
|
|
|
Dim Inv As New ClsInventarios
|
|
Dim Conta As New ClsContabilidad(Inv.IniciaTransacSQL())
|
|
Dim ObjGral As New ClsGenerales(Inv.IniciaTransacSQL())
|
|
|
|
Dim TieneError = False
|
|
|
|
Dim ObjConta As ClsContPAQi = Nothing
|
|
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso (UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC) Then
|
|
ObjConta = New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjConta.IniciaTransacSQL()
|
|
End If
|
|
|
|
If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, String.Format("{0}, Informacion = {1}", TxtDescripcion.Text, DescripcionDetalladaEliminar), "Inventarios", TxtFolio.Text + " / " + DdlConcepto.SelectedItem.Text) Then
|
|
TieneError = True
|
|
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)
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "divDescripcion"))
|
|
LimpiarMovimiento()
|
|
Else
|
|
If ObjConta IsNot Nothing Then ObjConta.RollBack()
|
|
Inv.RollBack()
|
|
|
|
Alert("Ocurrió un error al eliminar el movimiento. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
CveMovimiento = 0
|
|
|
|
If ObjConta IsNot Nothing Then ObjConta.Dispose()
|
|
Inv.Dispose()
|
|
ObjGral.Dispose()
|
|
Conta.Dispose()
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " AGREGAR - GUARDAR "
|
|
Private Function GetExistencias(CvePS As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, CveAlmacen As Integer, Optional CveSeccionAlmacen As Integer = -1, Optional Serie As String = "-1", Optional Lote As String = "-1", Optional FechaCaducidad As Date = MinFecha) As Decimal
|
|
Dim Inv As New ClsInventarios
|
|
Dim Existencia As Decimal = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, CveSeccionAlmacen:=CveSeccionAlmacen, 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 btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
|
' AgregarPS()
|
|
'End Sub
|
|
Protected Sub LkAgregarDetalle_Click(sender As Object, e As EventArgs) Handles LkAgregarDetalle.Click
|
|
If CveMovimientoDetalleEdit > 0 Then
|
|
ActualizarPS()
|
|
Else
|
|
AgregarPS()
|
|
End If
|
|
|
|
End Sub
|
|
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
|
|
|
|
AddNew(DdlProducto2.SelectedValue.ToEntero, DdlProducto2.SelectedText, DdlUnidad.SelectedValue.ToEntero, DdlUnidad.SelectedItem.Text, txtCantidad.Text.ToDecimal,
|
|
txtPrecio.Text.ToDecimal, TxtnSerie.Text.Replace(" ", String.Empty), LblCodigo.Text, HdnCodigoAF.Value, HdnCveActivoFijo.Value, TxtObservacionesdetalle.Text,
|
|
TxtnLote.Text.Trim, TxtnFechaCaducidad.Text.ToDate, DdlSeccionAlmacen.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedItem.Text, CveCultivoCuadroDetalle:=DdlModalCultivosCuadro.SelectedValue.Toentero)
|
|
LimpiarAgregar()
|
|
|
|
txtCantidad.Text = ""
|
|
TxtnLote.Text = ""
|
|
LblCodigo.Text = ""
|
|
TxtnSerie.Text = ""
|
|
TxtnLote.Text = ""
|
|
TxtnFechaCaducidad.Text = ""
|
|
HdnCodigoAF.Value = "-1"
|
|
HdnCveActivoFijo.Value = "-1"
|
|
DdlModalCultivosCuadro.SelectedValueExist(-1)
|
|
|
|
RegistraScript("CodigoAF = "";")
|
|
|
|
If Not UsuarioActual.Empresa.Funcionalidad(105).ToString = "1" Then
|
|
DdlProducto2.SelectedValue = "-1"
|
|
Else
|
|
DdlProducto2.SelectedValue = ""
|
|
DdlProducto2.SelectedText = ""
|
|
End If
|
|
|
|
txtCantidad.Focus()
|
|
End Sub
|
|
|
|
|
|
Protected Sub AddNew(CvePS As Integer, PS As String, CveUM As Integer, UM As String, Cantidad As Decimal, PU As Decimal, Serie As String, CodigoAF As String, Codigo As String, CveAF As String, Observaciones As String, Lote As String, FechaCaducidad As Date, CveSeccionAlmacen As Integer, SeccionAlmacen As String, Optional CargarGV As Boolean = True, Optional CveCultivoCuadroDetalle As Integer = -1)
|
|
|
|
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 RowPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).Rows(0)
|
|
|
|
Dim CveMetodoInventario As Integer = RowPS("Inv_CveMetodoInventario").ToString().ToEntero()
|
|
|
|
Dim FechaCaducidadVal As Date = If(RowPS("AplicaCaducidad").ToString = "True", FechaCaducidad, MinFecha)
|
|
|
|
|
|
If RowPS("AplicaSerie").ToString = "True" And (String.IsNullOrEmpty(Serie.Trim()) OrElse Serie = "-1") Then
|
|
Valido = False
|
|
Alert("El producto requiere Serie", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
If RowPS("VentaMinima").ToString.ToDecimal > 0 Then
|
|
If Cantidad Mod RowPS("VentaMinima").ToString().ToDecimal <> 0 Then
|
|
Alert(String.Format("El producto se vende solo en cantidades de {0}", RowPS("VentaMinima").ToString()))
|
|
Valido = False
|
|
End If
|
|
End If
|
|
|
|
Dim tCveSubProyecto As Integer
|
|
Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue))
|
|
If drA2 IsNot Nothing Then
|
|
tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero
|
|
End If
|
|
|
|
If UsuarioActual.CveEmpresa = 119 AndAlso Not tCveSubProyecto.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347).Split(","c)) Then
|
|
FechaCaducidadVal = MinFecha
|
|
FechaCaducidad = MinFecha
|
|
Lote = ""
|
|
End If
|
|
|
|
'salida
|
|
If Valido AndAlso DdlConcepto.SelectedValue.Contiene({"3", "5", "7", "8", "11", "12", "13", "15", "16", "17", "20", "21", "30", "31"}) Then ' salida de almacen
|
|
|
|
Dim Existencia As Decimal = GetExistencias(CvePS, CveUM, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, -1, If(Serie = "", "-1", Serie), If(Lote = "", "-1", Lote), FechaCaducidadVal)
|
|
' LbAgregar.ToolTip = Existencia.ToString
|
|
If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUM} {If(Serie <> "", $" AND Serie = '{Serie}'", "")}") < 0 Then
|
|
If Existencia <= 0 Then
|
|
Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Valido = False
|
|
Else
|
|
Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
If Not UsuarioActual.TienePermisoProceso(114) Then
|
|
Cantidad = Existencia
|
|
End If
|
|
End If
|
|
Valido = If(UsuarioActual.TienePermisoProceso(114), True, False)
|
|
End If
|
|
End If
|
|
|
|
|
|
If Valido Then
|
|
Dim CveClasificacion As Integer
|
|
'Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS")
|
|
If RowPS IsNot Nothing Then CveClasificacion = RowPS("CveClasificacion").ToString.ToEntero
|
|
|
|
'VALIDA QUE LA SERIE NO SEA IGUAL AL CODIGO O CODIGOBARRAS
|
|
If Serie <> "" And (Serie.ToUpper = RowPS("Codigo").ToString.ToUpper Or Serie.ToUpper = RowPS("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") = String.Format("{0} - {1}", Codigo, 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("FechaCaducidad") = FechaCaducidad
|
|
registro.Item("Observaciones") = Observaciones
|
|
registro.Item("AplicaCaducidad") = RowPS("AplicaCaducidad").ToString
|
|
registro.Item("CveCultivoCuadroDetalle") = CveCultivoCuadroDetalle
|
|
|
|
DtMovimientos.Rows.Add(registro)
|
|
|
|
If CargarGV Then
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
|
|
|
If EsNuevoMov Then
|
|
CveMovimiento = 0
|
|
End If
|
|
|
|
If EsConsumoInterno And DdlPersonal.SelectedValue.ToEntero <= 0 Then
|
|
Alert("El personal es requerido. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If GvM.Rows.Count > 0 Then
|
|
|
|
'Dim CveMovimiento As Integer
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
Dim ObjContaAC As ClsContPAQi = Nothing
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim ErrorAC As Boolean = False
|
|
Dim IDPoliza As Integer = 0
|
|
Dim ImporteConcepto As Decimal = 0
|
|
|
|
Try
|
|
|
|
'Para Campos Nuevos AF y OC
|
|
Dim SubProyecto = -1
|
|
Dim ActivoFijo = -1
|
|
|
|
If UsuarioActual.CveEmpresa = 66 AndAlso (DdlConcepto.SelectedValue.ToEntero = 3 Or DdlConcepto.SelectedValue.ToEntero = 11) Then
|
|
SubProyecto = DdlSubProyecto.SelectedValue.ToEntero
|
|
ActivoFijo = -1 'HdnCveActivoFijo.Value.ToEntero
|
|
ElseIf UsuarioActual.CveEmpresa = 66 AndAlso Not CveMovimiento > 0 Then
|
|
SubProyecto = -2
|
|
ActivoFijo = -2
|
|
End If
|
|
|
|
'Esto es parte de consumo interno
|
|
If DdlActivoFijo.SelectedValue.ToEntero > 0 Then
|
|
ActivoFijo = DdlActivoFijo.SelectedValue.ToEntero
|
|
End If
|
|
|
|
'ACTUALIZAR
|
|
If CveMovimiento > 0 Then
|
|
Dim Mensaje As String = ""
|
|
|
|
'Actualiza Movimiento
|
|
If Not ObjInventario.UpdateMovimiento(CveMovimiento, DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime).ToDate,
|
|
TxtFolio.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Guia:=TxtGuia.Text, Observaciones:=TxtObservaciones.Text) Then
|
|
Mensaje = "Error al Actualizar el Movimiento"
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
|
|
' Actualizo los movimientos
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
|
|
'Determina PU dependiendo MONEDA
|
|
If DdlConcepto.SelectedValue.ToEntero = 2 AndAlso DdlMoneda.SelectedValue.ToEntero = 2 Then
|
|
ImporteConcepto = Dr("PU").ToString.ToDecimal * GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
|
|
Else
|
|
ImporteConcepto = Dr("PU").ToString.ToDecimal
|
|
End If
|
|
|
|
'Actualiza existentes
|
|
If Dr("CveMovimientoDetalle").ToString.ToEntero > 0 Then
|
|
'cuando es normal
|
|
If Dr("Estatus").ToString = "E" Then
|
|
'hay que eliminarlo
|
|
If Not ObjInventario.RemoveMovimientoDetalle(Dr("CveMovimientoDetalle").ToString.ToEntero, Dr("CveMovimiento").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
ElseIf Dr("Estatus").ToString = "U" Then
|
|
|
|
If Not ObjInventario.UpdateMovimientoDetalle(Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveMovimientoDetalle").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("Serie").ToString, Dr("Observaciones").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
Mensaje = "Error al Actualizar los movimientos"
|
|
ErrorMovInv = True : Exit For
|
|
End If
|
|
|
|
End If
|
|
|
|
'Agrega nuevos
|
|
Else
|
|
|
|
If GlobalDTInvConceptos.FiltraParametros(String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue.ToEntero)).Rows.Count > 0 AndAlso GlobalDTInvConceptos.FiltraParametros(String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue.ToEntero)).Rows(0)("Origen").ToString.ToEntero < 0 Then
|
|
If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), Serie:=If(Dr("Serie").ToString = "", "-1", Dr("Serie").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString)) >= Dr("Cantidad").ToString.ToDouble Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveCultivoCuadroDetalle:=Dr("CveCultivoCuadroDetalle").ToString.ToEntero) Then
|
|
Mensaje = "Error al Agregar los nuevos movimientos"
|
|
ErrorMovInv = True : Exit For
|
|
End If
|
|
Else
|
|
If UsuarioActual.TienePermisoProceso(114) Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveCultivoCuadroDetalle:=Dr("CveCultivoCuadroDetalle").ToString.ToEntero) Then
|
|
Mensaje = "Error al Agregar los nuevos movimientos"
|
|
ErrorMovInv = True : Exit For
|
|
End If
|
|
Else
|
|
Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("CodigoAF"))
|
|
ErrorMovInv = True : Exit For
|
|
End If
|
|
End If
|
|
Else
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveCultivoCuadroDetalle:=Dr("CveCultivoCuadroDetalle").ToString.ToEntero) Then
|
|
Mensaje = "Error al Agregar los nuevos movimientos"
|
|
ErrorMovInv = True : Exit For
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
If UsuarioActual.Empresa.UsaAC AndAlso Not ErrorMovInv Then
|
|
|
|
'cargar también los movimentos detalle
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", "CveMovimientoDetalle")
|
|
End If
|
|
|
|
Dim Importe As Double = DtMovimientos.SUM("Total", "Estatus IN ('','U')")
|
|
IDPoliza = HdnIdPoliza.Value.ToEntero
|
|
|
|
If Importe > 0 AndAlso IDPoliza > 0 Then
|
|
Dim CuentaAbonoAlmacen, CuentaCargoCOG As Integer
|
|
|
|
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjContaAC.IniciaTransacSQL()
|
|
ObjContaAC.RemoveAllMovimientos(IDPoliza)
|
|
|
|
Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue))
|
|
If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero
|
|
|
|
If UsuarioActual.CveEmpresa = 48 Then ' APH
|
|
CuentaCargoCOG = 1386
|
|
End If
|
|
|
|
If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then
|
|
If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", "", 0, TxtFecha.Text.ToDate, "") Then
|
|
'actualizo el idcuenta del presupuesto
|
|
If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", "", 0, TxtFecha.Text.ToDate, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorAC AndAlso Not ErrorMovInv Then
|
|
Dim Msg As String = "Movimiento Actualizado"
|
|
If IDPoliza > 0 Then ObjContaAC.AjustaPoliza(IDPoliza)
|
|
ObjInventario.Commit() ' aplica los movimientos insertados
|
|
|
|
'recargo los datos para que esten actualizados, y no se duplique un rgistro nuevo
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
DtMovimientos = ObjInventario.DtResultados
|
|
End If
|
|
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.Commit()
|
|
Alert(Msg, TipoMensaje.MsgInformacion, "document.location.href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento=" & CveMovimiento & """;")
|
|
UPDatos.Update()
|
|
Else
|
|
ObjInventario.RollBack()
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
|
Alert(Mensaje, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
|
|
'GUARDAR
|
|
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 obs As String = TxtObservaciones.Text.Trim()
|
|
If obs = "" Then
|
|
obs = DdlConcepto.SelectedItem.Text
|
|
If DdlPersonal.SelectedValue.ToEntero > 0 Then obs = obs & " - " & DdlPersonal.SelectedItem.Text
|
|
End If
|
|
Dim CveAlmacen As Integer = DdlAlmacen.SelectedValue.ToEntero
|
|
|
|
Dim CveModalidad As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveModalidad").ToEntero()
|
|
|
|
Dim EsContabilizable As Boolean = (CveModalidad = 1)
|
|
|
|
Dim TotalCantidad As Double = DtMovimientos.SUMD("Cantidad")
|
|
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inv/ES", 53, 0, 0, 1, TxtFecha.Text.ToDate, obs, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
|
|
|
|
CveMovimiento = ObjInventario.AddMovimiento(CveAlmacen, DdlConcepto.SelectedValue.ToEntero, 1, Fecha, tFolio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, 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:="ES/1")
|
|
|
|
|
|
If CveMovimiento <= 0 OrElse CvePrePoliza <= 0 Then
|
|
Alert("No se pudo almacenar el movimiento correctamente", TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ObjInventario.RollBack() 'deshace lo insertado
|
|
Else
|
|
Dim Mensaje As String = ""
|
|
|
|
''VALIDA EXISTENCIAS
|
|
Dim Cont As Integer = 0
|
|
If DdlConcepto.SelectedValue.Contiene({"3", "11", "13", "21", "30", "31"}) Then
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
Dim FechaCaducidadVal As Date = If(Dr("AplicaCaducidad").ToString = "True", Dr("FechaCaducidad").ToString.ToDate, MinFecha)
|
|
If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), Serie:=If(Dr("Serie").ToString = "", "-1", Dr("Serie").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), FechaCaducidad:=FechaCaducidadVal) >= Dr("Cantidad").ToString.ToDouble Then
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=FechaCaducidadVal, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveCultivoCuadroDetalle:=Dr("CveCultivoCuadroDetalle").ToString.ToEntero) Then
|
|
Mensaje = "Error al guardar los movimientos"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
'Else
|
|
'If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
|
|
' For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows
|
|
' If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal * Tipo) Then
|
|
' ErrorMovInv = True
|
|
' Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
'End If
|
|
End If
|
|
Else
|
|
|
|
If UsuarioActual.TienePermisoProceso(114) Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveCultivoCuadroDetalle:=Dr("CveCultivoCuadroDetalle").ToString.ToEntero) Then
|
|
Mensaje = "Error al guardar los movimientos"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
'Else
|
|
'If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
|
|
' For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows
|
|
' If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal * Tipo) Then
|
|
' ErrorMovInv = True
|
|
' Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
'End If
|
|
End If
|
|
Else
|
|
Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("PS"))
|
|
Alert(Mensaje, TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ErrorMovInv = True : Exit For
|
|
End If
|
|
|
|
End If
|
|
Cont += 1
|
|
Next
|
|
|
|
Else
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
If DdlConcepto.SelectedValue.ToEntero = 2 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, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Observaciones:=Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveCultivoCuadroDetalle:=Dr("CveCultivoCuadroDetalle").ToString.ToEntero) Then
|
|
Mensaje = "Error al guardar los movimientos"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
'Else
|
|
' If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
|
|
' For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows
|
|
' If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal * Tipo) Then
|
|
' ErrorMovInv = True
|
|
' Mensaje = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
' End If
|
|
End If
|
|
Cont += 1
|
|
Next
|
|
End If
|
|
|
|
|
|
'Registro la prepóliza
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUMD("Total", "").RoundSQL()
|
|
Dim tValorOtro As Decimal = tValorInventario
|
|
Dim idCtaContable As Integer = 0
|
|
Dim IdCtaContableOtro As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos
|
|
Dim TipoMovtoAlmacen As Boolean = False
|
|
Dim TipoMovtoOtro As Boolean = True
|
|
Dim tCveSubProyecto As Integer = -1
|
|
|
|
Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue))
|
|
If drA2 IsNot Nothing Then
|
|
idCtaContable = drA2("IdCtaContable").ToString.ToEntero
|
|
tCveSubProyecto = drA2("CveSubProyecto").ToString.ToEntero
|
|
End If
|
|
|
|
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & DdlConcepto.SelectedValue).ToEntero
|
|
If OrigenMov = 1 Then TipoMovtoAlmacen = False Else TipoMovtoAlmacen = True
|
|
TipoMovtoOtro = Not TipoMovtoAlmacen
|
|
|
|
Dim CveConceptoContable As Integer = 260
|
|
Dim CveClasificacion As Integer = -1
|
|
Select Case DdlConcepto.SelectedValue.ToEntero
|
|
Case 28, 31
|
|
CveConceptoContable = 51
|
|
|
|
'[IPP] PARCHE CTA CONTABLE PARA SALIDA DE DEMOSTRACION
|
|
If DdlConcepto.SelectedValue.ToEntero = 31 Then
|
|
IdCtaContableOtro = 1319
|
|
End If
|
|
|
|
Case 30
|
|
CveConceptoContable = 181
|
|
TipoMovtoOtro = False
|
|
If DdlSubProyecto.Visible = True AndAlso DdlSubProyecto.SelectedValue.ToEntero > 0 Then tCveSubProyecto = DdlSubProyecto.SelectedValue.ToEntero
|
|
If UsuarioActual.Empresa.Funcionalidad(342).ToEntero > 0 Then
|
|
IdCtaContableOtro = UsuarioActual.Empresa.Funcionalidad(342).ToEntero
|
|
End If
|
|
Case 13, 29
|
|
CveConceptoContable = 69
|
|
TipoMovtoOtro = True
|
|
tValorOtro = -tValorOtro
|
|
Dim drr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero("")
|
|
If drr IsNot Nothing Then
|
|
CveClasificacion = drr("CveClasificacion").ToString.ToEntero
|
|
IdCtaContableOtro = drr("IdCuentaCostos").ToString.ToEntero
|
|
End If
|
|
|
|
|
|
End Select
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoAlmacen, tValorInventario, TxtObservaciones.Text.Trim, 68, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, idCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorInventario, CveClasificacion:=CveClasificacion, Contabilizable:=EsContabilizable) Then
|
|
ErrorMovInv = True
|
|
Else
|
|
'Select Case DdlConcepto.SelectedValue.ToEntero
|
|
' Case 30
|
|
|
|
'Dim Total As Decimal = 0
|
|
If CveConceptoContable = 181 Then
|
|
Dim Dt As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}).Copy
|
|
'Dim IdCuentaGasto As Integer = 0
|
|
For Each Dr As DataRow In Dt.Rows
|
|
Dim Total As Decimal = ObjInventario.DtResultados.FiltraParametros($"CveClasificacion = {Dr("CveClasificacion").ToString}").SUM("Total").ToDecimal.RoundSQL()
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoAlmacen, Total, TxtObservaciones.Text.Trim, CveConceptoContable, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, -1, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=Total, CveClasificacion:=Dr("CveClasificacion").ToString.ToEntero, CveSubProyecto:=tCveSubProyecto) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
Next
|
|
Else
|
|
|
|
End If
|
|
|
|
'Case Else
|
|
|
|
'End Select
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
'------------------------------------------------
|
|
If Not ErrorMovInv Then
|
|
'DEVENGAR
|
|
Dim TotalPorDevengar As Double = 0
|
|
|
|
'cuando tiene AC y es salida de almacen, se manda al gasto, solo aplica si el almacen es contable
|
|
If UsuarioActual.Empresa.UsaAC AndAlso (DdlConcepto.SelectedValue = "3") AndAlso EsContabilizable Then
|
|
Dim DtII As DataTable = Nothing
|
|
Dim TotalDetalle As Double = 0.0
|
|
Dim Importe As Decimal = DtMovimientos.SUMD("Total", "Estatus IN ('','U')")
|
|
'NOTA. CUANDO ES SALIDA, EN AUTOMATICO NO TENEMOS LOS VALORES DE LA SALIDA TODAVIA, Y POR ESO IMPORTE ES CERO, ES RECARGAR CON LOS DATOS YA INSERTADOS
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
DtII = ObjInventario.DtResultados
|
|
End If
|
|
|
|
TotalPorDevengar += Importe ' GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Math.Round(Gvr.DataKey("PU").ToString.ToDouble, 4) * Math.Round(Gvr.DataKey("CantidadF").ToString.ToDouble, 4))
|
|
TotalPorDevengar = Math.Round(TotalPorDevengar, 4)
|
|
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjContaAC.IniciaTransacSQL()
|
|
|
|
Dim AC As New ClsAC
|
|
Dim DtPresupuestos As DataTable = Nothing
|
|
If AC.GetPresupuestoEgresos(-1, True, UsuarioActual.Empresa.EjercicioActual, UsuarioActual.CveEmpresa) Then
|
|
DtPresupuestos = AC.DtResultados.Copy
|
|
Else
|
|
Alert("Ocurrió un error al cargar los Presupuestos. Por favor vuelva a cargar la página", TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
AC.Dispose()
|
|
|
|
IDPoliza = ObjContaAC.AddPoliza(3, "Salida de Almacen", TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate)
|
|
|
|
If IDPoliza > 0 Then
|
|
Dim CuentaCargoCOG As Integer
|
|
Dim CuentaAbonoAlmacen As Integer = 0
|
|
Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue))
|
|
|
|
If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero
|
|
|
|
''For Each gvr As GridViewRow In GvAC.Rows
|
|
'For Each Dr As DataRow In DtII.Rows
|
|
' Importe = Dr("Cantidad").ToString.ToDouble * Dr("PU").ToString.ToDouble ' gvr.FCTextBox("TxtImporte").Text.ToDouble
|
|
' TotalDetalle += Importe
|
|
|
|
|
|
'saco de que partida se va a descontar y se enviara a gasto
|
|
' Dim drP As DataRow = DtPresupuestos.FiltroPrimero(String.Format("CveClasificacion = {0}", Dr("CveClasificacion")))
|
|
' If drP IsNot Nothing Then CuentaCargoCOG = drP("IdCuentaMatriz").ToString.ToEntero
|
|
|
|
If UsuarioActual.CveEmpresa = 48 Then ' APH
|
|
CuentaCargoCOG = 1386
|
|
End If
|
|
|
|
Dim ConceptoRenglon As String = "Salida de Almacen"
|
|
|
|
If IDPoliza > 0 Then
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
Dim DtMovtos = ObjInventario.DtResultados
|
|
Importe = DtMovtos.SUMD("Total", "Estatus = ''")
|
|
|
|
If Importe > 0 Then
|
|
If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then
|
|
If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", ConceptoRenglon, 0, TxtFecha.Text.ToDate, "") Then
|
|
'actualizo el idcuenta del presupuesto
|
|
If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", ConceptoRenglon, 0, TxtFecha.Text.ToDate, "") Then
|
|
ErrorAC = True
|
|
Mensaje = "No se pudo insertar movimiento en la poliza 2."
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
Mensaje = "No se pudo insertar movimiento en la poliza 1."
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
End If
|
|
End If
|
|
|
|
If IDPoliza > 0 Then
|
|
ObjInventario.UpdateMovimientoPoliza(IDPoliza, CveMovimiento, UsuarioActual.CveEmpresa)
|
|
End If
|
|
|
|
Else
|
|
ErrorAC = True
|
|
Mensaje = "No se pudo insertar la poliza"
|
|
End If
|
|
End If
|
|
'TERMINA: DEVENGAR
|
|
|
|
|
|
''PREPOLIZA - SE CAMBIO DE LUGAR EL USO DE ESTA PARTE
|
|
'If EsConsumoInterno Then
|
|
' If Not ErrorAC And Not ErrorMovInv Then
|
|
' Dim DtCostos As DataTable = Nothing
|
|
' Dim ValorInventario As Decimal = 0
|
|
|
|
' If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
' DtCostos = ObjInventario.DtResultados
|
|
' Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
|
|
' Dim IdCtaContable As Integer = 0
|
|
|
|
' If tmpCostos.Rows.Count > 0 Then
|
|
' Dim Concepto As String = $"Consumo Interno: {ObjInventario.Folio} - {TxtObservaciones.Text}"
|
|
' Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv/ConsumoInterno", 53, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, $"Consumo Interno: {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
' 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, False, ValorInventario, Concepto, 6, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario) Then
|
|
' ErrorMovInv = True
|
|
' Exit For
|
|
' End If
|
|
|
|
' Next
|
|
|
|
' IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero
|
|
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DtCostos.SUM("Total"), Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUM("Total")) Then
|
|
' ErrorMovInv = True
|
|
' End If
|
|
' End If
|
|
' End If
|
|
|
|
' End If
|
|
'End If
|
|
|
|
Dim RetornoVirtual As MMovimientoVirtual = Nothing
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
RetornoVirtual = GenerarMovimientoVirtual(CveMovimiento, ObjInventario)
|
|
End If
|
|
|
|
If RetornoVirtual IsNot Nothing Then
|
|
ErrorMovInv = RetornoVirtual.TieneError
|
|
End If
|
|
|
|
If Not ErrorAC And Not ErrorMovInv Then
|
|
Dim Msg As New StringBuilder
|
|
Msg.AppendFormat("<br/>El Movimiento se registro con el Folio: <b><a href='/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}'>{0}</a></b>", ObjInventario.Folio, 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 RetornoVirtual IsNot Nothing Then
|
|
If RetornoVirtual.CveMovimientoVirtual > 0 Then
|
|
Msg.AppendFormat("<br/><br/>Se generó el movimiento virtual con el folio: <b><a class=""Texto"" target='_blank' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"">{1}</a></b>", RetornoVirtual.CveMovimientoVirtual, RetornoVirtual.FolioVirtual)
|
|
End If
|
|
End If
|
|
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.AjustaPoliza(IDPoliza)
|
|
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
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.Commit()
|
|
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
'Limpia Valores cuando inserta de campos especiales
|
|
If UsuarioActual.CveEmpresa = 66 Then
|
|
DdlSubProyecto.SelectedValueExist("-1")
|
|
UPEncabezado.Update()
|
|
End If
|
|
|
|
UPDatos.Update()
|
|
|
|
|
|
If UsuarioActual.TienePermisoProceso(139) Then
|
|
CargaDatos(CveMovimiento)
|
|
Else
|
|
LimpiarMovimiento()
|
|
End If
|
|
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
Else
|
|
ObjInventario.RollBack()
|
|
CveMovimiento = 0
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
|
Alert(Mensaje, TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
|
|
|
|
Else
|
|
ObjInventario.RollBack() 'deshace lo insertado
|
|
CveMovimiento = 0
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
|
Alert("ocurrió un Error al registrar los movimientos", TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
|
|
End If
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
End If
|
|
|
|
|
|
Catch ex As Exception
|
|
Try 'por si ya le habian dado rollback o commit
|
|
ObjInventario.RollBack() 'deshace lo insertad
|
|
Catch exx As Exception
|
|
|
|
End Try
|
|
CveMovimiento = 0
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
|
Alert("Ocurrió un Error inesperado en el registro" & ex.Message, TipoMensaje.MsgError)
|
|
GuardaLog("Ocurrió un Error inesperado en el registro" & ex.ToString())
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End Try
|
|
|
|
ObjInventario.Dispose() 'elimino la instancia
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose()
|
|
|
|
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
|
|
|
|
EsNuevoMov = False
|
|
End Sub
|
|
|
|
#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
|
|
Public Sub BtnAddCodigo_Click(sender As Object, e As EventArgs) Handles BtnAddCodigo.Click
|
|
|
|
If TxtCodigo.Text.Trim = "" And TxtCodigoBarras.Text.Trim = "" Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim DrP As DataRow = Nothing
|
|
|
|
If TxtCodigo.Text.Trim <> String.Empty Then
|
|
DrP = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($" Codigo = '{TxtCodigo.Text.Trim}'")
|
|
ElseIf TxtCodigoBarras.Text.Trim <> String.Empty Then
|
|
DrP = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($" CodigoBarras = '{TxtCodigoBarras.Text.Trim}'")
|
|
End If
|
|
|
|
|
|
|
|
Dim Costo As Decimal = TxtAltaCosto.Text.ToDecimal
|
|
|
|
If DrP IsNot Nothing AndAlso DrP("CvePS").ToString.ToEntero > 0 Then
|
|
GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrP("CvePS").ToString.ToEntero, DrP("CveUnidadMedida").ToString.ToEntero, Costo)
|
|
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 SerieLote As String = "-1")
|
|
Dim ObjInv As New ClsInventarios
|
|
|
|
If CveMovimiento <= 0 Then
|
|
CveMovimiento = ObjInv.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, 1, TxtFecha.Text.ToDate, TxtFolio.Text.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Modulo:="ES/CS1")
|
|
End If
|
|
|
|
ObjInv.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, CostoPromedio, -1, Serie:=SerieLote)
|
|
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 = ""
|
|
LblCodigo.Text = ""
|
|
HdnCodigoAF.Value = "-1"
|
|
HdnCveActivoFijo.Value = "-1"
|
|
|
|
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
|
|
|
|
DdlConcepto.Items.Clear()
|
|
|
|
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)", "CveConcepto NOT IN (1,2,4,5,8,9,10,12,26,27)")
|
|
|
|
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, 135), "CveConcepto NOT IN (4,5,10)", filtro).ToString, CveTipoAlmacen)
|
|
|
|
End If
|
|
|
|
DdlConcepto.DataSource = GlobalDTInvConceptos.FiltraParametros(filtro)
|
|
DdlConcepto.DataBind()
|
|
|
|
If IsNothing(Request("CveMovimiento")) Then
|
|
DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
If Not DdlConcepto.Items.Contains(New ListItem("Seleccione", "-1")) Then
|
|
DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
'PRODUCTOS FINANCIEROS
|
|
If CveTipoAlmacen.Contiene(12, 15) Then
|
|
If DdlConcepto.Items.FindByValue("1") Is Nothing Then
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 1, 1, 0), New ListItem(" Inventario Inicial ", "1"))
|
|
End If
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 1, 1, 0), New ListItem(" Salida por Ajuste ", "34"))
|
|
|
|
End If
|
|
|
|
'ACTIVO FIJO
|
|
If CveTipoAlmacen = 15 Then
|
|
If DdlConcepto.Items.FindByValue("2") Is Nothing Then
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Entrada Almacen ", "2"))
|
|
End If
|
|
If DdlConcepto.Items.FindByValue("3") Is Nothing Then
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 3, 3, DdlConcepto.Items.Count), New ListItem("Salida de Almacen", "3"))
|
|
End If
|
|
End If
|
|
|
|
'cONSUMO INTERNO
|
|
If CveTipoAlmacen = 14 Then
|
|
If DdlConcepto.Items.FindByValue("2") Is Nothing Then
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Entrada Almacen ", "2"))
|
|
End If
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 1, 1, 0), New ListItem(" Salida por Ajuste ", "34"))
|
|
End If
|
|
|
|
' RECEPCION USADOS
|
|
If CveTipoAlmacen = 22 Then
|
|
If DdlConcepto.Items.FindByValue("3") Is Nothing Then
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Salida Almacen ", "3"))
|
|
End If
|
|
If DdlConcepto.Items.FindByValue("45") Is Nothing Then
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Salida de Usado ", "45"))
|
|
End If
|
|
|
|
End If
|
|
|
|
'[IPP]: PARCHE PARA JAM
|
|
If UsuarioActual.CveEmpresa = 119 And CveTipoAlmacen.Contiene(4, 8, 16) Then
|
|
If DdlConcepto.Items.FindByValue("2") Is Nothing Then
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 2, 2, DdlConcepto.Items.Count), New ListItem("Entrada Almacen ", "2"))
|
|
End If
|
|
If DdlConcepto.Items.FindByValue("3") Is Nothing Then
|
|
DdlConcepto.Items.Insert(If(DdlConcepto.Items.Count >= 3, 3, DdlConcepto.Items.Count), New ListItem("Salida de Almacen", "3"))
|
|
End If
|
|
|
|
End If
|
|
|
|
'tIPO Devolución proveedor
|
|
If CveTipoAlmacen.Contiene(21) Then
|
|
DdlConcepto.Items.Insert(0, New ListItem("Entrada Almacen ", "2"))
|
|
If UsuarioActual.CveUsuario = 100 Then
|
|
DdlConcepto.Items.Insert(1, New ListItem("Devolución al Proveedor ", "13"))
|
|
End If
|
|
End If
|
|
|
|
If CveTipoAlmacen.Contiene(22) Then
|
|
DdlConcepto.Items.Insert(0, New ListItem("Entrada Almacen ", "2"))
|
|
End If
|
|
|
|
'2185
|
|
If UsuarioActual.CveEmpresa = 72 AndAlso (UsuarioActual.CveUsuario = 1490 OrElse UsuarioActual.CveRol = 1) Then
|
|
|
|
'DdlConcepto.Items.Add(New ListItem("Seleccione", "-1"))
|
|
DdlConcepto.Items.Add(New ListItem("Entrada por Ajuste", "32"))
|
|
|
|
If CveTipoAlmacen.Contiene(12, 14, 19) Then
|
|
DdlConcepto.Items.Add(New ListItem("Salida por Ajuste", "34"))
|
|
End If
|
|
|
|
End If
|
|
|
|
''condicion de limpieza si es el usuario 1490, se dejan sino
|
|
If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) Then
|
|
If Not UsuarioActual.CveUsuario.Contiene(1490, 2185) Then 'luz del mar(1490), y celia(2185)
|
|
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("1"))
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("2"))
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("3"))
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("16"))
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("17"))
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("31"))
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("32"))
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("33"))
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("34"))
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("34")) 'si esta dos veces, se tiene que ejecutar 2 veces
|
|
DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("35"))
|
|
|
|
End If
|
|
End If
|
|
|
|
If UsuarioActual.CveUsuario.Contiene(2185, 100) Then
|
|
DdlConcepto.Items.Add(New ListItem("Entrada por Ajuste", "32"))
|
|
DdlConcepto.Items.Add(New ListItem("Salida por Ajuste", "34"))
|
|
|
|
End If
|
|
|
|
DdlConcepto.SelectedValue = "-1"
|
|
ddlConcepto_SelectedIndexChanged(DdlConcepto, EventArgs.Empty)
|
|
|
|
UpGenerales.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub ddlConcepto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConcepto.SelectedIndexChanged
|
|
|
|
|
|
If CveMovimiento > 0 And Not EsNuevoMov Then
|
|
Exit Sub
|
|
End If
|
|
|
|
If CveMovimiento <= 0 Or EsNuevoMov Then SiguienteFolio()
|
|
Dim CveConcepto = DdlConcepto.SelectedValue
|
|
|
|
DivCodigoBarras.Visible = False
|
|
TxtFecha.Enabled = True
|
|
TxtObservaciones.Enabled = True
|
|
|
|
DivCliente.Visible = False
|
|
DivClienteSucursal.Visible = False
|
|
DivDepartamentoEntrega.Visible = False
|
|
TxtDepartamentoEntrega.Text = ""
|
|
TxtPedidoContrato.Text = ""
|
|
|
|
Select Case CveConcepto
|
|
Case "1", "2", "22", "32", "33" ' ENTRADAS
|
|
DivCodigoBarras.Visible = True
|
|
TxtCodigoBarras.Focus()
|
|
|
|
If CveMovimiento > 0 Then
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
TxtFecha.Enabled = False
|
|
End If
|
|
|
|
VisualizaPU(True)
|
|
TrPersonal.Visible = False
|
|
TrResponsable.Visible = True
|
|
If UsuarioActual.CveEmpresa.Contiene(66, 13) Then
|
|
TrSubProyectoActivoFijo.Visible = True
|
|
VisualizaAF(True)
|
|
CargaSubProyectos()
|
|
End If
|
|
If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = True
|
|
|
|
Case "3", "11", "21", "31"
|
|
VisualizaPU(False)
|
|
TrPersonal.Visible = False
|
|
TrResponsable.Visible = True
|
|
If UsuarioActual.CveEmpresa.Contiene(66, 13) Then
|
|
TrSubProyectoActivoFijo.Visible = True
|
|
VisualizaAF(True)
|
|
CargaSubProyectos()
|
|
End If
|
|
If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = False
|
|
|
|
If CveConcepto = "3" Then
|
|
ActivaClientes()
|
|
End If
|
|
|
|
Case "7"
|
|
VisualizaPU(False)
|
|
TrSubProyectoActivoFijo.Visible = False
|
|
TrResponsable.Visible = False
|
|
CargaPersonal()
|
|
If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = False
|
|
Case "10"
|
|
VisualizaPU(True)
|
|
|
|
Case "28"
|
|
TrProveedor.Visible = True
|
|
DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
DdlProveedor.DataBind()
|
|
|
|
Case Else
|
|
DivCodigoBarras.Visible = False
|
|
TrSubProyectoActivoFijo.Visible = False
|
|
VisualizaAF(False)
|
|
If GvM.Rows.Count > 0 Then GvM.FooterRow.Visible = True
|
|
TrPersonal.Visible = False
|
|
TrResponsable.Visible = False
|
|
End Select
|
|
|
|
UpCodigoBarras.Update()
|
|
UppGrid.Update()
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub VisualizaPU(Opcion As Boolean)
|
|
'tdPU.Visible = Opcion
|
|
'tdTxtPU.Visible = Opcion
|
|
txtPrecio.Visible = Opcion
|
|
GvM.Columns(4).Visible = Opcion
|
|
|
|
TdTotal.Visible = Opcion
|
|
ThTotal.Visible = Opcion
|
|
GvM.Columns(5).Visible = Opcion
|
|
End Sub
|
|
Private Sub VisualizaPUExtranjero(Opcion As Boolean)
|
|
tdPUExtranjero.Visible = Opcion
|
|
tdPUExtranjero2.Visible = Opcion
|
|
GvM.Columns(6).Visible = Opcion
|
|
End Sub
|
|
Private Sub VisualizaAF(Opcion As Boolean)
|
|
tdAF.Visible = Opcion
|
|
ThAF.Visible = Opcion
|
|
GvM.Columns(8).Visible = Opcion
|
|
End Sub
|
|
Private Sub SiguienteFolio()
|
|
Dim Inv As New ClsInventarios
|
|
Dim Folio As Integer = Inv.GetFolioSiguiente(DdlConcepto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa)
|
|
Inv.Dispose()
|
|
|
|
TxtFolio.Text = Folio.ToString
|
|
FolioAsignado = Folio
|
|
UPEncabezado.Update()
|
|
End Sub
|
|
Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged
|
|
ChangeDdlProducto()
|
|
End Sub
|
|
Private Sub ChangeDdlProducto()
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "" Then
|
|
Dim filtro As String = ""
|
|
If Not (DdlClasificacion.SelectedValue = "-1") Then
|
|
|
|
If isWhitFamily() Then
|
|
filtro = String.Format("CveSubFamilia={0}", DdlClasificacion.SelectedValue)
|
|
Else
|
|
filtro = String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue)
|
|
End If
|
|
End If
|
|
|
|
DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros($"{filtro} AND CveTipoPS = 2", "PSCodigo")
|
|
DdlProducto2.DataBind()
|
|
DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
Else
|
|
If isWhitFamily() Then
|
|
DdlProducto2.ddlWS.Attributes.Add("data-idSubFamilia", DdlClasificacion.SelectedValue)
|
|
Else
|
|
DdlProducto2.ddlWS.Attributes.Add("data-idClasificacion", DdlClasificacion.SelectedValue)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange
|
|
ElProductoChange()
|
|
End Sub
|
|
Private Sub ElProductoChange()
|
|
TxtnSerie.Visible = False
|
|
divSerie.Visible = False
|
|
|
|
TxtnLote.Visible = False
|
|
divLote.Visible = False
|
|
|
|
EscondeColumnasGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
If DdlProducto2.SelectedValue.ToEntero > 0 Then
|
|
Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, DdlProducto2.SelectedValue.ToEntero).FiltroPrimero("")
|
|
If dr IsNot Nothing Then
|
|
If CBool(dr("AplicaSerie")) Then
|
|
|
|
TxtnSerie.Visible = True
|
|
divSerie.Visible = True
|
|
|
|
End If
|
|
If CBool(dr("AplicaLote")) Then
|
|
TxtnLote.Visible = True
|
|
divLote.Visible = True
|
|
|
|
End If
|
|
If CBool(dr("AplicaSeccion")) Then
|
|
divSeccionAlmacen.Visible = True
|
|
'DdlSeccionAlmacen.Items.Clear()
|
|
'DdlSeccionAlmacen.ClearSelection()
|
|
'DdlSeccionAlmacen.DataSource = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, DdlProducto2.SelectedValue.ToEntero)
|
|
'DdlSeccionAlmacen.DataBind()
|
|
CargaSeccionesAlmacen(DdlSeccionAlmacen, DdlAlmacen.SelectedValue.ToEntero, DdlProducto2.SelectedValue.ToEntero, UsuarioActual.CveEmpresa)
|
|
|
|
End If
|
|
If CBool(dr("AplicaCaducidad")) Then
|
|
divCaducidad.Visible = True
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
DdlUnidad.Items.Clear()
|
|
DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
DdlUnidad.DataBind()
|
|
UPDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " GVM "
|
|
Private Sub CargaGVM(DtTemp As DataTable)
|
|
GvM.DataSource = DtTemp '.FiltraPorIndices(0, If(DtTemp.Rows.Count > 20, 19, DtTemp.Rows.Count - 1))
|
|
GvM.DataBind()
|
|
|
|
EscondeColumnasGVM(DtTemp)
|
|
End Sub
|
|
Private Sub EscondeColumnasGVM(DtTemp As DataTable)
|
|
'LblSerie.Visible = False
|
|
TxtnSerie.Visible = False
|
|
'TrSerieLote.Visible = False
|
|
'TrSerieLote2.Visible = False
|
|
|
|
If Not String.IsNullOrWhiteSpace(UsuarioActual.Empresa.Funcionalidad(147)) Then GvM.Columns(11).HeaderText = UsuarioActual.Empresa.Funcionalidad(147)
|
|
|
|
GvM.Columns(9).Visible = False
|
|
'PERMISO SOLO PARA EDITAR SERIELOTE
|
|
If UsuarioActual.TienePermisoProceso(245) Then
|
|
GvM.Columns(9).Visible = True
|
|
TxtnSerie.Visible = True
|
|
End If
|
|
|
|
TxtnLote.Visible = False
|
|
'TrLote.Visible = False
|
|
'TrLote2.Visible = False
|
|
GvM.Columns(10).Visible = False
|
|
|
|
'TxtnBatch.Visible = False
|
|
'TrBatch.Visible = False
|
|
'TrBatch2.Visible = False
|
|
'GvM.Columns(11).Visible = False
|
|
|
|
Dim TienePermisoImportes = UsuarioActual.TienePermisoProceso(201)
|
|
tdPUExtranjero.Visible = False
|
|
tdPUExtranjero2.Visible = False
|
|
GvM.Columns(6).Visible = False
|
|
|
|
tdCI.Visible = False
|
|
tdCI2.Visible = False
|
|
GvM.Columns(7).Visible = False
|
|
|
|
If DtTemp.SUM("PUExtranjero") > 0 Then
|
|
tdPUExtranjero.Visible = TienePermisoImportes
|
|
tdPUExtranjero2.Visible = TienePermisoImportes
|
|
GvM.Columns(6).Visible = TienePermisoImportes
|
|
End If
|
|
|
|
If DtTemp.SUM("CostoIndirecto") > 0 Then
|
|
tdCI.Visible = TienePermisoImportes
|
|
tdCI2.Visible = TienePermisoImportes
|
|
GvM.Columns(7).Visible = TienePermisoImportes
|
|
End If
|
|
|
|
If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then
|
|
GvM.Columns(9).Visible = DtTemp.MAX("Serie") <> ""
|
|
GvM.Columns(10).Visible = DtTemp.MAX("Lote") <> ""
|
|
GvM.Columns(11).Visible = DtTemp.MAX("FechaCaducidad").ToDate > MinFecha
|
|
GvM.Columns(12).Visible = DtTemp.MAX("CveSeccionAlmacen").ToEntero > 0
|
|
|
|
End If
|
|
'UppGrid.Update()
|
|
End Sub
|
|
Protected Sub GvM_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvM.RowDataBound
|
|
Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201)
|
|
|
|
If e.Row.RowType = DataControlRowType.Header Then
|
|
LbTotalMovimientos.Text = String.Format("Total de Movimientos: {0}", CType(GvM.DataSource, DataTable).Rows.Count.ToString)
|
|
End If
|
|
|
|
|
|
If e.Row.RowType = DataControlRowType.Footer Then
|
|
|
|
e.Row.FCLiteral("lbTotProducto").Visible = TienePermisoImportes
|
|
e.Row.FCLiteral("lbTotPrecio").Visible = TienePermisoImportes
|
|
e.Row.FCLiteral("lbTotPrecioExtranjero").Visible = TienePermisoImportes
|
|
e.Row.FCLiteral("LtTotCI").Visible = TienePermisoImportes
|
|
|
|
If TienePermisoImportes Then
|
|
e.Row.FCLiteral("lbTotPrecioExtranjero").Text = DtMovimientos.SUM("TotalExtranjero", "Estatus IN ('','U')").FormatoNumero
|
|
e.Row.FCLiteral("LtTotCI").Text = DtMovimientos.SUM("CostoIndirecto", "Estatus IN ('','U')").FormatoNumero
|
|
e.Row.FCLiteral("lbTotPrecio").Text = DtMovimientos.SUM("Total", "Estatus IN ('','U')").FormatoNumero
|
|
End If
|
|
End If
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
|
|
e.Row.FCTextBox("LblEditCodigo").Attributes.Add("onkeyup", String.Format("EnterAFEdit(event,this,{0},{1});", e.Row.FCHiddenField("HdnCveActivoFijo").ClientID, e.Row.FCHiddenField("HdnCodigoAF").ClientID))
|
|
e.Row.FCTextBox("LblEditCodigo").Attributes.Add("onblur", String.Format("AFBlurEdit(this,{0},{1});", e.Row.FCHiddenField("HdnCveActivoFijo").ClientID, e.Row.FCHiddenField("HdnCodigoAF").ClientID))
|
|
e.Row.FCImage("ImgAF").Attributes.Add("onclick", String.Format("AbrirVentana('/AF/PopUpBuscarAF.aspx?OPCION=OCE&RI={0}',950,600,'N');", e.Row.RowIndex))
|
|
|
|
'PERMISO SOLO PARA EDITAR OBSERVACIONES
|
|
If PermiteGuardarObservacionDetalle() Then
|
|
e.Row.FCTextBox("txtPrecio").Enabled = False
|
|
e.Row.FCTextBox("LblEditCodigo").Enabled = False
|
|
e.Row.FCTextBox("TxtSerie").Enabled = False
|
|
e.Row.FCTextBox("TxtLote").Enabled = False
|
|
e.Row.FCDropDownList("DdlSeccionAlmacen").Enabled = False
|
|
End If
|
|
|
|
'PERMISO SOLO PARA EDITAR SERIELOTE
|
|
If UsuarioActual.TienePermisoProceso(245) Then
|
|
If (CveMovimiento > 0) Or (TieneRelacionado > 0 Or CveMovimientoRelacionado > 0) Then 'CveMovimiento > 0 And e.Row.DBCampo("TienePrePoliza").ToEntero > 0
|
|
e.Row.FCTextBox("txtPrecio").Enabled = False
|
|
e.Row.FCTextBox("LblEditCodigo").Enabled = False
|
|
e.Row.FCTextBox("TxtSerie").Enabled = False
|
|
e.Row.FCTextBox("TxtLote").Enabled = False
|
|
e.Row.FCDropDownList("DdlSeccionAlmacen").Enabled = False
|
|
e.Row.FCTextBox("txtPrecio").Enabled = False
|
|
End If
|
|
e.Row.FCTextBox("TxtSerie").Enabled = True
|
|
End If
|
|
|
|
If EsNuevoMov Then
|
|
e.Row.FCTextBox("TxtCantidad").Enabled = True
|
|
e.Row.FCTextBox("txtPrecio").Enabled = True
|
|
End If
|
|
|
|
Else
|
|
If CveMovimiento > 0 Then
|
|
'DEPENDE PERMISOS HABILITA
|
|
e.Row.FCLinkButton("lnkRemove").Visible = PermiteEliminar()
|
|
e.Row.FCLinkButton("imgE").Visible = PermiteGuardar()
|
|
|
|
If e.Row.DBCampo("CountMovimientoEntradaDetalle").ToEntero > 0 Then
|
|
TieneSalida = True
|
|
e.Row.FCLinkButton("lnkRemove").Visible = False
|
|
e.Row.FCLinkButton("imgE").Visible = False
|
|
End If
|
|
|
|
'SI TIENE PREPOLIZAS NO PUEDE EDITAR NI ELIMINAR
|
|
If e.Row.DBCampo("TienePrePoliza").ToEntero > 0 Then
|
|
e.Row.FCLinkButton("lnkRemove").Visible = False
|
|
e.Row.FCLinkButton("imgE").Visible = False
|
|
End If
|
|
|
|
'APAGA TODO SI TIENE MOVIMIENTO RELACIONADO
|
|
If TieneRelacionado > 0 Or CveMovimientoRelacionado > 0 Then
|
|
e.Row.FCLinkButton("lnkRemove").Visible = False
|
|
e.Row.FCLinkButton("imgE").Visible = False
|
|
End If
|
|
|
|
'PERMISO SOLO PARA EDITAR OBSERVACIONES
|
|
If PermiteGuardarObservacionDetalle() Then
|
|
e.Row.FCLinkButton("imgE").Visible = True
|
|
End If
|
|
|
|
'PERMISO SOLO PARA EDITAR SERIELOTE
|
|
If UsuarioActual.TienePermisoProceso(245) Then
|
|
e.Row.FCLinkButton("imgE").Visible = True
|
|
End If
|
|
|
|
If EsNuevoMov Then
|
|
e.Row.FCLinkButton("lnkRemove").Visible = True
|
|
End If
|
|
|
|
End If
|
|
|
|
Dim Cantidad = e.Row.FCLiteral("lbCantidad").Text.ToDecimal
|
|
If Not UsuarioActual.TienePermisoProceso(265) Or Cantidad <= 1 Or Cantidad Mod 1 <> 0 Then
|
|
e.Row.FCLinkButton("lnkDividir").Visible = False
|
|
End If
|
|
End If
|
|
|
|
|
|
End If
|
|
End Sub
|
|
Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvM.RowEditing
|
|
Dim i As Integer = e.NewEditIndex
|
|
GvM.EditIndex = i
|
|
|
|
Dim Gv As GridView = DirectCast(sender, GridView)
|
|
Dim GvRow As GridViewRow = Gv.Rows(i)
|
|
If CveMovimiento > 0 Then
|
|
CveMovimientoDetalleEdit = GvRow.DataKey("CveMovimientoDetalle").ToEntero
|
|
txtCantidad.Enabled = False
|
|
DdlClasificacion.Enabled = False
|
|
DdlProducto2.Enabled = False
|
|
DdlUnidad.Enabled = False
|
|
|
|
'codigo provisional, hay entradas con productos, que al asignar serie, debe de tener e ncantidad = 1
|
|
If GvRow.DataKey("Cantidad").ToEntero() > 1 Then txtCantidad.Enabled = True
|
|
End If
|
|
txtCantidad.Text = GvRow.DataKey("Cantidad").ToEntero().ToString
|
|
DdlProducto2.SelectedValue = GvRow.DataKey("CvePS")
|
|
DdlProducto2.SelectedText = GvRow.DataKey("CodigoPS")
|
|
ElProductoChange()
|
|
DdlUnidad.SelectedValue = GvRow.DataKey("CveUM")
|
|
CveAFEdit = GvRow.DataKey("CveAF").ToEntero
|
|
txtPrecio.Text = GvRow.DataKey("PU").ToDouble.FormatoNumero
|
|
TxtnSerie.Text = GvRow.DataKey("Serie")
|
|
TxtnLote.Text = GvRow.DataKey("Lote")
|
|
TxtnFechaCaducidad.Text = GvRow.DataKey("FechaCaducidad").ToDate.ToShortDateString
|
|
TxtObservacionesdetalle.Text = GvRow.DataKey("Observaciones")
|
|
|
|
DdlSeccionAlmacen.DataSource = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, GvRow.DataKey("CvePS").ToEntero)
|
|
DdlSeccionAlmacen.DataBind()
|
|
DdlSeccionAlmacen.SelectedValueExist(GvRow.DataKey("CveSeccionAlmacen"))
|
|
|
|
LkAgregarDetalle.Text = "Actualizar"
|
|
Dim Origen As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue)).ToEntero
|
|
divPrecio.Visible = Origen = 1
|
|
txtPrecio.Visible = Origen = 1
|
|
UpAgregar.Update()
|
|
RegistraScript("$('#ModalAgregar').modal()")
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
End Sub
|
|
Protected Sub EditPS(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
If CveMovimiento > 0 Then
|
|
CveMovimientoDetalleEdit = GvRow.DataKey("CveMovimientoDetalle").ToEntero
|
|
divCantidad.Visible = False
|
|
divClasificacionProducto.Visible = False
|
|
divUnidadMedida.Visible = False
|
|
End If
|
|
txtCantidad.Text = GvRow.DataKey("Cantidad").ToEntero().ToString
|
|
DdlProducto2.SelectedValue = GvRow.DataKey("CvePS")
|
|
DdlProducto2.SelectedText = GvRow.DataKey("CodigoPS")
|
|
ElProductoChange()
|
|
DdlUnidad.SelectedValue = GvRow.DataKey("CveUM")
|
|
CveAFEdit = GvRow.DataKey("CveAF").ToEntero
|
|
txtPrecio.Text = GvRow.DataKey("PU").ToDouble.FormatoNumero
|
|
TxtnSerie.Text = GvRow.DataKey("Serie")
|
|
TxtnLote.Text = GvRow.DataKey("Lote")
|
|
TxtnFechaCaducidad.Text = GvRow.DataKey("FechaCaducidad")
|
|
TxtObservacionesdetalle.Text = GvRow.DataKey("Observaciones")
|
|
DdlSeccionAlmacen.SelectedValueExist(GvRow.DataKey("CveSeccionAlmacen"))
|
|
|
|
Dim Origen As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue)).ToEntero
|
|
divPrecio.Visible = Origen = 1
|
|
txtPrecio.Visible = Origen = 1
|
|
LkAgregarDetalle.Text = "Actualizar"
|
|
UpAgregar.Update()
|
|
RegistraScript("$('#ModalAgregar').modal()")
|
|
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 Cantidad As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDouble
|
|
'Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", No))
|
|
|
|
'If Drs.Count > 0 Then
|
|
' Drs(0)("Cantidad") = Cantidad
|
|
' 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
|
|
Protected Sub DividirRow(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
|
|
Dim Cantidad As Integer = Drs(0)("Cantidad").ToString.ToEntero
|
|
|
|
Dim CvePS = Drs(0)("CvePS")
|
|
Dim Producto = Drs(0)("CodigoPS")
|
|
Dim PU = Drs(0)("PU")
|
|
Dim CveSeccion = Drs(0)("CveSeccionAlmacen")
|
|
|
|
Drs(0)("Cantidad") = "1"
|
|
Drs(0)("Total") = PU
|
|
Drs(0)("Estatus") = "U"
|
|
|
|
For counter As Integer = 1 To Cantidad - 1
|
|
|
|
txtCantidad.Text = "1"
|
|
DdlProducto2.SelectedValue = CvePS.ToString
|
|
DdlProducto2.SelectedText = Producto.ToString
|
|
txtPrecio.Text = PU.ToString
|
|
If DdlSeccionAlmacen.Visible = True And CveSeccion.ToString <> "" Then
|
|
DdlSeccionAlmacen.SelectedValue = CveSeccion.ToString
|
|
End If
|
|
|
|
ElProductoChange()
|
|
|
|
AgregarPS()
|
|
txtPrecio.Text = ""
|
|
DdlUnidad.SelectedItem.Text = ""
|
|
|
|
Next
|
|
|
|
End If
|
|
DtMovimientos.AcceptChanges()
|
|
End If
|
|
|
|
GvM.EditIndex = -1
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " CONTABILIZAR "
|
|
|
|
Public Function ContabilizaMovimientoAlmacen(ByRef ObjConta As ClsContabilidad, Fecha As Date, Concepto As String, Modulo As String, CveMovimientoSalida As Integer, CveMovimientoEntrada As Integer, Importe As Decimal, CveUsuario As Integer, CveEmpresa As Integer, Contabilizable As Boolean) As Integer
|
|
Dim Retorno As Integer = -1
|
|
Dim ErrorMovInv As Boolean = False
|
|
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas(Modulo, 53, 0, 0, 1, Fecha, Concepto, CveUsuario, CveEmpresa)
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Importe, "", 68, Concepto, Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=Importe, Contabilizable:=Contabilizable) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Importe, "", 68, Concepto, Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=Importe, Contabilizable:=Contabilizable) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ErrorMovInv Then Retorno = CvePrePoliza
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
Protected Sub BtnContabilizar_Click(sender As Object, e As EventArgs) Handles BtnContabilizar.Click
|
|
Dim ObjContaAC As ClsContPAQi = Nothing
|
|
Dim ObjInventario As New ClsInventarios
|
|
ObjInventario.IniciaTransacSQL() 'Inicia la transacción
|
|
|
|
'DEVENGAR
|
|
Dim IDPoliza As Integer
|
|
Dim ErrorAC = False
|
|
Dim TotalPorDevengar As Double = 0
|
|
Dim Folio As String = ""
|
|
Dim Fecha As Date = TxtFecha.Text.ToDate
|
|
|
|
|
|
'cuando tiene AC y es salida de almacen, se manda al gasto
|
|
If UsuarioActual.Empresa.UsaAC AndAlso DdlConcepto.SelectedValue = "3" Then
|
|
|
|
'Dim Total As Double = 0
|
|
|
|
'TotalPorDevengar += Total ' GvInv.Rows.Cast(Of GridViewRow)().Sum(Function(Gvr) Math.Round(Gvr.DataKey("PU").ToString.ToDouble, 4) * Math.Round(Gvr.DataKey("CantidadF").ToString.ToDouble, 4))
|
|
|
|
|
|
TotalPorDevengar = Math.Round(TotalPorDevengar, 4)
|
|
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjContaAC.IniciaTransacSQL()
|
|
|
|
IDPoliza = ObjContaAC.AddPoliza(3, "Salida de Almacen", TotalPorDevengar, TotalPorDevengar, UsuarioActual.CveUsuario, Fecha)
|
|
If IDPoliza > 0 Then
|
|
|
|
Dim CuentaCargoCOG As Integer
|
|
Dim CuentaAbonoAlmacen As Integer = 0
|
|
Dim Importe As Double = DtMovimientos.SUM("Total", "Estatus = ''")
|
|
Folio = ObjContaAC.Folio.ToString
|
|
|
|
Dim drA As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacen.SelectedValue))
|
|
If drA IsNot Nothing Then CuentaAbonoAlmacen = drA("IdCtaContable").ToString.ToEntero
|
|
|
|
|
|
If UsuarioActual.CveEmpresa = 48 Then ' APH
|
|
CuentaCargoCOG = 1386
|
|
End If
|
|
|
|
|
|
If CuentaCargoCOG > 0 AndAlso CuentaAbonoAlmacen > 0 Then
|
|
If ObjContaAC.AddMovimiento(IDPoliza, CuentaCargoCOG, False, Importe, "", "", 0, Fecha, "") Then
|
|
'actualizo el idcuenta del presupuesto
|
|
If Not ObjContaAC.AddMovimiento(IDPoliza, CuentaAbonoAlmacen, True, Importe, "", "", 0, Fecha, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
If IDPoliza > 0 Then
|
|
ObjInventario.UpdateMovimientoPoliza(IDPoliza, CveMovimiento, UsuarioActual.CveEmpresa)
|
|
End If
|
|
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
|
|
|
|
End If
|
|
'TERMINA: DEVENGAR
|
|
|
|
If Not ErrorAC Then
|
|
|
|
ObjInventario.Commit() ' aplica los movimientos insertados
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.AjustaPoliza(IDPoliza) : ObjContaAC.Commit()
|
|
Alert(String.Format("Movimiento Registrado<br/><br/> <a href ='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' class='Texto'>Poliza {1}</a>", IDPoliza, Folio), TipoMensaje.MsgInformacion)
|
|
UPDatos.Update()
|
|
BtnContabilizar.Visible = PermiteContabilizar()
|
|
Else
|
|
ObjInventario.RollBack()
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
|
Alert("Error", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " VinculaAF "
|
|
Protected Sub BtnVinculaAF_Click(sender As Object, e As EventArgs)
|
|
If HdnCveActivoFijo.Value.ToEntero = -2 Then
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, LblCodigo.Text, "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1) Then
|
|
If ObjAF.DtResultados.Rows.Count = 1 Then
|
|
HdnCodigoAF.Value = ObjAF.DtResultados.Rows(0)("Codigo").ToString
|
|
HdnCveActivoFijo.Value = ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString
|
|
|
|
LblCodigo.Text = HdnCodigoAF.Value
|
|
Else
|
|
HdnCodigoAF.Value = "-1"
|
|
HdnCveActivoFijo.Value = "-1"
|
|
LblCodigo.Text = ""
|
|
Alert("No se encontró un Activo Fijo con el código proporcionado.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
Else
|
|
LblCodigo.Text = HdnCodigoAF.Value
|
|
End If
|
|
|
|
'LbAgregar.Focus()
|
|
|
|
UPDatos.Update()
|
|
End Sub
|
|
|
|
Protected Sub BtnVinculaAFEdit_Click(sender As Object, e As EventArgs)
|
|
If HdnCodAFEdit.Value.Trim = "" Then Exit Sub
|
|
|
|
Dim ObjAF As New ClsAF
|
|
|
|
If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, HdnCodAFEdit.Value, "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "", -1) Then
|
|
If ObjAF.DtResultados.Rows.Count = 1 Then
|
|
RegistraScript(String.Format("EnterAFEditOK('{0}','{1}');", ObjAF.DtResultados.Rows(0)("CveActivoFijo").ToString, ObjAF.DtResultados.Rows(0)("Codigo").ToString))
|
|
Else
|
|
Alert("No se encontró un Activo Fijo con el código proporcionado.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript(String.Format("EnterAFEditOK({0},{1});", "-1", "-1"))
|
|
End If
|
|
End If
|
|
|
|
ObjAF.Dispose()
|
|
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
|
|
'If ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento IN (6,2) AND CvePrioridad=3").Rows.Count > 0 Then
|
|
' DivEventoUrgente.Visible = True
|
|
'End If
|
|
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()
|
|
'File.Delete(String.Format("\Empresas\{0}\OI\Temp\OI{1}{2}.{3}", CveEmpresaActual, UsuarioActual.CveUsuario, DtDetalle.Rows.Count, FileExtension))
|
|
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
|
|
'Dim Prioridad As Integer = If(ChkEventoPrioridad.Checked, 3, 1)
|
|
|
|
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 = "[]"
|
|
'ChkEventoPrioridad.Checked = False
|
|
Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion)
|
|
RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal")
|
|
|
|
''obtener el Evento de bitacora para enviar el correo
|
|
'If ObjEventoBitacora.GetEvento(ObjEventoBitacora.CveEvento, UsuarioActual.CveUsuario, CveEmpresaActual) Then
|
|
' If ObjEventoBitacora.DtResultados IsNot Nothing AndAlso ObjEventoBitacora.DtResultados.Rows.Count > 0 Then
|
|
' Dim dr As DataRow = ObjEventoBitacora.DtResultados.Rows(0)
|
|
' EnviarCorreoBitacora(String.Format("{0}, {1} comento: ""{2}""", dr("FechaIng"), dr("Usuario"), dr("Descripcion")), String.Format("http://sig.adsistemas.mx/Empresas/{0}/OI/{1}", CveEmpresaActual, ObjEventoBitacora.Archivo))
|
|
' End If
|
|
'End If
|
|
|
|
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 " AGREGA CON TXT | CODIGO - SERIE "
|
|
Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs)
|
|
|
|
If TxtCodigoPS.Text.Trim = "" Then
|
|
Exit Sub
|
|
End If
|
|
|
|
TdSeriePS.Visible = False
|
|
TdSeccionPSAdd.Visible = False
|
|
|
|
Dim Dr = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras= '{TxtCodigoPS.Text}'")
|
|
If Dr Is Nothing Then
|
|
Alert($"No se ha encontrado un producto con el Codigo ""<b>{TxtCodigoPS.Text}</b>"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(FocusAdd,200);")
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
TxtCodigoPS.Text = ""
|
|
Exit Sub
|
|
End If
|
|
|
|
If Dr("AplicaSerie").ToString = "True" Then
|
|
TdSeriePSAdd.Visible = True
|
|
TxtSeriePS.Focus()
|
|
CvePSSerieLote = Dr("CvePS").ToString.ToEntero
|
|
PSSerieLote = Dr("PSCodigo").ToString
|
|
CveUMSerieLote = Dr("CveUM").ToString.ToEntero
|
|
UMSerieLote = Dr("UnidadMedida").ToString
|
|
Exit Sub
|
|
End If
|
|
Dim CveSeccionAlmacen As Integer = -1
|
|
Dim SeccionAlmacen As String = ""
|
|
|
|
If Dr("AplicaSeccion").ToString = "True" Then
|
|
If DdlAlmacen.SelectedValue.ToEntero <= 1 Then
|
|
Alert("No se ha especificado el almacen para especificar la sección", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
DdlSeccionPSAdd.Items.Clear()
|
|
Dim dtt As DataTable = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, Dr("CvePS").ToString.ToEntero)
|
|
DdlSeccionPSAdd.DataSource = dtt
|
|
DdlSeccionPSAdd.DataBind()
|
|
If dtt.Rows.Count > 1 Then
|
|
DdlSeccionPSAdd.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
' si solo hay un movimiento, debe de agregar, sino debe de esperar a que seleccionen
|
|
Exit Sub
|
|
DdlSeccionPSAdd.Focus()
|
|
TdSeccionPSAdd.Visible = True
|
|
Else
|
|
CveSeccionAlmacen = DdlSeccionPSAdd.SelectedValue.ToEntero
|
|
SeccionAlmacen = DdlSeccionPSAdd.SelectedItem.Text
|
|
End If
|
|
|
|
End If
|
|
|
|
AddNew(Dr("CvePS").ToString.ToEntero, Dr("PSCodigo").ToString, Dr("CveUM").ToString.ToEntero, Dr("UnidadMedida").ToString, 1, Dr("CostoPromedio").ToString.ToDecimal, "", "", "", "", "", "", MinFecha, CveSeccionAlmacen, SeccionAlmacen)
|
|
|
|
TxtCodigoPS.Text = ""
|
|
TxtCodigoPS.Focus()
|
|
|
|
End Sub
|
|
Protected Sub BtnSeriePSAdd_Click(sender As Object, e As EventArgs)
|
|
|
|
If TxtSeriePS.Text.Trim = "" Then
|
|
Exit Sub
|
|
End If
|
|
If TdSeccionPSAdd.Visible Then
|
|
If DdlSeccionAlmacen.SelectedValue.ToEntero <= 0 Then
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
AddNew(CvePSSerieLote, PSSerieLote, CveUMSerieLote, UMSerieLote, 1, 0, TxtSeriePS.Text.Trim, "", "", "", "", "", MinFecha, -1, "")
|
|
|
|
TdSeriePSAdd.Visible = False
|
|
TxtSeriePS.Text = ""
|
|
TxtCodigoPS.Text = ""
|
|
TxtCodigoPS.Focus()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " CONSUMO INTERNO "
|
|
Private Sub ActivaConsumoInterno()
|
|
EsConsumoInterno = True
|
|
|
|
Panel1.Visible = False
|
|
DdlConcepto.Items.Insert(0, New ListItem("Salida por Consumo Interno", "30"))
|
|
DdlConcepto.SelectedValue = "30"
|
|
DdlAlmacen.AutoPostBack = False
|
|
DivFolio1.Visible = False
|
|
DivFolio2.Visible = False
|
|
DivConcepto1.Visible = False
|
|
DivConcepto2.Visible = False
|
|
divMonedaSeccion.Visible = False
|
|
divGuia.Visible = False
|
|
TrResponsable.Visible = False
|
|
CargaPersonal()
|
|
LtlTitulo.Text = "Consumo Interno"
|
|
|
|
'RECARGA ALMACENES SOLO DE CONSUMO INTERNO
|
|
DdlAlmacen.Items.Clear()
|
|
DdlAlmacen.DataBind()
|
|
Dim dttA As DataTable = Nothing
|
|
dttA = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 14)
|
|
dttA.Merge(GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1))
|
|
|
|
DdlAlmacen.DataSource = dttA '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)
|
|
End If
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
|
|
TrSubProyectoActivoFijo.Visible = True
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto, "Seleccione Uno")
|
|
|
|
DVCultivosCuadro.Visible = True
|
|
CargaCultivos()
|
|
End If
|
|
|
|
|
|
TrActivoFijo.Visible = True
|
|
DdlActivoFijo.Items.Clear()
|
|
DdlActivoFijo.DataSource = GlobalDTActivoFijos(UsuarioActual.CveEmpresa).FiltraParametros(" CveEstadoActivoFijo IN(1,3,4,9) ")
|
|
DdlActivoFijo.DataBind()
|
|
DdlActivoFijo.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
DdlActivoFijo.SelectedValueExist(-1)
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaCultivos()
|
|
DdlModalCultivosCuadro.Items.Clear()
|
|
DdlModalCultivosCuadro.DataSource = GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto = {DdlSubProyecto.SelectedValue} AND Estatus = 1 ", "TemporadaCuadro")
|
|
DdlModalCultivosCuadro.DataBind()
|
|
DdlModalCultivosCuadro.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "PAQUETERIA GUIA"
|
|
Protected Sub LnkAgregarGuia_Click(sender As Object, e As EventArgs)
|
|
RegistraScript(String.Format("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx?CveMovimiento={0}',800,620);", CveMovimiento))
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarGuia_Click(sender As Object, e As EventArgs)
|
|
|
|
'Dim objInventario As New ClsInventarios
|
|
|
|
'If objInventario.AddPaqueteriaGuia(DdlPaqueteria.SelectedValue.ToEntero, CveMovimiento, TxtPaqueteriaGuia.Text.Trim, TxtPaqueteriaNumcajas.Text.ToEntero, TxtPaqueteriaPeso.Text.ToDecimal, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
|
|
' TxtRastreo.Text.Trim, TxtDimensiones.Text.Trim, TxtFechaEst.Text.Trim) Then
|
|
' CargaGvPaqueteria()
|
|
' LimpiacontrolesPaqueteria()
|
|
'End If
|
|
|
|
'objInventario.Dispose()
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkRemovePaqueteriaGuia_Click(sender As Object, e As EventArgs)
|
|
|
|
'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
'Dim CvePaqueteriaGuia As Integer = GvRow.DataKey("CvePaqueteriaGuia").ToString.ToEntero
|
|
'Dim objInventario As New ClsInventarios
|
|
|
|
'If objInventario.RemovePaqueteriaGuia(CvePaqueteriaGuia, UsuarioActual.CveEmpresa) Then
|
|
' CargaGvPaqueteria()
|
|
'End If
|
|
|
|
'objInventario.Dispose()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaGvPaqueteria()
|
|
|
|
'Dim objInventario As New ClsInventarios
|
|
|
|
'If objInventario.GetPaqueteriaGuia(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
' GvPaqueriaGuias.DataSource = objInventario.DtResultados
|
|
|
|
' If objInventario.DtResultados.Rows.Count > 0 Then
|
|
' BtnAgregarGuia.Attributes.Add("data-toggle", "confirmation")
|
|
' BtnAgregarGuia.Attributes.Add("data-popout", "true")
|
|
' BtnAgregarGuia.Attributes.Add("data-original-title", "¿Está seguro de registrar una nueva guia a la factura?")
|
|
' BtnAgregarGuia.Attributes.Add("data-btn-ok-label", "si")
|
|
|
|
' Else
|
|
|
|
' BtnAgregarGuia.Attributes.Remove("data-toggle")
|
|
' BtnAgregarGuia.Attributes.Remove("data-popout")
|
|
' BtnAgregarGuia.Attributes.Remove("data-original-title")
|
|
' BtnAgregarGuia.Attributes.Remove("data-btn-ok-label")
|
|
|
|
|
|
' End If
|
|
|
|
'Else
|
|
' GvPaqueriaGuias.DataSource = Nothing
|
|
'End If
|
|
|
|
'objInventario.Dispose()
|
|
'GvPaqueriaGuias.DataBind()
|
|
'UpModalGuias.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub LimpiacontrolesPaqueteria()
|
|
|
|
'DdlPaqueteria.SelectedIndex = 0
|
|
'TxtPaqueteriaGuia.Text = ""
|
|
'TxtPaqueteriaNumcajas.Text = ""
|
|
'TxtPaqueteriaPeso.Text = ""
|
|
|
|
'TxtRastreo.Text = ""
|
|
'TxtDimensiones.Text = ""
|
|
'TxtFechaEst.Text = ""
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkGuiaPaqueteriaGuia_Click(sender As Object, e As EventArgs)
|
|
'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
'Dim CvePaqueteriaGuia As Integer = GvRow.DataKey("CvePaqueteriaGuia").ToString.ToEntero
|
|
'Dim NumCajas As String = GvRow.DataKey("NumCajas").ToString
|
|
'Dim Guia As String = GvRow.DataKey("Guia").ToString
|
|
'Dim Peso As String = GvRow.DataKey("Peso").ToString.ToDecimal.ToString("####.00")
|
|
'Dim DTDatosClienteGuia As New DataTable
|
|
'Dim DTMovimientosDetalle As New DataTable
|
|
'Dim CvePaqueteria As Integer = GvRow.DataKey("CvePaqueteria").ToString.ToEntero
|
|
'Dim RutaRdlc As String = Server.MapPath("~") & "\Empresas\Grales\Formatos\GuiasFormato" & CvePaqueteria & ".rdlc"
|
|
|
|
'Dim Rastreo As String = GvRow.DataKey("Rastreo")
|
|
'Dim Dimensiones As String = GvRow.DataKey("Dimensiones")
|
|
'Dim FechaEstimada As String = GvRow.DataKey("FechaEstimada")
|
|
'Dim ValorStimado As Double = 0
|
|
|
|
'If Not File.Exists(RutaRdlc) Then
|
|
' RutaRdlc = Server.MapPath("~") & "\Empresas\Grales\Formatos\GuiasFormato0.rdlc"
|
|
'End If
|
|
|
|
'RutaRdlc = RutaRdlc.Replace(Server.MapPath("~") & "\", "")
|
|
|
|
'Dim params As New List(Of ReportParameter)
|
|
'Dim ObjInventario As New ClsInventarios
|
|
|
|
'If ObjInventario.GetPaqueteriaGuiasInfoFormato(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
' DTDatosClienteGuia = ObjInventario.DtResultados
|
|
'Else
|
|
' ObjInventario.Dispose()
|
|
' Exit Sub
|
|
'End If
|
|
|
|
'If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
|
|
' DTMovimientosDetalle = ObjInventario.DtResultados
|
|
' DTMovimientosDetalle.Columns.Add("Peso")
|
|
' DTMovimientosDetalle.Columns.Add("Dimensiones")
|
|
' DTMovimientosDetalle.AcceptChanges()
|
|
|
|
' For Each Drow As DataRow In DTMovimientosDetalle.Rows
|
|
' Drow("Peso") = Peso
|
|
' Drow("Dimensiones") = Dimensiones
|
|
' DTMovimientosDetalle.AcceptChanges()
|
|
' Next
|
|
|
|
' ValorStimado = DtMovimientos.SUM("PU")
|
|
' ObjInventario.Dispose()
|
|
'Else
|
|
' ObjInventario.Dispose()
|
|
' Exit Sub
|
|
'End If
|
|
|
|
'If DTDatosClienteGuia.Rows.Count > 0 Then
|
|
' params.Add(New ReportParameter("NombreComercial", DTDatosClienteGuia.Rows(0)("NombreComercial").ToString))
|
|
' params.Add(New ReportParameter("Direccion", DTDatosClienteGuia.Rows(0)("Direccion").ToString))
|
|
' params.Add(New ReportParameter("Colonia", DTDatosClienteGuia.Rows(0)("Colonia").ToString))
|
|
' params.Add(New ReportParameter("NoExt", DTDatosClienteGuia.Rows(0)("NoExt").ToString))
|
|
' params.Add(New ReportParameter("NoInt", DTDatosClienteGuia.Rows(0)("NoInt").ToString))
|
|
' params.Add(New ReportParameter("Localidad", DTDatosClienteGuia.Rows(0)("Localidad").ToString))
|
|
' params.Add(New ReportParameter("Telefono", DTDatosClienteGuia.Rows(0)("Telefono").ToString))
|
|
' params.Add(New ReportParameter("RFCCliente", DTDatosClienteGuia.Rows(0)("RFC").ToString))
|
|
' params.Add(New ReportParameter("CiudadCliente", DTDatosClienteGuia.Rows(0)("Ciudad").ToString))
|
|
'Else
|
|
' Exit Sub
|
|
'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)
|
|
|
|
'params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
'params.Add(New ReportParameter("EmpresaDireccion", UsuarioActual.Empresa.Direccion))
|
|
'params.Add(New ReportParameter("EmpresaTelefono", UsuarioActual.Empresa.Telefono))
|
|
'params.Add(New ReportParameter("EmpresaColonia", UsuarioActual.Empresa.Colonia))
|
|
'params.Add(New ReportParameter("EmpresaLocalidad", UsuarioActual.Empresa.Localidad))
|
|
'params.Add(New ReportParameter("RFCEmpresa", UsuarioActual.Empresa.RFC))
|
|
'params.Add(New ReportParameter("CiudadEmpresa", UsuarioActual.Empresa.Ciudad))
|
|
|
|
'params.Add(New ReportParameter("EmpresaTelefono", UsuarioActual.Empresa.Telefono))
|
|
'params.Add(New ReportParameter("NumCajas", NumCajas))
|
|
'params.Add(New ReportParameter("Peso", Peso))
|
|
'params.Add(New ReportParameter("Guia", Guia))
|
|
|
|
'params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
'params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
|
|
'params.Add(New ReportParameter("Anio", Now.Year.ToString))
|
|
'params.Add(New ReportParameter("Mes", Now.Month.ToString("00")))
|
|
'params.Add(New ReportParameter("Dia", Now.Day.ToString("00")))
|
|
|
|
'params.Add(New ReportParameter("Rastreo", Rastreo))
|
|
'params.Add(New ReportParameter("Dimensiones", Dimensiones))
|
|
'params.Add(New ReportParameter("FechaEstimada", FechaEstimada))
|
|
|
|
'If Imagen.Exists Then
|
|
' params.Add(New ReportParameter("LogoPath", logouri))
|
|
'Else
|
|
' params.Add(New ReportParameter("LogoPath", ""))
|
|
'End If
|
|
|
|
'ImprimirPDF(RutaRdlc, DTMovimientosDetalle, params, $"ReporteGuia_{Now.ToString("yyyyMMddhhmmss")}")
|
|
|
|
End Sub
|
|
|
|
Private Sub GvPaqueriaGuias_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPaqueriaGuias.RowDataBound
|
|
|
|
'If e.Row.RowType = DataControlRowType.DataRow Then
|
|
' Dim Lnk As LinkButton = e.Row.FCLinkButton("LnkGuiaPaqueteriaGuia")
|
|
' Dim Destinatario As String = e.Row.DataKey("Mail").ToString
|
|
|
|
' If Destinatario.Length = 0 Then
|
|
' e.Row.FCLinkButton("LnkGuiaPaqueteriaMail").Visible = False
|
|
' Else
|
|
' e.Row.FCLinkButton("LnkGuiaPaqueteriaMail").Attributes.Add("title", "Enviar correo a: " & Destinatario)
|
|
' End If
|
|
|
|
' ScriptManager.GetCurrent(Me).RegisterPostBackControl(Lnk)
|
|
'End If
|
|
|
|
End Sub
|
|
|
|
Private Sub GvPaqueteriaCreaEnlaces()
|
|
|
|
'For Each GvRow As GridViewRow In GvPaqueriaGuias.Rows
|
|
|
|
' If GvRow.RowType = DataControlRowType.DataRow Then
|
|
' Dim Lnk As LinkButton = GvRow.FCLinkButton("LnkGuiaPaqueteriaGuia")
|
|
' ScriptManager.GetCurrent(Me).RegisterPostBackControl(Lnk)
|
|
' End If
|
|
|
|
'Next
|
|
End Sub
|
|
|
|
Protected Sub LnkGuiaPaqueteriaMail_Click(sender As Object, e As EventArgs)
|
|
|
|
'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
|
|
|
|
'Dim SerieFolio As String = GvRow.DataKey("SerieFolio").ToString
|
|
'Dim NombreComercial As String = GvRow.DataKey("NombreComercial").ToString
|
|
'Dim Destinatario As String = GvRow.DataKey("Mail").ToString
|
|
'Dim Paqueteria As String = GvRow.DataKey("Paqueteria").ToString
|
|
'Dim Guia As String = GvRow.DataKey("Guia").ToString
|
|
'Dim Rastreo As String = GvRow.DataKey("Rastreo").ToString
|
|
'Dim CveVenta As Integer = GvRow.DataKey("CveVenta").ToEntero
|
|
|
|
'EnviarCorreoNotificacion(SerieFolio, NombreComercial, Destinatario, Paqueteria, Guia, Rastreo, CveVenta)
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub EnviarCorreoNotificacion(SerieFolio As String, NombreComercial As String, Destinatario As String, Paqueteria As String, Guia As String, Rastreo As String, CveVenta As Integer)
|
|
|
|
'Dim Correo As New ClsSisMail()
|
|
'Dim Asunto As String = UsuarioActual.Empresa.NombreCorto & " Envio de pedido: " & SerieFolio
|
|
'Dim Cuerpo As New StringBuilder
|
|
|
|
'Cuerpo.AppendLine($"Estimado {NombreComercial} le informamos que los productos de la factura {SerieFolio} han sido enviados mediante la paquetería {Paqueteria} con Guia {Guia} , Rastreo {Rastreo}.<br><br>")
|
|
|
|
'Cuerpo.AppendLine("<table><tr>")
|
|
'Cuerpo.AppendLine("<th>Cantidad</th><th>Producto</th>")
|
|
|
|
'For Each Drow As DataRow In DtMovimientos.Rows
|
|
' Cuerpo.AppendLine($"<tr><td>{Drow("Cantidad").ToString.ToEntero }</td><td>{Drow("PS").ToString}</td></tr>")
|
|
'Next
|
|
'Cuerpo.AppendLine("</tr></table>")
|
|
'Cuerpo.AppendLine("<br><br>Dudas y aclaraciones departamento de ateción al cliente Tel. 2142200.")
|
|
|
|
'Destinatario = "rakcsle.rakcsle@gmail.com"
|
|
|
|
'If Correo.SendMail(UsuarioActual.Empresa, Destinatario, Asunto, Cuerpo.ToString) Then
|
|
' GuardarBitacora(CveVenta, "", "Notificación de envío de productos al cliente")
|
|
' Alert("Correo enviado existosamente a " & Destinatario)
|
|
'Else
|
|
' Alert("Se presento un error al enviar el correo a " & Destinatario)
|
|
'End If
|
|
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "DDL CLIENTE / CLIENTE SUCURSAL - SELECTED INDEX CHANGED"
|
|
Private Sub InicializaClientes()
|
|
If UsuarioActual.CveEmpresa.Contiene(72, 80) AndAlso CveMovimiento <= 0 Then
|
|
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
DdlClientes.DataBind()
|
|
|
|
DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlClientes.SelectedValue = "-1"
|
|
End If
|
|
End Sub
|
|
Protected Sub ActivaClientes()
|
|
If UsuarioActual.CveEmpresa.Contiene(72, 80) Then
|
|
DivCliente.Visible = True
|
|
DivDepartamentoEntrega.Visible = True
|
|
'TxtDepartamentoEntrega.Text = ""
|
|
End If
|
|
|
|
'If UsuarioActual.CveRol = 1 Then
|
|
' RfvCliente.Enabled = False
|
|
'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()
|
|
CargaSucursalesCliente()
|
|
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("Seleccione", "-1"))
|
|
DdlClientesSucursales.SelectedValue = "-1"
|
|
|
|
UpGenerales.Update()
|
|
End If
|
|
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
|
|
Contabilizar()
|
|
End Sub
|
|
|
|
Private Sub Contabilizar()
|
|
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
|
|
|
|
Dim CvePrePolizaRegistrada As Integer = -1
|
|
|
|
ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa)
|
|
Dim CveVenta As Integer = ObjInventario.CveVenta
|
|
Dim MovAlmacen As Boolean = False
|
|
|
|
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & DdlConcepto.SelectedValue).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
|
|
Dim ConceptoPoliza As String = String.Format("{0}-{1}", DdlConcepto.SelectedItem.Text, If(DdlConcepto.SelectedValue.ToEntero.Contiene(3), HplVenta.Text, TxtFolio.Text))
|
|
Dim Contabilizable As Boolean = True
|
|
|
|
If tmpCostos.Rows.Count > 0 Then
|
|
Dim Concepto As String = If(TxtObservaciones.Text = "", ConceptoPoliza, $" {TxtObservaciones.Text}")
|
|
Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv_EntradaSalida", 74, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
CvePrePolizaRegistrada = CvePrePoliza
|
|
|
|
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 ObjConta.GetRetCuenta(176, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
|
|
IdCtaContable = ObjConta.DtResultados.FiltroPrimeroValor("IdCtaContable").ToEntero
|
|
End If
|
|
|
|
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
|
|
If ObjInventario.Modulo.Contiene("RA/G4") Then
|
|
Contabilizable = True
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total").RoundSQL, Concepto, 205, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveCompra:=CveCompra, CveMovimientoAlmacen:=CveMovimientoRelacionado, ImporteMX:=DtCostos.SUMD("Total").RoundSQL, Contabilizable:=Contabilizable) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
Else
|
|
If ObjInventario.Modulo.Contiene("TA/G1", "Recons") Then
|
|
Contabilizable = False
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total").RoundSQL, Concepto, 289, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoRelacionado, ImporteMX:=DtCostos.SUMD("Total").RoundSQL, Contabilizable:=Contabilizable) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
Else
|
|
If ObjInventario.Modulo = "ASA/G1" Then
|
|
Contabilizable = False
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total").RoundSQL, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimientoRelacionado, ImporteMX:=DtCostos.SUMD("Total").RoundSQL, Contabilizable:=Contabilizable) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
Else
|
|
If DdlConcepto.SelectedValue.Contiene("6", "22", "23", "7", "16", "21", "24") Then
|
|
'genero las prepolizas manuales
|
|
Dim tCveConcepto As Integer = 95
|
|
Dim CveCuenta As Integer
|
|
If UsuarioActual.CveEmpresa = 119 Then CveCuenta = 55519
|
|
IdCtaContable = 1
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, DtCostos.SUMD("Total"), Concepto, tCveConcepto, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveClasificacion:=-1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=DtCostos.SUMD("Total"), CveSubProyecto:=-1, CveCuenta:=CveCuenta, Contabilizable:=Contabilizable) Then
|
|
ErrorMovInv = True
|
|
|
|
End If
|
|
|
|
Else
|
|
|
|
Dim tCveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").ToEntero
|
|
Dim tCveConcepto As Integer = 69
|
|
If DdlConcepto.SelectedValue = "30" Then
|
|
tCveConcepto = 181
|
|
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(342).ToEntero
|
|
End If
|
|
|
|
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) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={DdlAlmacen.SelectedValue.ToEntero}").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:=Contabilizable) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If ErrorMovInv = False Then
|
|
ObjInventario.Commit()
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
|
|
If CvePrePolizaRegistrada > 0 Then
|
|
Response.Redirect($"../Contabilidad/RegPrePoliza.aspx?CvePrePoliza={CvePrePolizaRegistrada}", True)
|
|
End If
|
|
|
|
Else
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "CAMBIO INVENTARIO FISICO"
|
|
Protected Sub LnkCambioInventarioFisico_Click(sender As Object, e As EventArgs)
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivModalCambioFisico"))
|
|
End Sub
|
|
|
|
Protected Sub LnkCambioVigencia_Click(sender As Object, e As EventArgs)
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivModalCambiarVigencias"))
|
|
|
|
TxtCantCambio.Text = ""
|
|
TxtSerieCambio.Text = ""
|
|
TxtFechaCambio.Text = Now.ToString("dd/MM/yyyy")
|
|
TxtObsCambioVigencia.Text = ""
|
|
|
|
Th5.Visible = False
|
|
Th6.Visible = False
|
|
Th7.Visible = False
|
|
Th8.Visible = False
|
|
|
|
|
|
Td5.Visible = False
|
|
Td6.Visible = False
|
|
Td7.Visible = False
|
|
Td8.Visible = False
|
|
|
|
DdlPSCambioSalida.txtText.Value = ""
|
|
DdlPSCambioSalida.txtValue.Value = ""
|
|
|
|
DdlSeccionCambio.SelectedValueExist(-1)
|
|
DdlAlmacenCambioVigencias.SelectedValueExist(-1)
|
|
|
|
|
|
AplicaVigenciaCambioVigencia = False
|
|
|
|
UpCambioSalida.Update()
|
|
UpModalCambiarVigencias.Update()
|
|
|
|
End Sub
|
|
|
|
#Region "ENTRADAS"
|
|
Private Sub BtnAgregarEntrada_Click(sender As Object, e As EventArgs) Handles BtnAgregarEntrada.Click
|
|
If Not DdlPS.SelectedValue.ToEntero > 0 Then
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
AddPSEntrada(DdlPS.SelectedValue.ToEntero, TxtCantidadInvFisico.Text.ToDouble, TxtCostoPromedio.Text.ToDecimal)
|
|
End Sub
|
|
|
|
Protected Sub AddPSEntrada(CvePS As Integer, Cantidad As Double, CostoPromedio As Double)
|
|
If DdlAlmacenInventarioFisico.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlPS.SelectedText = "" : Exit Sub
|
|
|
|
Dim Valido As Boolean = True
|
|
|
|
If Valido Then
|
|
Dim CveClasificacion As Integer
|
|
Dim CveUM As Double
|
|
Dim CodigoPS As String = ""
|
|
Dim PS As String = ""
|
|
|
|
Dim CveSeccionAlmacen As Integer = DdlSeccionAlmacenEntrada.SelectedValue.ToEntero
|
|
Dim Serie As String = If(TxtSerieEntrada.Text = "", "", TxtSerieEntrada.Text)
|
|
Dim Lote As String = If(TxtLoteEntrada.Text = "", "", TxtLoteEntrada.Text)
|
|
Dim Caducidad As String = If(TxtCaducidadEntrada.Text = "", MinFecha.ToShortDateString, TxtCaducidadEntrada.Text)
|
|
|
|
Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS")
|
|
If dr IsNot Nothing Then
|
|
CveClasificacion = dr("CveClasificacion").ToString.ToEntero
|
|
CveUM = dr("CveUM").ToString.ToEntero
|
|
CodigoPS = dr("PSCodigo").ToString.ToString
|
|
PS = dr("PS").ToString.ToString
|
|
End If
|
|
|
|
Dim registro As DataRow = DtMovimientosEntradaInvFisico.NewRow
|
|
registro.Item("Cantidad") = Cantidad
|
|
registro.Item("CveUM") = CveUM
|
|
registro.Item("CvePS") = CvePS
|
|
registro.Item("CodigoPS") = CodigoPS
|
|
registro.Item("PS") = PS
|
|
registro.Item("PU") = CostoPromedio
|
|
registro.Item("Total") = Cantidad * CostoPromedio
|
|
registro.Item("CveClasificacion") = CveClasificacion
|
|
registro.Item("Estatus") = ""
|
|
registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen
|
|
registro.Item("Serie") = Serie
|
|
registro.Item("Lote") = Lote
|
|
registro.Item("FechaCaducidad") = Caducidad
|
|
|
|
DtMovimientosEntradaInvFisico.Rows.Add(registro)
|
|
CargaGvEntradas(DtMovimientosEntradaInvFisico)
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaGvEntradas(DtTemp As DataTable)
|
|
GvEntradas.DataSource = DtTemp
|
|
GvEntradas.DataBind()
|
|
UpEntradasGv.Update()
|
|
If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then
|
|
GvEntradas.Columns(3).Visible = DtTemp.MAX("CveSeccionAlmacen").ToEntero > 0
|
|
GvEntradas.Columns(4).Visible = DtTemp.MAX("Serie") <> ""
|
|
GvEntradas.Columns(5).Visible = DtTemp.MAX("Lote") <> ""
|
|
GvEntradas.Columns(6).Visible = DtTemp.MAX("FechaCaducidad").ToDate > MinFecha
|
|
If Not String.IsNullOrWhiteSpace(UsuarioActual.Empresa.Funcionalidad(147)) Then GvEntradas.Columns(6).HeaderText = UsuarioActual.Empresa.Funcionalidad(147)
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub DdlPSInvFisico_ValueChanged(sender As Object, e As EventArgs) Handles DdlPS.selectedindexchange
|
|
ProductChange()
|
|
End Sub
|
|
|
|
Private Sub ProductChange()
|
|
|
|
If DdlPS.SelectedValue.ToEntero > 0 Then
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
Dim CostoPromedio As Decimal = ObjInventario.GetCostoPS(DdlPS.SelectedValue.ToEntero, txtCantidad.Text.ToDouble, DdlAlmacenInventarioFisico.SelectedValue.ToEntero, "", TxtFecha.Text.ToDate)
|
|
'GlobalDTPS(UsuarioActual.CveEmpresa, DdlPS.SelectedValue.ToEntero).FiltroPrimeroValor("CostoPromedio", "").ToDecimal
|
|
If CostoPromedio > 0 Then
|
|
|
|
TxtCostoPromedio.Text = CostoPromedio.FormatoNumero
|
|
Else
|
|
TxtCostoPromedio.Text = "0.00"
|
|
End If
|
|
ObjInventario.Dispose()
|
|
End If
|
|
|
|
|
|
UpModalInventarioFisico.Update()
|
|
End Sub
|
|
|
|
Protected Sub DeleteRowInvFisicoEntrada(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
|
|
|
|
If DtMovimientosEntradaInvFisico.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then
|
|
Dim i As Integer
|
|
i = lnkRemove.CommandArgument.ToString.ToEntero
|
|
Dim Drs As DataRow() = DtMovimientosEntradaInvFisico.Select(String.Format("No = {0}", i))
|
|
If Drs.Count > 0 Then
|
|
|
|
Drs(0).Delete()
|
|
End If
|
|
DtMovimientosEntradaInvFisico.AcceptChanges()
|
|
End If
|
|
|
|
GvEntradas.EditIndex = -1
|
|
|
|
CargaGvEntradas(DtMovimientosEntradaInvFisico)
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "SALIDAS"
|
|
Private Sub BtnAgregarSalida_Click(sender As Object, e As EventArgs) Handles BtnAgregarSalida.Click
|
|
Dim ObjProductosServicios As New ClsProductosServicios()
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim CveUM As Integer
|
|
Dim Mensaje As String = ""
|
|
'Dim FechaCaducidad As Date
|
|
'Dim lote As String
|
|
If ObjProductosServicios.GetPS(DdlPSSalida.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then
|
|
If ObjProductosServicios.DtResultados.Rows.Count > 0 Then
|
|
CveUM = ObjProductosServicios.CveUnidadMedida.ToString.ToEntero
|
|
End If
|
|
End If
|
|
|
|
Dim Lote As String = If(TxtLoteSalida.Text = "", "", TxtLoteSalida.Text)
|
|
Dim FechaCaducidad As Date = If(TxtCaducidadSalida.Text = "", MinFecha.ToShortDateString, TxtCaducidadSalida.Text).ToDate
|
|
|
|
If ObjInventario.GetExistenciasPS(DdlPSSalida.SelectedValue.ToEntero, CveUM, UsuarioActual.CveEmpresa, DdlAlmacenInventarioFisico.SelectedValue.ToEntero, PendientePorSurtir:=1, Lote:=Lote, FechaCaducidad:=FechaCaducidad) >= TxtCantidadSalidaInv.Text.ToDouble Then
|
|
If Not DdlPSSalida.SelectedValue.ToEntero > 0 Then
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
AddPSSalida(DdlPSSalida.SelectedValue.ToEntero, TxtCantidadSalidaInv.Text.ToDouble)
|
|
Else
|
|
Mensaje = String.Format("No hay existencias suficientes del producto: {0}", ObjProductosServicios.PS)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Alert(Mensaje, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
ObjProductosServicios.Dispose()
|
|
|
|
End Sub
|
|
|
|
Protected Sub AddPSSalida(CvePS As Integer, Cantidad As Double)
|
|
If DdlAlmacenInventarioFisico.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlPSSalida.SelectedText = "" : Exit Sub
|
|
|
|
Dim Valido As Boolean = True
|
|
|
|
If Valido Then
|
|
Dim CveClasificacion As Integer
|
|
Dim CveUM As Double
|
|
Dim CodigoPS As String = ""
|
|
Dim PS As String = ""
|
|
|
|
Dim CveSeccionAlmacen As Integer = DdlSeccionAlmacenSalida.SelectedValue.ToEntero
|
|
Dim Serie As String = If(TxtSerieSalida.Text = "", "", TxtSerieSalida.Text)
|
|
Dim Lote As String = If(TxtLoteSalida.Text = "", "", TxtLoteSalida.Text)
|
|
Dim Caducidad As String = If(TxtCaducidadSalida.Text = "", MinFecha.ToShortDateString, TxtCaducidadSalida.Text)
|
|
|
|
Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS")
|
|
If dr IsNot Nothing Then
|
|
CveClasificacion = dr("CveClasificacion").ToString.ToEntero
|
|
CveUM = dr("CveUM").ToString.ToEntero
|
|
CodigoPS = dr("PSCodigo").ToString.ToString
|
|
PS = dr("PS").ToString.ToString
|
|
End If
|
|
|
|
Dim registro As DataRow = DtMovimientosSalidaInvFisico.NewRow
|
|
registro.Item("Cantidad") = Cantidad
|
|
registro.Item("CveUM") = CveUM
|
|
registro.Item("CvePS") = CvePS
|
|
registro.Item("CodigoPS") = CodigoPS
|
|
registro.Item("PS") = PS
|
|
registro.Item("PU") = 0
|
|
registro.Item("Total") = 0
|
|
registro.Item("CveClasificacion") = CveClasificacion
|
|
registro.Item("Estatus") = ""
|
|
registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen
|
|
registro.Item("Serie") = Serie
|
|
registro.Item("Lote") = Lote
|
|
registro.Item("FechaCaducidad") = Caducidad
|
|
|
|
DtMovimientosSalidaInvFisico.Rows.Add(registro)
|
|
CargaGvSalidas(DtMovimientosSalidaInvFisico)
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaGvSalidas(DtTemp As DataTable)
|
|
GvSalidas.DataSource = DtTemp
|
|
GvSalidas.DataBind()
|
|
UpSalidaGv.Update()
|
|
If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then
|
|
GvSalidas.Columns(2).Visible = DtTemp.MAX("CveSeccionAlmacen").ToEntero > 0
|
|
GvSalidas.Columns(3).Visible = DtTemp.MAX("Serie") <> ""
|
|
GvSalidas.Columns(4).Visible = DtTemp.MAX("Lote") <> ""
|
|
GvSalidas.Columns(5).Visible = DtTemp.MAX("FechaCaducidad").ToDate > MinFecha
|
|
GvSalidas.Columns(5).HeaderText = UsuarioActual.Empresa.Funcionalidad(147)
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub DeleteRowInvFisicoSalida(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
|
|
|
|
If DtMovimientosSalidaInvFisico.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then
|
|
Dim i As Integer
|
|
i = lnkRemove.CommandArgument.ToString.ToEntero
|
|
Dim Drs As DataRow() = DtMovimientosSalidaInvFisico.Select(String.Format("No = {0}", i))
|
|
If Drs.Count > 0 Then
|
|
|
|
Drs(0).Delete()
|
|
End If
|
|
DtMovimientosSalidaInvFisico.AcceptChanges()
|
|
End If
|
|
|
|
GvSalidas.EditIndex = -1
|
|
|
|
CargaGvSalidas(DtMovimientosSalidaInvFisico)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "CAMBIO VIGENCIA"
|
|
Private Sub LnkAddSalidaCambio_Click(sender As Object, e As EventArgs) Handles LnkAddSalidaCambio.Click
|
|
|
|
If Not DdlPSCambioSalida.SelectedValue.ToEntero > 0 Then
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Alert("Es necesario especificar el producto.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
If AplicaVigenciaCambioVigencia And TxtSerieCambio.Text.Trim.Length = 0 Then
|
|
Alert("Es necesario especificar la serie del producto.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
AddPSCambioSalida(DdlPSCambioSalida.SelectedValue.ToEntero, TxtCantCambio.Text.ToDouble)
|
|
End Sub
|
|
|
|
Protected Sub DdlPSCambioSalida_selectedindexchange(sender As Object, e As EventArgs)
|
|
|
|
Td6.Visible = False
|
|
Th6.Visible = False
|
|
|
|
If DdlPSCambioSalida.SelectedValue.ToEntero > 0 Then
|
|
|
|
Using ObjPS As New ClsProductosServicios()
|
|
If ObjPS.GetPS(DdlPSCambioSalida.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) AndAlso ObjPS.DtResultados.Rows.Count > 0 Then
|
|
|
|
AplicaVigenciaCambioVigencia = If(ObjPS.DtResultados.Rows(0)("AplicaSerie").ToString = "", False, Boolean.Parse(ObjPS.DtResultados.Rows(0)("AplicaSerie").ToString))
|
|
|
|
Td6.Visible = AplicaVigenciaCambioVigencia
|
|
Th6.Visible = AplicaVigenciaCambioVigencia
|
|
|
|
End If
|
|
End Using
|
|
|
|
|
|
End If
|
|
|
|
UpCambioSalida.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub AddPSCambioSalida(CvePS As Integer, Cantidad As Double)
|
|
If DdlAlmacenCambioVigencias.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgAdvertencia) : RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") : DdlPSCambioSalida.SelectedText = "" : Exit Sub
|
|
|
|
Dim Valido As Boolean = True
|
|
|
|
If Valido Then
|
|
Dim CveClasificacion As Integer
|
|
Dim CveUM As Double
|
|
Dim CodigoPS As String = ""
|
|
Dim PS As String = ""
|
|
|
|
Dim CveSeccionAlmacen As Integer = DdlSeccionCambio.SelectedValue.ToEntero
|
|
Dim Serie As String = If(TxtSerieCambio.Text = "", "", TxtSerieCambio.Text)
|
|
Dim Lote As String = If(TxtLoteCambio.Text = "", "", TxtLoteCambio.Text)
|
|
Dim Caducidad As String = If(TxtCaducidadCambio.Text = "", MinFecha.ToShortDateString, TxtCaducidadCambio.Text)
|
|
|
|
Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimero("", "PS")
|
|
If dr IsNot Nothing Then
|
|
CveClasificacion = dr("CveClasificacion").ToString.ToEntero
|
|
CveUM = dr("CveUM").ToString.ToEntero
|
|
CodigoPS = dr("PSCodigo").ToString.ToString
|
|
PS = dr("PS").ToString.ToString
|
|
End If
|
|
|
|
Dim registro As DataRow = DtMovimientosCambioVigencias.NewRow
|
|
registro.Item("Cantidad") = Cantidad
|
|
registro.Item("CveUM") = CveUM
|
|
registro.Item("CvePS") = CvePS
|
|
registro.Item("CodigoPS") = CodigoPS
|
|
registro.Item("PS") = PS
|
|
registro.Item("PU") = 0
|
|
registro.Item("Total") = 0
|
|
registro.Item("CveClasificacion") = CveClasificacion
|
|
registro.Item("Estatus") = ""
|
|
registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen
|
|
registro.Item("Serie") = Serie
|
|
registro.Item("Lote") = Lote
|
|
registro.Item("FechaCaducidad") = Caducidad
|
|
|
|
If CvePS > 0 Then
|
|
Using ObjPS As New ClsProductosServicios()
|
|
If ObjPS.GetPS(CvePS, -1, UsuarioActual.CveEmpresa) AndAlso ObjPS.DtResultados.Rows.Count > 0 Then
|
|
Dim CvePSAdicionalVigencia = ObjPS.DtResultados.Rows(0)("CvePSAdicionalVigencia").ToString.ToEntero()
|
|
Dim CodigoPSVigencia As String = ObjPS.DtResultados.Rows(0)("CodigoPSVigencia").ToString
|
|
'SI EXISTE UN MOVIMIENTO DE VIGENCIA
|
|
If CvePSAdicionalVigencia > 0 Then
|
|
|
|
If ObjPS.GetPS(CvePSAdicionalVigencia, -1, UsuarioActual.CveEmpresa) AndAlso ObjPS.DtResultados.Rows.Count > 0 Then
|
|
registro.Item("CvePSVigencia") = CvePSAdicionalVigencia
|
|
registro.Item("CodigoPSVigencia") = CodigoPSVigencia
|
|
registro.Item("CveUMVigencia") = ObjPS.DtResultados.Rows(0)("CveUM").ToString.ToEntero()
|
|
|
|
DtMovimientosCambioVigencias.Rows.Add(registro)
|
|
End If
|
|
|
|
Else
|
|
Alert("Este producto no tiene un producto de vigencia relacionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End Using
|
|
End If
|
|
|
|
CargaGvCambioSalidas(DtMovimientosCambioVigencias)
|
|
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub DeleteRowCambioVigencia(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
|
|
|
|
If DtMovimientosCambioVigencias.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then
|
|
Dim i As Integer
|
|
i = lnkRemove.CommandArgument.ToString.ToEntero
|
|
Dim Drs As DataRow() = DtMovimientosCambioVigencias.Select(String.Format("No = {0}", i))
|
|
If Drs.Count > 0 Then
|
|
|
|
Drs(0).Delete()
|
|
End If
|
|
DtMovimientosCambioVigencias.AcceptChanges()
|
|
End If
|
|
|
|
GvSalidasCambioVigencia.EditIndex = -1
|
|
|
|
CargaGvCambioSalidas(DtMovimientosCambioVigencias)
|
|
End Sub
|
|
|
|
Private Sub CargaGvCambioSalidas(DtTemp As DataTable)
|
|
GvSalidasCambioVigencia.DataSource = DtTemp
|
|
GvSalidasCambioVigencia.DataBind()
|
|
|
|
If DtTemp IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then
|
|
GvSalidasCambioVigencia.Columns(2).Visible = DtTemp.MAX("CveSeccionAlmacen").ToEntero > 0
|
|
GvSalidasCambioVigencia.Columns(3).Visible = DtTemp.MAX("Serie") <> ""
|
|
GvSalidasCambioVigencia.Columns(4).Visible = DtTemp.MAX("Lote") <> ""
|
|
GvSalidasCambioVigencia.Columns(5).Visible = DtTemp.MAX("FechaCaducidad").ToDate > MinFecha
|
|
GvSalidasCambioVigencia.Columns(5).HeaderText = UsuarioActual.Empresa.Funcionalidad(147)
|
|
End If
|
|
UpGvCambioSalidas.Update()
|
|
End Sub
|
|
Protected Sub GvSalidasCambioVigencia_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
e.Row.Cells(1).CssClass = "SubTotales"
|
|
e.Row.Cells(6).CssClass = "Totales"
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "GUARDAR"
|
|
Private Sub BtnAplicarCambioInvFisico_Click(sender As Object, e As EventArgs) Handles BtnAplicarCambioInvFisico.Click
|
|
|
|
If GvEntradas.Rows.Count = 0 And GvSalidas.Rows.Count = 0 Then
|
|
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')")
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivModalCambioFisico"))
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
Dim CveMovimientoEntrada As Integer
|
|
Dim CveMovimientoSalida As Integer
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim Mensaje As String = ""
|
|
Dim ValorEntrada As Decimal = 0
|
|
Dim ValorSalida As Decimal = 0
|
|
Dim ImporteConcepto As Decimal = 0
|
|
Dim tConcepto As String = TxtIFDescripcion.Text.Trim
|
|
Dim Fecha = TxtFechaInvFisico.Text.ToDate.ToString("yyyy/MM/dd").ToDate
|
|
Dim tCveSubProyectoEntrada As Integer = -1
|
|
Dim tCveSubProyectoSalida As Integer = -1
|
|
Dim TipoMovto As Boolean = False
|
|
Dim idCtaContableEntrada As Integer = 0
|
|
Dim idCtaContableSalida As Integer = 0
|
|
|
|
Dim IdCuentaOtrosIngresos As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos
|
|
Select Case UsuarioActual.CveEmpresa
|
|
Case 119
|
|
IdCuentaOtrosIngresos = 1319
|
|
End Select
|
|
|
|
Dim CveAlmacen As Integer = DdlAlmacenInventarioFisico.SelectedValue.ToEntero
|
|
|
|
Dim CveModalidad As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveModalidad").ToEntero()
|
|
|
|
Dim EsContabilizable As Boolean = (CveModalidad = 1)
|
|
|
|
'MOVIMIENTO DE ENTRADA
|
|
If DtMovimientosEntradaInvFisico.Rows.Count > 0 Then
|
|
Dim FolioEntrada As Integer = ObjInventario.GetFolioSiguiente(32, UsuarioActual.CveEmpresa)
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 32, 1, Fecha, FolioEntrada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtIFDescripcion.Text.Trim, Modulo:="ES/AJ1")
|
|
Else
|
|
CveMovimientoEntrada = -1
|
|
End If
|
|
|
|
'MOVIMIENTO DE SALIDA
|
|
If DtMovimientosSalidaInvFisico.Rows.Count > 0 Then
|
|
Dim FolioSalida As Integer = ObjInventario.GetFolioSiguiente(34, UsuarioActual.CveEmpresa)
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacen, 34, 1, Fecha, FolioSalida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveMovimientoRelacionado:=CveMovimientoEntrada, Observaciones:=TxtIFDescripcion.Text.Trim, Modulo:="ES/AJ2")
|
|
|
|
End If
|
|
|
|
'Registro PrePoliza
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inv/E/S INVENTARIO FISICO", 53, 0, 0, 1, Fecha, TxtIFDescripcion.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
|
|
|
|
'VALIDA, sino hay registrado ningun movimiento, que no siga
|
|
If (CveMovimientoEntrada <= 0 AndAlso CveMovimientoSalida <= 0) Or CvePrePoliza <= 0 Then
|
|
Alert("Ocurrió un error al realizar los registros. Por favor verifique y vuelva a intentar", TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ObjInventario.RollBack() 'deshace lo insertado.
|
|
ObjInventario.Dispose() 'elimino la instancia
|
|
Exit Sub
|
|
End If
|
|
|
|
'VALIDA EXISTENCIAS SALIDA E INSERTA DETALLES
|
|
For Each Dr As DataRow In DtMovimientosSalidaInvFisico.Rows
|
|
If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenInventarioFisico.SelectedValue.ToEntero, PendientePorSurtir:=1) >= Dr("Cantidad").ToString.ToDouble Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero,
|
|
Dr("PU").ToString.ToDecimal, -1, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString,
|
|
Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate) Then
|
|
Mensaje = "Ocurrió un error al guardar los movimientos de salida"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("PS"))
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If Not ErrorMovInv Then
|
|
For Each Dr As DataRow In DtMovimientosEntradaInvFisico.Rows
|
|
ImporteConcepto = Dr("PU").ToString.ToDecimal
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero,
|
|
ImporteConcepto, -1, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString,
|
|
Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate) Then
|
|
Mensaje = "Ocurrió un error al guardar los movimientos de entrada"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
'Obtiene valor entrada
|
|
If Not ErrorMovInv AndAlso CveMovimientoEntrada > 0 Then
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
|
|
Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUMD("Total", "").RoundSQL()
|
|
ValorEntrada = tValorInventario
|
|
|
|
Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacenInventarioFisico.SelectedValue))
|
|
If drA2 IsNot Nothing Then
|
|
idCtaContableEntrada = drA2("IdCtaContable").ToString.ToEntero
|
|
tCveSubProyectoEntrada = drA2("CveSubProyecto").ToString.ToEntero
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
Mensaje = "Ocurrió un error al validar los movimientos contables de entrada"
|
|
End If
|
|
End If
|
|
|
|
'Obtiene valor salida
|
|
If Not ErrorMovInv AndAlso CveMovimientoSalida > 0 Then
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
Dim tValorInventario As Decimal = ObjInventario.DtResultados.SUMD("Total", "").RoundSQL()
|
|
ValorSalida = tValorInventario
|
|
Dim drA2 As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", DdlAlmacenInventarioFisico.SelectedValue))
|
|
If drA2 IsNot Nothing Then
|
|
idCtaContableSalida = drA2("IdCtaContable").ToString.ToEntero
|
|
tCveSubProyectoSalida = drA2("CveSubProyecto").ToString.ToEntero
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
Mensaje = "Ocurrió un error al validar los movimientos contables de salida"
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
'NOTA
|
|
' cuando el valor entrada sea mayor al de salida, el valor de salida debe de ser negativo y cargado
|
|
' cuando el valor salida sea mayor al de entrada, el valor de entrada debe de ser negativo y abonado
|
|
|
|
'Registro la prepólizaDetalle Entradas
|
|
If CveMovimientoEntrada > 0 Then
|
|
TipoMovto = False
|
|
If ValorEntrada <= ValorSalida Then
|
|
TipoMovto = True : ValorEntrada = -ValorEntrada ' invierto su naturaleza
|
|
End If
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, ValorEntrada, "", 68, tConcepto, Fecha, idCtaContableEntrada, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=ValorEntrada, CveSubProyecto:=tCveSubProyectoEntrada, Contabilizable:=EsContabilizable) Then
|
|
ErrorMovInv = True
|
|
Mensaje = "Ocurrió un error al guardar los movimientos contables de entrada"
|
|
End If
|
|
End If
|
|
|
|
'Registro la prepólizaDetalle Salidas
|
|
If CveMovimientoSalida > 0 Then
|
|
TipoMovto = True
|
|
If ValorSalida < ValorEntrada Then
|
|
TipoMovto = False : ValorSalida = -ValorSalida ' invierto su naturaleza
|
|
End If
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, ValorSalida, "", 68, tConcepto, Fecha, idCtaContableSalida, -1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=ValorSalida, CveSubProyecto:=tCveSubProyectoSalida, Contabilizable:=EsContabilizable) Then
|
|
ErrorMovInv = True
|
|
Mensaje = "Ocurrió un error al guardar los movimientos contables de salida"
|
|
End If
|
|
End If
|
|
|
|
If ValorEntrada >= ValorSalida Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorEntrada + ValorSalida, "", 260, tConcepto, Fecha, IdCuentaOtrosIngresos, -1, CveMovimientoAlmacen:=CveMovimientoSalida, CveSubProyecto:=tCveSubProyectoEntrada, ImporteMX:=ValorEntrada + ValorSalida, Contabilizable:=EsContabilizable) Then
|
|
ErrorMovInv = True
|
|
Mensaje = "Ocurrió un error al guardar los movimientos contables de ajuste de ingreso"
|
|
End If
|
|
ElseIf ValorSalida >= ValorEntrada Then
|
|
'inserta el gasto
|
|
Dim dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimero("")
|
|
Dim tCveClasificacion As Integer = -1
|
|
Dim tIdCtaGasto As Integer = -1
|
|
If dr IsNot Nothing Then
|
|
tCveClasificacion = dr("CveClasificacion").ToString.ToEntero
|
|
tIdCtaGasto = dr("IdCuentaGasto").ToString.ToEntero
|
|
End If
|
|
|
|
'[IPP] PARCHE - CUENTA CONTABLE DIRECTA
|
|
Select Case UsuarioActual.CveEmpresa
|
|
Case 119
|
|
tIdCtaGasto = 1321
|
|
End Select
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorSalida + ValorEntrada, "", 290, tConcepto, Fecha, tIdCtaGasto, -1, CveMovimientoAlmacen:=CveMovimientoSalida, CveClasificacion:=tCveClasificacion, CveSubProyecto:=tCveSubProyectoSalida, ImporteMX:=ValorSalida + ValorEntrada, Contabilizable:=EsContabilizable) Then
|
|
ErrorMovInv = True
|
|
Mensaje = "Ocurrió un error al guardar los movimientos contables de ajuste de salida"
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
If Not ErrorMovInv Then
|
|
If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then
|
|
ObjConta.GetPrePolizasDetalle(CvePrePoliza, UsuarioActual.CveEmpresa)
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
ErrorMovInv = True
|
|
Mensaje = "Ocurrió un error al validar los movimientos contables"
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Dim RetornoVirtual As MMovimientoVirtual = Nothing
|
|
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
|
RetornoVirtual = GenerarMovimientoVirtual(CveMovimiento, ObjInventario)
|
|
End If
|
|
|
|
If RetornoVirtual IsNot Nothing Then
|
|
ErrorMovInv = RetornoVirtual.TieneError
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
ObjInventario.Commit() ' aplica los movimientos insertados
|
|
|
|
Dim Msg As New StringBuilder
|
|
Msg.AppendFormat("<br/>El Movimiento se registro con el Folio: <b>{0}</b>", ObjInventario.Folio)
|
|
If CveMovimientoEntrada > 0 Then Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento Entrada</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada)))
|
|
If CveMovimientoSalida > 0 Then Msg.AppendFormat("<br/><br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento Salida</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivModalCambioFisico"))
|
|
GvEntradas.DataBind()
|
|
GvSalidas.DataBind()
|
|
TxtIFDescripcion.Text = ""
|
|
|
|
Else
|
|
ObjInventario.RollBack()
|
|
|
|
Alert(Mensaje, TipoMensaje.MsgError)
|
|
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
ObjInventario.Dispose() 'elimino la instancia
|
|
|
|
End Sub
|
|
Private Sub BtnGuardarCambiosVigencia_Click(sender As Object, e As EventArgs) Handles BtnGuardarCambiosVigencia.Click
|
|
|
|
|
|
|
|
If GvSalidasCambioVigencia.Rows.Count = 0 Then
|
|
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')")
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivModalCambioFisico"))
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
Dim CveMovimientoEntrada As Integer = -1
|
|
Dim CveMovimientoSalida As Integer = -1
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim Mensaje As String = ""
|
|
Dim ValorEntrada As Decimal = 0
|
|
Dim ValorSalida As Decimal = 0
|
|
Dim ImporteConcepto As Decimal = 0
|
|
Dim tConcepto As String = TxtObsCambioVigencia.Text.Trim
|
|
Dim Fecha = TxtFechaCambio.Text.ToDate.ToString("yyyy/MM/dd").ToDate
|
|
Dim tCveSubProyecto As Integer = -1
|
|
Dim TipoMovto As Boolean = False
|
|
Dim idCtaContableEntrada As Integer = 0
|
|
Dim idCtaContableSalida As Integer = 0
|
|
|
|
Dim FolioSalida As Integer = 0
|
|
Dim FolioEntrada As Integer = 0
|
|
|
|
Dim IdCuentaOtrosIngresos As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos
|
|
|
|
Dim CveAlmacen As Integer = DdlAlmacenCambioVigencias.SelectedValue.ToEntero
|
|
|
|
Dim CveModalidad As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveModalidad").ToEntero()
|
|
|
|
Dim EsContabilizable As Boolean = (CveModalidad = 1)
|
|
|
|
'MOVIMIENTOS
|
|
If DtMovimientosCambioVigencias.Rows.Count > 0 Then
|
|
FolioSalida = ObjInventario.GetFolioSiguiente(8, UsuarioActual.CveEmpresa)
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacen, 8, 1, Fecha, FolioSalida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObsCambioVigencia.Text.Trim, Modulo:="ES/CV1")
|
|
|
|
FolioEntrada = ObjInventario.GetFolioSiguiente(9, UsuarioActual.CveEmpresa)
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacen, 9, 1, Fecha, FolioEntrada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObsCambioVigencia.Text.Trim, CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ES/CV2")
|
|
End If
|
|
|
|
|
|
'VALIDA, sino hay registrado ningun movimiento, que no siga
|
|
If (CveMovimientoEntrada <= 0 AndAlso CveMovimientoSalida <= 0) Then
|
|
Alert("Ocurrió un error al realizar los registros. Por favor verifique y vuelva a intentar", TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ObjInventario.RollBack() 'deshace lo insertado.
|
|
ObjInventario.Dispose() 'elimino la instancia
|
|
Exit Sub
|
|
End If
|
|
|
|
'VALIDA EXISTENCIAS SALIDA E INSERTA DETALLES
|
|
For Each Dr As DataRow In DtMovimientosCambioVigencias.Rows
|
|
If ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenInventarioFisico.SelectedValue.ToEntero, PendientePorSurtir:=1) >= Dr("Cantidad").ToString.ToDouble Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero,
|
|
Dr("PU").ToString.ToDecimal, -1, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString,
|
|
Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate) Then
|
|
Mensaje = "Ocurrió un error al guardar los movimientos de salida"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
Else
|
|
'OBTIENE EL COSTO DE LA SALIDA
|
|
If Not ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa, CveMovimientoDetalle:=ObjInventario.CveMovimientoDetalle) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
Mensaje = "Ocurrió un error al guardar los movimientos de salida"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
Else
|
|
Dim PUEntrada As Decimal = ObjInventario.DtResultados.Rows(0)("PU").ToString().ToDecimal()
|
|
ImporteConcepto += PUEntrada * Dr("Cantidad").ToString.ToDecimal()
|
|
|
|
'INSERTA EL MOVIMIENTO DE ENTRADA
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUMVigencia").ToString.ToEntero, Dr("CvePSVigencia").ToString.ToEntero, PUEntrada, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString,
|
|
Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate) Then
|
|
Mensaje = "Ocurrió un error al guardar los movimientos de entrada"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Else
|
|
Mensaje = String.Format("No hay existencias suficientes del producto: {0}", Dr("PS"))
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
'CONTABILIZAR MOVIMIENTOS
|
|
If Not ErrorMovInv Then
|
|
If Not ContabilizaMovimientoAlmacen(ObjConta, Now, "CAMBIO DE VIGENCIA", "ES/CV", CveMovimientoSalida, CveMovimientoEntrada, ImporteConcepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False) > 0 Then
|
|
ErrorMovInv = True
|
|
Mensaje = "No se pudo generar el movimiento de prepoliza"
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
ObjInventario.Commit() ' aplica los movimientos insertados
|
|
|
|
Dim Msg As New StringBuilder
|
|
Msg.AppendFormat("<br/>El Movimiento de entrada se registró con el Folio: <b><a class=""Texto"" target='_blank' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"">{1}</a></b>", CveMovimientoEntrada, FolioEntrada)
|
|
If CveMovimientoEntrada > 0 Then Msg.AppendFormat("<br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento Entrada</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada)))
|
|
Msg.AppendFormat("<br/><br/>El Movimiento de salida se registró con el Folio: <b><a class=""Texto"" target='_blank' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"">{1}</a></b>", CveMovimientoSalida, FolioSalida)
|
|
If CveMovimientoSalida > 0 Then Msg.AppendFormat("<br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento Salida</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
RegistraScript("playsonidito('beep-07.wav');$('#DivModalCambiarVigencias').modal('hide');")
|
|
|
|
DtMovimientosCambioVigencias.Clear()
|
|
|
|
GvSalidasCambioVigencia.DataSource = DtMovimientosCambioVigencias
|
|
GvSalidasCambioVigencia.DataBind()
|
|
|
|
TxtObsCambioVigencia.Text = ""
|
|
|
|
Else
|
|
ObjInventario.RollBack()
|
|
|
|
Alert(Mensaje, TipoMensaje.MsgError)
|
|
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
ObjInventario.Dispose() 'elimino la instancia
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "Inventario Fisico"
|
|
Private Sub DdlPS_Change(sender As Object, e As EventArgs) Handles DdlPS.selectedindexchange
|
|
If DdlPS.SelectedValue.ToEntero > 0 Then
|
|
Dim drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("")
|
|
|
|
If drp IsNot Nothing Then
|
|
Dim AplicaSerie As Boolean = CBool(drp("AplicaSerie"))
|
|
Dim AplicaSeccion As Boolean = CBool(drp("AplicaSeccion"))
|
|
Dim AplicaLote As Boolean = CBool(drp("AplicaLote"))
|
|
Dim AplicaCaducidad As Boolean = CBool(drp("AplicaCaducidad"))
|
|
'activa Serie
|
|
ThSerieEntrada.Visible = AplicaSerie
|
|
TrSerieEntrada.Visible = AplicaSerie
|
|
TxtnSerie.Visible = AplicaSerie
|
|
|
|
Dim CveSubProyectoAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenInventarioFisico.SelectedValue.ToEntero).FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero
|
|
|
|
If UsuarioActual.CveEmpresa = 119 AndAlso Not CveSubProyectoAlmacen.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347).Split(","c)) Then
|
|
AplicaLote = False
|
|
AplicaCaducidad = False
|
|
End If
|
|
|
|
'activa seccion
|
|
ThSeccionEntrada.Visible = AplicaSeccion
|
|
TrSeccionEntrada.Visible = AplicaSeccion
|
|
|
|
'activa lote
|
|
ThLoteEntrada.Visible = AplicaLote
|
|
TrLoteEntrada.Visible = AplicaLote
|
|
|
|
'activa caducidad
|
|
ThCaducidadEntrada.Visible = AplicaCaducidad
|
|
ThCaducidadEntrada.InnerText = UsuarioActual.Empresa.Funcionalidad(147)
|
|
TrCaducidadEntrada.Visible = AplicaCaducidad
|
|
|
|
Else
|
|
TxtnSerie.Visible = False
|
|
End If
|
|
UpEntradaFisico.Update()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub DdlPSSalida_Change(sender As Object, e As EventArgs) Handles DdlPSSalida.selectedindexchange
|
|
If DdlPSSalida.SelectedValue.ToEntero > 0 Then
|
|
Dim drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPSSalida.SelectedValue.ToEntero).FiltroPrimero("")
|
|
|
|
|
|
If drp IsNot Nothing Then
|
|
Dim AplicaSerie As Boolean = CBool(drp("AplicaSerie"))
|
|
Dim AplicaSeccion As Boolean = CBool(drp("AplicaSeccion"))
|
|
Dim AplicaLote As Boolean = CBool(drp("AplicaLote"))
|
|
Dim AplicaCaducidad As Boolean = CBool(drp("AplicaCaducidad"))
|
|
'activa Serie
|
|
ThSerieSalida.Visible = AplicaSerie
|
|
TrSerieSalida.Visible = AplicaSerie
|
|
TxtnSerie.Visible = AplicaSerie
|
|
|
|
Dim CveSubProyectoAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenInventarioFisico.SelectedValue.ToEntero).FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero
|
|
|
|
If UsuarioActual.CveEmpresa = 119 AndAlso Not CveSubProyectoAlmacen.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347).Split(","c)) Then
|
|
AplicaLote = False
|
|
AplicaCaducidad = False
|
|
End If
|
|
'activa seccion
|
|
ThSeccionSalida.Visible = AplicaSeccion
|
|
TrSeccionSalida.Visible = AplicaSeccion
|
|
|
|
'activa lote
|
|
ThLoteSalida.Visible = AplicaLote
|
|
TrLoteSalida.Visible = AplicaLote
|
|
|
|
'activa caducidad
|
|
ThCaducidadSalida.Visible = AplicaCaducidad
|
|
ThCaducidadSalida.InnerText = UsuarioActual.Empresa.Funcionalidad(147)
|
|
TrCaducidadSalida.Visible = AplicaCaducidad
|
|
|
|
Else
|
|
TxtnSerie.Visible = False
|
|
End If
|
|
UpSalidaFisico.Update()
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
Private Sub GuardarBitacora(CveVenta As Integer, RutaAdjunto As String, Obser As String)
|
|
Dim ObjEventos As New ClsOIEventos()
|
|
|
|
|
|
Try
|
|
If ObjEventos.AddEventoBitacora(Obser, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then
|
|
|
|
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Se presento un error al guardar la Bitacora", ex)
|
|
End Try
|
|
|
|
ObjEventos.Dispose()
|
|
|
|
End Sub
|
|
|
|
#Region "DESCARGAR E IMPRIMIR LISTADO"
|
|
Public Sub DescargarFormato()
|
|
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\FormatoEntradasSalidas.xlsx"
|
|
|
|
Dim Archivo As New IO.FileInfo(Directorio)
|
|
If Archivo.Exists Then
|
|
Response.Clear()
|
|
Response.ClearHeaders()
|
|
Response.ClearContent()
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
|
|
Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
Response.ContentType = "text/plain"
|
|
Response.Flush()
|
|
Response.TransmitFile(Archivo.FullName)
|
|
Response.End()
|
|
End If
|
|
End Sub
|
|
Public Sub LbDescargarExcel_Click(sender As Object, e As EventArgs) Handles LbDescargarExcelConceptos.Click
|
|
DescargarFormato()
|
|
End Sub
|
|
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
|
|
Dim dt As New DataTable
|
|
'Dim Conexion As Odbc.OdbcConnection = Nothing
|
|
Dim ErrorArchivo = False
|
|
Dim n As Integer = 0
|
|
Try
|
|
Select Case Tipo
|
|
Case "EXCEL"
|
|
dt = ReadExcelFile(Ruta + FileName, True)
|
|
dt = dt.FiltraParametros("Cantidad <> '' ")
|
|
'Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
|
'Conexion.Open()
|
|
'Dim cmd = Conexion.CreateCommand()
|
|
'cmd.CommandType = CommandType.Text
|
|
'cmd.CommandText = "Select * FROM [Hoja1$]"
|
|
'Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
|
'DataAdapter.Fill(dt)
|
|
Case Else
|
|
Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End Select
|
|
Catch ex As Exception
|
|
ErrorArchivo = True
|
|
OnError("Ocurrio un Error al leer el archivo <br/>" & ex.Message, ex)
|
|
End Try
|
|
' Conexion.Close()
|
|
If Not ErrorArchivo Then
|
|
If Not dt.Columns(0).ColumnName = "Cantidad" Then
|
|
Alert("El nombre de la primera columna debe ser 'Cantidad'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(1).ColumnName = "Código" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Código'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
'If Not dt.Columns(2).ColumnName = "Codigo Barras" Then
|
|
' Alert("El nombre de la tecera columna debe ser 'Codigo Barras'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
' Exit Sub
|
|
'End If
|
|
If Not dt.Columns(2).ColumnName = "Producto/Servicio" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Producto/Servicio'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(3).ColumnName = "UM" Then
|
|
Alert("El nombre de la quinta columna debe ser 'U.M'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(4).ColumnName = "Precio Unitario" Then
|
|
Alert("El nombre de la sexta columna debe ser 'Precio Unitario'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
dt.TableName = "Datos"
|
|
Try
|
|
Dim DTSeccionesAlmacen As DataTable = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1)
|
|
If Not ErrorArchivo Then
|
|
NumRow = 0
|
|
Dim RowNoEncontrados As String = ""
|
|
Dim NumAgregados As Integer = 0
|
|
Dim PSTemp As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa)
|
|
|
|
For Each Row As DataRow In dt.Rows
|
|
Dim Cantidad As Decimal = Row("Cantidad").ToString.ToDecimal
|
|
Dim UM As String = Row("UM").ToString
|
|
Dim Codigo As String = Row("Código").ToString.Trim.ToUpper
|
|
'Dim CodigoBarras As String = Row("Codigo Barras").ToString.Trim.ToUpper
|
|
Dim ProductoServicio As String = Row("Producto/Servicio").ToString.Trim.ToUpper
|
|
Dim PrecioUnitario As Decimal = Row("Precio Unitario").ToString.ToDecimal
|
|
Dim Serie As String = Row("Serie").ToString
|
|
Dim Lote As String = Row("Lote").ToString
|
|
Dim Caducidad As String = Row("Caducidad").ToString
|
|
Dim SeccionAlmacen As String = Row("SeccionAlmacen").ToString
|
|
|
|
Dim CvePS As Integer = 0
|
|
Dim CveUM As Integer = 0
|
|
Dim DataTemp As DataTable
|
|
|
|
NumRow = NumRow + 1
|
|
|
|
Dim CveSeccionAlmacen As Integer = -1
|
|
If SeccionAlmacen <> "" Then
|
|
CveSeccionAlmacen = DTSeccionesAlmacen.FiltroPrimeroValor("CveSeccion", String.Format("SeccionAlmacen = '{0}'", SeccionAlmacen)).ToEntero
|
|
End If
|
|
|
|
|
|
|
|
If Codigo <> "" Then
|
|
DataTemp = PSTemp.FiltraParametros(String.Format("Codigo = '{0}'", Codigo))
|
|
CvePS = DataTemp.FiltroPrimeroValor("CvePS", "").ToEntero
|
|
DataTemp.Dispose()
|
|
If CvePS = 0 Then
|
|
RowNoEncontrados &= Codigo & "<\BR>"
|
|
End If
|
|
Else
|
|
RowNoEncontrados &= "<\BR> - En la fila " & NumRow & " no se especificó código, código de barras ó descripción."
|
|
End If
|
|
|
|
|
|
'If Codigo <> "" Then
|
|
' Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c)
|
|
' If StrArray.Length > 0 Then
|
|
' If CBool(StrArray(0)) = True Then
|
|
' CvePS = StrArray(1).ToEntero
|
|
' Else
|
|
' RowNoEncontrados &= StrArray(1) & "<\BR>"
|
|
' End If
|
|
' End If
|
|
' 'ElseIf CodigoBarras <> "" Then
|
|
' ' Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c)
|
|
' ' If StrArray.Length > 0 Then
|
|
' ' If CBool(StrArray(0)) = True Then
|
|
' ' CvePS = StrArray(1).ToEntero
|
|
' ' Else
|
|
' ' RowNoEncontrados &= StrArray(1) & "<\BR>"
|
|
' ' End If
|
|
' ' End If
|
|
'ElseIf ProductoServicio <> "" Then
|
|
' Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c)
|
|
' If StrArray.Length > 0 Then
|
|
' If CBool(StrArray(0)) = True Then
|
|
' CvePS = StrArray(1).ToEntero
|
|
' Else
|
|
' RowNoEncontrados &= StrArray(1) & "<\BR>"
|
|
' End If
|
|
' End If
|
|
'Else
|
|
' RowNoEncontrados &= "<\BR> - En la fila " & NumRow & " no se especificó código, código de barras ó descripción."
|
|
'End If
|
|
|
|
If CvePS > 0 Then
|
|
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0)
|
|
|
|
If DrPS IsNot Nothing Then
|
|
CveUM = DrPS("CveUnidadMedida").ToString().ToEntero()
|
|
UM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimeroValor("UnidadMedida", $"CveUnidadMedida={CveUM}")
|
|
End If
|
|
AddNew(CvePS, ProductoServicio, CveUM, UM, Cantidad, PrecioUnitario, Serie.Replace(" ", String.Empty), "", Codigo, "-1", "",
|
|
Lote, Caducidad.ToDate, CveSeccionAlmacen, SeccionAlmacen, CargarGV:=False)
|
|
|
|
NumAgregados = NumAgregados + 1
|
|
|
|
End If
|
|
|
|
Next
|
|
|
|
If RowNoEncontrados.Length > 0 Then
|
|
Alert("Se Cargaron " & NumAgregados & " Productos o Servicios.<\BR>Los siguientes Productos o Servicios no se encontraron en la Base de Datos.<\BR>" & RowNoEncontrados, TipoMensaje.MsgAdvertencia)
|
|
If NumAgregados > 0 Then
|
|
RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal")
|
|
TxtExcel.Text = "[]"
|
|
End If
|
|
Else
|
|
Alert("Se Cargaron " & NumAgregados & " Productos o Servicios correctamente.")
|
|
RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal")
|
|
TxtExcel.Text = "[]"
|
|
End If
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al cargar los datos", ex)
|
|
End Try
|
|
|
|
End If
|
|
dt.Dispose()
|
|
End Sub
|
|
Private Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
|
|
If DdlAlmacen.SelectedValue.ToEntero > 0 Then
|
|
If TxtExcel.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
|
|
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.path
|
|
Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb", "xls"), "EXCEL", "CSV")
|
|
CargarArchivo(Directorio, file.filename, Tipo)
|
|
Else
|
|
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
|
|
End If
|
|
Else
|
|
Alert("Seleccione un almacén", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("$('#DivCargaExcel').modal('hide')", "hidemodal")
|
|
End If
|
|
End Sub
|
|
Private Function GetPS(Opt As String, Valor As String) As String
|
|
Dim StrReturn As String = String.Empty
|
|
Dim CvePS As Integer = 0
|
|
Dim Condicion As String = String.Format("{0} = '{1}'", Opt, Valor)
|
|
If Opt = "Codigo" Then
|
|
CvePS = GlobalDTPS(UsuarioActual.CveEmpresa, Codigo:=Valor).FiltroPrimeroValor("CvePS", "").ToString.ToEntero
|
|
Else
|
|
CvePS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", Condicion).ToString.ToEntero
|
|
End If
|
|
|
|
If CvePS > 0 Then
|
|
StrReturn = "True|" & CvePS.ToString
|
|
Else
|
|
StrReturn = "False| - No se encontró " & Valor & " en la fila " & NumRow & ", columna " & Opt
|
|
End If
|
|
Return StrReturn
|
|
End Function
|
|
#End Region
|
|
Protected Sub LnkAgregarNuevoMov_Click(sender As Object, e As EventArgs)
|
|
EsNuevoMov = True
|
|
|
|
For Each gvr As GridViewRow In GvM.Rows
|
|
If (gvr.RowState <> 5 AndAlso gvr.RowState <> DataControlRowState.Edit) Then GvM.Rows(gvr.RowIndex).FCLinkButton("lnkRemove").Visible = True
|
|
Next
|
|
|
|
If DdlAlmacen.Visible Then DdlAlmacen.Enabled = True
|
|
DdlAlmacen.SelectedValueExist(-1)
|
|
If DdlConcepto.Visible Then DdlConcepto.Enabled = True
|
|
DdlConcepto.SelectedValueExist(-1)
|
|
If TxtDepartamentoEntrega.Visible Then TxtDepartamentoEntrega.Enabled = True
|
|
If TxtPedidoContrato.Visible Then TxtPedidoContrato.Enabled = True
|
|
If TxtFolio.Visible Then TxtFolio.Enabled = True
|
|
If TxtFecha.Visible Then TxtFecha.Enabled = True
|
|
If TxtResponsable.Visible Then TxtResponsable.Enabled = True
|
|
If TxtObservaciones.Visible Then TxtObservaciones.Enabled = True
|
|
If DdlProveedor.Visible Then DdlProveedor.Enabled = True
|
|
If TxtRemision.Visible Then TxtRemision.Enabled = True
|
|
If DdlMoneda.Visible Then DdlMoneda.Enabled = True
|
|
If TxtGuia.Visible Then TxtGuia.Enabled = True
|
|
|
|
If BtnEliminar.Visible Then BtnEliminar.Visible = False
|
|
|
|
LnkAgregarNuevoMov.Visible = False
|
|
End Sub
|
|
|
|
'#Region "SECCION ALMACEN"
|
|
' Private Sub CreaDtSeccionAlmacen()
|
|
' DtSeccionAlmacen = New DataTable
|
|
' DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal))
|
|
' DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer))
|
|
' DtSeccionAlmacen.Columns.Add("CveSeccionAlmacen", GetType(Integer))
|
|
' DtSeccionAlmacen.Columns.Add("SeccionAlmacen", GetType(String))
|
|
' DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer))
|
|
' End Sub
|
|
' Private Sub CargaDdlAlmacen()
|
|
' DdlSeccionAlmacenModal.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero)
|
|
' DdlSeccionAlmacenModal.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
' DdlSeccionAlmacenModal.DataBind()
|
|
' End Sub
|
|
' Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs)
|
|
' If Not DdlConcepto.SelectedValue.ToEntero > 0 Then
|
|
' Alert("Tiene que seleccionar un concepto", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
' End If
|
|
' Tipo = GlobalDTInvConceptos().FiltroPrimeroValor("Origen", $"CveConcepto = {DdlConcepto.SelectedValue}").ToEntero
|
|
' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
' CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal
|
|
' IndexSeccionAlmacen = gvRow.RowIndex
|
|
' CargaSeccionAlmacen()
|
|
' RegistraScript("$('#DModalSeccionAlmacen').modal()")
|
|
' End Sub
|
|
|
|
' Private Sub CargaSeccionAlmacen()
|
|
' Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen")
|
|
' GvSeccionAlmacen.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}")
|
|
' GvSeccionAlmacen.DataBind()
|
|
|
|
' TxtCantidadSeccion.Text = ""
|
|
' DdlSeccionAlmacenModal.SelectedIndex = 0
|
|
' Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion
|
|
' If CantidadRestante = 0 Then
|
|
' RVTxtCantidad.MaximumValue = "1"
|
|
' TxtCantidadSeccion.Enabled = False
|
|
' Else
|
|
' RVTxtCantidad.MaximumValue = CantidadRestante.ToString
|
|
' TxtCantidadSeccion.Enabled = True
|
|
' End If
|
|
|
|
' If CantidadTotalSeccion > 0 Then
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = False
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = "Cuenta con sección almacen"
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = False
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen"
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = False
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = "Cuenta con sección almacen"
|
|
' Else
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").Visible = True
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("imgE").ToolTip = ""
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = True
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = ""
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").Visible = True
|
|
' GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkDividir").ToolTip = ""
|
|
' End If
|
|
|
|
' If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 AndAlso Tipo = -1 Then
|
|
' DdlAlmacen.Enabled = False
|
|
' DdlAlmacen.ToolTip = "Cuenta con sección almacen"
|
|
' Else
|
|
' DdlAlmacen.Enabled = True
|
|
' DdlAlmacen.ToolTip = ""
|
|
' End If
|
|
|
|
' UpModalSeccionAlmacen.Update()
|
|
' UppGrid.Update()
|
|
' End Sub
|
|
|
|
' Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs)
|
|
' If Tipo = -1 Then
|
|
' Dim ObjInv As New ClsInventarios
|
|
' Dim CantidadDisponible As Decimal = 0
|
|
' If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacenModal.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero,
|
|
' CvePS, UsuarioActual.CveEmpresa) Then
|
|
' If ObjInv.DtResultados.Rows.Count > 0 Then
|
|
' CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString.ToDecimal
|
|
' End If
|
|
' End If
|
|
' ObjInv.Dispose()
|
|
|
|
' CantidadDisponible -= DtSeccionAlmacen.FiltraParametros($"CvePS = {CvePS} AND CveSeccionAlmacen = {DdlSeccionAlmacenModal.SelectedValue}").SUMD("CantidadSeccionAlmacen")
|
|
|
|
' If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then
|
|
' Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: <b>{CantidadDisponible}</b>", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
' End If
|
|
' End If
|
|
|
|
' Dim Row As DataRow = Nothing
|
|
' DtSeccionAlmacen.AcceptChanges()
|
|
' Row = DtSeccionAlmacen.NewRow
|
|
' Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal
|
|
' Row("IndexSeccionAlmacen") = IndexSeccionAlmacen
|
|
' Row("CveSeccionAlmacen") = DdlSeccionAlmacenModal.SelectedValue.ToEntero
|
|
' Row("SeccionAlmacen") = DdlSeccionAlmacenModal.SelectedItem.Text
|
|
' Row("Consec") = DtSeccionAlmacen.Rows.Count + 1
|
|
' DtSeccionAlmacen.Rows.Add(Row)
|
|
' DtSeccionAlmacen.AcceptChanges()
|
|
' CargaSeccionAlmacen()
|
|
' End Sub
|
|
|
|
' Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs)
|
|
' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
' Dim Index As Integer = 0
|
|
' For Each Dr As DataRow In DtSeccionAlmacen.Rows
|
|
' If Dr("Consec").ToString.ToEntero = gvRow.DataKey("Consec").ToEntero() Then
|
|
' Exit For
|
|
' End If
|
|
' Index += 1
|
|
' Next
|
|
' DtSeccionAlmacen.Rows.RemoveAt(Index)
|
|
' DtSeccionAlmacen.AcceptChanges()
|
|
' CargaSeccionAlmacen()
|
|
' End Sub
|
|
|
|
'#End Region
|
|
|
|
Protected Sub LkAgregar_Click() Handles LnkAgregarProducto.Click
|
|
|
|
If EsConsumoInterno And UsuarioActual.Empresa.Funcionalidad(590) = "1" Then
|
|
|
|
If DdlSubProyecto.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Debe seleccionar un Centro de Costos.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
Else
|
|
CargaCultivos()
|
|
End If
|
|
|
|
End If
|
|
|
|
limpiarModalDetalle()
|
|
UpAgregar.Update()
|
|
RegistraScript("$('#ModalAgregar').modal()")
|
|
End Sub
|
|
|
|
Private Sub ActualizarPS()
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
If Not ObjInventario.UpdateMovimientoDetalle(txtCantidad.Text.ToDouble, DdlUnidad.SelectedValue.ToEntero, DdlProducto2.SelectedValue.ToEntero, txtPrecio.Text.ToDouble, CveAFEdit,
|
|
CveMovimientoDetalleEdit, DdlSeccionAlmacen.SelectedValue.ToEntero, TxtnSerie.Text, TxtObservacionesdetalle.Text,
|
|
CveUsuarioModifico:=UsuarioActual.CveUsuario, CveCultivoCuadroDetalle:=DdlModalCultivosCuadro.SelectedValue.ToEntero) Then
|
|
Alert("Error al Actualizar los movimientos")
|
|
Else
|
|
Alert("Movimiento actualizado correctamente")
|
|
RegistraScript("$('#ModalAgregar').modal('hide')")
|
|
End If
|
|
ObjInventario.Dispose()
|
|
End Sub
|
|
|
|
Private Sub limpiarModalDetalle()
|
|
txtCantidad.Enabled = True
|
|
DdlClasificacion.Enabled = True
|
|
DdlProducto2.Enabled = True
|
|
DdlUnidad.Enabled = True
|
|
divCantidad.Visible = True
|
|
divClasificacionProducto.Visible = True
|
|
divUnidadMedida.Visible = True
|
|
txtCantidad.Text = ""
|
|
DdlProducto2.SelectedValue = "-1"
|
|
DdlProducto2.SelectedText = ""
|
|
ElProductoChange()
|
|
txtPrecio.Text = ""
|
|
TxtnSerie.Text = ""
|
|
TxtnLote.Text = ""
|
|
TxtnFechaCaducidad.Text = ""
|
|
TxtObservacionesdetalle.Text = ""
|
|
DdlSeccionAlmacen.ClearSelection()
|
|
LkAgregarDetalle.Text = "Agregar"
|
|
DdlModalCultivosCuadro.SelectedValueExist(-1)
|
|
If DdlMonedaTC.SelectedValue.ToEntero = 2 Then
|
|
VisualizaPUExtranjero(UsuarioActual.TienePermisoProceso(201))
|
|
Else
|
|
VisualizaPUExtranjero(False)
|
|
End If
|
|
Dim Origen As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", String.Format("CveConcepto = {0}", DdlConcepto.SelectedValue)).ToEntero
|
|
divPrecio.Visible = Origen = 1
|
|
txtPrecio.Visible = Origen = 1
|
|
UpAgregar.Update()
|
|
End Sub
|
|
|
|
|
|
Private Sub RegeneraRM(CveMovD As Integer, CveMov2 As Integer)
|
|
'Dim Retorno As Integer = -1
|
|
'Dim ErrorMovInv As Boolean = False
|
|
'Dim ObjConta As New ClsContabilidad
|
|
'ObjConta.IniciaTransacSQL()
|
|
'Dim ObjInventario As New ClsInventarios(ObjConta.IniciaTransacSQL)
|
|
'Dim CveMovimientoInsertado As Integer = 0
|
|
'Dim Fecha As Date
|
|
'Dim Importe As Decimal
|
|
|
|
'If ObjInventario.GetMovimientosDetalleTransitorio(CveMovD, UsuarioActual.CveEmpresa) Then
|
|
|
|
|
|
' Fecha = ObjInventario.DtResultados.Rows(0)("FechaMovto").ToString.ToDate
|
|
|
|
' Dim dtvirtual As DataTable = ObjInventario.DtResultados
|
|
|
|
' If dtvirtual.Rows.Count > 0 Then
|
|
' CveMovimientoInsertado = ObjInventario.AddMovimiento(352, 8, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="TA/VM")
|
|
|
|
' For Each RowVirtual As DataRow In dtvirtual.Rows
|
|
' Dim CvePS = RowVirtual("CvePS").ToString().ToEntero()
|
|
' Dim CantidadUsado As Double = RowVirtual("Cantidad").ToString().ToDouble()
|
|
' Dim PU As Decimal = RowVirtual("PUOriginal").ToString().ToDecimal()
|
|
' Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero()
|
|
' Dim CveMovimientoDetalle As Integer = RowVirtual("CveMovimientoDetalle").ToString().ToEntero()
|
|
|
|
' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInsertado, CantidadUsado, CveUM, CvePS, PU, -1, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
' ErrorMovInv = True
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
|
|
' If ObjInventario.GetMovimientosDetalle(CveMovimientoInsertado, UsuarioActual.CveEmpresa) Then
|
|
|
|
' Dim resultado As DataTable = ObjInventario.DtResultados
|
|
' Importe = resultado.SUMD("Total").RoundSQL
|
|
|
|
' Dim Contabilizable As Boolean = False
|
|
' Dim Concepto As String = "Traspaso"
|
|
' Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Manualx", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Importe, "", 68, Concepto, Fecha, -1, -1, CveMovimientoAlmacen:=CveMovimientoInsertado, ImporteMX:=Importe, Contabilizable:=Contabilizable) Then
|
|
' ErrorMovInv = True
|
|
' End If
|
|
|
|
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Importe, "", 68, Concepto, Fecha, -1, -1, CveMovimientoAlmacen:=CveMovD, ImporteMX:=Importe, Contabilizable:=Contabilizable) Then
|
|
' ErrorMovInv = True
|
|
' End If
|
|
|
|
' If Not ErrorMovInv Then Retorno = CvePrePoliza
|
|
|
|
' End If
|
|
' End If
|
|
'Else
|
|
' ErrorMovInv = True
|
|
'End If
|
|
|
|
'If ErrorMovInv Then
|
|
' ObjConta.RollBack()
|
|
' Alert("No se aplico", TipoMensaje.MsgError)
|
|
'Else
|
|
' ObjConta.Commit()
|
|
' Alert("Se aplico", TipoMensaje.MsgInformacion)
|
|
'End If
|
|
|
|
'ObjConta.Dispose()
|
|
'ObjInventario.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Sub LnkGenerarVirtual_Click(sender As Object, e As EventArgs)
|
|
If CveMovimiento > 0 Then
|
|
Dim ObjInventario As New ClsInventarios
|
|
ObjInventario.IniciaTransacSQL()
|
|
|
|
Dim Retorno = GenerarMovimientoVirtual(Me.CveMovimiento, ObjInventario)
|
|
|
|
If Retorno.TieneError Then
|
|
ObjInventario.RollBack()
|
|
Else
|
|
ObjInventario.Commit()
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
|
|
If Retorno.CveMovimientoVirtual > 0 AndAlso Not Retorno.TieneError Then
|
|
Alert($"Se generó el movimiento virtual con el folio:<b>{Retorno.FolioVirtual}<b/>")
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Private Function GenerarMovimientoVirtual(CveMovimiento As Integer, ObjInventario As ClsInventarios) As MMovimientoVirtual
|
|
Dim ErrorMovInv As Boolean = False
|
|
|
|
Dim DtPSVirtual As New DataTable("DtTamanios")
|
|
Dim CveMovimientoVirtual As Integer = -1
|
|
Dim FolioVirtual As Integer = -1
|
|
|
|
Dim tCveAlmacen As Integer = -1
|
|
Dim tOrigen As Integer = -1
|
|
|
|
Try
|
|
If ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
tCveAlmacen = ObjInventario.DtResultados.FiltroPrimeroValor("CveAlmacen").ToEntero()
|
|
tOrigen = ObjInventario.DtResultados.FiltroPrimeroValor("Origen").ToEntero()
|
|
End If
|
|
|
|
Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=tCveAlmacen).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero()
|
|
|
|
'VERIFICA SI TIENE ALMACEN VIRTUAL
|
|
If CveAlmacenVirtual > 0 Then
|
|
If ObjInventario.GetMovimientosDetalleVirtual(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
DtPSVirtual = ObjInventario.DtResultados
|
|
End If
|
|
|
|
If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 Then
|
|
|
|
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, If(tOrigen > 0, 36, 37), 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveMovimientoRelacionado:=CveMovimiento, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="ES/GV")
|
|
FolioVirtual = ObjInventario.Folio
|
|
|
|
For Each RowUsado As DataRow In DtPSVirtual.Rows
|
|
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
|
|
Dim CantidadUsado As Decimal = RowUsado("Cantidad").ToString().ToDecimal()
|
|
Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal()
|
|
Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
End If
|
|
Catch ex As Exception
|
|
ErrorMovInv = True
|
|
End Try
|
|
|
|
Return New MMovimientoVirtual With {.TieneError = ErrorMovInv, .CveMovimientoVirtual = CveMovimientoVirtual, .FolioVirtual = FolioVirtual.ToString()}
|
|
End Function
|
|
|
|
|
|
Protected Sub LnkGenerarPDF_Click(sender As Object, e As EventArgs)
|
|
GeneraPDFFactura()
|
|
End Sub
|
|
Private Sub GeneraPDFFactura()
|
|
Try
|
|
Dim objFactura = CreaObjetosVenta()
|
|
PdfFactura(objFactura)
|
|
objFactura.Dispose()
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al generar el PDF", ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Function CreaObjetosVenta() As Modelos.Factura
|
|
Dim ObjFactura = New Modelos.Factura
|
|
ObjFactura.Version = "3.3"
|
|
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
|
ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa
|
|
ObjFactura.TipoCambio = 0
|
|
ObjFactura.ConvertirPesos = False
|
|
ObjFactura.TipoCambio = 0
|
|
ObjFactura.CveMoneda = 1
|
|
ObjFactura.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {ObjFactura.CveMoneda} ")
|
|
ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", "CveMoneda = 1")
|
|
ObjFactura.MonedaAbreviatura = GlobalDTMonedas.FiltroPrimeroValor("Abreviatura", $"CveMoneda = {ObjFactura.CveMoneda} ")
|
|
ObjFactura.TipoDocto = "Tra"
|
|
ObjFactura.RefDocto = ""
|
|
ObjFactura.Folio = Folio.ToEntero
|
|
ObjFactura.Serie = "Tra"
|
|
ObjFactura.CveMesa = -1
|
|
ObjFactura.Fecha = Now
|
|
ObjFactura.CvePrePoliza = -1
|
|
ObjFactura.FechaPago = Now
|
|
ObjFactura.MotivoDescuento = ""
|
|
ObjFactura.Observaciones = ""
|
|
ObjFactura.FechaEjecucion = Now
|
|
ObjFactura.UsuarioCreo = UsuarioActual.Usuario
|
|
ObjFactura.CveCondicionEntrega = -1
|
|
ObjFactura.CondicionEntrega = ""
|
|
ObjFactura.NumeroCuenta = ""
|
|
ObjFactura.CondicionesPago = 0
|
|
ObjFactura.FormaPago = 0
|
|
ObjFactura.PedidoContrato = ""
|
|
ObjFactura.OrdenCompra = ""
|
|
ObjFactura.NumeroContrato = ""
|
|
ObjFactura.NumeroDescripcionContrato = ""
|
|
ObjFactura.DescripcionContrato = ""
|
|
ObjFactura.CveCorte = -1
|
|
ObjFactura.TipoDocumento = "Traspaso"
|
|
ObjFactura.Alfa1 = ""
|
|
ObjFactura.Alfa2 = ""
|
|
ObjFactura.Alfa3 = ""
|
|
ObjFactura.Descuento = 0
|
|
ObjFactura.Amortizacion = 0
|
|
ObjFactura.CveContrato = 0
|
|
ObjFactura.CveVendedor = 0
|
|
ObjFactura.FechaVencimiento = Now
|
|
ObjFactura.TipoEstatus = 0
|
|
ObjFactura.Det_OrdenCompra = ""
|
|
ObjFactura.Inv_CveEstatusEntrega = 0
|
|
ObjFactura.FormaPago33 = ""
|
|
ObjFactura.MetodoPago33 = ""
|
|
ObjFactura.UsoCFDI = ""
|
|
ObjFactura.CveClienteSucursal = 0
|
|
Dim CveSubProyecto As Integer = -1
|
|
If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacen.SelectedValue}").Rows.Count > 0 Then
|
|
CveSubProyecto = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacen.SelectedValue}").Rows(0)("CveSubProyecto").ToString.ToEntero
|
|
End If
|
|
ObjFactura.CveSubProyecto = CveSubProyecto
|
|
ObjFactura.CveSubProyectoCobranza = CveSubProyecto
|
|
ObjFactura.CveSubProyectoEjecucion = CveSubProyecto
|
|
|
|
ObjFactura.SubTotal = 0
|
|
ObjFactura.Descuento = 0
|
|
ObjFactura.Amortizacion = 0
|
|
ObjFactura.IVA = 0
|
|
ObjFactura.RetIVA = 0
|
|
ObjFactura.RetISR = 0
|
|
ObjFactura.IEPS = 0
|
|
ObjFactura.Total = 0
|
|
ObjFactura.RFCReceptor = "XAXX010101000"
|
|
|
|
Dim dt As DataTable = DtMovimientos.Copy
|
|
|
|
dt.Columns.Add("TotalImporte", Type.GetType("System.Double"))
|
|
dt.Columns.Add("Descuento", Type.GetType("System.Double"))
|
|
dt.Columns.Add("UM")
|
|
dt.Columns.Add("SATClaveUM")
|
|
dt.Columns.Add("SATClaveProdServ")
|
|
dt.Columns.Add("Noidentificacion")
|
|
dt.Columns.Add("CuentaPredial")
|
|
dt.Columns.Add("Obs")
|
|
dt.Columns.Add("ImporteIVA", Type.GetType("System.Double"))
|
|
dt.Columns.Add("PorcentajeIVA", Type.GetType("System.Double"))
|
|
|
|
|
|
For Each Row As DataRow In dt.Rows
|
|
Row("TotalImporte") = Row("Total")
|
|
Row("Descuento") = 0
|
|
Row("UM") = Row("UnidadMedida")
|
|
Row("SATClaveUM") = Row("SATClaveUnidadMedida")
|
|
Row("SATClaveProdServ") = Row("SATClavePS")
|
|
Row("Noidentificacion") = Row("Codigo")
|
|
Row("CuentaPredial") = ""
|
|
Row("Obs") = Row("Observaciones")
|
|
Row("ImporteIVA") = 0
|
|
Row("PorcentajeIVA") = 0
|
|
Next
|
|
|
|
'DETALLES
|
|
ObjFactura.DtDetalle = dt
|
|
|
|
'SUBPROYECTO
|
|
ObjFactura.SetSubProyectoMatriz(Me)
|
|
ObjFactura.SetSubProyecto(Me)
|
|
|
|
ObjFactura.Inv_CveMovimiento = Me.CveMovimiento
|
|
|
|
ObjFactura.Timbre = PreParaTimbre(ObjFactura)
|
|
|
|
Return ObjFactura
|
|
End Function
|
|
Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre
|
|
Dim Timbre As New CFDITimbre
|
|
Timbre.Comprobante.TipoComprobante = "T"
|
|
Timbre.Comprobante.Folio = Obj.Folio.ToString
|
|
Timbre.Comprobante.Serie = Obj.Serie
|
|
Timbre.Comprobante.Fecha = Obj.Fecha
|
|
Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33
|
|
Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33
|
|
Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT
|
|
Timbre.Comprobante.SubTotal = Obj.SubTotal
|
|
Timbre.Comprobante.Descuentos = Obj.Descuento
|
|
Timbre.Comprobante.Moneda = Obj.MonedaSAT
|
|
Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString)
|
|
Timbre.Comprobante.Total = Obj.Total
|
|
|
|
Timbre.Comprobante.LugarExpedicion = Obj.SubProyecto.CP
|
|
Timbre.Comprobante.Confirmacion = ""
|
|
|
|
Timbre.Receptor.RFC = "XAXX010101000"
|
|
Timbre.Receptor.Nombre = UsuarioActual.Empresa.Empresa
|
|
Timbre.Receptor.UsoCFDI = "P01"
|
|
|
|
Dim totSubTotal As Decimal = Obj.SubTotal
|
|
Dim totIVA As Decimal = Obj.IVA
|
|
Dim totRetIVA As Decimal = Obj.RetIVA
|
|
Dim totRetISR As Decimal = Obj.RetISR
|
|
Dim i As Integer = 1
|
|
|
|
'DETALLES
|
|
Dim tPS As String = ""
|
|
|
|
For Each drr As DataRow In Obj.DtDetalle.Rows
|
|
If drr("PS").ToString.Length = 1 Then
|
|
tPS = drr("Obs").ToString
|
|
Else
|
|
If drr("PS").ToString.Length = 0 Then
|
|
tPS = ""
|
|
Else
|
|
tPS = String.Format("{0} {1}", drr("PS"), drr("Obs"))
|
|
End If
|
|
End If
|
|
|
|
'CONDICIONANTE, ESPECIAL
|
|
If UsuarioActual.CveEmpresa = 15 Then drr("UM") = "" 'LES COMENTAN QUE NO DEBE IR LA ETIQUETA DE LA UNIDAD EN EL PRODUCTO
|
|
|
|
Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString.ToDecimal,
|
|
.Descripcion = tPS,
|
|
.ValorUnitario = drr("PU").ToString.ToDecimal,
|
|
.Importe = drr("TotalImporte").ToString.ToDecimal,
|
|
.Descuento = drr("Descuento").ToString.ToDecimal,
|
|
.Unidad = drr("UM").ToString,
|
|
.ClaveUnidad = drr("SATClaveUM").ToString,
|
|
.ClaveProdServ = drr("SATClaveProdServ").ToString,
|
|
.Noidentificacion = drr("Noidentificacion").ToString,
|
|
.CuentaPredial = drr("CuentaPredial").ToString}
|
|
'VERIFICA SUMA SUBTOTALES
|
|
If i = Obj.DtDetalle.Rows.Count AndAlso totSubTotal <> concepto.Importe Then 'PROCESO DE AJUSTA DE DECIMALES
|
|
concepto.Importe = totSubTotal
|
|
End If
|
|
totSubTotal = totSubTotal - concepto.Importe
|
|
|
|
'SIEMPRE ESTAMOS AGREGANDO EL IVA
|
|
'concepto.Impuestos.Add(New CFDIConceptosImpuestos With {.TrasladooRetencion = "T", .Base = concepto.Importe - concepto.Descuento, .TasaOCuota = drr("PorcentajeIVA").ToString.ToDecimal, .Impuesto = "002", .Importe = drr("ImporteIVA").ToString.ToDecimal})
|
|
|
|
Timbre.Conceptos.Add(concepto)
|
|
i += 1
|
|
Next
|
|
Return Timbre
|
|
End Function
|
|
Private Class MMovimientoVirtual
|
|
Public Property CveMovimientoVirtual As Integer
|
|
Public Property FolioVirtual As String
|
|
Public Property TieneError As Boolean
|
|
End Class
|
|
|
|
End Class
|