2799 lines
147 KiB
VB.net
2799 lines
147 KiB
VB.net
Option Strict On
|
|
Option Explicit On
|
|
|
|
Imports System.Data
|
|
Imports System.IO
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
|
|
Partial Class Inventarios_RecepcionEntrega
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property CveVentaAD As Integer
|
|
Get
|
|
Return CType(ViewState("CveVentaAD"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveVentaAD") = value
|
|
End Set
|
|
End Property
|
|
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 DtDatosDetalleLote As DataTable
|
|
Get
|
|
Return CType(ViewState("DtDatosDetalleLote"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatosDetalleLote") = 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 EsInterno As Boolean
|
|
Get
|
|
Return CBool(If(ViewState("EsInterno") Is Nothing, 0, ViewState("EsInterno")))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsInterno") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveMetodoInventarioLote As Integer
|
|
Get
|
|
Return CType(ViewState("CveMetodoInventarioLote"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMetodoInventarioLote") = 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 TipoEstatus As Integer
|
|
Get
|
|
Return CType(ViewState("TipoEstatus"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoEstatus") = 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 CveSubProyecto As Integer
|
|
Get
|
|
Return CType(ViewState("CveSubProyecto"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveSubProyecto") = 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
|
|
Private Property CveTraspasoSurtir As Integer
|
|
Get
|
|
Return CType(ViewState("CveTraspasoSurtir"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveTraspasoSurtir") = value
|
|
End Set
|
|
End Property
|
|
Private Property TipoEntrega As Integer
|
|
Get
|
|
Return CType(ViewState("TipoEntrega"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoEntrega") = 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
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
InicializaValores()
|
|
CargaParametrosAD()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " INICIALIZA VALORES "
|
|
Private Sub InicializaValores()
|
|
TipoEstatus = -1
|
|
CveVendedor = -1
|
|
CveCliente = -1
|
|
CveSubProyecto = -1
|
|
Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2)"
|
|
|
|
If (UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1") Then
|
|
DdlClientes.setEsWebService(True)
|
|
DdlClientes.Attributes.Add("data-metodo", "getcliente")
|
|
DdlClientes.SelectedText = "Todos"
|
|
DdlClientes.SelectedValue = "-1"
|
|
Else
|
|
DdlClientes.setEsWebService(False)
|
|
DdlClientes.ddl.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
DdlClientes.ddl.DataBind()
|
|
DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End If
|
|
|
|
If UsuarioActual.CveSubProyecto = 8804 Then
|
|
StrAlmacenes = "CveTipoAlmacen IN (1,2,12)"
|
|
End If
|
|
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
|
|
|
DdlAlmacenTransitorio.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3)
|
|
DdlAlmacenTransitorio.DataBind()
|
|
DdlAlmacenTransitorio.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
|
|
RVFecha.MaximumValue = MaxFecha.ToShortDateString
|
|
If UsuarioActual.CveEmpresa.Contiene(119) Then RVFecha.MinimumValue = Now.ToShortDateString : CEFecha.StartDate = Now Else RVFecha.MinimumValue = MinFecha.ToShortDateString
|
|
|
|
If Not UsuarioActual.TienePermisoProceso(190) Then
|
|
'CARGA SOLO LAS SUCURSALES DE LOS ALMCENES QUE TIENE ASIGNADO EL USUARIO
|
|
Dim ObjInventarios As New ClsInventarios
|
|
If ObjInventarios.GetSucursalesAlmacenUsuario(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
DdlSubProyectos.DataSource = ObjInventarios.DtResultados
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
Else
|
|
DdlSubProyectos.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
End If
|
|
DdlSubProyectos.DataBind()
|
|
DdlSubProyectos.SelectedValueExist(UsuarioActual.CveSubProyecto.ToString)
|
|
|
|
If UsuarioActual.TienePermisoProceso(152) Then DdlSubProyectos.Enabled = False
|
|
|
|
CreaDtDetalle()
|
|
CreaDtDetalleLote()
|
|
CargaPendientes()
|
|
|
|
CantidadTotal = 0
|
|
IndexSeccionAlmacen = 0
|
|
CvePS = 0
|
|
CreaDtSeccionAlmacen()
|
|
CargaDdlAlmacen()
|
|
|
|
LnkVerSecciones.Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1"
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA PARAMETROS - EXCLUSIVO USO AD "
|
|
Private Sub CargaParametrosAD()
|
|
|
|
CveVentaAD = -1
|
|
|
|
If UsuarioActual.CveUsuario <> 100 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not IsNothing(Request("CveVenta")) AndAlso IsNumeric(Request("CveVenta")) Then
|
|
CveVentaAD = Request("CveVenta").ToEntero
|
|
CargaVentaPorSurtir(Request("CveVenta").ToEntero)
|
|
LbSurtida.Visible = True
|
|
LbSurtida.Text = "SOLO MODO VISUAL"
|
|
BtnGuardar.Visible = False
|
|
End If
|
|
|
|
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, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) 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()
|
|
DivTipoCambioAdvertencia.Visible = False
|
|
|
|
Dim ObjInventarios As New ClsInventarios
|
|
Dim DtPendientes As New DataTable
|
|
|
|
If ObjInventarios.VentasPendientesAlmacenGet(-1, TxtFechaPendientes.Text.ToDate, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
|
|
|
|
|
|
If UsuarioActual.TienePermisoProceso(266) AndAlso UsuarioActual.TienePermisoProceso(267) Then
|
|
DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Dev','Rem','Traspaso','Ped','PDev','DPe','Ant')")
|
|
ElseIf UsuarioActual.TienePermisoProceso(266) AndAlso Not UsuarioActual.TienePermisoProceso(267) Then
|
|
DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Dev','Rem','Traspaso','Ant')")
|
|
ElseIf UsuarioActual.TienePermisoProceso(267) AndAlso Not UsuarioActual.TienePermisoProceso(266) Then
|
|
DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ped','PDev','DPe')")
|
|
Else
|
|
DtPendientes = ObjInventarios.DtResultados
|
|
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
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(540) = "1" Then
|
|
BtnGuardar.Enabled = False
|
|
Dim FI As Date = Now.AddDays(-1)
|
|
Dim FF As Date = Now.AddDays(-7)
|
|
If ObjInventarios.RepNotasSinAlmacen(1, -1, FI, FF, "-1", -1, UsuarioActual.Empresa.CveEmpresa) Then
|
|
If ObjInventarios.DtResultados IsNot Nothing AndAlso ObjInventarios.DtResultados.Rows.Count > 1 Then
|
|
BtnGuardar.Enabled = False
|
|
Alert("No se podrá realizar entrega de mercancía si no se les da salida a los documentos pendientes. Para más información ver el Reporte de notas sin entrada en la sección Ventas.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
BtnGuardar.Enabled = True
|
|
|
|
End If
|
|
End If
|
|
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()
|
|
DtPendientes.Dispose()
|
|
|
|
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 = If(e.Row.DBCampo("TipoEntrega") = "1", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("CveTraspasoSolicitud"))
|
|
|
|
|
|
|
|
Select Case e.Row.DBCampo("TipoEntrega").ToString.ToEntero
|
|
Case 1
|
|
If UsuarioActual.TienePermisoProceso(201) Then
|
|
Dim Css = "Texto"
|
|
Dim Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DBCampo("CveVenta")}"
|
|
e.Row.FCLabel("LblFolio").Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.FCLabel("LblFolio").Text + "</a>"
|
|
End If
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(72, 80) Then
|
|
GVPendientes.Columns(4).Visible = True
|
|
e.Row.FCHyperLink("HplDownPDF").Visible = True
|
|
e.Row.FCHyperLink("HplDownPDF").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=VTA&CVEVENTA={0}", e.Row.DBCampo("CveVenta"))))
|
|
End If
|
|
|
|
If e.Row.DBCampo("TipoDocto").ToString.Contiene({"Rem", "Ing", "Ped", "PeC", "Ant"}) And e.Row.DBCampo("EsDevolucionVenta").ToString.ToEntero = 0 Then
|
|
e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary btn-sm"
|
|
e.Row.FCLinkButton("BtnSurtir").Text = " Surtir <i class='fa fa-arrow-right' ></i>"
|
|
Else
|
|
e.Row.FCLinkButton("BtnSurtir").CssClass = "btn yellow-gold btn-sm"
|
|
e.Row.FCLinkButton("BtnSurtir").Text = "<i class='fa fa-arrow-left' > Recibir</i>"
|
|
End If
|
|
Case 2
|
|
Dim Css = "Texto"
|
|
Dim Liga = $"/Inventarios/TrasladoSolicitud.aspx?&CveTraspasoSolicitud={e.Row.DBCampo("CveTraspasoSolicitud")}"
|
|
e.Row.FCLabel("LblFolio").Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.FCLabel("LblFolio").Text + "</a>"
|
|
e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary btn-sm"
|
|
e.Row.FCLinkButton("BtnSurtir").Text = " Traspasar <i class='fa fa-arrow-right' ></i>"
|
|
End Select
|
|
UpPendientes.Update()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA VENTA POR SURTIR "
|
|
Protected Sub BtnSurtir_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim Boton = CType(sender, LinkButton)
|
|
CveVentaAD = -1
|
|
|
|
If Boton.CommandArgument.ToEntero > 0 Then
|
|
TimmerRefresh.Enabled = False
|
|
|
|
DivTransitorio1.Visible = False
|
|
ChkTransitorio.Checked = False
|
|
TxtResponsable.Text = ""
|
|
DivTransitorio2.Visible = False
|
|
|
|
|
|
Select Case CType(Boton.NamingContainer, GridViewRow).DataKey("TipoEntrega").ToEntero
|
|
Case 1 ' VENTA
|
|
CargaVentaPorSurtir(CType(sender, LinkButton).CommandArgument.ToEntero)
|
|
Case 2 ' TRASPASO
|
|
DivTransitorio1.Visible = True
|
|
CargaTraspasoPorSurtir(CType(Boton.NamingContainer, GridViewRow).DataKey("CveTraspasoSolicitud").ToEntero)
|
|
End Select
|
|
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub BtnBuscar_Click(sender As Object, e As EventArgs)
|
|
CveVentaAD = -2
|
|
CargaVentaPorSurtir(DdlFolio.SelectedValue.ToEntero)
|
|
End Sub
|
|
Private Sub CargaVentaPorSurtir(CveVenta As Integer)
|
|
LbSurtida.Visible = False
|
|
CveContrato = -1
|
|
CveSubProyecto = -1
|
|
DtDatos = Nothing
|
|
TipoEntrega = 1
|
|
BtnGuardar.Visible = True
|
|
|
|
Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2)"
|
|
|
|
If UsuarioActual.CveSubProyecto = 8804 Then
|
|
StrAlmacenes = "CveTipoAlmacen IN (1,2,12)"
|
|
End If
|
|
|
|
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()
|
|
|
|
DtDatosDetalleLote = Nothing
|
|
CreaDtDetalleLote()
|
|
|
|
If DtDatos.Rows(0) IsNot Nothing Then
|
|
EsDevolucionVenta = DtDatos.Rows(0)("EsDevolucionVenta").ToString.ToEntero
|
|
TipoDocto = DtDatos.Rows(0)("TipoDocto").ToString
|
|
TipoMovimiento = If(TipoDocto.Contiene({"Rem", "Ing", "Ped", "PeC", "Ant"}) And (EsDevolucionVenta = 0 Or CveVentaAD > 0), 1, 2)
|
|
|
|
LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString
|
|
'LbFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
|
|
HLFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
|
|
If UsuarioActual.TienePermisoProceso(201) Then
|
|
HLFolio.NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={CveVenta}"
|
|
End If
|
|
|
|
LbObservaciones.Text = DtDatos.Rows(0)("Observaciones").ToString
|
|
LbObservacionesAlmacen.Text = DtDatos.Rows(0)("ObservacionesAlmacen").ToString
|
|
CveVentaSurtir = CveVenta
|
|
CveAlmacenTraspasoDestino = DtDatos.Rows(0)(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "CveAlmacenTraspasoOrigen", "CveAlmacenTraspasoDestino")).ToString.ToEntero
|
|
CveAlmacenTraspasoOrigen = DtDatos.Rows(0)(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "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
|
|
CveSubProyecto = DtDatos.Rows(0)("CveSubProyecto").ToString.ToEntero
|
|
EsInterno = CBool(DtDatos.Rows(0)("EsInterno").ToString)
|
|
|
|
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 And Not (TipoMovimiento = 2 And TipoDocto = "Rem") 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
|
|
|
|
'DEVOLUCION REMISION
|
|
If TipoMovimiento = 2 And TipoDocto = "Rem" And Not CveAlmacenTraspasoDestino > 0 Then
|
|
Alert("La remisión que se intenta devolver presenta inconsistencias. Comuniquese con servicio tecnico SIG.", TipoMensaje.MsgError)
|
|
BtnGuardar.Visible = False
|
|
End If
|
|
|
|
DdlAlmacen.Items.Clear()
|
|
If CveAlmacenTraspasoOrigen > 0 Then 'Not (EsDevolucionVenta = 1 And DtDatos.Rows(0)("TipoDocto").ToString = "Rem" And UsuarioActual.Empresa.Funcionalidad(145) = "1") - ESTO ES PARA CUANDO SEA REMISION DE ENTREGA POR ADELANTADO FUNCIONA LA DEVOLUCION
|
|
DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString))
|
|
Else
|
|
'[IPP] PARCHE - Debe hacerse permiso proceso - 17Enero2018
|
|
Dim RestriccionAlmacenSubProyecto = If(UsuarioActual.CveEmpresa.Contiene(72, 80), $" AND CveSubProyecto = {CveSubProyecto}", "")
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"{StrAlmacenes} {RestriccionAlmacenSubProyecto}")
|
|
End If
|
|
DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
|
If CveAlmacenTraspasoOrigen > 0 Then
|
|
DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
|
|
End If
|
|
|
|
'TxtFecha.Text = If(EsDevolucionVenta = 1, Now.ToShortDateString, 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 ' cuando es cancelación
|
|
Dim Filtro As String '= If(ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString.Contiene({"Ing", "Dev", "Ped"}), "CveConcepto = 3", "CveConcepto = 9")
|
|
Select Case ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString
|
|
Case "Ing", "Ped"
|
|
Filtro = "CveConcepto = 3"
|
|
Case "Dev"
|
|
'cuand es devolucionventa=1, es cancelación de la devolución
|
|
If EsDevolucionVenta = 1 Then Filtro = "CveConcepto = 18" Else Filtro = "CveConcepto = 3"
|
|
Case Else
|
|
Filtro = "CveConcepto = 9"
|
|
End Select
|
|
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
|
|
|
|
CargaDocumentos(CveVenta)
|
|
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()
|
|
DtSeccionAlmacen.Rows.Clear()
|
|
DtSeccionAlmacen.AcceptChanges()
|
|
End Sub
|
|
Private Sub CargaTraspasoPorSurtir(CveTraspaso As Integer)
|
|
LbSurtida.Visible = False
|
|
CveContrato = -1
|
|
CveSubProyecto = -1
|
|
DtDatos = Nothing
|
|
TipoEntrega = 2
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
If ObjInventario.EntregaAlmacenTraspasosGet(CveTraspaso) Then
|
|
If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
CveTraspasoSurtir = CveTraspaso
|
|
TipoMovimiento = 1
|
|
|
|
DtDatos = ObjInventario.DtResultados
|
|
DtDatos.Columns.Add("Consec", GetType(Integer))
|
|
DtDatos.Columns.Add("CantidadGV", GetType(Double))
|
|
DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
|
|
|
|
LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString
|
|
HLFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString
|
|
If UsuarioActual.TienePermisoProceso(201) Then
|
|
HLFolio.NavigateUrl = $"/Inventarios/TrasladoSolicitud.aspx?CveTraspasoSolicitud={CveTraspasoSurtir}"
|
|
End If
|
|
LbObservaciones.Text = DtDatos.Rows(0)("Observaciones").ToString
|
|
|
|
Dim Index = 1
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
Dr("Consec") = Index
|
|
Index += 1
|
|
Next
|
|
|
|
DtDatosDetalle = Nothing
|
|
CreaDtDetalle()
|
|
|
|
DtDatosDetalleLote = Nothing
|
|
CreaDtDetalleLote()
|
|
|
|
CveAlmacenTraspasoDestino = DtDatos.Rows(0)("CveAlmacenDestino").ToString.ToEntero
|
|
CveAlmacenTraspasoOrigen = DtDatos.Rows(0)("CveAlmacenOrigen").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
|
|
|
|
'If DtDatos.Rows.Cast(Of DataRow).Any(Function(Row) Row("CveTamaño").ToString().ToEntero() > 0) Then
|
|
|
|
'End If
|
|
|
|
|
|
DdlAlmacen.Items.Clear()
|
|
If CveAlmacenTraspasoOrigen > 0 Then
|
|
DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString))
|
|
End If
|
|
|
|
DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
|
If CveAlmacenTraspasoOrigen > 0 Then
|
|
DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen)
|
|
End If
|
|
|
|
'TxtFecha.Text = DtDatos.Rows(0)("Fecha").ToString
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
|
|
DivCodigoSeriePS.Visible = True
|
|
Else
|
|
DivCodigoSeriePS.Visible = False
|
|
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.Columns(7).Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1"
|
|
|
|
GvDatos.Columns(8).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1"
|
|
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
UpVenta.Update()
|
|
|
|
'CARGA LO PRECARGADO CON SERIELOTE
|
|
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
|
|
|
|
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").Contiene("5", "6") Then
|
|
e.Row.FCButton("BtnSerieLote").Visible = True
|
|
e.Row.FCButton("BtnSerieLote").Text = If(e.Row.DBCampo("Inv_CveMetodoInventario").ToString = "5", "SerieLote", "Lote-Batch")
|
|
e.Row.FCButton("BtnSerieLote").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec"), e.Row.DBCampo("Inv_CveMetodoInventario"))
|
|
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"
|
|
|
|
If TipoDocto = "DPe" Then
|
|
CveConsecSerieLote = e.Row.DBCampo("Consec").ToString.ToEntero
|
|
PSSerieLote = e.Row.DBCampo("PS").ToString
|
|
CvePSSerieLote = e.Row.DBCampo("CvePS").ToEntero
|
|
CveUMSerieLote = e.Row.DBCampo("CveUM").ToEntero
|
|
LbCantidad.Text = e.Row.DBCampo("CantidadF")
|
|
LbCantidad2.Text = e.Row.DBCampo("CantidadF")
|
|
AgregaSerieLote(e.Row.DBCampo("ObservacionesDetalle"), 3)
|
|
End If
|
|
|
|
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
|
|
'NO BLOQUEA PARA ROL AD
|
|
If UsuarioActual.CveRol = 1 Then
|
|
If e.Row.DBCampo("Inv_CveMetodoInventario").Contiene("5", "6") Then
|
|
e.Row.FCTextBox("TbCantidadF").Enabled = False
|
|
Else
|
|
e.Row.FCTextBox("TbCantidadF").Text = e.Row.DBCampo("CantidadF").FormatoNumero()
|
|
End If
|
|
End If
|
|
|
|
If Not UsuarioActual.CveRol = 1 Then
|
|
e.Row.FCTextBox("TbCantidadF").Enabled = False
|
|
End If
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then
|
|
e.Row.FCLinkButton("LBSeccionAlmacen").CommandArgument = $"{e.Row.DBCampo("CvePS").ToString.ToEntero}|{e.Row.DBCampo("CantidadF").ToString.ToDecimal}|{DdlAlmacen.SelectedValue.ToEntero}"
|
|
End If
|
|
|
|
'SI ES TRASPASO OBLIGATORIO SURTIR TODO
|
|
If TipoEntrega = 2 Then
|
|
e.Row.FCCheckBox("cbInv").Enabled = False
|
|
End If
|
|
|
|
'If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then
|
|
' Dim ObjInventarios As New ClsInventarios
|
|
' If ObjInventarios.SeccionAlmacenRecomendadoSurtidoGet(e.Row.DBCampo("CvePS").ToString.ToEntero, e.Row.DBCampo("CantidadF").ToString.ToDecimal, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) Then
|
|
' e.Row.FCLabel("LbSeccionAlmacen").Text = ObjInventarios.DtResultados().Rows(0)(0).ToString
|
|
' End If
|
|
' ObjInventarios.Dispose()
|
|
'End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaDocumentos(tCveVenta As Integer)
|
|
Dim objInv As New ClsEdocumentacion
|
|
|
|
If objInv.DocumentacionElectronicaGet(-1, -1, -1, UsuarioActual.CveEmpresa, -1, tCveVenta) Then
|
|
GvDocs.DataSource = objInv.DtResultados.FiltraParametros("Adjunto <> ''")
|
|
End If
|
|
objInv.Dispose()
|
|
GvDocs.DataBind()
|
|
End Sub
|
|
Protected Sub LBSeccionAlmacen_Click(sender As Object, e As EventArgs)
|
|
Dim Argumentos = CType(sender, LinkButton).CommandArgument.Split("|"c)
|
|
|
|
Dim ObjInventarios As New ClsInventarios
|
|
If ObjInventarios.SeccionAlmacenRecomendadoSurtidoGet(Argumentos(0).ToEntero, Argumentos(1).ToEntero, UsuarioActual.CveEmpresa, Argumentos(2).ToEntero) Then
|
|
GVSeccionAlmacen.DataSource = ObjInventarios.DtResultados
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
|
|
GVSeccionAlmacen.DataBind()
|
|
UpSeccionAlmacen.Update()
|
|
|
|
RegistraScript("$('#ModalSeccionAlmacen').modal('show')")
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " AGREGAR "
|
|
|
|
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)
|
|
|
|
LbProducto2.Text = Argumentos(2)
|
|
LbCantidad2.Text = Argumentos(3)
|
|
|
|
CvePSSerieLote = Argumentos(0).ToEntero
|
|
CveUMSerieLote = Argumentos(1).ToEntero
|
|
PSSerieLote = Argumentos(2).ToString
|
|
CveConsecSerieLote = Argumentos(4).ToEntero
|
|
CveMetodoInventarioLote = Argumentos(5).ToEntero
|
|
|
|
If CveMetodoInventarioLote = 5 Then
|
|
RegistraScript("$('#DivSerie').modal('show')")
|
|
CargaSerie()
|
|
UpSerie.Update()
|
|
ElseIf CveMetodoInventarioLote = 6 Then
|
|
RegistraScript("$('#DivLote').modal('show')")
|
|
CargaLote()
|
|
UpLoteBatch.Update()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#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(Optional CerrarCompletado As Boolean = False)
|
|
RegistraScript("$('#DivSerie').modal('show')", "show")
|
|
'RegistraScript("document.getElementById(""TxtSerieLote"").focus();")
|
|
|
|
Dim AplicaCaducidad = False
|
|
If GlobalDTPS(UsuarioActual.CveEmpresa, ).FiltraParametros("").Rows(0) IsNot Nothing Then
|
|
AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").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()
|
|
|
|
'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, CveSubProyecto:=CveSubProyecto) Then
|
|
DtSerieLote = ObjInventarios.DtResultados
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
Else
|
|
DtSerieLote = DtExistencias.FiltraParametros("SerieLote <> ''")
|
|
End If
|
|
'SERIE LOTE RECOMENDADO - QUITA YA COMPLETADOS EN EL CLIENTE
|
|
If DtSerieLote.Rows.Count > 0 Then
|
|
'CALCULA YA COMPLETADOS
|
|
Dim DrsRemove As New List(Of DataRow)
|
|
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").ToString.Replace("'", "''"))).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("AplicaSerieLote") = "True" 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()
|
|
|
|
'VALIDA QUE SIGA AGREGANDO
|
|
If DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote)).Rows.Count = LbCantidad.Text.ToEntero Then
|
|
BtnAgregarPS.Enabled = False
|
|
If CerrarCompletado Then
|
|
RegistraScript("$('#DivSerie').modal('hide')", "hide")
|
|
End If
|
|
UpSerie.Update()
|
|
Exit Sub
|
|
Else
|
|
BtnAgregarPS.Enabled = True
|
|
UpSerie.Update()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs)
|
|
If TxtSerieLote.Text.Trim.Length >= 2 AndAlso TxtSerieLote.Text.Trim.StartsWith("*") AndAlso TxtSerieLote.Text.Trim.EndsWith("*") Then
|
|
Dim ArraySeries() As String = Nothing
|
|
Dim Series As String = Nothing
|
|
|
|
Series = TxtSerieLote.Text.Trim
|
|
Series = Series.Remove(0, 1)
|
|
Series = Series.Remove(Series.Length - 1, 1)
|
|
ArraySeries = Series.Trim.Split(","c)
|
|
|
|
For i As Integer = 0 To ArraySeries.Length - 1
|
|
If ArraySeries(i).Trim.Length > 1 Then AgregaSerieLote(ArraySeries(i).Trim, 1)
|
|
Next
|
|
Else
|
|
AgregaSerieLote(TxtSerieLote.Text.Trim, 1)
|
|
End If
|
|
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')", "Error1")
|
|
TxtSerieLote.Text = ""
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim AplicaCaducidad = False
|
|
If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0) IsNot Nothing Then
|
|
AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").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, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=If(TipoEntrega = 2, 1, -1))
|
|
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')", "Error2")
|
|
ObjInventarios.Dispose()
|
|
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')", "Error3")
|
|
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')", "Sonidito")
|
|
|
|
If Tipo = 1 Then
|
|
TxtSerieLote.Text = ""
|
|
TxtFechaCaducidad.Text = Now.ToShortDateString
|
|
End If
|
|
|
|
If Tipo < 3 Then
|
|
CargaSerie(True)
|
|
End If
|
|
|
|
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 LOTE BATCH "
|
|
|
|
Private Sub CreaDtDetalleLote()
|
|
If DtDatosDetalleLote Is Nothing Then
|
|
DtDatosDetalleLote = New DataTable
|
|
DtDatosDetalleLote.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
DtDatosDetalleLote.Columns.Add("Consec", GetType(Integer))
|
|
DtDatosDetalleLote.Columns.Add("ConsecId", GetType(Integer))
|
|
DtDatosDetalleLote.Columns.Add("Cantidad", GetType(Double))
|
|
DtDatosDetalleLote.Columns.Add("CvePS", GetType(Integer))
|
|
DtDatosDetalleLote.Columns.Add("PS", GetType(String))
|
|
DtDatosDetalleLote.Columns.Add("CveUM", GetType(Integer))
|
|
DtDatosDetalleLote.Columns.Add("Lote", GetType(String))
|
|
DtDatosDetalleLote.Columns.Add("Batch", GetType(String))
|
|
DtDatosDetalleLote.Columns.Add("FechaCaducidad", GetType(String))
|
|
DtDatosDetalleLote.Columns.Add("FueTraspaso", GetType(Integer))
|
|
End If
|
|
End Sub
|
|
Private Sub CargaLote(Optional CerrarCompletado As Boolean = False)
|
|
|
|
RegistraScript("$('#DivLote').modal('show')")
|
|
GvLote.DataSource = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote), "Consec DESC")
|
|
GvLote.DataBind()
|
|
|
|
'VALIDA QUE SIGA AGREGANDO
|
|
If DtDatosDetalleLote.SUM("Cantidad", String.Format("ConsecId = {0}", CveConsecSerieLote)) = LbCantidad2.Text.ToDecimal Then
|
|
BtnLote.Enabled = False
|
|
If CerrarCompletado Then
|
|
RegistraScript("$('#DivLote').modal('hide')", "hide")
|
|
End If
|
|
Else
|
|
BtnLote.Enabled = True
|
|
End If
|
|
|
|
'LOTE RECOMENDADO
|
|
Dim DtLotes As New DataTable
|
|
If TipoMovimiento = 1 Then
|
|
Dim ObjInventarios As New ClsInventarios
|
|
If ObjInventarios.LoteBatchRecomendadoGet(CvePSSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) Then
|
|
DtLotes = ObjInventarios.DtResultados
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
Else
|
|
DtLotes = DtExistencias.FiltraParametros("Lote <> ''")
|
|
End If
|
|
|
|
Dim DrsRemove As New List(Of DataRow)
|
|
|
|
If DtLotes.Rows.Count > 0 Then
|
|
'CALCULA YA COMPLETADOS
|
|
DtLotes.Columns.Add("CantidadSeleccionada", GetType(Integer))
|
|
For Each dr As DataRow In DtLotes.Rows
|
|
dr("CantidadSeleccionada") = DtDatosDetalleLote.SUM("Cantidad", String.Format("Consec = {0} AND Lote = '{1}' AND Batch = '{2}'", CveConsecSerieLote, dr("Lote"), dr("Batch")))
|
|
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
|
|
DtLotes.Rows.Remove(dr)
|
|
Next
|
|
|
|
If DtLotes.Rows.Count > 0 Then
|
|
Dim Mensaje As New StringBuilder
|
|
Mensaje.AppendFormat("Recomendado: Existencia: <b>{0}</b> Lote: <b>{1}</b> Batch: <b>{2}</b> Fecha Caducidad: <b>{3}</b> ", DtLotes.Rows(0)("Existencia").ToString.FormatoNumero, DtLotes.Rows(0)("Lote"), DtLotes.Rows(0)("Batch"), DtLotes.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
|
|
LbLoteRecomendado.Text = Mensaje.ToString
|
|
Else
|
|
LbLoteRecomendado.Text = "No se encontro ningún Lote-Batch recomendato."
|
|
End If
|
|
Else
|
|
LbLoteRecomendado.Text = "No se encontro ningún Lote-Batch recomendato."
|
|
End If
|
|
|
|
|
|
'SI TIENE SALIDA POR LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD
|
|
Dim Contador As Decimal = 0
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then
|
|
Contador = DtDatosDetalleLote.SUM("Cantidad", String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).ToDecimal
|
|
Gvr.FCCheckBox("cbInv").Enabled = False
|
|
Gvr.FCCheckBox("cbInv").Checked = True
|
|
Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString.FormatoNumero
|
|
End If
|
|
Next
|
|
|
|
RVCantidadLote.MaximumValue = (If((LbCantidad2.Text.ToDecimal - Contador) = 0, 0.02, LbCantidad2.Text.ToDecimal - Contador)).ToString.FormatoNumero
|
|
|
|
TxtCantidadLote.Text = "1"
|
|
TxtLote.Text = ""
|
|
TxtBatch.Text = ""
|
|
TxtLote.Focus()
|
|
|
|
UpLoteBatch.Update()
|
|
UpDatos.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarPS2_Click(sender As Object, e As EventArgs)
|
|
AgregaLote(TxtLote.Text.Trim, TxtBatch.Text.Trim, 1)
|
|
End Sub
|
|
Private Sub AgregaLote(Lote As String, Batch As String, Tipo As Integer)
|
|
|
|
If Lote = "" Then
|
|
Alert("El campo Lote es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'VALIDACION DE SERIES DUPLICADAS
|
|
Dim MensajeAlert As New StringBuilder
|
|
Dim DtDuplicado As New DataTable
|
|
Dim DtSeriesNuevas As New DataTable
|
|
DtSeriesNuevas.Columns.Add("Serie", GetType(String))
|
|
|
|
DtDuplicado = DtDatosDetalleLote.FiltraParametros($"ConsecId = {CveConsecSerieLote} AND Lote = '{Lote}' AND Batch = '{Batch}'")
|
|
If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then
|
|
Alert($"<br/> El numero de Lote <b>""{Lote}""</b> y Batch = '{Batch}' proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim Row = DtDatosDetalleLote.NewRow
|
|
Dim CantidadLote = TxtCantidadLote.Text.ToDecimal
|
|
|
|
Dim MensajeSinExistencias As New StringBuilder
|
|
Dim ObjInventarios As New ClsInventarios
|
|
|
|
'VERIFICA EXISTENCIAS
|
|
If TipoMovimiento = 1 Then
|
|
Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerieLote, CveUMSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Lote:=Lote, Batch:=Batch, ExcluyeApartados:=If(TipoEntrega = 2, 1, -1))
|
|
If Existencia < CantidadLote Then
|
|
Alert($"No hay existencia suficiente del producto <b>""{PSSerieLote}""</b> con el lote definido <b>""{Lote}""</b> y el batch <b>""{Batch}""</b>. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ObjInventarios.Dispose()
|
|
Exit Sub
|
|
End If
|
|
Else
|
|
If DtExistencias IsNot Nothing Then
|
|
Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {CvePSSerieLote} AND CveUM = {CveUMSerieLote} AND Lote = '{Lote}' AND Batch = '{Batch}'")
|
|
If Existencia < CantidadLote Then
|
|
Alert($"No hay existencia suficiente del producto <b>""{PSSerieLote}""</b> con el lote definido <b>""{Lote}""</b> y el batch <b>""{Batch}""</b>. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
ObjInventarios.Dispose()
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Dim FechaCaducidad = ""
|
|
If ObjInventarios.LoteBatchRecomendadoGet(CvePSSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) AndAlso ObjInventarios.DtResultados.Rows.Count > 0 Then
|
|
FechaCaducidad = ObjInventarios.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString
|
|
End If
|
|
|
|
Row("ConsecId") = CveConsecSerieLote
|
|
Row("Consec") = DtDatosDetalle.Rows.Count + 1
|
|
Row("Cantidad") = CantidadLote
|
|
Row("CvePS") = CvePSSerieLote
|
|
Row("PS") = PSSerieLote
|
|
Row("CveUM") = CveUMSerieLote
|
|
Row("Lote") = Lote
|
|
Row("Batch") = Batch
|
|
Row("FechaCaducidad") = FechaCaducidad
|
|
|
|
DtDatosDetalleLote.Rows.Add(Row)
|
|
ObjInventarios.Dispose()
|
|
|
|
If Tipo = 1 Then
|
|
TxtCantidadLote.Text = "1"
|
|
TxtLote.Text = ""
|
|
TxtBatch.Text = ""
|
|
End If
|
|
|
|
CargaLote(True)
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvLote_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvLote.RowDeleting
|
|
|
|
Dim keySerieLote As String = e.Keys("Lote").ToString
|
|
Try
|
|
For Each dr As DataRow In DtDatosDetalleLote.Rows
|
|
If dr("Lote").ToString = keySerieLote Then
|
|
dr.Delete()
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
DtDatosDetalleLote.AcceptChanges()
|
|
CargaLote()
|
|
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 Not TipoDocto.Contiene("Dev") Then
|
|
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, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=If(TipoEntrega = 2, 1, -1))
|
|
ObjInventario.Dispose()
|
|
If Not Existencia >= TxtCantidad.Text.ToDecimal + 1 Then
|
|
TxtCodigoPS.Text = ""
|
|
Alert($"No hay existencias suficientes del producto: <br/><b>""{Gvr.DataKey("Codigo")}-{Gvr.DataKey("PS")}""</b>. <br/>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: <br/><b>""{Gvr.DataKey("Codigo")}-{Gvr.DataKey("PS")}""</b>. <br/>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
|
|
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 = Gvr.DataKey("CveClasificacion").ToString.ToEntero.Contiene(17601, 17881) OrElse Gvr.DataKey("CvePS").ToString.ToEntero.Contiene(343032, 343033)
|
|
|
|
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
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " GUARDAR "
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
|
|
|
Select Case TipoEntrega
|
|
Case 1
|
|
GuardaVenta()
|
|
Case 2
|
|
GuardaTraspaso()
|
|
End Select
|
|
|
|
End Sub
|
|
|
|
Private Sub GuardaVenta()
|
|
|
|
|
|
'' INICIA: VALIDACIONES
|
|
|
|
'Valida el estatus de la Venta, si es = 5 O DevolucionVenta = 2, NO SE SURTE!
|
|
Dim ObjVentaInv As New ClsInventarios
|
|
If ObjVentaInv.GetEstatusVentaPorSurir(CveVentaSurtir) Then
|
|
TipoEstatus = ObjVentaInv.TipoEstatus
|
|
EsDevolucionVenta = ObjVentaInv.EsDevolucionVenta
|
|
End If
|
|
ObjVentaInv.Dispose()
|
|
|
|
If TipoEstatus = 5 Or EsDevolucionVenta.Contiene(2, 3) Then
|
|
Alert("No se puede surtir esta venta, verifique que no esté cancelada o ya registrado su movimiento en almacen", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
'VALIDA CANTIDAD DE SALIDA
|
|
Dim Cantidad As Decimal = 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 "176" 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
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then
|
|
If Cantidad <> DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") Then
|
|
Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
Dim EsInterno As Integer = -1
|
|
If TipoDocto = "Ped" Then
|
|
EsInterno = If(Me.EsInterno, 1, 0)
|
|
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 ObjAcumuladores As New ClsAcumuladores(ObjInventario.IniciaTransacSQL())
|
|
Dim CveMovimiento As Integer
|
|
Dim Folio As Integer
|
|
Dim ErrorMovInv As Boolean
|
|
Dim DtDetalle As New DataTable
|
|
Dim DtDetalleLote As New DataTable
|
|
Dim TextoError = ""
|
|
|
|
Dim CveMovimientoGarantia As Integer = -1
|
|
Dim FolioGarantia As Integer = -1
|
|
|
|
Dim CveMovimientoVirtual As Integer = -1
|
|
Dim FolioVirtual As Integer = -1
|
|
|
|
'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.ToDecimal
|
|
End If
|
|
Index += 1
|
|
Next
|
|
|
|
'VALIDA SI HUBO CAMBIOS EN LA EXISTENCIA
|
|
Dim DtDatosVenta As New DataTable
|
|
If ObjInventario.EntregaAlmacenGet(CveVentaSurtir) Then
|
|
DtDatosVenta = ObjInventario.DtResultados
|
|
End If
|
|
Dim CantidadGV = GvDatos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDecimal)
|
|
If CantidadGV <> DtDatosVenta.SUM("CantidadF").ToDecimal Then
|
|
ObjInventario.RollBack()
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
ObjVentas.Dispose()
|
|
ObjEventos.Dispose()
|
|
CargaVentaPorSurtir(CveVentaSurtir)
|
|
CargaPendientes()
|
|
Alert("Ha sido cambiada la informacion de existencias de la venta actual, se han recargado la información.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not ObjVentas.UpdateVentasDevolucionAlmacen(3, CveVentaSurtir) Then
|
|
ObjInventario.RollBack()
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
ObjVentas.Dispose()
|
|
ObjEventos.Dispose()
|
|
Exit Sub
|
|
End If
|
|
|
|
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 CveMovimientoSalida = -1, FolioSalida = -1, CveMovimientoEntrada = -1, CveMovimientoEntradaApartado = -1, FolioEntrada = -1, CveMovimientoSalidaDevRem = -1, FolioMovimientoSalidaDevRem = -1, CveMovimientoEntradaDevRem = -1, FolioMovimientoEntradaDevRem = -1
|
|
|
|
Try
|
|
'VALIDA EXISTENCIA 2
|
|
If TipoMovimiento = 1 Then
|
|
Dim StrXML As New StringBuilder
|
|
StrXML.Append("<conceptos>")
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
If Dr("CantidadGV").ToString.ToDecimal > 0 Then
|
|
If Dr("Inv_CveMetodoInventario").ToString = "5" Then
|
|
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
|
|
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
StrXML.AppendFormat("<concepto CvePS=""{0}"" CveUM=""{1}"" Cantidad= ""{2}"" Serie=""{3}"" ></concepto>", Dr1("CvePS"), Dr1("CveUM"), 1, Dr1("SerieLote"))
|
|
Next
|
|
ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then
|
|
DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
|
|
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
StrXML.AppendFormat("<concepto CvePS=""{0}"" CveUM=""{1}"" Cantidad= ""{2}"" Serie=""{3}"" ></concepto>", Dr1("CvePS"), Dr1("CveUM"), DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'"), Dr1("Lote"))
|
|
Next
|
|
Else
|
|
StrXML.AppendFormat("<concepto CvePS=""{0}"" CveUM=""{1}"" Cantidad= ""{2}"" Serie=""{3}"" ></concepto>", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), "-1")
|
|
End If
|
|
End If
|
|
Next
|
|
StrXML.Append("</conceptos>")
|
|
|
|
Dim TieneErrorExistencia = False
|
|
If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), If(TipoEntrega = 2, 1, -1), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
If ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
TieneErrorExistencia = True
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
TextoError += $"<b> - {Dr("CodigoPS")}</b> Existencia: {Dr("Existencia").ToString.ToDecimal.ToString("#,##0.##")} <br/>"
|
|
Next
|
|
End If
|
|
Else
|
|
TieneErrorExistencia = True
|
|
End If
|
|
|
|
If TieneErrorExistencia Then
|
|
ObjInventario.RollBack()
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
ObjVentas.Dispose()
|
|
ObjEventos.Dispose()
|
|
If TextoError.Length > 0 Then
|
|
Alert($" Lo(s) siguiente(s) Productos <b>no tienen</b> existencia suficiente:<br/><br/>{TextoError}", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
|
|
End If
|
|
|
|
'' TERMINA: VALIDACIONES
|
|
|
|
|
|
'' COMIENZA: APARTADOS
|
|
Dim CantidadPendiente As Decimal = 0
|
|
Dim CantidadSaldo As Decimal = 0
|
|
|
|
|
|
If CveVendedor > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(146) = "1" Or CveCliente > 0) AndAlso TipoDocto <> "Ped" Then 'no debe considerar cuando es pedido de contrato
|
|
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.ToDecimal > 0 Then
|
|
|
|
If Dr("Inv_CveMetodoInventario").ToString = "5" 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, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) Then
|
|
For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").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:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente),
|
|
CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G1")
|
|
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 Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("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
|
|
|
|
DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1
|
|
DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle")
|
|
Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente
|
|
Exit For
|
|
Next
|
|
End If
|
|
If ErrorMovInv Then Exit For
|
|
Next
|
|
|
|
ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then
|
|
|
|
DtDetalle = DtDatosDetalleLote.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"), Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) Then
|
|
|
|
CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal
|
|
|
|
For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").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:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente),
|
|
CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G2")
|
|
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 = If(Dr1("Cantidad").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("Cantidad").ToString.ToDecimal)
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("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
|
|
|
|
DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1
|
|
DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle")
|
|
|
|
CantidadSaldo -= CantidadPendiente
|
|
Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente
|
|
If CantidadSaldo <= 0 Then 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, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1) Then
|
|
|
|
CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal
|
|
|
|
For Each Dr1 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").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:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G3")
|
|
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") = Dr1("Almacen").ToString.ToEntero
|
|
DrMovto("CveAlmacen") = Dr1("CveAlmacen").ToString.ToEntero
|
|
DrMovto("CveMovimientoSalida") = CveMovimientoSalida
|
|
DrMovto("FolioSalida") = FolioSalida
|
|
DtTraspasos.Rows.Add(DrMovto)
|
|
End If
|
|
|
|
|
|
CantidadPendiente = If(Dr1("ExistenciaFinal").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("ExistenciaFinal").ToString.ToDecimal)
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, CveVentaDetalle:=Dr("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
|
|
|
|
CantidadSaldo -= CantidadPendiente
|
|
Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente
|
|
If CantidadSaldo <= 0 Then Exit For
|
|
Next
|
|
|
|
If ErrorMovInv Then Exit For
|
|
|
|
End If
|
|
|
|
End If
|
|
If ErrorMovInv Then Exit For
|
|
|
|
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, Modulo:="RE/G4")
|
|
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, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) 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
|
|
'' TERMINA: APARTADOS
|
|
|
|
' COMIENZA: GARANTIAS
|
|
If TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoMovimiento = 1 Then
|
|
|
|
Dim CveAlmacenGarantia As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero()
|
|
Dim DtGarantias As DataTable = Nothing
|
|
|
|
If ObjAcumuladores.GetGarantiasDetalle(CveVentaSurtir) Then
|
|
DtGarantias = ObjAcumuladores.DtResultados.Copy()
|
|
End If
|
|
|
|
If DtGarantias IsNot Nothing AndAlso DtGarantias.Rows.Count > 0 AndAlso CveAlmacenGarantia > 0 Then
|
|
CveMovimientoGarantia = ObjInventario.AddMovimiento(CveAlmacenGarantia, 2, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, Modulo:="RE/G5")
|
|
FolioGarantia = ObjInventario.Folio
|
|
|
|
For Each RowGarantia As DataRow In DtGarantias.Rows
|
|
Dim CvePS = RowGarantia("CvePS").ToString().ToEntero()
|
|
Dim CveTamaño As Integer = RowGarantia("CveTamaño").ToString().ToEntero()
|
|
Dim CveUM As Integer = RowGarantia("CveUnidadMedida").ToString().ToEntero()
|
|
Dim PU As Double = RowGarantia("Importe").ToString().ToDouble() ' / RowGarantia("Cantidad").ToString().ToDouble()
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU, -1) 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
|
|
End If
|
|
' TERMINA: GARANTIAS
|
|
|
|
' COMIENZA: VIRTUAL
|
|
If TipoDocto.Contiene("Ing") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
|
|
|
|
Dim DtPSVirtual As New DataTable("DtTamanios")
|
|
DtPSVirtual.Columns.Add(New DataColumn("CvePS", GetType(Integer)))
|
|
DtPSVirtual.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
|
|
DtPSVirtual.Columns.Add(New DataColumn("PU", GetType(Decimal)))
|
|
DtPSVirtual.Columns.Add(New DataColumn("CveUM", GetType(Integer)))
|
|
|
|
Dim DtTamanios As DataTable = Nothing
|
|
|
|
If ObjAcumuladores.TamañoGet(-1, UsuarioActual.CveEmpresa) Then
|
|
DtTamanios = ObjAcumuladores.DtResultados.Copy()
|
|
End If
|
|
|
|
Dim CveConceptoMovimientoVirtual As Integer = -1
|
|
Dim CveAlmacenVirtual As Integer = -1
|
|
Dim CveMovimientoRelacionadoVirtual As Integer = -1
|
|
|
|
If TipoMovimiento = 1 Then
|
|
For Each GvRow As GridViewRow In GvDatos.Rows
|
|
If GvRow.RowType = DataControlRowType.DataRow Then
|
|
|
|
For Each Tam As DataRow In DtTamanios.Rows
|
|
If Tam("CveTamaño").ToString() = GvRow.DataKey("CveTamaño") Then
|
|
Dim CvePSCargo = Tam("CvePSCargo").ToString().ToEntero()
|
|
Dim Row As DataRow = DtPSVirtual.NewRow()
|
|
Row("CvePS") = CvePSCargo
|
|
Row("Cantidad") = GvRow.FCTextBox("TbCantidadF").Text.ToDecimal()
|
|
Row("PU") = 0
|
|
Row("CveUM") = GvRow.DataKey("CveUM").ToEntero()
|
|
|
|
DtPSVirtual.Rows.Add(Row)
|
|
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
Next
|
|
CveConceptoMovimientoVirtual = 3
|
|
CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero()
|
|
|
|
ElseIf TipoMovimiento = 2 Then
|
|
Dim CveMovimientoSalidaDev As Integer = -1
|
|
If ObjInventario.GetInv_Mov(CveVentaSurtir, UsuarioActual.CveEmpresa) Then
|
|
Dim RowMovimiento As DataRow = ObjInventario.DtResultados.FiltroPrimero("CvePS IS NULL AND CveTipoAlmacen = 24 AND CveConcepto = 3 AND CveVenta > 0")
|
|
CveMovimientoSalidaDev = RowMovimiento("CveMovimiento").ToString().ToEntero()
|
|
CveAlmacenVirtual = RowMovimiento("CveAlmacen").ToString().ToEntero()
|
|
CveMovimientoRelacionadoVirtual = CveMovimientoSalidaDev
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
'CARGA CONCEPTOS DEVUELTOS EN LA VENTA
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaDev, UsuarioActual.CveEmpresa) Then
|
|
DtPSVirtual = ObjInventario.DtResultados.Copy()
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
CveConceptoMovimientoVirtual = 18
|
|
End If
|
|
|
|
If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then
|
|
CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1,
|
|
Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveMovimientoRelacionado:=CveMovimientoRelacionadoVirtual, Modulo:="RE/G6")
|
|
FolioVirtual = ObjInventario.Folio
|
|
|
|
If CveMovimientoVirtual > 0 Then
|
|
For Each RowUsado As DataRow In DtPSVirtual.Rows
|
|
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
|
|
Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble()
|
|
Dim PU As Double = RowUsado("PU").ToString().ToDouble()
|
|
Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero()
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) 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
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If DtPSVirtual.Rows.Count = 0 Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
' TERMINA: VIRTUAL
|
|
|
|
If Not ErrorMovInv Then
|
|
Dim ConceptoMovimiento = 3
|
|
ConceptoMovimiento = If(TipoMovimiento = 1, ConceptoMovimiento, 18)
|
|
ConceptoMovimiento = If(CveAlmacenTraspasoDestino > 0, 8, ConceptoMovimiento)
|
|
|
|
Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero
|
|
|
|
'DEVOLUCION REMISION
|
|
If TipoMovimiento = 2 And TipoDocto = "Rem" Then
|
|
ConceptoMovimiento = 8
|
|
Almacen1 = CveAlmacenTraspasoDestino
|
|
CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero
|
|
End If
|
|
|
|
'CANCELACION DE DEVOLUCION
|
|
If TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1 Then
|
|
ConceptoMovimiento = 3
|
|
Almacen1 = DdlAlmacen.SelectedValue.ToEntero
|
|
CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero
|
|
End If
|
|
|
|
CveMovimiento = ObjInventario.AddMovimiento(Almacen1, 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, Modulo:="RE/G7")
|
|
Folio = ObjInventario.Folio
|
|
|
|
'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN)
|
|
'If Not (CveContrato > 0 And CveAlmacenTraspasoDestino > 0) Then
|
|
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:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) 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
|
|
|
|
'ES EL MOVIMIENTO PRINCIPAL
|
|
CantidadPendiente = 0
|
|
Dim Cont As Integer = 0
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal
|
|
If CantidadPendiente > 0 Then
|
|
Dim PU As Decimal = 0
|
|
|
|
'SI FUE POR SERIELOTE
|
|
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
|
|
DtDetalleLote = DtDatosDetalleLote.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 AndAlso DtExistencias IsNot Nothing Then
|
|
PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal
|
|
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
|
|
ElseIf DtDetalleLote.Rows.Count > 0 Then
|
|
For Each Dr1 As DataRow In DtDetalleLote.Rows
|
|
If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then
|
|
PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").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 AndAlso DtExistencias IsNot Nothing Then
|
|
PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal
|
|
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
|
|
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) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
Cont += 1
|
|
End If
|
|
Next
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
'End If
|
|
|
|
|
|
'ENTRADA POR TRASPASO CUANDO ES REMISION
|
|
If Not ErrorMovInv Then
|
|
If CveAlmacenTraspasoDestino > 0 AndAlso Not (TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1) 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, Modulo:="RE/G8")
|
|
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, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, EsInterno:=EsInterno) 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 IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero
|
|
Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero
|
|
Dim IdCtaContable As Integer = 0
|
|
Dim CveCuenta As Integer = 0
|
|
If tmpCostos.Rows.Count > 0 Then
|
|
|
|
|
|
If ObjVentas.GetVenta(CveVentaSurtir, UsuarioActual.CveEmpresa) Then
|
|
Dim Fecha As Date = TxtFecha.Text.ToDate ' If(TipoMovimiento <> 1, TxtFecha.Text.ToDate, ObjVentas.DtResultados(0)("Fecha").ToString.ToDate)
|
|
Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero
|
|
Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString
|
|
Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString
|
|
Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL()
|
|
Dim TotalCostoAcumulado As Decimal = 0
|
|
Dim cont As Integer = 1
|
|
|
|
Dim ValorMultiplicador = 1
|
|
|
|
If TipoMovimiento = 1 Then
|
|
ValorMultiplicador = 1
|
|
ElseIf TipoMovimiento = 2 Then
|
|
ValorMultiplicador = -1
|
|
ElseIf TipoMovimiento = 2 AndAlso TipoDocto.Contiene({"Dev"}) And (EsDevolucionVenta = 1) Then
|
|
ValorMultiplicador = 1
|
|
End If
|
|
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
'Se agrega movimiento separado por la cuenta de ventas (ER)
|
|
For Each RowInv As DataRow In tmpCostos.Rows
|
|
ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL()
|
|
TotalCostoAcumulado += ValorInventario
|
|
|
|
'cuando es el último movimiento y hay diferencias en los importes
|
|
If cont = DtCostos.FiltraParametros("", "", {"CveClasificacion"}).Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then
|
|
ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado)
|
|
End If
|
|
|
|
'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString)
|
|
IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
|
|
CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
|
|
|
|
If Not ErrorMovInv Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
cont += 1
|
|
Next
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorMultiplicador * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * TotalCosto, CveCuenta:=CveCuentaAlmacen) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
'AutoConta - El movimiento 1 es el de Venta
|
|
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
|
|
|
|
If AutoConta And Not ErrorMovInv Then
|
|
Dim ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
|
|
|
|
If IdCtaContable > 0 Then
|
|
If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
|
|
Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico")
|
|
End If
|
|
Else
|
|
Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
ObjContPaq.Dispose()
|
|
End If
|
|
|
|
Else
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un Error al ingresar las prepolizas"
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
'DEVOLUCION APARTADOS
|
|
If Not ErrorMovInv Then
|
|
If TipoMovimiento = 2 Then
|
|
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, Modulo:="RE/G9")
|
|
FolioSalida = ObjInventario.Folio
|
|
CveAlmacenApartado = Dr("CveAlmacen").ToString.ToEntero
|
|
|
|
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)
|
|
End If
|
|
|
|
If Not CveMovimientoSalidaApartado > 0 Then
|
|
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.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) 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, Modulo:="RE/G10")
|
|
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.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) 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
|
|
|
|
'QUEMA DEVOLUCION | QUEMA = LA QUITA DE PENDIENTE POR RECIBIR (DEVOLVER)
|
|
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 And EsDevolucionVenta = 0 Then
|
|
If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, CveVentaSurtir) Then
|
|
TextoError = "Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar."
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
'AGREGA BITACORA A VENTA
|
|
If Not ErrorMovInv Then
|
|
Dim MensajeBitacora = If(TipoMovimiento = 1, "Surtida", "Devuelta")
|
|
If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: <a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a>", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaSurtir) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
ErrorMovInv = True
|
|
OnError("Ocurrió un error al guardar", ex)
|
|
End Try
|
|
|
|
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)))
|
|
|
|
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
|
|
|
|
If CveMovimientoGarantia > 0 Then
|
|
Msg.AppendFormat("<br/>Movimiento de Entrada (garantías): <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a></b>", CveMovimientoGarantia, FolioGarantia)
|
|
Msg.AppendFormat("<br/><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoGarantia)))
|
|
End If
|
|
|
|
If CveMovimientoVirtual > 0 Then
|
|
Msg.AppendFormat("<br/><br/> Movimiento de Salida del Almacen Virtual: ")
|
|
Msg.AppendFormat("<b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a></b>", CveMovimientoVirtual, FolioVirtual)
|
|
Msg.AppendFormat("<br/><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtual)))
|
|
End If
|
|
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
Limpia()
|
|
CargaPendientes()
|
|
Else
|
|
ObjInventario.RollBack()
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
|
|
ObjAcumuladores.Dispose()
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
ObjVentas.Dispose()
|
|
ObjEventos.Dispose()
|
|
|
|
End Sub
|
|
|
|
Private Sub GuardaTraspaso()
|
|
|
|
'OBLIGA A SURTIR TODO
|
|
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
|
|
|
|
'VALIDA TRANSITORIO
|
|
If ChkTransitorio.Checked Then
|
|
If TxtResponsable.Text.Trim = "" Then
|
|
Alert("Debe seleccionar un responsable para el traspaso transitorio.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);")
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlAlmacenTransitorio.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Debe seleccionar un almacen transitorio.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);")
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
Dim ObjInventario As New ClsInventarios : ObjInventario.IniciaTransacSQL()
|
|
Dim CveMovimientoSalida As Integer
|
|
Dim ConceptoMovimiento = 0
|
|
Dim FolioSalida As Integer
|
|
Dim CveMovimientoEntrada As Integer
|
|
Dim FolioEntrada As Integer
|
|
Dim ErrorMovInv As Boolean
|
|
Dim DtDetalle As New DataTable
|
|
Dim DtDetalleLote 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.ToDecimal
|
|
End If
|
|
Index += 1
|
|
Next
|
|
|
|
'VALIDA SI HUBO CAMBIOS EN LA EXISTENCIA
|
|
Dim DtDatosTraspaso As New DataTable
|
|
If ObjInventario.EntregaAlmacenTraspasosGet(CveTraspasoSurtir) Then
|
|
DtDatosTraspaso = ObjInventario.DtResultados
|
|
End If
|
|
Dim CantidadGV = GvDatos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDecimal)
|
|
If DtDatos.SUM("CantidadF") <> DtDatosTraspaso.SUM("CantidadF") Then
|
|
ObjInventario.RollBack()
|
|
ObjInventario.Dispose()
|
|
CargaTraspasoPorSurtir(CveTraspasoSurtir)
|
|
CargaPendientes()
|
|
Alert("Ha sido cambiada la informacion de existencias del traspaso actual. Por favor verifique.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'VALIDA QUE EL TRASPASO SIGA VIGENTE
|
|
If ObjInventario.AddTrasladoSolicitudGet(CveTraspasoSurtir, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 AndAlso ObjInventario.DtResultados.Rows(0)("CveTrasladoEstatus").ToString = "2" Then
|
|
ObjInventario.RollBack()
|
|
ObjInventario.Dispose()
|
|
CargaTraspasoPorSurtir(CveTraspasoSurtir)
|
|
CargaPendientes()
|
|
Alert("Ha sido cambiada la informacion del traspaso actual. Por favor verifique.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'VALIDA ALMACENES
|
|
Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero
|
|
Dim Almacen2 = CveAlmacenTraspasoDestino
|
|
If Almacen1 <= 0 Or Almacen2 <= 0 Then
|
|
Alert("Ocurrió un error al obtener los almacenes del movimiento. Por favor recargue y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
ObjInventario.RollBack()
|
|
ObjInventario.Dispose()
|
|
Exit Sub
|
|
End If
|
|
|
|
'VERIFICAR EXISTENCIA
|
|
Dim StrXML As New StringBuilder
|
|
StrXML.Append("<conceptos>")
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
If Dr("CantidadGV").ToString.ToDecimal > 0 Then
|
|
If Dr("Inv_CveMetodoInventario").ToString = "5" Then
|
|
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
|
|
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
StrXML.AppendFormat("<concepto CvePS=""{0}"" CveUM=""{1}"" Cantidad= ""{2}"" Serie=""{3}"" ></concepto>", Dr1("CvePS"), Dr1("CveUM"), 1, Dr1("SerieLote"))
|
|
Next
|
|
ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then
|
|
DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec")))
|
|
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
StrXML.AppendFormat("<concepto CvePS=""{0}"" CveUM=""{1}"" Cantidad= ""{2}"" Serie=""{3}"" ></concepto>", Dr1("CvePS"), Dr1("CveUM"), DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'"), Dr1("Lote"))
|
|
Next
|
|
Else
|
|
StrXML.AppendFormat("<concepto CvePS=""{0}"" CveUM=""{1}"" Cantidad= ""{2}"" Serie=""{3}"" ></concepto>", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), "-1")
|
|
End If
|
|
End If
|
|
Next
|
|
StrXML.Append("</conceptos>")
|
|
|
|
Dim TieneErrorExistencia = False
|
|
If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), If(TipoEntrega = 2, 1, -1), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
If ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
TieneErrorExistencia = True
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
TextoError += $"<b> - {Dr("CodigoPS")}</b> Existencia: {Dr("Existencia").ToString.ToDecimal.ToString("#,##0.##")} <br/>"
|
|
Next
|
|
End If
|
|
Else
|
|
TieneErrorExistencia = True
|
|
End If
|
|
|
|
If TieneErrorExistencia Then
|
|
ObjInventario.RollBack()
|
|
ObjInventario.Dispose()
|
|
If TextoError.Length > 0 Then
|
|
Alert($" Lo(s) siguiente(s) Productos <b>no tienen</b> existencia suficiente:<br/><br/>{TextoError}", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
|
|
'SALIDA POR TRASPASO
|
|
If Not ErrorMovInv Then
|
|
ConceptoMovimiento = 26
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:="",
|
|
CveContrato:=-1, CveAlmacenDestino:=CveAlmacenTraspasoDestino, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT")
|
|
FolioSalida = ObjInventario.Folio
|
|
If CveMovimientoSalida > 0 Then
|
|
Dim CantidadPendiente As Decimal = 0
|
|
|
|
For Each Dr As DataRow In DtDatos.Rows
|
|
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
|
|
DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
|
|
If DtDetalle.Rows.Count > 0 Then 'SI FUE POR SERIELOTE
|
|
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=-1, CveContratoDetalle:=Dr("CveContratoDetalle").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
|
|
ElseIf DtDetalleLote.Rows.Count > 0 Then 'SI FUE POR LOTE BATCH
|
|
For Each Dr1 As DataRow In DtDetalleLote.Rows
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr1("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=-1, CveContratoDetalle:=Dr("CveContratoDetalle").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 'NORMAL
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("CantidadGV").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, -1, CveContratoDetalle:=Dr("CveContratoDetalle").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
|
|
Next
|
|
Else
|
|
TextoError = "Ocurrió un error al generar el movimiento de salida."
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
'ENTRADA POR TRASPASO
|
|
If Not ErrorMovInv Then
|
|
'sino es transitorio, los transitorios, ya no se hace otro movimiento
|
|
If Not ChkTransitorio.Checked Then
|
|
ConceptoMovimiento = 27 ' If(ChkTransitorio.Checked, 2, 27)
|
|
Almacen2 = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, CveAlmacenTraspasoDestino)
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(Almacen2, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim,
|
|
Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalida, CveAlmacenDestino:=CveAlmacenTraspasoDestino,
|
|
Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT1")
|
|
FolioEntrada = ObjInventario.Folio
|
|
If CveMovimientoEntrada > 0 Then
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
Else
|
|
TextoError = "Ocurrió un error al generar el movimiento de entrada"
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
'MARCA SOLICITUD CON EL MOVIMIENTO GENERADO
|
|
If Not ErrorMovInv Then
|
|
If Not ObjInventario.UpdateTraspasoSolicitudMovimiento(CveTraspasoSurtir, CveMovimientoSalida) Then
|
|
TextoError = "Ocurrió un error al vincular los movimientos con la solicitud de traspaso. Por favor verifique y vuelva a intentar"
|
|
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>", CveMovimientoSalida, FolioSalida)
|
|
Msg.AppendFormat("<br/><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Movimiento</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
|
|
|
|
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)))
|
|
|
|
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 = ""
|
|
LbObservaciones.Text = ""
|
|
'LbFolio.Text = ""
|
|
HLFolio.Text = ""
|
|
|
|
'DATOS DEL MOVIMINETO
|
|
TxtObservaciones.Text = ""
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
DdlAlmacen.SelectedValueExist(-1)
|
|
CargaFolios()
|
|
|
|
'VARIABLES GENERALES
|
|
CveVentaSurtir = -1
|
|
DtDatosDetalle = Nothing
|
|
DtDatosDetalleLote = Nothing
|
|
DtDatos = Nothing
|
|
|
|
DivTipoCambioAdvertencia.Visible = False
|
|
|
|
'TRASPASO
|
|
DivTransitorio1.Visible = False
|
|
ChkTransitorio.Checked = False
|
|
TxtResponsable.Text = ""
|
|
DivTransitorio2.Visible = False
|
|
|
|
LbSurtida.Visible = False
|
|
TimmerRefresh.Enabled = True
|
|
UpGenerales.Update()
|
|
CargaGvDatos()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " TRASPASO - TRANSITORIO "
|
|
Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs)
|
|
|
|
TxtResponsable.Text = ""
|
|
DivTransitorio2.Visible = ChkTransitorio.Checked
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#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("CvePS", GetType(Integer))
|
|
DtSeccionAlmacen.Columns.Add("SeccionAlmacen", GetType(String))
|
|
DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer))
|
|
End Sub
|
|
Private Sub CargaDdlAlmacen()
|
|
DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlSeccionAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSeccionAlmacen.DataBind()
|
|
End Sub
|
|
Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs)
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
|
|
If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
|
|
Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
CantidadTotal = gvRow.FCTextBox("TbCantidadF").Text.ToDecimal
|
|
IndexSeccionAlmacen = gvRow.RowIndex
|
|
CvePS = gvRow.DataKey("CvePS").ToEntero
|
|
CargaSeccionAlmacen()
|
|
RegistraScript("$('#DModalSeccionAlmacen').modal()")
|
|
End Sub
|
|
|
|
Private Sub CargaSeccionAlmacen()
|
|
Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen")
|
|
GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}")
|
|
GvSeccion.DataBind()
|
|
|
|
TxtCantidadSeccion.Text = ""
|
|
DdlSeccionAlmacen.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
|
|
GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = False
|
|
GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "Cuenta con sección almacen"
|
|
|
|
Else
|
|
GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = True
|
|
GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = ""
|
|
|
|
End If
|
|
|
|
If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then
|
|
DdlAlmacen.Enabled = False
|
|
DdlAlmacen.ToolTip = "Cuenta con sección almacen"
|
|
Else
|
|
DdlAlmacen.Enabled = True
|
|
DdlAlmacen.ToolTip = ""
|
|
End If
|
|
|
|
UpModalSeccionAlmacen.Update()
|
|
UpDatos.Update()
|
|
UpGenerales.Update()
|
|
End Sub
|
|
|
|
Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ObjInv As New ClsInventarios
|
|
Dim CantidadDisponible As Decimal = 0
|
|
If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacen.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 = {DdlSeccionAlmacen.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
|
|
|
|
Dim Row As DataRow = Nothing
|
|
DtSeccionAlmacen.AcceptChanges()
|
|
Row = DtSeccionAlmacen.NewRow
|
|
Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal
|
|
Row("IndexSeccionAlmacen") = IndexSeccionAlmacen
|
|
Row("CveSeccionAlmacen") = DdlSeccionAlmacen.SelectedValue.ToEntero
|
|
Row("SeccionAlmacen") = DdlSeccionAlmacen.SelectedItem.Text
|
|
Row("CvePS") = CvePS
|
|
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
|
|
|
|
Protected Sub LnkVerSecciones_Click(sender As Object, e As EventArgs)
|
|
If Not CveVentaSurtir > 0 Then
|
|
Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then
|
|
Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjInv As New ClsInventarios
|
|
If ObjInv.GetExistenciaSeccionAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
GvVerSeccionesAlmacen.DataSource = ObjInv.DtResultados
|
|
End If
|
|
ObjInv.Dispose()
|
|
GvVerSeccionesAlmacen.DataBind()
|
|
UpVerSeccionesAlmacen.Update()
|
|
RegistraScript("$('#ModalVerSeccionesAlmacen').modal()")
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " GUIAS - SABE QUE ES PORQUE NO VEO QUE SE UTILIZE EN ALGUNA PARTE - EN MIRAS DE ELIMINAR - IPP 24 AGOSTO 2017 "
|
|
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
|
|
|
|
Private Sub GvDocs_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocs.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
Dim ImgDownLoad As Literal = e.Row.FCLiteral("HplDown")
|
|
Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString
|
|
Dim ArchivoRuta As String = ""
|
|
|
|
If Adjunto.Trim.Length > 0 Then
|
|
ArchivoRuta = UsuarioActual.Empresa.Ruta & "Documentacion\Ventas\" & Adjunto
|
|
Dim fi As New FileInfo(ArchivoRuta)
|
|
Dim linkDescarga As String = ""
|
|
If fi.Exists() Then
|
|
linkDescarga = $"/Empresas/{UsuarioActual.CveEmpresa}/Documentacion/ventas/{fi.Name}"
|
|
ImgDownLoad.Visible = True
|
|
ImgDownLoad.Text = String.Format(" <a class='btn btn-circle btn-sm blue' href='{0}' target='_black' ><i class='fa fa-download' title='Descargar documento'></i></a>", linkDescarga)
|
|
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
End Class
|