1369 lines
68 KiB
VB.net
1369 lines
68 KiB
VB.net
Option Strict On
|
|
Option Explicit On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
Partial Class Inventarios_RecepcionEntrega
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property DtDatos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtDatos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatos") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtDatosDetalle As DataTable
|
|
Get
|
|
Return CType(ViewState("DtDatosDetalle"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatosDetalle") = 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 CveConsecSerieLote As Integer
|
|
Get
|
|
Return CType(ViewState("CveConsecSerieLote"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveConsecSerieLote") = 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 CveUMSerieLote As Integer
|
|
Get
|
|
Return CType(ViewState("CveUMSerieLote"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUMSerieLote") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveVentaSurtir As Integer
|
|
Get
|
|
Return CType(ViewState("CveVentaSurtir"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveVentaSurtir") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveContrato As Integer
|
|
Get
|
|
Return CType(ViewState("CveContrato"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveContrato") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveAlmacenTraspasoOrigen As Integer
|
|
Get
|
|
Return CType(ViewState("CveAlmacenTraspasoOrigen"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAlmacenTraspasoOrigen") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveAlmacenTraspasoDestino As Integer
|
|
Get
|
|
Return CType(ViewState("CveAlmacenTraspasoDestino"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAlmacenTraspasoDestino") = value
|
|
End Set
|
|
End Property
|
|
Private Property TipoMovimiento As Integer
|
|
Get
|
|
Return CType(ViewState("TipoMovimiento"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoMovimiento") = value
|
|
End Set
|
|
End Property
|
|
Private Property TipoDocto As String
|
|
Get
|
|
Return CType(ViewState("TipoDocto"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("TipoDocto") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtExistencias As DataTable
|
|
Get
|
|
Return CType(ViewState("DtExistencias"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtExistencias") = value
|
|
End Set
|
|
End Property
|
|
Private Property RowIndexCantidadEspecial As Integer
|
|
Get
|
|
Return CType(ViewState("RowIndexCantidadEspecial"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("RowIndexCantidadEspecial") = value
|
|
End Set
|
|
End Property
|
|
Private Property CantidadEspecialTemp As Decimal
|
|
Get
|
|
Return CType(ViewState("CantidadEspecialTemp"), Decimal)
|
|
End Get
|
|
Set(value As Decimal)
|
|
ViewState("CantidadEspecialTemp") = value
|
|
End Set
|
|
End Property
|
|
Private Property EsDevolucionVenta As Integer
|
|
Get
|
|
Return CType(ViewState("EsDevolucionVenta"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("EsDevolucionVenta") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveVendedor As Integer
|
|
Get
|
|
Return CType(ViewState("CveVendedor"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveVendedor") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveCliente As Integer
|
|
Get
|
|
Return CType(ViewState("CveCliente"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCliente") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveMovimiento As Integer
|
|
Get
|
|
Return CType(ViewState("CveMovimiento"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMovimiento") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
InicializaValores()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " Inicializa Valores "
|
|
Private Sub InicializaValores()
|
|
CveVendedor = -1
|
|
CveCliente = -1
|
|
|
|
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
DdlClientes.DataBind()
|
|
DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
|
'DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
TxtFechaPendientes.Text = Now.ToShortDateString
|
|
TxtFechaCaducidad.Text = Now.ToShortDateString
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
|
|
DdlSucursal.DataSource = GlobalDTSucursales.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
DdlSucursal.DataBind()
|
|
DdlSucursal.SelectedValueExist(UsuarioActual.CveSucursal.ToString)
|
|
If UsuarioActual.TienePermisoProceso(152) Then DdlSucursal.Enabled = False
|
|
|
|
CreaDtDetalle()
|
|
CargaPendientes()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA PENDIENTES POR SURTIR "
|
|
Protected Sub DdlCliente_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaFolios()
|
|
End Sub
|
|
Private Sub CargaFolios()
|
|
Dim ObjInventarios As New ClsInventarios
|
|
|
|
DdlFolio.Items.Clear()
|
|
|
|
If DdlClientes.SelectedValue.ToEntero > 0 Then
|
|
If ObjInventarios.VentasPendientesAlmacenGet(DdlClientes.SelectedValue.ToEntero, MinFecha, DdlSucursal.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
DdlFolio.DataSource = ObjInventarios.DtResultados
|
|
Else
|
|
Alert("Ocurrió un error al obtener las Compras pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
End If
|
|
|
|
ObjInventarios.Dispose()
|
|
|
|
DdlFolio.DataBind()
|
|
DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
UpFiltros.Update()
|
|
End Sub
|
|
Protected Sub TimmerRefresh_Tick(sender As Object, e As EventArgs)
|
|
CargaPendientes()
|
|
End Sub
|
|
Protected Sub BtnConsultarPendientes_Click(sender As Object, e As EventArgs)
|
|
CargaPendientes()
|
|
End Sub
|
|
Private Sub CargaPendientes()
|
|
Dim ObjInventarios As New ClsInventarios
|
|
Dim DtPendientes As New DataTable
|
|
|
|
If ObjInventarios.VentasPendientesAlmacenGet(-1, TxtFechaPendientes.Text.ToDate, DdlSucursal.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
DtPendientes = ObjInventarios.DtResultados
|
|
'If DtPendientes.Rows.Count > 0 Then
|
|
' TipoMovimiento = If(DtPendientes.Rows(0)("TipoDocto").ToString.Contiene({"Rem", "Ing"}), 1, 2)
|
|
'End If
|
|
Else
|
|
DtPendientes = Nothing
|
|
Alert("Ocurrió un error al obtener las Compras pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjInventarios.Dispose()
|
|
|
|
If DtPendientes IsNot Nothing Then
|
|
GVPendientes.DataSource = DtPendientes
|
|
End If
|
|
|
|
LtActualizado.Text = String.Format("Actualizado: {0}", Now.ToString("H:mm"))
|
|
|
|
GVPendientes.DataBind()
|
|
UpPendientes.Update()
|
|
End Sub
|
|
Protected Sub GVPendientes_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVPendientes.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
e.Row.FCLinkButton("BtnSurtir").CommandArgument = e.Row.DBCampo("CveVenta")
|
|
|
|
If e.Row.DBCampo("TipoDocto").ToString.Contiene({"Rem", "Ing", "Ped"}) And e.Row.DBCampo("EsDevolucionVenta").ToString.ToEntero = 0 Then
|
|
e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary "
|
|
e.Row.FCLinkButton("BtnSurtir").Text = " Surtir <i class='fa fa-arrow-right' ></i>"
|
|
Else
|
|
e.Row.FCLinkButton("BtnSurtir").CssClass = "btn yellow-gold "
|
|
e.Row.FCLinkButton("BtnSurtir").Text = "<i class='fa fa-arrow-left' > Recibir</i>"
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA VENTA POR SURTIR "
|
|
Protected Sub BtnSurtir_Click(sender As Object, e As EventArgs)
|
|
If CType(sender, LinkButton).CommandArgument.ToEntero > 0 Then
|
|
CargaVentaPorSurtir(CType(sender, LinkButton).CommandArgument.ToEntero)
|
|
TimmerRefresh.Enabled = False
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnBuscar_Click(sender As Object, e As EventArgs)
|
|
CargaVentaPorSurtir(DdlFolio.SelectedValue.ToEntero)
|
|
End Sub
|
|
Private Sub CargaVentaPorSurtir(CveVenta As Integer)
|
|
LbSurtida.Visible = False
|
|
CveContrato = -1
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
If ObjInventario.EntregaAlmacenGet(CveVenta) Then
|
|
If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
|
|
|
|
DtDatos = ObjInventario.DtResultados
|
|
DtDatos.Columns.Add("Consec", GetType(Integer))
|
|
DtDatos.Columns.Add("CantidadGV", GetType(Double))
|
|
DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
|
|
Dim Index = 1
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
Dr("Consec") = Index
|
|
Index += 1
|
|
Next
|
|
|
|
DtDatosDetalle = Nothing
|
|
CreaDtDetalle()
|
|
|
|
If DtDatos.Rows(0) IsNot Nothing Then
|
|
EsDevolucionVenta = DtDatos.Rows(0)("EsDevolucionVenta").ToString.ToEntero
|
|
TipoMovimiento = If(DtDatos.Rows(0)("TipoDocto").ToString.Contiene({"Rem", "Ing", "Ped"}) And EsDevolucionVenta = 0, 1, 2)
|
|
TipoDocto = DtDatos.Rows(0)("TipoDocto").ToString
|
|
LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString
|
|
LbFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
|
|
LbOberservaciones.Text = DtDatos.Rows(0)("Observaciones").ToString
|
|
CveVentaSurtir = CveVenta
|
|
CveAlmacenTraspasoDestino = DtDatos.Rows(0)(If(EsDevolucionVenta = 1, "CveAlmacenTraspasoOrigen", "CveAlmacenTraspasoDestino")).ToString.ToEntero
|
|
CveAlmacenTraspasoOrigen = DtDatos.Rows(0)(If(EsDevolucionVenta = 1, "CveAlmacenTraspasoDestino", "CveAlmacenTraspasoOrigen")).ToString.ToEntero
|
|
CveContrato = DtDatos.Rows(0)("CveContrato").ToString.ToEntero
|
|
CveVendedor = DtDatos.Rows(0)("CveVendedor").ToString.ToEntero
|
|
CveCliente = DtDatos.Rows(0)("CveCliente").ToString.ToEntero
|
|
|
|
|
|
If DtDatos.SUM("CantidadS") <= 0 Then
|
|
GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario gvEscondeColumna"
|
|
Else
|
|
GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario"
|
|
End If
|
|
|
|
If CveAlmacenTraspasoDestino > 0 Then
|
|
DivTipoCambioAdvertencia.Visible = True
|
|
LtTipoCambioAdvertencia.Text = $"Los productos seran Trasladados al Almacen: <b>{GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoDestino}")}</b>"
|
|
Else
|
|
DivTipoCambioAdvertencia.Visible = False
|
|
End If
|
|
|
|
DdlAlmacen.Items.Clear()
|
|
If CveAlmacenTraspasoOrigen > 0 Then
|
|
DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString))
|
|
Else
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (1,2)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
End If
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
|
If CveAlmacenTraspasoOrigen > 0 Then
|
|
DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
|
|
End If
|
|
|
|
|
|
TxtFecha.Text = DtDatos.Rows(0)("Fecha").ToString
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
|
|
DivCodigoSeriePS.Visible = True
|
|
Else
|
|
DivCodigoSeriePS.Visible = False
|
|
End If
|
|
|
|
If TipoMovimiento = 2 Then
|
|
Dim Filtro = If(ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString.Contiene({"Ing", "Dev"}), "CveConcepto = 3", "CveConcepto = 9")
|
|
If ObjInventario.GetInv_Mov(ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
DtExistencias = ObjInventario.DtResultados.FiltraParametros($"CvePS Is Not NULL AND {Filtro}")
|
|
|
|
If Not DtExistencias.Rows.Count > 0 Then
|
|
Alert("La Venta original de la Devolución no tiene salida de Almacén.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
Else
|
|
Alert("Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
End If
|
|
|
|
|
|
Else
|
|
Alert("No se encontraron productos pendientes por surtir. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
Else
|
|
DtDatos = Nothing
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
UpGenerales.Update()
|
|
CargaGvDatos()
|
|
End Sub
|
|
Private Sub CargaGvDatos()
|
|
If DtDatos IsNot Nothing Then
|
|
GvDatos.DataSource = DtDatos
|
|
End If
|
|
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
UpVenta.Update()
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DBCampo("Inv_CveMetodoInventario") = "5" Then
|
|
e.Row.FCButton("BtnSerieLote").Visible = True
|
|
e.Row.FCButton("BtnSerieLote").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec"))
|
|
e.Row.FCTextBox("TbCantidadF").Enabled = False
|
|
e.Row.FCCheckBox("cbInv").Enabled = False
|
|
Dim Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DBCampo("Consec"))).Rows.Count
|
|
e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString
|
|
'e.Row.FCTextBox("TbCantidadF").Text = "0"
|
|
Else
|
|
e.Row.FCButton("BtnSerieLote").Visible = False
|
|
e.Row.FCTextBox("TbCantidadF").Enabled = True
|
|
e.Row.FCTextBox("TbCantidadF").Attributes.Add("onblur", String.Format("ValidarCantidad(this, {0})", e.Row.DBCampo("CantidadF")))
|
|
End If
|
|
|
|
|
|
'FUNCIONALIDAD PISTOLA DE CODIGOS
|
|
If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" Then
|
|
e.Row.FCTextBox("TbCantidadF").Enabled = False
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " AGREGA POR SERIE/LOTE "
|
|
Private Sub CreaDtDetalle()
|
|
If DtDatosDetalle Is Nothing Then
|
|
DtDatosDetalle = New DataTable
|
|
DtDatosDetalle.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
DtDatosDetalle.Columns.Add("Consec", GetType(Integer))
|
|
DtDatosDetalle.Columns.Add("ConsecId", GetType(Integer))
|
|
DtDatosDetalle.Columns.Add("CvePS", GetType(Integer))
|
|
DtDatosDetalle.Columns.Add("PS", GetType(String))
|
|
DtDatosDetalle.Columns.Add("CveUM", GetType(Integer))
|
|
DtDatosDetalle.Columns.Add("SerieLote", GetType(String))
|
|
DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(String))
|
|
DtDatosDetalle.Columns.Add("FueTraspaso", GetType(Integer))
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaSerie()
|
|
|
|
'RegistraScript("document.getElementById(""TxtSerieLote"").focus();")
|
|
|
|
Dim AplicaCaducidad = False
|
|
If GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS = {0}", CvePSSerieLote)).Rows(0) IsNot Nothing Then
|
|
AplicaCaducidad = If(GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS = {0}", CvePSSerieLote)).Rows(0)("AplicaCaducidad").ToString = "True", True, False)
|
|
End If
|
|
|
|
If AplicaCaducidad Then
|
|
GvSerie.Columns(1).Visible = True
|
|
TdCaducidad1.Visible = True
|
|
TdCaducidad2.Visible = True
|
|
Else
|
|
GvSerie.Columns(1).Visible = False
|
|
TdCaducidad1.Visible = False
|
|
TdCaducidad2.Visible = False
|
|
End If
|
|
|
|
GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote), "Consec DESC")
|
|
GvSerie.DataBind()
|
|
|
|
'VALIDA QUE SIGA AGREGANDO
|
|
If DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote)).Rows.Count = LbCantidad.Text.ToEntero Then
|
|
BtnAgregarPS.Enabled = False
|
|
Else
|
|
BtnAgregarPS.Enabled = True
|
|
End If
|
|
|
|
'SERIE LOTE RECOMENDADO
|
|
Dim DtSerieLote As New DataTable
|
|
If TipoMovimiento = 1 Then
|
|
Dim ObjInventarios As New ClsInventarios
|
|
If ObjInventarios.SerieLoteRecomendadoGet(CvePSSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) Then
|
|
DtSerieLote = ObjInventarios.DtResultados
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
Else
|
|
DtSerieLote = DtExistencias.FiltraParametros("SerieLote <> ''")
|
|
End If
|
|
|
|
Dim DrsRemove As New List(Of DataRow)
|
|
|
|
If DtSerieLote.Rows.Count > 0 Then
|
|
'CALCULA YA COMPLETADOS
|
|
DtSerieLote.Columns.Add("CantidadSeleccionada", GetType(Integer))
|
|
For Each dr As DataRow In DtSerieLote.Rows
|
|
dr("CantidadSeleccionada") = DtDatosDetalle.FiltraParametros(String.Format("Consec = {0} AND SerieLote = '{1}'", CveConsecSerieLote, dr("SerieLote"))).Rows.Count
|
|
If dr("CantidadSeleccionada").ToString.ToDecimal = dr("Existencia").ToString.ToDecimal Then
|
|
DrsRemove.Add(dr)
|
|
End If
|
|
Next
|
|
|
|
'ELIMINA YA COMPLETADOS EN PAGINA
|
|
For Each dr As DataRow In DrsRemove
|
|
DtSerieLote.Rows.Remove(dr)
|
|
Next
|
|
|
|
If DtSerieLote.Rows.Count > 0 Then
|
|
Dim Mensaje As New StringBuilder
|
|
Mensaje.AppendFormat("Serie / Lote Recomendado: <b>{0}</b>", DtSerieLote.Rows(0)("SerieLote"))
|
|
If AplicaCaducidad Then Mensaje.AppendFormat(", Caducicdad: <b>{0}</b>", DtSerieLote.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
|
|
LbSerieLoteRecomendado.Text = Mensaje.ToString 'String.Format("Serie / Lote Recomendado: <b>{0}</b>, Caducicdad: <b>{1}</b>", ObjInventarios.DtResultados.Rows(0)("SerieLote"), ObjInventarios.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
|
|
Else
|
|
LbSerieLoteRecomendado.Text = "No se encontro ningun Serie/Lote."
|
|
End If
|
|
Else
|
|
LbSerieLoteRecomendado.Text = "No se encontro ningun Serie/Lote."
|
|
End If
|
|
|
|
|
|
|
|
'SI TIENE SALIDA POR SERIE LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD
|
|
Dim Contador = 0
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then
|
|
Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count
|
|
Gvr.FCCheckBox("cbInv").Enabled = False
|
|
Gvr.FCCheckBox("cbInv").Checked = True
|
|
Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString
|
|
End If
|
|
Next
|
|
|
|
UpDatos.Update()
|
|
End Sub
|
|
Protected Sub BtnSerieLote_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c)
|
|
|
|
LbProducto.Text = Argumentos(2)
|
|
LbCantidad.Text = Argumentos(3)
|
|
|
|
CveConsecSerieLote = Argumentos(4).ToEntero
|
|
CvePSSerieLote = Argumentos(0).ToEntero
|
|
PSSerieLote = Argumentos(2).ToString
|
|
CveUMSerieLote = Argumentos(1).ToEntero
|
|
|
|
DivSerie.Visible = True
|
|
RegistraScript(String.Format("$('#{0}').modal('show')", DivSerie.ClientID))
|
|
CargaSerie()
|
|
UpSerie.Update()
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs)
|
|
AgregaSerieLote(TxtSerieLote.Text.Trim, 1)
|
|
End Sub
|
|
Private Sub AgregaSerieLote(SerieLote As String, Tipo As Integer)
|
|
|
|
If SerieLote.Trim = "" Then
|
|
Alert("El campo Serie es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If DtDatosDetalle.FiltraParametros($"CvePS = {CvePSSerieLote} AND SerieLote = '{SerieLote}'").Rows.Count > 0 Then
|
|
Alert("La SerieLote indicada ya esta registrada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
TxtSerieLote.Text = ""
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim AplicaCaducidad = False
|
|
If GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS = {0}", CvePSSerieLote)).Rows(0) IsNot Nothing Then
|
|
AplicaCaducidad = If(GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS = {0}", CvePSSerieLote)).Rows(0)("AplicaCaducidad").ToString = "True", True, False)
|
|
End If
|
|
|
|
|
|
'Valida Existencia
|
|
If TipoMovimiento = 1 Then
|
|
Dim ObjInventarios As New ClsInventarios
|
|
Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerieLote, CveUMSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=SerieLote, CveVendedor:=CveVendedor, CveCliente:=CveCliente)
|
|
If Existencia < 1 Then
|
|
Alert($"No hay existencia suficiente del producto <b>""{PSSerieLote}""</b> con la SerieLote definida <b>""{SerieLote}""</b>. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia, If(Tipo = 2, "window.setTimeout(Focus,200);", ""))
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ObjInventarios.Dispose()
|
|
If Tipo = 1 Then
|
|
DivSerie.Visible = True
|
|
RegistraScript(String.Format("$('#{0}').modal('show')", DivSerie.ClientID))
|
|
End If
|
|
Exit Sub
|
|
End If
|
|
Else
|
|
If DtExistencias IsNot Nothing Then
|
|
Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {CvePSSerieLote} AND CveUM = {CveUMSerieLote} AND SerieLote = '{SerieLote}'")
|
|
If Existencia < 1 Then
|
|
Alert($"No hay existencia suficiente del producto <b>""{PSSerieLote}""</b> con la SerieLote definida <b>""{SerieLote}""</b>. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia, If(Tipo = 2, "window.setTimeout(Focus,200);", ""))
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
If Tipo = 1 Then
|
|
DivSerie.Visible = True
|
|
RegistraScript(String.Format("$('#{0}').modal('show')", DivSerie.ClientID))
|
|
End If
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
Dim Row = DtDatosDetalle.NewRow
|
|
|
|
Row("ConsecId") = CveConsecSerieLote
|
|
Row("Consec") = DtDatosDetalle.Rows.Count + 1
|
|
Row("PS") = PSSerieLote
|
|
Row("CvePS") = CvePSSerieLote
|
|
Row("CveUM") = CveUMSerieLote
|
|
Row("SerieLote") = SerieLote
|
|
Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidad.Text, MinFecha.ToShortDateString)
|
|
|
|
DtDatosDetalle.Rows.Add(Row)
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
|
|
If Tipo = 1 Then
|
|
TxtSerieLote.Text = ""
|
|
TxtFechaCaducidad.Text = Now.ToShortDateString
|
|
End If
|
|
|
|
CargaSerie()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvSerie_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSerie.RowDeleting
|
|
|
|
Dim keySerieLote As String = e.Keys("SerieLote").ToString
|
|
Try
|
|
For Each dr As DataRow In DtDatosDetalle.Rows
|
|
If dr("SerieLote").ToString = keySerieLote Then
|
|
dr.Delete()
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
DtDatosDetalle.AcceptChanges()
|
|
CargaSerie()
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " AGREGA CON TXT | CODIGO - SERIE "
|
|
Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs)
|
|
|
|
If TxtCodigoPS.Text = "" Then
|
|
Exit Sub
|
|
End If
|
|
|
|
TdSeriePS.Visible = False
|
|
Dim Existe = False
|
|
Dim PSTemp = ""
|
|
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.DataKey("CodigoBarras") = TxtCodigoPS.Text.Trim Then
|
|
Dim TxtCantidad = GvDatos.Rows(Gvr.RowIndex).FCTextBox("TbCantidadF")
|
|
If Gvr.DataKey("CantidadF").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then
|
|
|
|
|
|
|
|
''VALIDA EXISTENCIA
|
|
If TipoMovimiento = 1 Then
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim Existencia = ObjInventario.GetExistenciasPS(Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveCliente:=CveCliente)
|
|
ObjInventario.Dispose()
|
|
If Not Existencia >= TxtCantidad.Text.ToDecimal + 1 Then
|
|
TxtCodigoPS.Text = ""
|
|
Alert($"No hay existencias suficientes del producto: <b>""{Gvr.DataKey("PS")}""</b>. Solo hay disponibles <b>{Existencia.FormatoNumero}</b> en Almacen. Por favor Verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
Else
|
|
If DtExistencias IsNot Nothing Then
|
|
Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {Gvr.DataKey("CvePS")} AND CveUM = {Gvr.DataKey("CveUM").ToString.ToEntero}")
|
|
If Not Existencia >= TxtCantidad.Text.ToDecimal + 1 Then
|
|
TxtCodigoPS.Text = ""
|
|
Alert($"No hay existencias suficientes del producto: <b>""{Gvr.DataKey("PS")}""</b>. Solo hay disponibles <b>{Existencia.FormatoNumero}</b> en Almacen. Por favor Verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If Gvr.DataKey("AplicaSerieLote") = "True" Then
|
|
TdSeriePS.Visible = True
|
|
TxtSeriePS.Focus()
|
|
|
|
CveConsecSerieLote = Gvr.DataKey("Consec").ToString.ToEntero
|
|
PSSerieLote = Gvr.DataKey("PS").ToString
|
|
CvePSSerieLote = Gvr.DataKey("CvePS").ToEntero
|
|
CveUMSerieLote = Gvr.DataKey("CveUM").ToEntero
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
Dim CantidadEspecial = If(Gvr.DataKey("CveClasificacion").ToString.ToEntero = 17601, True, False)
|
|
|
|
If CantidadEspecial Then
|
|
RegistraScript("CantidadEspecial();window.setTimeout(FocusCantidadEspecial,200);")
|
|
LtlProductoCantidad.Text = $"{Gvr.DataKey("Codigo")}"
|
|
RowIndexCantidadEspecial = Gvr.RowIndex
|
|
CantidadEspecialTemp = Gvr.DataKey("CantidadF").ToDecimal
|
|
TxtCodigoPS.Text = ""
|
|
Exit Sub
|
|
Else
|
|
TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero
|
|
TxtCodigoPS.Text = ""
|
|
UpDatos.Update()
|
|
Exit Sub
|
|
End If
|
|
|
|
VerificaVentaSurtida()
|
|
Exit Sub
|
|
End If
|
|
|
|
Existe = True
|
|
PSTemp = Gvr.DataKey("PS").ToString
|
|
'Alert($"Ya se ha cargado la totalidad del Producto ""<b>{Gvr.DataKey("PS").ToString}</b>"" con el Codigo ""<b>{TxtCodigoPS.Text}</b>"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
|
|
'VerificaVentaSurtida()
|
|
'Exit Sub
|
|
End If
|
|
Next
|
|
|
|
VerificaVentaSurtida()
|
|
If Existe Then
|
|
Alert($"Ya se ha cargado la totalidad del Producto ""<b>{PSTemp}</b>"" con el Codigo ""<b>{TxtCodigoPS.Text}</b>"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
|
|
Else
|
|
Alert($"No se ha encontrado un producto para surtir con el Codigo ""<b>{TxtCodigoPS.Text}</b>"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
|
|
End If
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
TxtCodigoPS.Text = ""
|
|
|
|
End Sub
|
|
Private Sub VerificaVentaSurtida()
|
|
Dim Surtida = True
|
|
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.DataKey("CantidadF").ToDecimal <> Gvr.FCTextBox("TbCantidadF").Text.ToDecimal Then
|
|
Surtida = False
|
|
Exit Sub
|
|
End If
|
|
Next
|
|
|
|
If Surtida Then
|
|
LbSurtida.Visible = True
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs)
|
|
AgregaSerieLote(TxtSeriePS.Text.Trim, 2)
|
|
|
|
TdSeriePS.Visible = False
|
|
TxtSeriePS.Text = ""
|
|
TxtCodigoPS.Text = ""
|
|
TxtCodigoPS.Focus()
|
|
VerificaVentaSurtida()
|
|
|
|
End Sub
|
|
Protected Sub BtnGuardarCantidadEspecial_Click(sender As Object, e As EventArgs)
|
|
AgregaCantidadEspecial()
|
|
End Sub
|
|
Private Sub AgregaCantidadEspecial()
|
|
Dim TxtCantidad = GvDatos.Rows(RowIndexCantidadEspecial).FCTextBox("TbCantidadF")
|
|
If CantidadEspecialTemp - TxtCantidadEspecialDiv.Text.ToDecimal - TxtCantidad.Text.ToDecimal >= 0 Then
|
|
TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + TxtCantidadEspecialDiv.Text.ToDecimal).ToString.FormatoNumero
|
|
'RegistraScript("$('#ModalCantidad').modal('hide');")
|
|
RegistraScript("$('#DivCantidadEspecial').hide(200);")
|
|
UpDatos.Update()
|
|
TxtCodigoPS.Focus()
|
|
Else
|
|
Alert("La cantidad excede la pendiente por surtir. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
|
|
TxtCantidadEspecialDiv.Text = "1"
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " GUARDAR "
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
|
|
|
'VALIDA CANTIDAD DE SALIDA
|
|
Dim Cantidad = 0.0D
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
|
|
Cantidad = Gvr.FCTextBox("TbCantidadF").Text.ToDecimal
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If Not Cantidad > 0 Then
|
|
Alert("No se detecto ningun movimiento por hacer. Por favor verifique e intente nuevamente.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'PROCESO , si tiene proceso "X" no lo valida
|
|
If Not UsuarioActual.TienePermisoProceso(176) Then
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.DataKey("CantidadF").ToDecimal <> Gvr.FCTextBox("TbCantidadF").Text.ToDecimal Then
|
|
Alert("En la factura no se han especificado todos los productos a entregar, favor de especificarlos para poder dar salida.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If EsDevolucionVenta = 1 Or TipoDocto.Contiene({"Ped"}) Then
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Not Gvr.FCCheckBox("cbInv").Checked Or (Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadC").ToString.ToDecimal) Then
|
|
Alert("Es necesario surtir todos los productos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL())
|
|
Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL())
|
|
Dim CveMovimiento As Integer
|
|
Dim Folio As Integer
|
|
Dim ErrorMovInv As Boolean
|
|
Dim DtDetalle As New DataTable
|
|
Dim TextoError = ""
|
|
|
|
|
|
'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH
|
|
Dim Index = 0
|
|
For Each gvr As GridViewRow In GvDatos.Rows
|
|
If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then
|
|
DtDatos.Rows(Index)("CantidadGV") = gvr.FCTextBox("TbCantidadF").Text.ToDouble
|
|
End If
|
|
Index += 1
|
|
Next
|
|
|
|
|
|
'VALIDA EXISTENCIA 2
|
|
If TipoMovimiento = 1 Then
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
If Dr("CantidadGV").ToString.ToDouble > 0 Then
|
|
If Dr("AplicaSerieLote").ToString = "True" Then
|
|
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
|
|
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
If Not ObjInventario.GetExistenciasPS(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=Dr1("SerieLote").ToString, CveVendedor:=CveVendedor, CveCliente:=CveCliente) >= 1 Then
|
|
TextoError += String.Format("No hay existencias suficientes del producto: {0} <br/>", Dr("PS"))
|
|
End If
|
|
Next
|
|
Else
|
|
If Not ObjInventario.GetExistenciasPS(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveCliente:=CveCliente) >= Dr("CantidadGV").ToString.ToDecimal Then
|
|
TextoError += String.Format("No hay existencias suficientes del producto: {0} <br/>", Dr("PS"))
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
If TextoError <> "" Then
|
|
Alert(TextoError, TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ObjInventario.RollBack()
|
|
ObjInventario.Dispose()
|
|
Exit Sub
|
|
End If
|
|
Else
|
|
If DtExistencias IsNot Nothing Then
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
If Dr("CantidadGV").ToString.ToDouble > 0 Then
|
|
|
|
If Dr("AplicaSerieLote").ToString = "True" Then
|
|
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
|
|
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
If Not DtExistencias.SUM("Cantidad", $"CvePS = {Dr1("CvePS").ToString.ToEntero} AND CveUM = {Dr1("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'") >= 1 Then
|
|
TextoError += String.Format("<b> - {0}</b> <br/>", Dr1("PS"))
|
|
End If
|
|
Next
|
|
Else
|
|
If Not DtExistencias.SUM("Cantidad", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}") >= Dr("CantidadGV").ToString.ToDouble Then
|
|
TextoError += String.Format("<b> - {0}</b> <br/>", Dr("PS"))
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
If TextoError <> "" Then
|
|
Alert($" Lo(s) siguiente(s) Productos <b>no tienen</b> existencia suficiente:<br/><br/> {TextoError}", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ObjInventario.RollBack()
|
|
ObjInventario.Dispose()
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
'' COMIENZA: APARTADOS
|
|
Dim DtTraspasos As New DataTable
|
|
DtTraspasos.Columns.Add("CveAlmacen", GetType(Integer))
|
|
DtTraspasos.Columns.Add("Almacen", GetType(String))
|
|
DtTraspasos.Columns.Add("CveMovimientoSalida", GetType(Integer))
|
|
DtTraspasos.Columns.Add("FolioSalida", GetType(Integer))
|
|
DtTraspasos.Columns.Add("CveMovimientoEntrada", GetType(Integer))
|
|
DtTraspasos.Columns.Add("FolioEntrada", GetType(Integer))
|
|
|
|
Dim DtMovtosDetalle As New DataTable
|
|
DtMovtosDetalle.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
DtMovtosDetalle.Columns.Add("CveMovimientoDetalle1", GetType(Integer))
|
|
DtMovtosDetalle.Columns.Add("CveMovimientoDetalle2", GetType(Integer))
|
|
DtMovtosDetalle.Columns.Add("CveMovimientoDetalle3", GetType(Integer))
|
|
|
|
Dim CveMovimientoSalida = -1, FolioSalida = -1, CveMovimientoEntrada = -1, CveMovimientoEntradaApartado = -1, FolioEntrada = -1
|
|
Dim CantidadPendiente = 0.0
|
|
Dim CantidadSaldo = 0.0
|
|
|
|
|
|
If TipoMovimiento = 1 Then ' SI ES DEVOLUCION NO APLICA APARTADO
|
|
' SALIDA POR TRASPASO DE LOS ALMACENES DE APARTADO
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
If Dr("CantidadGV").ToString.ToDouble > 0 Then
|
|
|
|
If Dr("AplicaSerieLote").ToString = "True" Then
|
|
|
|
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
|
|
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=Dr1("SerieLote").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveCliente:=CveCliente) Then
|
|
For Each Dr2 As DataRow In ObjInventario.DtResultados.Rows
|
|
|
|
'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
|
|
CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero
|
|
|
|
If Not CveMovimientoSalida > 0 Then
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero)
|
|
FolioSalida = ObjInventario.Folio
|
|
|
|
If Not CveMovimientoSalida > 0 Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
|
|
Dim DrMovto = DtTraspasos.NewRow
|
|
DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero
|
|
DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero
|
|
DrMovto("CveMovimientoSalida") = CveMovimientoSalida
|
|
DrMovto("FolioSalida") = FolioSalida
|
|
DtTraspasos.Rows.Add(DrMovto)
|
|
End If
|
|
|
|
|
|
CantidadPendiente = 1
|
|
|
|
If ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, SerieLote:=Dr1("SerieLote").ToString) Then
|
|
Dim Row = DtMovtosDetalle.NewRow
|
|
Row("CveVentaDetalle") = Dr("CveVentaDetalle").ToString.ToEntero
|
|
Row("CveMovimientoDetalle1") = ObjInventario.CveMovimientoDetalle
|
|
DtMovtosDetalle.Rows.Add(Row)
|
|
Else
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
|
|
DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1
|
|
DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle")
|
|
Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDouble + CantidadPendiente
|
|
Exit For
|
|
Next
|
|
End If
|
|
Next
|
|
|
|
Else
|
|
|
|
If ObjInventario.GetExistenciasProducto(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveCliente:=CveCliente) Then
|
|
|
|
CantidadSaldo = Dr("CantidadGV").ToString.ToDouble
|
|
|
|
For Each Dr1 As DataRow In ObjInventario.DtResultados.Rows
|
|
|
|
'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO
|
|
CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr1("CveAlmacen")}").ToEntero
|
|
|
|
If Not CveMovimientoSalida > 0 Then
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero)
|
|
FolioSalida = ObjInventario.Folio
|
|
|
|
If Not CveMovimientoSalida > 0 Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
|
|
Dim DrMovto = DtTraspasos.NewRow
|
|
DrMovto("CveAlmacen") = Dr1("CveAlmacen").ToString.ToEntero
|
|
DrMovto("CveMovimientoSalida") = CveMovimientoSalida
|
|
DrMovto("FolioSalida") = FolioSalida
|
|
DtTraspasos.Rows.Add(DrMovto)
|
|
End If
|
|
|
|
|
|
CantidadPendiente = If(Dr1("Existencia").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("Existencia").ToString.ToDecimal)
|
|
|
|
If ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
|
|
Dim Row = DtMovtosDetalle.NewRow
|
|
Row("CveVentaDetalle") = Dr("CveVentaDetalle").ToString.ToEntero
|
|
Row("CveMovimientoDetalle1") = ObjInventario.CveMovimientoDetalle
|
|
DtMovtosDetalle.Rows.Add(Row)
|
|
Else
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
|
|
CantidadSaldo -= CantidadPendiente
|
|
Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDouble + CantidadPendiente
|
|
If CantidadSaldo <= 0 Then Exit For
|
|
Next
|
|
|
|
If ErrorMovInv Then Exit For
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
'ENTRADA POR TRASPASO AL ALMACEN GENERAL
|
|
If Not ErrorMovInv Then
|
|
For Each Dr1 As DataRow In DtTraspasos.Rows
|
|
CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero
|
|
|
|
CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente)
|
|
FolioEntrada = ObjInventario.Folio
|
|
|
|
If Not CveMovimientoEntradaApartado > 0 Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
|
|
Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado
|
|
Dr1("FolioEntrada") = FolioEntrada
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
If ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero) Then
|
|
DtMovtosDetalle.Select($"CveMovimientoDetalle1 = {Dr("CveMovimientoDetalle")}")(0)("CveMovimientoDetalle2") = ObjInventario.CveMovimientoDetalle
|
|
Else
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If ErrorMovInv Then Exit For
|
|
|
|
Next
|
|
End If
|
|
End If
|
|
'' TERMINA: APARTADOS
|
|
|
|
|
|
|
|
|
|
Dim ConceptoMovimiento = 3
|
|
ConceptoMovimiento = If(TipoMovimiento = 1, ConceptoMovimiento, 18)
|
|
ConceptoMovimiento = If(CveAlmacenTraspasoDestino > 0, 8, ConceptoMovimiento)
|
|
|
|
CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveAlmacenDestino:=CveAlmacenTraspasoDestino)
|
|
Folio = ObjInventario.Folio
|
|
|
|
If CveMovimiento > 0 Then
|
|
|
|
|
|
'SACA LO DE TRASPASOS - APARTADO
|
|
For Each Dr1 As DataRow In DtTraspasos.Rows
|
|
CveMovimientoSalida = Dr1("CveMovimientoEntrada").ToString.ToEntero
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
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, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=DtMovtosDetalle.Select($"CveMovimientoDetalle2 = {Dr("CveMovimientoDetalle")}")(0)("CveVentaDetalle").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
If ErrorMovInv Then Exit For
|
|
Next
|
|
|
|
|
|
CantidadPendiente = 0.0
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
CantidadPendiente = Dr("CantidadGV").ToString.ToDouble - Dr("CantidadTraspaso").ToString.ToDouble
|
|
If CantidadPendiente > 0 Then
|
|
Dim PU = 0.0
|
|
|
|
'SI FUE POR SERIE LOTE
|
|
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
|
|
If DtDetalle.Rows.Count > 0 Then
|
|
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
If TipoMovimiento = 2 Then
|
|
PU = DtExistencias.FiltroPrimero($"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'")("PU").ToString.ToDouble
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
Next
|
|
Else
|
|
If TipoMovimiento = 2 Then
|
|
PU = DtExistencias.FiltroPrimero($"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}")("PU").ToString.ToDouble
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
|
|
If Not ErrorMovInv Then
|
|
|
|
|
|
|
|
If CveAlmacenTraspasoDestino > 0 Then ' TRASPASO CUANDO ES REMISION
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestino, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero)
|
|
FolioEntrada = ObjInventario.Folio
|
|
|
|
If CveMovimientoEntrada <= 0 Then
|
|
TextoError = "No se pudo generar el movimiento de entrada correctamente"
|
|
ErrorMovInv = True
|
|
Else
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
Else 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN - SALIDA ALMACEN
|
|
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
|
|
|
|
|
|
If ObjVentas.GetVenta(CveVentaSurtir, UsuarioActual.CveEmpresa) Then
|
|
Dim CvePrePoliza As Integer = ObjVentas.DtResultados(0)("CvePrePoliza").ToString.ToEntero
|
|
Dim Fecha As Date = ObjVentas.DtResultados(0)("Fecha").ToString.ToDate
|
|
Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero
|
|
Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString
|
|
|
|
'Se agrega movimiento separado por la cuenta de ventas (ER)
|
|
For Each RowInv As DataRow In tmpCostos.Rows
|
|
ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal
|
|
|
|
|
|
'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString)
|
|
IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
|
|
If ValorInventario <> 0 Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, If(TipoMovimiento = 1, 1, -1) * ValorInventario, SerieFolio, 68, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=If(TipoMovimiento = 1, 1, -1) * ValorInventario) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
If Not ErrorMovInv Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, If(TipoMovimiento = 1, 1, -1) * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=If(TipoMovimiento = 1, 1, -1) * ValorInventario) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
Else
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un Error al ingresar las prepolizas"
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
'DEVOLUCION
|
|
If TipoMovimiento = 2 Then
|
|
|
|
'APARTADOS
|
|
If ObjInventario.VentasAlmacenApartadosGet(CveVentaSurtir) Then
|
|
Dim DtTempApartados = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 9", "CveAlmacen")
|
|
Dim CveMovimientoSalidaApartado = -1
|
|
Dim CveAlmacenApartado = -1
|
|
Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero)
|
|
|
|
For Each Dr As DataRow In DtTempApartados.Rows
|
|
|
|
If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString.ToEntero Then
|
|
CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, CveAlmacenDestino:=Dr("CveAlmacen").ToString.ToEntero)
|
|
FolioSalida = ObjInventario.Folio
|
|
CveAlmacenApartado = Dr("CveAlmacen").ToString.ToEntero
|
|
End If
|
|
|
|
If CveMovimientoSalidaApartado > 0 Then
|
|
Dim DrMovto = DtTraspasos.NewRow
|
|
DrMovto("Almacen") = Dr("Almacen").ToString.ToEntero
|
|
DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString.ToEntero
|
|
DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado
|
|
DrMovto("FolioSalida") = FolioSalida
|
|
DtTraspasos.Rows.Add(DrMovto)
|
|
Else
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de control de apartados"
|
|
Exit For
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de control de apartados"
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If Not ErrorMovInv Then
|
|
For Each Dr1 As DataRow In DtTraspasos.Rows
|
|
CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero
|
|
|
|
CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente)
|
|
FolioEntrada = ObjInventario.Folio
|
|
|
|
If Not CveMovimientoEntradaApartado > 0 Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
|
|
Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado
|
|
Dr1("FolioEntrada") = FolioEntrada
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If ErrorMovInv Then Exit For
|
|
|
|
Next
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
|
|
If Not ErrorMovInv And EsDevolucionVenta = 1 Then
|
|
If Not ObjVentas.UpdateVentasDevolucionAlmacen(2, CveVentaSurtir) Then
|
|
TextoError = "Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar."
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
If Not ObjEventos.AddEventoBitacora(String.Format("Venta Surtida en Folio: <a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a>", CveMovimiento, Folio), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaSurtir) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
ObjInventario.Commit()
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
Dim Msg As New StringBuilder
|
|
Msg.AppendFormat("Movimiento Salida: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a></b>", CveMovimiento, Folio)
|
|
Msg.AppendFormat("<br/><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
|
|
|
|
|
|
'Msg.AppendFormat("<input type=""text"" id=""NumeroGuia""/>")
|
|
'Dim script As String = "$('#TxtNumeroGuia').val($('#NumeroGuia').val());$('#BtnNumeroGuia').click();"
|
|
|
|
If CveMovimientoEntrada > 0 Then
|
|
Msg.AppendFormat("<br/><br/> Movimiento Entrada (Traspaso): <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a></b>", CveMovimientoEntrada, FolioEntrada)
|
|
Msg.AppendFormat("<br/> <a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada)))
|
|
End If
|
|
|
|
|
|
If DtTraspasos.Rows.Count > 0 Then
|
|
Msg.AppendFormat("<br/><br/> Movimientos de Control (Apartados):")
|
|
For Each Dr As DataRow In DtTraspasos.Rows
|
|
Msg.AppendFormat("<br/>Almacén {0} | Salida por Traspaso: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{2}</a></b> | Entrada por Traspaso: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={3}"" target=""_blank"">{4}</a></b> ", Dr("Almacen"), Dr("CveMovimientoSalida"), Dr("FolioSalida"), Dr("CveMovimientoEntrada"), Dr("FolioEntrada"))
|
|
Next
|
|
End If
|
|
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
Limpia()
|
|
CargaPendientes()
|
|
Else
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ObjInventario.RollBack()
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
End Sub
|
|
|
|
Private Sub Limpia()
|
|
|
|
'DATOS DE LA VENTA
|
|
LbCantidad.Text = ""
|
|
LbCliente.Text = ""
|
|
LbOberservaciones.Text = ""
|
|
LbFolio.Text = ""
|
|
|
|
'DATOS DEL MOVIMINETO
|
|
TxtObservaciones.Text = ""
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
DdlAlmacen.SelectedValueExist(-1)
|
|
CargaFolios()
|
|
|
|
'VARIABLES GENERALES
|
|
CveVentaSurtir = -1
|
|
DtDatosDetalle = Nothing
|
|
DtDatos = Nothing
|
|
|
|
DivTipoCambioAdvertencia.Visible = False
|
|
|
|
LbSurtida.Visible = False
|
|
TimmerRefresh.Enabled = True
|
|
UpGenerales.Update()
|
|
CargaGvDatos()
|
|
End Sub
|
|
|
|
Private Sub BtnNumeroGuia_Click(sender As Object, e As EventArgs) Handles BtnNumeroGuia.Click
|
|
Dim Objeto As New ClsInventarios
|
|
If Objeto.UpdateMovimientoGuia(TxtGuia.Text, CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
Alert("Se ha guardado correctamente la póliza", TipoMensaje.MsgConfirmacion)
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
End Class
|