4081 lines
188 KiB
VB.net
4081 lines
188 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
'Imports DocumentFormat.OpenXml.Wordprocessing
|
|
|
|
Partial Class Inventarios_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 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 Double
|
|
Get
|
|
Return CType(ViewState("CostoPromedioSerieLote"), Double)
|
|
End Get
|
|
Set(value As Double)
|
|
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 DtSeccionAlmacen As DataTable
|
|
Get
|
|
Return CType(ViewState("DtSeccionAlmacen"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtSeccionAlmacen") = 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
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
CveMovimiento = -1
|
|
CveMovimientoRelacionado = -1
|
|
TieneRelacionado = -1
|
|
TieneSalida = False
|
|
EstatusAlmacenCompra = -1
|
|
EsConsumoInterno = False
|
|
EsNuevoMov = False
|
|
CvePrePoliza = -1
|
|
|
|
CreaDT()
|
|
CargaCombos()
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
RVFecha.MaximumValue = Now.ToShortDateString
|
|
InicializaClientes()
|
|
|
|
CantidadTotal = 0
|
|
IndexSeccionAlmacen = 0
|
|
Tipo = 0
|
|
CreaDtSeccionAlmacen()
|
|
CargaDdlAlmacen()
|
|
|
|
'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
|
|
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
|
|
|
|
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
|
|
|
|
'SECCION ALMACEN EXISTENCIAS
|
|
GvM.Columns(14).Visible = UsuarioActual.Empresa.Funcionalidad(563).ToString = "1" AndAlso Not CveMovimiento > 0
|
|
|
|
'BLOQUEA PERMISOS
|
|
BtnGuardar.Enabled = PermiteGuardar()
|
|
BtnEliminar.Enabled = PermiteEliminar()
|
|
BtnContabilizar.Enabled = PermiteContabilizar()
|
|
BtnNuevo.Enabled = PermiteCrearNuevo()
|
|
|
|
ActivaPermisoSeccionAlmacen()
|
|
If CveMovimiento > 0 Then
|
|
PermisoVerImportes()
|
|
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 ActivaPermisoSeccionAlmacen()
|
|
GvM.Columns(12).Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1"
|
|
TrSeccionAlmacen.Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1"
|
|
TrSeccionAlmacen2.Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1"
|
|
End Sub
|
|
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("SerieLote", Type.GetType("System.String"))
|
|
dt.Columns.Add("Lote", Type.GetType("System.String"))
|
|
dt.Columns.Add("Batch", Type.GetType("System.String"))
|
|
|
|
dt.Columns.Add("Observaciones")
|
|
dt.Columns.Add("CountMovimientoEntradaDetalle")
|
|
dt.Columns.Add("TotalExtranjero", Type.GetType("System.Double"))
|
|
|
|
CargaGVM(dt)
|
|
|
|
DtMovimientos = dt.Clone
|
|
DtMovimientosEntradaInvFisico = dt.Clone
|
|
DtMovimientosSalidaInvFisico = dt.Clone
|
|
|
|
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()
|
|
|
|
DdlSeccion.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlSeccion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSeccion.DataBind()
|
|
|
|
DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlSeccionAlmacen.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 Then
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
|
|
End If
|
|
DdlAlmacenInventarioFisico.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (9,11)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlAlmacenInventarioFisico.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
DdlAlmacenInventarioFisico.SelectedValue = "-1"
|
|
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacenInventarioFisico.DataBind()
|
|
|
|
If IsNothing(Request("CveMovimiento")) 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")
|
|
|
|
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")
|
|
|
|
DdlProducto2.DataBind()
|
|
DdlPS.DataBind()
|
|
DdlPSSalida.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"))
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub CargaSubProyectos()
|
|
DdlSubProyecto.DataSource = If(UsuarioActual.Empresa.Funcionalidad(102) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1))
|
|
DdlSubProyecto.DataBind()
|
|
'DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
Private Sub 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
|
|
|
|
|
|
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).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
|
|
|
|
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)))
|
|
CveCompra = Mov.CveCompra
|
|
CveConcepto = Mov.CveConcepto
|
|
|
|
If DtMov.Rows(0)("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", $"Tra-{Folio}", "Tra")))
|
|
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}", CveMovimiento, "PDF", $"Tra-{Folio}", "Tra")))
|
|
HplCartaPorte.Visible = True
|
|
HplCartaPorte.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimiento)))
|
|
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).FiltroPrimero(String.Format("CveCliente = {0}", Mov.CveCliente))
|
|
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.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
|
|
|
|
|
|
'cargar también los movimentos detalle
|
|
If Mov.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
DdlSeccion.SelectedValueExist(Mov.CveSeccion.ToString)
|
|
DtMovimientos = Mov.DtResultados.FiltraParametros("", "CveMovimientoDetalle")
|
|
|
|
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 DtMov.Rows(0)("CveProveedor").ToString.ToEntero > 0 Then
|
|
DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
DdlProveedor.DataBind()
|
|
DdlProveedor.SelectedValueExist(DtMov.Rows(0)("CveProveedor").ToString)
|
|
DdlProveedor.Enabled = False
|
|
TrProveedor.Visible = True
|
|
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
|
|
|
|
'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
|
|
|
|
BloqueaEdicionEncabezado()
|
|
Mov.Dispose()
|
|
UpGenerales.Update()
|
|
UPDatos.Update()
|
|
UppGrid.Update()
|
|
UPEncabezado.Update()
|
|
UpRegistroTipoCambio.Update()
|
|
|
|
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
|
|
DdlSeccion.Enabled = True
|
|
|
|
If CveMovimiento > 0 Then
|
|
DdlAlmacen.Enabled = False
|
|
DdlConcepto.Enabled = False
|
|
TxtFolio.Enabled = False
|
|
If Not PermiteGuardar() Then TxtFecha.Enabled = False
|
|
TxtResponsable.Enabled = False
|
|
TxtObservaciones.Enabled = False
|
|
DdlMoneda.Enabled = False
|
|
TxtGuia.Enabled = False
|
|
DdlSeccion.Enabled = False
|
|
End If
|
|
UppGrid.Update()
|
|
End Sub
|
|
|
|
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 = ""
|
|
TxtnBatch.Text = ""
|
|
TxtObservacionesdetalle.Text = ""
|
|
End Sub
|
|
|
|
Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
|
|
|
|
RegistraScript("$('#divDescripcion').modal()")
|
|
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.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, TxtDescripcion.Text, "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 SerieLote As String = "-1", Optional Lote As String = "-1", Optional Batch As String = "-1") As Double
|
|
Dim Inv As New ClsInventarios
|
|
Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, -1, FechaMovto:=String.Format("{0} {1}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd"), TxtHoraInicio.PostedTime), SerieLote:=SerieLote, Lote:=Lote, Batch:=Batch)
|
|
Inv.Dispose()
|
|
Return Existencia
|
|
End Function
|
|
|
|
Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
|
AgregarPS()
|
|
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.ToDouble, txtPrecio.Text.ToDouble, TxtnSerieLote.Text.Replace(" ", String.Empty), LblCodigo.Text, HdnCodigoAF.Value, HdnCveActivoFijo.Value, TxtObservacionesdetalle.Text, TxtnLote.Text.Trim, TxtnBatch.Text.Trim, DdlSeccionAlmacen.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedItem.Text)
|
|
LimpiarAgregar()
|
|
|
|
txtCantidad.Text = ""
|
|
TxtnLote.Text = ""
|
|
TxtnBatch.Text = ""
|
|
LblCodigo.Text = ""
|
|
TxtnSerieLote.Text = ""
|
|
HdnCodigoAF.Value = "-1"
|
|
HdnCveActivoFijo.Value = "-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 Double, PU As Double, SerieLote As String, CodigoAF As String, Codigo As String, CveAF As String, Observaciones As String, Lote As String, Batch As String, CveSeccionAlmacen As Integer, SeccionAlmacen As String)
|
|
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
|
|
'salida
|
|
If DdlConcepto.SelectedValue.Contiene({"3", "5", "7", "8", "11", "12", "13", "15", "16", "17", "20", "21", "30", "31"}) Then ' salida de almacen
|
|
Dim Existencia As Double = GetExistencias(CvePS, CveUM, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, If(SerieLote = "", "-1", SerieLote), If(Lote = "", "-1", Lote), If(Batch = "", "-1", Batch))
|
|
LbAgregar.ToolTip = Existencia.ToString
|
|
If Existencia - Cantidad - DtMovimientos.SUM("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUM} {If(SerieLote <> "", $" AND SerieLote = '{SerieLote}'", "")}") < 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 dr IsNot Nothing Then CveClasificacion = dr("CveClasificacion").ToString.ToEntero
|
|
|
|
'VALIDA QUE LA SERIE NO SEA IGUAL AL CODIGO O CODIGOBARRAS
|
|
If SerieLote <> "" And (SerieLote.ToUpper = dr("Codigo").ToString.ToUpper Or SerieLote.ToUpper = dr("CodigoBarras").ToString.ToUpper) Then
|
|
Alert($"La serie indicada <b>{SerieLote}</b> coincide con el codigo o codigo de barras del producto. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim registro As DataRow = DtMovimientos.NewRow
|
|
registro.Item("Cantidad") = Cantidad
|
|
registro.Item("CveUM") = CveUM
|
|
registro.Item("UnidadMedida") = UM
|
|
registro.Item("CvePS") = CvePS
|
|
registro.Item("CodigoPS") = PS
|
|
registro.Item("PS") = PS
|
|
registro.Item("PU") = PU
|
|
'registro.Item("PUExtranjero") = PU
|
|
registro.Item("Total") = Cantidad * PU
|
|
registro.Item("CveClasificacion") = CveClasificacion
|
|
registro.Item("Estatus") = ""
|
|
registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen
|
|
registro.Item("SeccionAlmacen") = SeccionAlmacen
|
|
|
|
|
|
registro.Item("CodigoAF") = CodigoAF
|
|
registro.Item("Codigo") = Codigo
|
|
registro.Item("CveAF") = CveAF
|
|
registro.Item("SerieLote") = If(SerieLote <> "", SerieLote, "")
|
|
registro.Item("Lote") = If(Lote <> "", Lote, "")
|
|
registro.Item("Batch") = If(Batch <> "", Batch, "")
|
|
registro.Item("Observaciones") = Observaciones
|
|
DtMovimientos.Rows.Add(registro)
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
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 = 0.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
|
|
|
|
'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.ToDouble * GlobalTipoCambio(TxtFecha.Text.ToDate)
|
|
Else
|
|
ImporteConcepto = Dr("PU").ToString.ToDouble
|
|
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("SerieLote").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), SerieLote:=If(Dr("SerieLote").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), Batch:=If(Dr("Batch").ToString = "", "-1", Dr("Batch").ToString)) >= Dr("Cantidad").ToString.ToDouble Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) 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, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) 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, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) 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
|
|
|
|
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 TotalCantidad As Double = DtMovimientos.SUMD("Cantidad")
|
|
If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then
|
|
If TotalCantidad <> DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") Then
|
|
ObjInventario.RollBack()
|
|
Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
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(DdlAlmacen.SelectedValue.ToEntero, 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)
|
|
|
|
|
|
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
|
|
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), SerieLote:=If(Dr("SerieLote").ToString = "", "-1", Dr("SerieLote").ToString), Lote:=If(Dr("Lote").ToString = "", "-1", Dr("Lote").ToString), Batch:=If(Dr("Batch").ToString = "", "-1", Dr("Batch").ToString)) >= 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.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) 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.ToDouble, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) 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.ToDouble * GlobalTipoCambio(TxtFecha.Text.ToDate)
|
|
Else
|
|
ImporteConcepto = Dr("PU").ToString.ToDouble
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, Dr("CveAF").ToString.ToEntero, Dr("CveSeccionAlmacen").ToString.ToEntero, Dr("SerieLote").ToString, Dr("Observaciones").ToString, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, CveUsuarioModifico:=UsuarioActual.CveUsuario) 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.SUM("Total", "").ToDecimal.RoundSQL()
|
|
Dim idCtaContable As Integer = 0
|
|
Dim IdCtaContableOtro As Integer = UsuarioActual.Empresa.IdCuentaOtrosIngresos
|
|
Dim TipoMovtoAlmacen As Boolean = False
|
|
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
|
|
|
|
Dim CveConceptoContable As Integer = 78
|
|
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
|
|
If UsuarioActual.Empresa.Funcionalidad(342).ToEntero > 0 Then
|
|
IdCtaContableOtro = UsuarioActual.Empresa.Funcionalidad(342).ToEntero
|
|
End If
|
|
Case 13, 29
|
|
CveConceptoContable = 69
|
|
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) Then
|
|
ErrorMovInv = True
|
|
Else
|
|
'Select Case DdlConcepto.SelectedValue.ToEntero
|
|
' Case 30
|
|
'Dim Dt As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}).Copy
|
|
'Dim IdCuentaGasto As Integer = 0
|
|
'Dim Total As Decimal = 0
|
|
'For Each Dr As DataRow In Dt.Rows
|
|
' Total = ObjInventario.DtResultados.FiltraParametros($"CveClasificacion = {Dr("CveClasificacion").ToString}").SUM("Total").ToDecimal.RoundSQL()
|
|
' IdCuentaGasto = ObjInventario.DtResultados.FiltraParametros($"CveClasificacion = {Dr("CveClasificacion").ToString}").Rows(0)("IdCuentaGasto").ToString.ToEntero
|
|
|
|
' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoAlmacen, Total, TxtObservaciones.Text.Trim, CveConceptoContable, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, IdCuentaGasto, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=Total, CveClasificacion:=Dr("CveClasificacion").ToString.ToEntero, CveSubProyecto:=tCveSubProyecto) Then
|
|
' ErrorMovInv = True
|
|
' End If
|
|
'Next
|
|
'Case Else
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoAlmacen, tValorInventario, TxtObservaciones.Text.Trim, CveConceptoContable, TxtObservaciones.Text.Trim, TxtFecha.Text.ToDate, IdCtaContableOtro, -1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=tValorInventario, CveSubProyecto:=tCveSubProyecto, CveClasificacion:=CveClasificacion) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
'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
|
|
If UsuarioActual.Empresa.UsaAC AndAlso (DdlConcepto.SelectedValue = "3") Then
|
|
Dim DtII As DataTable = Nothing
|
|
Dim TotalDetalle As Double = 0.0
|
|
Dim Importe As Double = DtMovimientos.SUM("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.SUM("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
|
|
|
|
|
|
If Not ErrorAC And Not ErrorMovInv Then
|
|
Dim Msg As New StringBuilder
|
|
Msg.AppendFormat("<br/>El Movimiento se registro con el Folio: <b>{0}</b>", ObjInventario.Folio)
|
|
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 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
|
|
DtSeccionAlmacen.Rows.Clear()
|
|
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.ToDouble
|
|
Exit Sub
|
|
End If
|
|
|
|
GuardaCodigoSerie(TxtCantidadProducto.Text.ToDouble, DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero, DrPS("CostoPromedio").ToString.ToDouble)
|
|
|
|
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 Double = TxtAltaCosto.Text.ToDouble
|
|
|
|
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 Double, 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)
|
|
End If
|
|
|
|
ObjInv.AddMovimientoDetalle(CveMovimiento, Cantidad, CveUM, CvePS, CostoPromedio, -1, SerieLote:=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
|
|
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
|
|
|
|
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
|
|
|
|
DdlConcepto.SelectedValue = "-1"
|
|
ddlConcepto_SelectedIndexChanged(DdlConcepto, EventArgs.Empty)
|
|
|
|
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()
|
|
TxtnSerieLote.Visible = False
|
|
TxtnLote.Visible = False
|
|
TxtnBatch.Visible = False
|
|
|
|
EscondeColumnasGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
|
|
If DdlProducto2.SelectedValue.ToEntero > 0 Then
|
|
Dim MetodoInventario As Integer = GlobalDTPS(UsuarioActual.CveEmpresa, DdlProducto2.SelectedValue.ToEntero).FiltroPrimeroValor("Inv_CveMetodoInventario", "").ToEntero ' ("Inv_CveMetodoInventario = 6", "PS")
|
|
If MetodoInventario = 5 Then
|
|
LblSerieLote.Visible = True
|
|
TxtnSerieLote.Visible = True
|
|
TrSerieLote.Visible = True
|
|
TrSerieLote2.Visible = True
|
|
GvM.Columns(9).Visible = True
|
|
End If
|
|
If MetodoInventario = 6 Then
|
|
TxtnLote.Visible = True
|
|
TrLote.Visible = True
|
|
TrLote2.Visible = True
|
|
GvM.Columns(10).Visible = True
|
|
|
|
TxtnBatch.Visible = True
|
|
TrBatch.Visible = True
|
|
TrBatch2.Visible = True
|
|
GvM.Columns(11).Visible = True
|
|
End If
|
|
End If
|
|
|
|
DdlUnidad.Items.Clear()
|
|
DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1)
|
|
DdlUnidad.DataBind()
|
|
UPDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " GVM "
|
|
Private Sub CargaGVM(DtTemp As DataTable)
|
|
GvM.DataSource = DtTemp
|
|
GvM.DataBind()
|
|
|
|
EscondeColumnasGVM(DtTemp)
|
|
End Sub
|
|
Private Sub EscondeColumnasGVM(DtTemp As DataTable)
|
|
LblSerieLote.Visible = False
|
|
TxtnSerieLote.Visible = False
|
|
TrSerieLote.Visible = False
|
|
TrSerieLote2.Visible = False
|
|
|
|
GvM.Columns(9).Visible = False
|
|
'PERMISO SOLO PARA EDITAR SERIELOTE
|
|
If UsuarioActual.TienePermisoProceso(245) Then
|
|
GvM.Columns(9).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 IsNot Nothing AndAlso DtTemp.Rows.Count > 0 Then
|
|
If DtTemp.MAX("SerieLote").ToString <> "" Then
|
|
LblSerieLote.Visible = True
|
|
TxtnSerieLote.Visible = True
|
|
TrSerieLote.Visible = True
|
|
TrSerieLote2.Visible = True
|
|
GvM.Columns(9).Visible = True
|
|
End If
|
|
|
|
If DtTemp.MAX("Lote").ToString <> "" Then
|
|
TxtnLote.Visible = True
|
|
TrLote.Visible = True
|
|
TrLote2.Visible = True
|
|
GvM.Columns(10).Visible = True
|
|
|
|
TxtnBatch.Visible = True
|
|
TrBatch.Visible = True
|
|
TrBatch2.Visible = True
|
|
GvM.Columns(11).Visible = True
|
|
End If
|
|
|
|
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
|
|
End If
|
|
|
|
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))
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then
|
|
e.Row.FCDropDownList("DdlSeccionAlmacen").DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa)
|
|
e.Row.FCDropDownList("DdlSeccionAlmacen").DataBind()
|
|
e.Row.FCDropDownList("DdlSeccionAlmacen").SelectedValueExist(e.Row.DBCampo("CveSeccionAlmacen"))
|
|
End If
|
|
|
|
|
|
'PERMISO SOLO PARA EDITAR OBSERVACIONES
|
|
If PermiteGuardarObservacionDetalle() Then
|
|
e.Row.FCTextBox("txtPrecio").Enabled = False
|
|
e.Row.FCTextBox("LblEditCodigo").Enabled = False
|
|
e.Row.FCTextBox("TxtSerieLote").Enabled = False
|
|
e.Row.FCTextBox("TxtLote").Enabled = False
|
|
e.Row.FCTextBox("TxtBatch").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("TxtSerieLote").Enabled = False
|
|
e.Row.FCTextBox("TxtLote").Enabled = False
|
|
e.Row.FCTextBox("TxtBatch").Enabled = False
|
|
e.Row.FCDropDownList("DdlSeccionAlmacen").Enabled = False
|
|
e.Row.FCTextBox("txtPrecio").Enabled = False
|
|
End If
|
|
e.Row.FCTextBox("TxtSerieLote").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
|
|
|
|
If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then
|
|
e.Row.FCLinkButton("imgE").Visible = False
|
|
e.Row.FCLinkButton("imgE").ToolTip = "Cuenta con sección almacen"
|
|
e.Row.FCLinkButton("lnkRemove").Visible = False
|
|
e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen"
|
|
e.Row.FCLinkButton("lnkDividir").Visible = False
|
|
e.Row.FCLinkButton("lnkDividir").ToolTip = "Cuenta con sección almacen"
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvM.RowEditing
|
|
GvM.EditIndex = e.NewEditIndex
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
End Sub
|
|
Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvM.RowCancelingEdit
|
|
GvM.EditIndex = -1
|
|
|
|
CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
|
|
End Sub
|
|
Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvM.RowUpdating
|
|
|
|
Dim Precio As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDouble
|
|
Dim No As Integer = GvM.Rows(e.RowIndex).DataKey("No").ToEntero
|
|
Dim serielote As String = GvM.Rows(e.RowIndex).FCTextBox("TxtSerieLote").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)("SerieLote") = serielote
|
|
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 "
|
|
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("Empresas\{0}\OI\Temp", UsuarioActual.CveEmpresa))
|
|
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("Empresas\{0}\OI", UsuarioActual.CveEmpresa))
|
|
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
|
|
|
|
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("Inv_CveMetodoInventario").ToString.ToEntero = 5 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
|
|
|
|
AddNew(Dr("CvePS").ToString.ToEntero, Dr("PSCodigo").ToString, Dr("CveUM").ToString.ToEntero, Dr("UnidadMedida").ToString, 1, Dr("CostoPromedio").ToString.ToDouble, "", "", "", "", "", "", "", -1, "")
|
|
|
|
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
|
|
|
|
AddNew(CvePSSerieLote, PSSerieLote, CveUMSerieLote, UMSerieLote, 1, 0, TxtSeriePS.Text.Trim, "", "", "", "", "", "", -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)
|
|
If UsuarioActual.CveEmpresa = 119 Then
|
|
dttA.Merge(GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1))
|
|
End If
|
|
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
|
|
|
|
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) 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
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
|
|
|
|
Dim DtCostos As DataTable = Nothing
|
|
Dim ValorInventario As Decimal = 0
|
|
Dim ValorInventarioME As Decimal = 0
|
|
|
|
ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa)
|
|
Dim CveVenta As Integer = ObjInventario.CveVenta
|
|
Dim MovAlmacen As Boolean = True
|
|
|
|
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & 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, TxtFolio.Text)
|
|
|
|
If tmpCostos.Rows.Count > 0 Then
|
|
Dim Concepto As String = $" {TxtObservaciones.Text}"
|
|
Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv_EntradaSalida", 74, DtCostos.SUM("Total"), DtCostos.SUM("Total"), 1, TxtFecha.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If HdnCveOrdenCompra.Value.ToEntero > 0 Then
|
|
MovAlmacen = False
|
|
For Each RowOC As DataRow In DTOCs.Rows
|
|
ValorInventario = DtCostos.SUM("Total", $"CveOrdenCompraDetalle = {RowOC("CveOrdenCompraDetalle")}").ToString.ToDecimal
|
|
ValorInventarioME = DtCostos.SUM("TotalExtranjero", $"CveOrdenCompraDetalle = {RowOC("CveOrdenCompraDetalle")}").ToString.ToDecimal
|
|
If ValorInventarioME > 0 Then
|
|
If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventarioME, Concepto, 228, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventarioME, ImporteME:=ValorInventarioME, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=LbTipoCambio.Text.ToDecimal) Then
|
|
ValorInventario = ValorInventario - ValorInventarioME
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorInventario, Concepto, 229, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveVenta:=CveVenta, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ValorInventario, ImporteME:=ValorInventarioME, CveOC:=HdnCveOrdenCompra.Value.ToEntero, CveOCDetalle:=RowOC("CveOrdenCompraDetalle").ToString.ToEntero, TipoCambio:=LbTipoCambio.Text.ToDecimal) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
If 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 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) 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
|
|
|
|
|
|
|
|
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) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If ErrorMovInv = False Then
|
|
ObjInventario.Commit()
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "CAMBIO INVENTARIO FISICO"
|
|
Protected Sub LnkCambioInventarioFisico_Click(sender As Object, e As EventArgs)
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivModalCambioFisico"))
|
|
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 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") = ""
|
|
|
|
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()
|
|
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
|
|
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)
|
|
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 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") = ""
|
|
|
|
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()
|
|
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 "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 tCveSubProyecto 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
|
|
|
|
'MOVIMIENTO DE ENTRADA
|
|
If DtMovimientosEntradaInvFisico.Rows.Count > 0 Then
|
|
Dim FolioEntrada As Integer = ObjInventario.GetFolioSiguiente(2, UsuarioActual.CveEmpresa)
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenInventarioFisico.SelectedValue.ToEntero, 2, 1, Fecha, FolioEntrada, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtIFDescripcion.Text.Trim)
|
|
|
|
End If
|
|
|
|
'MOVIMIENTO DE SALIDA
|
|
If DtMovimientosSalidaInvFisico.Rows.Count > 0 Then
|
|
Dim FolioSalida As Integer = ObjInventario.GetFolioSiguiente(3, UsuarioActual.CveEmpresa)
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenInventarioFisico.SelectedValue.ToEntero, 3, 1, Fecha, FolioSalida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveMovimientoRelacionado:=CveMovimientoEntrada, Observaciones:=TxtIFDescripcion.Text.Trim)
|
|
|
|
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) >= 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.ToDouble, -1) 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) 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
|
|
tCveSubProyecto = 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.SUM("Total", "").ToDecimal.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
|
|
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) 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) 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, ImporteMX:=ValorEntrada + ValorSalida) 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, "", 51, tConcepto, Fecha, tIdCtaGasto, -1, CveMovimientoAlmacen:=CveMovimientoSalida, CveClasificacion:=tCveClasificacion, CveSubProyecto:=tCveSubProyecto, ImporteMX:=ValorSalida + ValorEntrada) 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)
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
ErrorMovInv = True
|
|
Mensaje = "Ocurrió un error al validar los movimientos contables"
|
|
End If
|
|
End If
|
|
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
|
|
#End Region
|
|
|
|
#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 = AppDomain.CurrentDomain.BaseDirectory & "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"
|
|
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"
|
|
|
|
If Not ErrorArchivo Then
|
|
NumRow = 0
|
|
Dim RowNoEncontrados As String = ""
|
|
Dim NumAgregados As Integer = 0
|
|
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 CvePS As Integer = 0
|
|
Dim CveUM As Integer = 0
|
|
|
|
NumRow = NumRow + 1
|
|
|
|
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
|
|
'CveUM = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero
|
|
|
|
txtCantidad.Text = Cantidad.ToString
|
|
DdlProducto2.SelectedValue = CvePS.ToString
|
|
DdlProducto2.SelectedText = Codigo + " - " + ProductoServicio
|
|
txtPrecio.Text = PrecioUnitario.ToString
|
|
|
|
ElProductoChange()
|
|
|
|
AgregarPS()
|
|
txtPrecio.Text = ""
|
|
DdlUnidad.SelectedItem.Text = ""
|
|
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
|
|
End If
|
|
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.patch
|
|
Dim Tipo As String = If(file.Extencion.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
|
|
CvePS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", Opt & " = '" & Valor & "'").ToString.ToEntero
|
|
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 DdlSeccion.Visible Then DdlSeccion.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)
|
|
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
|
|
|
|
End Class
|