1832 lines
84 KiB
VB.net
1832 lines
84 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.IO.Packaging
|
|
Imports Extensiones
|
|
Partial Class Inventarios_PaquetesArmadoDesarmado
|
|
Inherits ClsPaginas
|
|
|
|
|
|
#Region " PROPIEDADES "
|
|
Public Property CveAlmacenArmado As Integer
|
|
Get
|
|
Return ViewState("CveAlmacenArmado").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAlmacenArmado") = value
|
|
End Set
|
|
End Property
|
|
Public Property CvePaqueteArmado() As Integer
|
|
Get
|
|
Return ViewState("CvePaqueteArmado").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePaqueteArmado") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveAlmacenDesarmado As Integer
|
|
Get
|
|
Return ViewState("CveAlmacenDesarmado").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAlmacenDesarmado") = value
|
|
End Set
|
|
End Property
|
|
Public Property CvePaqueteDesarmado() As Integer
|
|
Get
|
|
Return ViewState("CvePaqueteDesarmado").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePaqueteDesarmado") = 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 CveConsecSerieLote As Integer
|
|
Get
|
|
Return CType(ViewState("CveConsecSerieLote"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveConsecSerieLote") = 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 CveVendedor As Integer
|
|
Get
|
|
Return CType(ViewState("CveVendedor"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveVendedor") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveCliente As Integer
|
|
Get
|
|
Return CType(ViewState("CveCliente"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCliente") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property AplicaLotePaquete As Boolean
|
|
Get
|
|
Return CType(ViewState("AplicaLotePaquete"), Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("AplicaLotePaquete") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property AplicaCaducidadPaquete As Boolean
|
|
Get
|
|
Return CType(ViewState("AplicaCaducidadPaquete"), Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("AplicaCaducidadPaquete") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property AplicaSeriePaquete As Boolean
|
|
Get
|
|
Return CType(ViewState("AplicaSeriePaquete"), Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("AplicaSeriePaquete") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property DtSeriesDesarmado As DataTable
|
|
Get
|
|
Return CType(ViewState("DtSeriesDesarmado"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtSeriesDesarmado") = value
|
|
End Set
|
|
End Property
|
|
'1 ARMADO
|
|
'2 DESARMADO
|
|
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 DtExistenciasDesarmado As DataTable
|
|
Get
|
|
Return CType(ViewState("DtExistenciasDesarmado"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtExistenciasDesarmado") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DtDatosArmado As DataTable
|
|
Get
|
|
If ViewState("DtDatosArmado") Is Nothing Then
|
|
ViewState("DtDatosArmado") = New DataTable
|
|
End If
|
|
|
|
Return CType(ViewState("DtDatosArmado"), DataTable)
|
|
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatosArmado") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DtDatosDesArmado As DataTable
|
|
Get
|
|
If ViewState("DtDatosDesArmado") Is Nothing Then
|
|
ViewState("DtDatosDesArmado") = New DataTable
|
|
End If
|
|
|
|
Return CType(ViewState("DtDatosDesArmado"), DataTable)
|
|
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatosDesArmado") = 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()
|
|
|
|
If Request("CvePS") IsNot Nothing Then
|
|
DdlPaqueteArmado.SelectedValueExist(Request("CvePS").ToString())
|
|
End If
|
|
|
|
If Request("Cantidad") IsNot Nothing Then
|
|
TxtCantidadArmado.Text = Request("Cantidad").ToString()
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " INICIALIZA VALORES "
|
|
Private Sub InicializaValores()
|
|
CreaDtSeriesDesarmado()
|
|
|
|
|
|
'CARGA PS PAQUETES
|
|
DdlPaqueteArmado.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros("CvePSPaquete > 0")
|
|
DdlPaqueteArmado.DataBind()
|
|
DdlPaqueteArmado.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlPaqueteDesarmado.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros("CvePSPaquete > 0")
|
|
DdlPaqueteDesarmado.DataBind()
|
|
DdlPaqueteDesarmado.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
|
|
DdlAlmacenArmado.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen = 1")
|
|
DdlAlmacenArmado.DataBind()
|
|
DdlAlmacenArmado.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlAlmacenDesarmado.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen = 1")
|
|
DdlAlmacenDesarmado.DataBind()
|
|
DdlAlmacenDesarmado.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
TxtFechaArmado.Text = NowADS().ToShortDateString
|
|
TxtFechaDesarmado.Text = NowADS().ToShortDateString
|
|
|
|
DdlVendedorArmado.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
|
|
DdlVendedorArmado.DataBind()
|
|
DdlVendedorArmado.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlClienteArmado.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1)
|
|
DdlClienteArmado.DataBind()
|
|
DdlClienteArmado.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
RowClienteArmado.Visible = Not UsuarioActual.Empresa.Funcionalidad(146) = "1"
|
|
|
|
DdlVendedorDesarmado.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
|
|
DdlVendedorDesarmado.DataBind()
|
|
DdlVendedorDesarmado.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlClienteDesarmado.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1)
|
|
DdlClienteDesarmado.DataBind()
|
|
DdlClienteDesarmado.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
RowClienteDesarmado.Visible = Not UsuarioActual.Empresa.Funcionalidad(146) = "1"
|
|
|
|
UpGeneralesArmado.Update()
|
|
UpGeneralesDesarmado.Update()
|
|
|
|
CreaDtDetalle()
|
|
|
|
CveVendedor = -1
|
|
CveCliente = -1
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " APARTADOS "
|
|
Protected Sub DdlAlmacenArmado_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
RowApartadosArmado.Visible = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveAlmacen = {DdlAlmacenArmado.SelectedValue.ToEntero} AND CveTipoAlmacen = 9").ToEntero > 0
|
|
UpFiltraArmado.Update()
|
|
End Sub
|
|
Protected Sub DdlAlmacenDesarmado_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
RowApartadosDesarmado.Visible = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveAlmacen = {DdlAlmacenDesarmado.SelectedValue.ToEntero} AND CveTipoAlmacen = 9").ToEntero > 0
|
|
UpFiltraDesarmado.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " PROCESAR - VERIFICAR EXISTENCIAS "
|
|
Protected Sub BtnVerificarExistenciasArmado_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
AplicaSeriePaquete = False
|
|
AplicaLotePaquete = False
|
|
AplicaCaducidadPaquete = False
|
|
|
|
TipoMovimiento = 1
|
|
Limpia(TipoMovimiento)
|
|
|
|
Dim ObjProductosServicios As New ClsProductosServicios
|
|
DtDatosArmado = New DataTable
|
|
|
|
Dim drP As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPaqueteArmado.SelectedValue.ToEntero).FiltroPrimero("")
|
|
|
|
Dim CveUMTemp As Integer = drP("CveUM").ToString.ToEntero
|
|
If ObjProductosServicios.GetPaqueteDetalle(DdlPaqueteArmado.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, CveUMTemp, TxtCantidadArmado.Text.ToDouble, DdlAlmacenArmado.SelectedValue.ToEntero, TxtFechaArmado.Text.ToDate, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) Then
|
|
DtDatosArmado = ObjProductosServicios.DtResultados.FiltraParametros("CveTipoPS = 2").Copy
|
|
Else
|
|
DtDatosArmado = Nothing
|
|
Alert("Ocurrió un error al obtener los componentes del paquete. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjProductosServicios.Dispose()
|
|
|
|
If DtDatosArmado Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
CveVendedor = If(RowApartadosArmado.Visible, DdlVendedorArmado.SelectedValue.ToEntero, -1)
|
|
CveCliente = If(RowClienteArmado.Visible, DdlClienteArmado.SelectedValue.ToEntero, -1)
|
|
|
|
|
|
If DtDatosArmado.Rows.Count > 0 Then
|
|
For Each Dr As DataRow In DtDatosArmado.Rows
|
|
Dr("Cantidad") = Dr("Cantidad").ToString.ToDecimal * TxtCantidadArmado.Text.ToDecimal
|
|
Next
|
|
End If
|
|
|
|
Dim TextoExistencias As String = "No hay existencia suficiente de los siguientes componentes: <br/><br/>"
|
|
Dim ErrorExistencias As Boolean = False
|
|
For Each Dr As DataRow In DtDatosArmado.Rows
|
|
If Dr("CantidadDisponible2").ToString.ToDecimal < Dr("Cantidad").ToString.ToDecimal Then
|
|
TextoExistencias += $"<br/>- Componente: <b>""{Dr("CodigoPS")}""</b>."
|
|
ErrorExistencias = True
|
|
End If
|
|
Next
|
|
|
|
|
|
If ErrorExistencias Then
|
|
Alert(TextoExistencias, TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
AplicaSeriePaquete = CBool(drP("AplicaSerie"))
|
|
AplicaLotePaquete = CBool(drP("AplicaLote"))
|
|
AplicaCaducidadPaquete = CBool(drP("AplicaCaducidad"))
|
|
BtnGuadarArmado.Visible = True
|
|
End If
|
|
|
|
|
|
|
|
|
|
If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then
|
|
DivSeriesPaqueteArmado.Visible = True
|
|
Dim Dt As New DataTable
|
|
Dt.Columns.Add("Row", GetType(Integer))
|
|
Dt.Columns.Add("Serie", GetType(String))
|
|
Dt.Columns.Add("Lote", GetType(String))
|
|
Dt.Columns.Add("FechaCaducidad", GetType(Date))
|
|
|
|
For index = 1 To TxtCantidadArmado.Text.ToEntero
|
|
Dim Row = Dt.NewRow
|
|
Row("Row") = index
|
|
Row("Serie") = ""
|
|
Row("Lote") = ""
|
|
Row("FechaCaducidad") = MinFecha
|
|
Dt.Rows.Add(Row)
|
|
Next
|
|
|
|
GvSeriesPaqueteArmado.Columns(1).Visible = AplicaSeriePaquete
|
|
GvSeriesPaqueteArmado.Columns(2).Visible = AplicaLotePaquete
|
|
GvSeriesPaqueteArmado.Columns(3).Visible = AplicaCaducidadPaquete
|
|
|
|
GvSeriesPaqueteArmado.DataSource = Dt
|
|
GvSeriesPaqueteArmado.DataBind()
|
|
|
|
End If
|
|
|
|
|
|
|
|
UpSeriesPaqueteArmado.Update()
|
|
|
|
CvePaqueteArmado = DdlPaqueteArmado.SelectedValue.ToEntero
|
|
CveAlmacenArmado = DdlAlmacenArmado.SelectedValue.ToEntero
|
|
|
|
GvDatosArmado.DataSource = DtDatosArmado
|
|
GvDatosArmado.DataBind()
|
|
|
|
GvDatosArmado.Columns(4).Visible = DtDatosArmado.MAX("AplicaSerie", "") = "True"
|
|
GvDatosArmado.Columns(5).Visible = DtDatosArmado.MAX("AplicaSeccion") = "True"
|
|
GvDatosArmado.Columns(7).Visible = DtDatosArmado.MAX("AplicaLote") = "True"
|
|
GvDatosArmado.Columns(8).Visible = DtDatosArmado.MAX("AplicaCaducidad") = "True"
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
|
|
GvDatosArmado.Columns(6).Visible = True
|
|
GvDatosArmado.Columns(7).Visible = False
|
|
GvDatosArmado.Columns(8).Visible = False
|
|
End If
|
|
|
|
|
|
'If ErrorExistencias Then
|
|
' GvDatosArmado.Columns(4).Visible = False
|
|
'End If
|
|
|
|
UpDatosArmado.Update()
|
|
UpGeneralesArmado.Update()
|
|
End Sub
|
|
Protected Sub BtnVerificarExistenciasDesarmado_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
DvDesArmadoCaducidad.Visible = False
|
|
DvDesArmadoLote.Visible = False
|
|
DvDesArmadoSerie.Visible = False
|
|
|
|
DtDatosDetalle.Clear()
|
|
BtnGuadarDesarmado.Visible = False
|
|
TotalDesarmado.Visible = False
|
|
AplicaSeriePaquete = False
|
|
TxtSerieDesarmado.Text = ""
|
|
CvePaqueteDesarmado = -1
|
|
TipoMovimiento = 2
|
|
|
|
Limpia(TipoMovimiento)
|
|
|
|
DtSeriesDesarmado.Clear()
|
|
GvDatosDesarmado.Columns(4).Visible = False
|
|
DivSeriesPaqueteDesarmado.Visible = False
|
|
GvSeriesPaqueteDesarmado.DataBind()
|
|
BtnAgregarSerieDesarmado.Enabled = True
|
|
|
|
|
|
Dim drP As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPaqueteDesarmado.SelectedValue.ToEntero).FiltroPrimero("")
|
|
|
|
Dim CveUMTemp As Integer = drP("CveUM").ToString.ToEntero
|
|
CveVendedor = If(RowApartadosDesarmado.Visible, DdlVendedorDesarmado.SelectedValue.ToEntero, -1)
|
|
CveCliente = If(RowClienteDesarmado.Visible, DdlClienteDesarmado.SelectedValue.ToEntero, -1)
|
|
Dim FechaFin As String = TxtFechaDesarmado.Text.ToDateTime.ToString("yyyy/MM/dd 23:59")
|
|
|
|
Dim ObjInventarios As New ClsInventarios
|
|
Dim Existencia As Decimal = ObjInventarios.GetExistenciasPS(DdlPaqueteDesarmado.SelectedValue.ToEntero, CveUMTemp, UsuarioActual.CveEmpresa, DdlAlmacenDesarmado.SelectedValue.ToEntero, FechaMovto:=FechaFin, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente))
|
|
Dim CostoPromedio As Decimal = ObjInventarios.GetCostoPS(DdlPaqueteDesarmado.SelectedValue.ToEntero, TxtCantidadDesarmado.Text.ToDecimal, DdlAlmacenDesarmado.SelectedValue.ToEntero, "-1", FechaFin.ToDate, CveTipoAlmacen:=-1)
|
|
ObjInventarios.Dispose()
|
|
|
|
If Existencia - TxtCantidadDesarmado.Text.ToDouble < 0 Then
|
|
GvDatosDesarmado.Columns(4).Visible = False
|
|
Alert($"No hay existencia suficiente del paquete <b>""{DdlPaqueteDesarmado.SelectedItem.Text}""</b> para desarmar. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
Else
|
|
AplicaSeriePaquete = CBool(drP("AplicaSerie"))
|
|
AplicaLotePaquete = CBool(drP("AplicaLote"))
|
|
AplicaCaducidadPaquete = CBool(drP("AplicaCaducidad"))
|
|
End If
|
|
|
|
|
|
LbTotal.Text = (CostoPromedio * TxtCantidadDesarmado.Text.ToDecimal).FormatoNumero
|
|
|
|
|
|
Dim ObjProductosServicios As New ClsProductosServicios
|
|
DtDatosDesArmado = New DataTable
|
|
|
|
|
|
If ObjProductosServicios.GetPaqueteDetalle(DdlPaqueteDesarmado.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, CveUMTemp, TxtCantidadDesarmado.Text.ToDouble, DdlAlmacenArmado.SelectedValue.ToEntero, TxtFechaArmado.Text.ToDate, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) Then
|
|
DtDatosDesArmado = ObjProductosServicios.DtResultados.FiltraParametros("CveTipoPS = 2").Copy
|
|
Else
|
|
DtDatosDesArmado = Nothing
|
|
Alert("Ocurrió un error al obtener los componentes del paquete. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjProductosServicios.Dispose()
|
|
|
|
If DtDatosDesArmado Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
If DtDatosDesArmado.Rows.Count > 0 Then
|
|
For Each Dr As DataRow In DtDatosDesArmado.Rows
|
|
Dr("Cantidad") = Dr("Cantidad").ToString.ToDecimal * TxtCantidadDesarmado.Text.ToDecimal
|
|
Next
|
|
End If
|
|
|
|
If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then
|
|
|
|
DvDesArmadoCaducidad.Visible = AplicaSeriePaquete
|
|
DvDesArmadoLote.Visible = AplicaLotePaquete
|
|
DvDesArmadoSerie.Visible = AplicaCaducidadPaquete
|
|
|
|
GvSeriesPaqueteDesarmado.Columns(1).Visible = AplicaSeriePaquete
|
|
GvSeriesPaqueteDesarmado.Columns(2).Visible = AplicaLotePaquete
|
|
GvSeriesPaqueteDesarmado.Columns(3).Visible = AplicaCaducidadPaquete
|
|
|
|
DivSeriesPaqueteDesarmado.Visible = True
|
|
CreaDtSeriesDesarmado()
|
|
DtSeriesDesarmado.Clear()
|
|
|
|
GvSeriesPaqueteDesarmado.DataSource = DtSeriesDesarmado
|
|
GvSeriesPaqueteDesarmado.DataBind()
|
|
|
|
End If
|
|
UpSeriesPaqueteDesarmado.Update()
|
|
|
|
CvePaqueteDesarmado = DdlPaqueteDesarmado.SelectedValue.ToEntero
|
|
CveAlmacenDesarmado = DdlAlmacenDesarmado.SelectedValue.ToEntero
|
|
|
|
GvDatosDesarmado.DataSource = DtDatosDesArmado
|
|
GvDatosDesarmado.DataBind()
|
|
|
|
GvDatosArmado.Columns(4).Visible = DtDatosDesArmado.MAX("AplicaSerie", "") = "True"
|
|
GvDatosArmado.Columns(5).Visible = DtDatosDesArmado.MAX("AplicaSeccion") = "True"
|
|
GvDatosArmado.Columns(6).Visible = DtDatosDesArmado.MAX("AplicaLote") = "True"
|
|
GvDatosArmado.Columns(7).Visible = DtDatosDesArmado.MAX("AplicaCaducidad") = "True"
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
|
|
GvDatosArmado.Columns(6).Visible = True
|
|
GvDatosArmado.Columns(7).Visible = False
|
|
GvDatosArmado.Columns(8).Visible = False
|
|
End If
|
|
|
|
BtnGuadarDesarmado.Visible = True
|
|
|
|
TotalDesarmado.Visible = True
|
|
|
|
UpDatosDesarmado.Update()
|
|
UpGeneralesDesarmado.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " GUARDAR "
|
|
Protected Sub BtnGuadarArmado_Click(sender As Object, e As EventArgs)
|
|
If Not GvDatosArmado.Rows.Count > 0 Then
|
|
Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Guardar(1)
|
|
End Sub
|
|
|
|
Protected Sub BtnGuadarDesarmado_Click(sender As Object, e As EventArgs)
|
|
If Not GvDatosDesarmado.Rows.Count > 0 Then
|
|
Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Abs(LbTotal.Text.ToDecimal - LbTotalCalculado.Text.ToDecimal) > 0.01 Then
|
|
Alert("Los totales deben coincidir. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Guardar(2)
|
|
End Sub
|
|
|
|
Private Sub Guardar(Tipo As Integer)
|
|
|
|
|
|
'VALIDA SI EL COMPONENTE ES DE SERIE QUE SE INGRESEN TODAS LAS SERIES (CANTIDAD)
|
|
Select Case (Tipo)
|
|
Case 1 ' ARMADO
|
|
For Each gvr As GridViewRow In GvDatosArmado.Rows
|
|
If gvr.DataKey("AplicaSerie") = "True" Then
|
|
|
|
''If gvr.DataKey("Cantidad").ToEntero <> DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec"))).Rows.Count Then
|
|
'' Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
'' Exit Sub
|
|
''End If
|
|
'If gvr.FCTextBox("TxtSerie") Then
|
|
|
|
'End If
|
|
|
|
'If gvr.FCTextBox("TxtSerie").Text.Trim = "" Then
|
|
' Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
'End If
|
|
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
|
|
|
|
Dim DdlCaducidadProducto As DropDownList = gvr.FCDropDownList("DdlCaducidadProducto")
|
|
Dim ArrayCaducidad As String() = DdlCaducidadProducto.SelectedValue.Split("|"c)
|
|
Dim Lote As String = ArrayCaducidad(0)
|
|
Dim FechaCaducidad As String = ArrayCaducidad(1)
|
|
|
|
If gvr.DataKey("AplicaLote") = "True" Then
|
|
If Lote = "" Then
|
|
Alert("Es necesario ingresas todos los lotes de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If gvr.DataKey("AplicaCaducidad") = "True" Then
|
|
|
|
If FechaCaducidad.ToDate <= MinFecha Then
|
|
Alert("Es necesario ingresas todos las fechas de caducidad de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
End If
|
|
|
|
Else
|
|
If gvr.DataKey("AplicaLote") = "True" Then
|
|
If gvr.FCTextBox("TxtLote").Text.Trim = "" Then
|
|
Alert("Es necesario ingresas todos los lotes de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If gvr.DataKey("AplicaCaducidad") = "True" Then
|
|
|
|
If gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then
|
|
Alert("Es necesario ingresas todos las fechas de caducidad de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
Next
|
|
Case 2 ' DESARMADO
|
|
For Each gvr As GridViewRow In GvDatosDesarmado.Rows
|
|
|
|
If gvr.DataKey("AplicaSerie") = "True" Then
|
|
|
|
'If gvr.DataKey("AplicaSerie") = "True" Then
|
|
' 'If gvr.DataKey("Cantidad").ToEntero <> DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec"))).Rows.Count Then
|
|
' ' Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
' ' Exit Sub
|
|
' 'End If
|
|
'End If
|
|
|
|
If gvr.FCTextBox("Serie").Text.Trim = "" Then
|
|
Alert("Es necesario ingresas todas las series de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
End If
|
|
|
|
If gvr.DataKey("AplicaLote") = "True" Then
|
|
If gvr.FCTextBox("TxtLote").Text.Trim = "" Then
|
|
Alert("Es necesario ingresas todos los lotes de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If gvr.DataKey("AplicaCaducidad") = "True" Then
|
|
|
|
If gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then
|
|
Alert("Es necesario ingresas todos las fechas de caducidad de los componentes.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
Next
|
|
End Select
|
|
|
|
'VALIDA SI EL PAQUETE ES DE SERIE QUE SE INGRESEN TODAS LAS SERIES (CANTIDAD)
|
|
If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then
|
|
Select Case (Tipo)
|
|
Case 1 ' ARMADO
|
|
For Each gvr As GridViewRow In GvSeriesPaqueteArmado.Rows
|
|
|
|
If AplicaSeriePaquete Then
|
|
If gvr.FCTextBox("TxtSerie").Text.Trim = "" Then
|
|
Alert("Es necesario indicar las series del paquete a armar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If AplicaLotePaquete Then
|
|
If gvr.FCTextBox("TxtLote").Text.Trim = "" Then
|
|
Alert("Es necesario indicar los lotes del paquete a armar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If AplicaCaducidadPaquete Then
|
|
If gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then
|
|
Alert("Es necesario indicar fechas de caducidad validas del paquete a armar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
Case 2 ' DESARMADO
|
|
|
|
If TxtCantidadDesarmado.Text.ToEntero <> DtSeriesDesarmado.Rows.Count Then
|
|
Alert("Es necesario indicar las series, lotes o Fecha de caducidad del paquete a desarmar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
End Select
|
|
End If
|
|
|
|
|
|
|
|
Dim TextoError As New StringBuilder
|
|
If Tipo = 1 Then
|
|
Dim ObjInventarioVal As New ClsInventarios
|
|
Dim StrXML As New StringBuilder
|
|
StrXML.Append("<conceptos>")
|
|
Dim FechaCaducidad As Date
|
|
Dim Lote As String = ""
|
|
|
|
Dim TieneErrorExistencia As Boolean = False
|
|
|
|
For Each GvRow As GridViewRow In GvDatosArmado.Rows
|
|
|
|
FechaCaducidad = If(CBool(GvRow.DataKey("AplicaCaducidad")) AndAlso GvRow.FCTextBox("TxtCaducidad").ToString().ToDate > MinFecha, GvRow.FCTextBox("TxtCaducidad").Text.ToDate, MinFecha)
|
|
Lote = If(CBool(GvRow.DataKey("AplicaLote")), GvRow.FCTextBox("TxtLote").Text.Trim, "-1")
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
|
|
|
|
Dim DdlCaducidadProducto As DropDownList = GvRow.FCDropDownList("DdlCaducidadProducto")
|
|
Dim ArrayCaducidad As String() = DdlCaducidadProducto.SelectedValue.Split("|"c)
|
|
Lote = ArrayCaducidad(0)
|
|
FechaCaducidad = ArrayCaducidad(1).ToDate
|
|
|
|
End If
|
|
|
|
Dim Existencia As Decimal = ObjInventarioVal.GetExistenciasPS(GvRow.DataKey("CvePS").ToEntero, GvRow.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenArmado.SelectedValue.ToEntero(), FechaMovto:=TxtFechaArmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:="-1", Lote:=Lote, FechaCaducidad:=FechaCaducidad)
|
|
|
|
|
|
If GvRow.DataKey("Cantidad").ToDecimal > Existencia Then
|
|
TieneErrorExistencia = True
|
|
|
|
TextoError.AppendFormat("<b> - {0}</b> Existencia: {1:#,##0.##} <br/>", GvRow.DataKey("CodigoPS"), Existencia)
|
|
|
|
End If
|
|
|
|
''If Dr("CantidadGV").ToString().ToDecimal > 0 Then
|
|
'If CBool(GvRow.DataKey("AplicaSerie")) Then
|
|
' Alert("Aplica serie ")
|
|
' TieneErrorExistencia = True
|
|
' ' StrXML.AppendFormat("<concepto CvePS=""{0}"" CveUM=""{1}"" Cantidad= ""{2}"" CveSeccionAlmacen=""{3}"" Serie=""{4}"" Lote=""{5}"" FechaCaducidad=""{6}""></concepto>", GvRow.DataKey("CvePS"), GvRow.DataKey("CveUM"), 1, IfNull(Dr("CveSeccion"), -1), Dr1("Serie"), Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
|
|
|
|
'Else
|
|
' StrXML.AppendFormat("<concepto CvePS=""{0}"" CveUM=""{1}"" Cantidad= ""{2}"" CveSeccionAlmacen=""{3}"" Serie=""{4}"" Lote=""{5}"" FechaCaducidad=""{6}""></concepto>", GvRow.DataKey("CvePS"), GvRow.DataKey("CveUM"), GvRow.DataKey("Cantidad"), -1, "-1", Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
|
|
'End If
|
|
|
|
'End If
|
|
Next
|
|
|
|
'For Each Dr As DataRow In DtDatos.Rows
|
|
' FechaCaducidad = If(CBool(Dr("AplicaCaducidad")) AndAlso Dr("FechaCaducidad").ToString() <> "", Dr("FechaCaducidad").ToString().ToDate, MinFecha)
|
|
' Lote = If(CBool(Dr("AplicaLote")), Dr("Lote").ToString().Trim, "-1")
|
|
|
|
' If Dr("CantidadGV").ToString().ToDecimal > 0 Then
|
|
' If CBool(Dr("AplicaSerie")) 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}"" CveSeccionAlmacen=""{3}"" Serie=""{4}"" Lote=""{5}"" FechaCaducidad=""{6}""></concepto>", Dr1("CvePS"), Dr1("CveUM"), 1, IfNull(Dr("CveSeccion"), -1), Dr1("Serie"), Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
|
|
' Next
|
|
' Else
|
|
' StrXML.AppendFormat("<concepto CvePS=""{0}"" CveUM=""{1}"" Cantidad= ""{2}"" CveSeccionAlmacen=""{3}"" Serie=""{4}"" Lote=""{5}"" FechaCaducidad=""{6}""></concepto>", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), IfNull(Dr("CveSeccion"), -1), "-1", Lote, FechaCaducidad.ToString("yyyy/MM/dd"))
|
|
' End If
|
|
' End If
|
|
'Next
|
|
|
|
'StrXML.Append("</conceptos>")
|
|
|
|
|
|
'If ObjInventarioVal.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacenArmado.SelectedValue.ToEntero(), TxtFechaArmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), -1, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), If(Tipo = 2, 1, -1), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
' If ObjInventarioVal.DtResultados.Rows.Count > 0 Then
|
|
' TieneErrorExistencia = True
|
|
' For Each Dr As DataRow In ObjInventarioVal.DtResultados.Rows
|
|
' TextoError.AppendFormat("<b> - {0}</b> Existencia: {1:#,##0.##} <br/>", Dr("CodigoPS"), Dr("Existencia"))
|
|
' Next
|
|
' End If
|
|
'Else
|
|
' TieneErrorExistencia = True
|
|
'End If
|
|
|
|
If TieneErrorExistencia Then
|
|
'ObjInventarioVal.RollBack()
|
|
ObjInventarioVal.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
|
|
|
|
|
|
|
|
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
|
|
Dim TieneError As Boolean = False
|
|
Dim MensajeError As String = ""
|
|
|
|
Dim CveMovimientoSalida As Integer = 0
|
|
Dim FolioSalida As Integer = 0
|
|
Dim CveMovimientoEntrada As Integer = 0
|
|
Dim FolioEntrada As Integer = 0
|
|
Dim Fecha As Date = If(Tipo = 1, TxtFechaArmado.Text.ToDate, TxtFechaDesarmado.Text.ToDate)
|
|
Dim DtDetalle As New DataTable
|
|
|
|
Dim ConcepPrePoliza1 = "ARMPAQ1"
|
|
Dim ConcepPrePoliza2 = "ARMPAQ2"
|
|
Dim Modulo As String = "ARMPAQ1/ARMPAQ2"
|
|
|
|
Try
|
|
Select Case (Tipo)
|
|
Case 1 ' ARMADO
|
|
|
|
'SALIDA COMPONENTES
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenArmado, 5, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesArmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Modulo:="ARMPAQ1")
|
|
FolioSalida = ObjInventario.Folio
|
|
|
|
If CveMovimientoSalida <= 0 Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar."
|
|
Exit Select
|
|
End If
|
|
|
|
For Each Gvr As GridViewRow In GvDatosArmado.Rows
|
|
If Gvr.DataKey("Cantidad").ToString.ToDouble > 0 Then
|
|
Dim Lote As String = If(Gvr.FCTextBox("TxtLote").Text = "", "-1", Gvr.FCTextBox("TxtLote").Text)
|
|
Dim FechaCaducidad As String = If(Gvr.FCTextBox("TxtCaducidad").Text = "", "-1", Gvr.FCTextBox("TxtCaducidad").Text)
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
|
|
|
|
Dim DdlCaducidadProducto As DropDownList = Gvr.FCDropDownList("DdlCaducidadProducto")
|
|
Dim ArrayCaducidad As String() = DdlCaducidadProducto.SelectedValue.Split("|"c)
|
|
Lote = ArrayCaducidad(0)
|
|
FechaCaducidad = ArrayCaducidad(1)
|
|
|
|
End If
|
|
|
|
Dim CveSeccionAlmacen As Integer = Gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero()
|
|
If CBool(Gvr.DataKey("AplicaSerie")) Then
|
|
For Each Dr As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec").ToEntero)).Rows
|
|
If Not ObjInventario.GetExistenciasPS(Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenArmado.SelectedValue.ToEntero, FechaMovto:=Fecha.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Dr("Serie").ToString, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) >= 1 Then
|
|
MensajeError = String.Format("El Producto <b>{0}</b> con Serie: <b>{1}</b> no tiene existencia suficiente", Dr("PS"), Dr("Serie"))
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, 0, -1,
|
|
CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString, Lote:=Lote, FechaCaducidad:=FechaCaducidad.ToDate) Then
|
|
MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida. Por favor vuelva a intentar."
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
|
|
Else
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.DataKey("Cantidad").ToString.ToDecimal, Gvr.DataKey("CveUM").ToString.ToEntero,
|
|
Gvr.DataKey("CvePS").ToString.ToEntero, 0, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote,
|
|
FechaCaducidad:=FechaCaducidad.ToDate) Then
|
|
MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar."
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
'ENTRADA PAQUETE
|
|
If Not TieneError Then
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenArmado, 19, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesArmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ARMPAQ2")
|
|
FolioEntrada = ObjInventario.Folio
|
|
|
|
If CveMovimientoEntrada <= 0 Then
|
|
MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar."
|
|
TieneError = True
|
|
Else
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
Dim PUTemp As Decimal = 0
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
PUTemp += Dr("PU").ToString.ToDecimal * Dr("Cantidad").ToString.ToDecimal
|
|
Next
|
|
PUTemp = PUTemp / TxtCantidadArmado.Text.ToDecimal
|
|
Dim CvePSTemp = CvePaqueteArmado
|
|
Dim CveSeccionAlmacen As Integer = -1
|
|
Dim Drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteArmado).FiltroPrimero("")
|
|
|
|
Dim CveUMTemp As Integer = Drp("CveUM").ToString.ToEntero
|
|
Dim AplicaSeccion As Boolean = CBool(Drp("AplicaSeccion"))
|
|
If AplicaSeccion Then
|
|
CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenArmado, CvePaqueteArmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
|
|
End If
|
|
|
|
|
|
If AplicaSeriePaquete Then
|
|
Dim ContadorPaquete = 1
|
|
Dim DtSeriesComponentes As New DataTable
|
|
For Each Gvr As GridViewRow In GvSeriesPaqueteArmado.Rows
|
|
'AGREGA MOVTO DETALLE DE LA ENTRADA DEL PAQUETE
|
|
|
|
Dim Serie As String = Gvr.FCTextBox("TxtSerie").Text.Trim
|
|
Dim Lote As String = Gvr.FCTextBox("TxtLote").Text.Trim
|
|
Dim FechaCaducidad As Date = If(Gvr.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha, MinFecha, Gvr.FCTextBox("TxtCaducidad").Text.ToDate)
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, CveUMTemp, CvePSTemp, PUTemp, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de entrada"
|
|
Exit For
|
|
End If
|
|
|
|
'INGRESA EN TABLA DE CONTROL DE PAQUETES CON SERIE
|
|
For Each Gvr2 As GridViewRow In GvDatosArmado.Rows
|
|
If CBool(Gvr2.DataKey("AplicaSerie")) Then
|
|
DtSeriesComponentes = New DataTable
|
|
DtSeriesComponentes = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr2.DataKey("Consec").ToEntero)).Copy
|
|
Dim CantidadComponente = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr2.DataKey("Consec").ToEntero)).Rows.Count / TxtCantidadArmado.Text.ToEntero
|
|
|
|
For index As Integer = (ContadorPaquete - 1) * CantidadComponente.ToEntero To (ContadorPaquete * CantidadComponente.ToEntero) - 1
|
|
If Not ObjInventario.AddPaqueteRelacionSeries(CvePSTemp, Gvr.FCTextBox("TxtSerie").Text.Trim, DtSeriesComponentes.Rows(index)("CvePS").ToString.ToEntero, DtSeriesComponentes.Rows(index)("Serie").ToString) Then
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
Next
|
|
|
|
ContadorPaquete = ContadorPaquete + 1
|
|
Next
|
|
Else
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, TxtCantidadArmado.Text.ToDecimal, CveUMTemp, CvePSTemp, PUTemp, CveSeccionAlmacen:=CveSeccionAlmacen) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar los detalles del movimiento de entrada"
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
Case 2 'DESARMADO
|
|
|
|
|
|
'SALIDA PAQUETE
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenDesarmado, 20, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesDesarmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Modulo:="ARMPAQ3")
|
|
FolioSalida = ObjInventario.Folio
|
|
|
|
If CveMovimientoSalida <= 0 Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar."
|
|
Exit Select
|
|
End If
|
|
|
|
Dim CvePSTemp As Integer = CvePaqueteDesarmado
|
|
Dim CveSeccionAlmacen As Integer = -1
|
|
Dim Drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimero("")
|
|
|
|
Dim CveUMTemp As Integer = Drp("CveUM").ToString.ToEntero
|
|
'Dim AplicaSeccion As Boolean = CBool(Drp("AplicaSeccion"))
|
|
'If AplicaSeccion Then
|
|
' CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenDesarmado, CvePaqueteDesarmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
|
|
'End If
|
|
If AplicaSeriePaquete Or AplicaLotePaquete Or AplicaCaducidadPaquete Then
|
|
|
|
|
|
For Each Gvr As GridViewRow In GvSeriesPaqueteDesarmado.Rows
|
|
|
|
Dim Serie As String = If(AplicaSeriePaquete, Gvr.DataKey("Serie").Trim, "-1")
|
|
Dim Lote As String = If(AplicaLotePaquete, Gvr.DataKey("Lote").Trim, "-1")
|
|
Dim FechaCaducidad As Date = If(AplicaCaducidadPaquete, Gvr.DataKey("FechaCaducidad").Trim.ToDate, MinFecha)
|
|
|
|
'AGREGA MOVTO DETALLE DE LA SALIDA DEL PAQUETE
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, CveUMTemp, CvePSTemp, 0, CveSeccionAlmacen:=-3, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida"
|
|
Exit For
|
|
End If
|
|
|
|
'ELIMINA EN TABLA DE CONTROL DE PAQUETES CON SERIE
|
|
If Not ObjInventario.RemovePaqueteRelacionSeries(CvePSTemp, Gvr.DataKey("Serie").ToString) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida"
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
Else
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, TxtCantidadDesarmado.Text.ToDecimal, CveUMTemp, CvePSTemp, 0, CveSeccionAlmacen:=CveSeccionAlmacen) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar los movimientos de salida"
|
|
End If
|
|
End If
|
|
|
|
|
|
'ENTRADA COMPONENTES
|
|
If Not TieneError Then
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenDesarmado, 4, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesDesarmado.Text, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="ARMPAQ4")
|
|
FolioEntrada = ObjInventario.Folio
|
|
|
|
If CveMovimientoEntrada <= 0 Then
|
|
MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar."
|
|
TieneError = True
|
|
Else
|
|
For Each Gvr As GridViewRow In GvDatosDesarmado.Rows
|
|
|
|
Dim Lote As String = If(Gvr.FCTextBox("TxtLote").Text = "", "-1", Gvr.FCTextBox("TxtLote").Text)
|
|
Dim FechaCaducidad As String = If(Gvr.FCTextBox("TxtCaducidad").Text = "", "-1", Gvr.FCTextBox("TxtCaducidad").Text)
|
|
If CBool(Gvr.DataKey("AplicaSeccion")) Then
|
|
CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenDesarmado, CvePaqueteDesarmado).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero
|
|
End If
|
|
|
|
If CBool(Gvr.DataKey("AplicaSerie")) Then
|
|
For Each Dr As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec").ToEntero)).Rows
|
|
If Not ObjInventario.GetExistenciasPS(Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenArmado.SelectedValue.ToEntero, FechaMovto:=Fecha.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Dr("Serie").ToString, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente)) >= 1 Then
|
|
MensajeError = String.Format("El Producto <b>{0}</b> con Serie: <b>{1}</b> no tiene existencia suficiente", Dr("PS"), Dr("Serie"))
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, 1, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDecimal, -1,
|
|
CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Dr("Serie").ToString, Lote:=Lote, FechaCaducidad:=FechaCaducidad.ToDate) Then
|
|
MensajeError = "Ocurrió un error al guardar los detalles con serie del movimiento de salida. Por favor vuelva a intentar."
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
|
|
Else
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Gvr.DataKey("Cantidad").ToString.ToDecimal, Gvr.DataKey("CveUM").ToString.ToEntero,
|
|
Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.FCTextBox("TxtCosto").Text.ToDecimal, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Lote:=Lote,
|
|
FechaCaducidad:=FechaCaducidad.ToDate) Then
|
|
MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar."
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
ConcepPrePoliza1 = "ARMPAQ3"
|
|
ConcepPrePoliza2 = "ARMPAQ4"
|
|
Modulo = "ARMPAQ3/ARMPAQ4"
|
|
End Select
|
|
|
|
'CONTABILIZAR MOVIMIENTOS
|
|
If Not TieneError Then
|
|
Dim ImportePrePoliza As Decimal = 0D
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
|
|
ImportePrePoliza = ObjInventario.DtResultados.SUMD("Total")
|
|
End If
|
|
|
|
Dim MovAlmacen As Boolean = True
|
|
|
|
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & 19).ToEntero
|
|
|
|
If OrigenMov = 1 Then
|
|
MovAlmacen = True
|
|
Else
|
|
MovAlmacen = False
|
|
End If
|
|
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas(Modulo, 74, ImportePrePoliza, ImportePrePoliza, 1, Fecha, Modulo, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ImportePrePoliza, ImportePrePoliza, 68, ConcepPrePoliza2, ConcepPrePoliza2, CveMovimientoAlmacen:=CveMovimientoEntrada, CveSubProyecto:=-1, Contabilizable:=True) Then
|
|
TieneError = True
|
|
End If
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, ImportePrePoliza, ImportePrePoliza, 68, ConcepPrePoliza1, ConcepPrePoliza1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=True) Then
|
|
TieneError = True
|
|
End If
|
|
|
|
If ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, Opcion:=6) Then
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
GuardaLogAD($"Inventarios/RecepcionAlmacen-PPCompOC | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
TieneError = True
|
|
OnError("Ocurrió un error al generar el movimiento", ex)
|
|
End Try
|
|
|
|
If Not TieneError Then
|
|
Dim Msg As New StringBuilder
|
|
Msg.AppendFormat("<br/>El Movimiento de salida se registro con el Folio: <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/><br/>El Movimiento de entrada se registro con el Folio: <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)
|
|
ObjInventario.Commit()
|
|
|
|
Limpia(Tipo)
|
|
|
|
Else
|
|
Alert(MensajeError, TipoMensaje.MsgError)
|
|
ObjInventario.RollBack()
|
|
End If
|
|
|
|
ObjInventario.Dispose() 'elimino la instancia
|
|
ObjConta.Dispose()
|
|
End Sub
|
|
|
|
Private Sub Limpia(Tipo As Integer)
|
|
|
|
DtDatosDetalle.Clear()
|
|
AplicaSeriePaquete = False
|
|
|
|
|
|
'If Tipo = 1 Then
|
|
|
|
BtnGuadarArmado.Visible = False
|
|
DivSeriesPaqueteArmado.Visible = False
|
|
GvDatosArmado.Columns(4).Visible = False
|
|
|
|
CvePaqueteArmado = -1
|
|
CveAlmacenArmado = -1
|
|
TxtObservacionesArmado.Text = ""
|
|
UpGeneralesArmado.Update()
|
|
|
|
GvDatosArmado.DataBind()
|
|
UpDatosArmado.Update()
|
|
UpSeriesPaqueteArmado.Update()
|
|
'Else
|
|
|
|
CvePaqueteDesarmado = -1
|
|
CveAlmacenDesarmado = -1
|
|
TxtObservacionesDesarmado.Text = ""
|
|
UpGeneralesDesarmado.Update()
|
|
|
|
BtnGuadarDesarmado.Visible = False
|
|
TotalDesarmado.Visible = False
|
|
|
|
DtSeriesDesarmado.Clear()
|
|
GvDatosDesarmado.Columns(4).Visible = False
|
|
DivSeriesPaqueteDesarmado.Visible = False
|
|
GvSeriesPaqueteDesarmado.DataBind()
|
|
BtnAgregarSerieDesarmado.Enabled = True
|
|
|
|
LbTotalCalculado.Text = "0.00"
|
|
|
|
GvDatosDesarmado.DataBind()
|
|
UpDatosDesarmado.Update()
|
|
UpSeriesPaqueteDesarmado.Update()
|
|
|
|
'End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " GV ARMADO "
|
|
Protected Sub GvDatosArmado_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosArmado.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If CBool(e.Row.DBCampo("AplicaSerie")) Then
|
|
e.Row.FCButton("BtnSerie").Visible = True
|
|
e.Row.FCButton("BtnSerie").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°1", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PS"), e.Row.DBCampo("Cantidad"), e.Row.DBCampo("Consec"))
|
|
e.Row.FCLinkButton("BtnSeriePaquete").CommandArgument = e.Row.DBCampo("Consec")
|
|
'Dim Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DBCampo("Consec"))).Rows.Count
|
|
'e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString
|
|
|
|
'If AplicaSerie Then
|
|
e.Row.FCLinkButton("BtnSeriePaquete").Visible = True
|
|
e.Row.FCLinkButton("BtnSeriePaquete").Attributes.Add("data-toggle", "tooltip")
|
|
'End If
|
|
|
|
Else
|
|
e.Row.FCButton("BtnSerie").Visible = False
|
|
End If
|
|
|
|
If e.Row.DataKey("AplicaSeccion") = "False" Then
|
|
e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = False
|
|
Else
|
|
CargaSeccionesAlmacen(e.Row.FCDropDownList("DdlSeccionAlmacen"), DdlAlmacenArmado.SelectedValue.ToEntero, e.Row.DBCampo("CvePS").ToEntero, UsuarioActual.CveEmpresa)
|
|
End If
|
|
|
|
|
|
Dim DvFechaCaducidad As HtmlGenericControl = TryCast(e.Row.FindControl("DvFechaCaducidad"), HtmlGenericControl)
|
|
|
|
If e.Row.DataKey("AplicaCaducidad") = "True" Then
|
|
'e.Row.FCTextBox("TxtCaducidad").Visible = True
|
|
'e.Row.FCLinkButton("LnkCaducidad").Visible = True
|
|
|
|
'e.Row.FCTextBox("TxtCaducidad").ReadOnly = False
|
|
''CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = True
|
|
'e.Row.FCTextBox("TxtCaducidad").Enabled = True
|
|
DvFechaCaducidad.Visible = True
|
|
Else
|
|
'e.Row.FCTextBox("TxtCaducidad").Visible = False
|
|
'e.Row.FCLinkButton("LnkCaducidad").Visible = False
|
|
'e.Row.FCTextBox("TxtCaducidad").Enabled = True
|
|
|
|
'e.Row.FCTextBox("TxtCaducidad").ReadOnly = True
|
|
''CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = False
|
|
DvFechaCaducidad.Visible = False
|
|
End If
|
|
|
|
e.Row.FCTextBox("TxtLote").Visible = e.Row.DataKey("AplicaLote") = "True"
|
|
|
|
''FUNCIONALIDAD PISTOLA DE CODIGOS
|
|
'If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" Then
|
|
' e.Row.FCTextBox("TbCantidadF").Enabled = False
|
|
'End If
|
|
|
|
e.Row.FCButton("BtnDividir").Attributes.Add("onclick", String.Format("Dividir('{0}');", e.Row.FCTextBox("TxtDividir").ClientID))
|
|
e.Row.FCButton("BtnDividir").CommandArgument = e.Row.RowIndex.ToString()
|
|
e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCButton("BtnDividir").ClientID))
|
|
|
|
|
|
If Boolean.Parse(e.Row.DataKey("AplicaLote")) Or Boolean.Parse(e.Row.DataKey("AplicaCaducidad")) Then
|
|
|
|
CargarCaducidadProducto(e.Row.DataKey("CvePS").ToEntero, e.Row.FCDropDownList("DdlCaducidadProducto"))
|
|
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub DdlCaducidadProducto_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, DropDownList)).NamingContainer, GridViewRow)
|
|
|
|
Dim AplicaLote As Boolean = Boolean.Parse(GvRow.DataKey("AplicaLote"))
|
|
Dim AplicaCaducidad As Boolean = Boolean.Parse(GvRow.DataKey("AplicaCaducidad"))
|
|
Dim DdlCaducidadProducto As DropDownList = GvRow.FCDropDownList("DdlCaducidadProducto")
|
|
|
|
Dim ArrayCaducidad As String() = DdlCaducidadProducto.SelectedValue.Split("|"c)
|
|
Dim Lote As String = ArrayCaducidad(0)
|
|
Dim FechaCaducidad As String = ArrayCaducidad(1)
|
|
|
|
|
|
|
|
If AplicaLote Then
|
|
GvRow.FCTextBox("TxtLote").Text = Lote
|
|
End If
|
|
|
|
If AplicaCaducidad Then
|
|
GvRow.FCTextBox("TxtCaducidad").Text = FechaCaducidad
|
|
End If
|
|
|
|
UpDatosArmado.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargarCaducidadProducto(CvePS As Integer, ByRef DdlLoteFechaCaducidad As DropDownList)
|
|
|
|
Dim almacenes As String = DdlAlmacenArmado.SelectedValue
|
|
If almacenes = "" Then
|
|
almacenes = "-1"
|
|
End If
|
|
|
|
Dim ObjInventarios As New ClsInventarios
|
|
|
|
If ObjInventarios.GetExistenciasCaducidad(CvePS, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, almacenes) Then
|
|
|
|
For Each dr As DataRow In ObjInventarios.DtResultados.Rows
|
|
DdlLoteFechaCaducidad.Items.Add(New ListItem($"Lote: {dr("Lote").ToString} - Cad: {dr("FechaCaducidad").ToString.ToDate.ToString("dd/MM/yyyy")}", $"{dr("Lote").ToString}|{dr("FechaCaducidad").ToString.ToDate.ToString("dd/MM/yyyy")}"))
|
|
Next
|
|
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub Dividir(sender As Object, e As EventArgs)
|
|
Dim index2 As Integer = 0
|
|
|
|
If Not DtDatosArmado.Columns.Contains("Lote") Then
|
|
DtDatosArmado.Columns.Add("Lote", GetType(String))
|
|
End If
|
|
|
|
If Not DtDatosArmado.Columns.Contains("CveSeccion") Then
|
|
DtDatosArmado.Columns.Add("CveSeccion", GetType(Integer))
|
|
End If
|
|
|
|
If Not DtDatosArmado.Columns.Contains("FechaCaducidad") Then
|
|
DtDatosArmado.Columns.Add("FechaCaducidad", GetType(String))
|
|
End If
|
|
|
|
DtDatosArmado.AcceptChanges()
|
|
|
|
For Each Row As DataRow In DtDatosArmado.Rows
|
|
|
|
|
|
Row("Lote") = GvDatosArmado.Rows(index2).FCTextBox("TxtLote").Text
|
|
'End If
|
|
'If GvDatosArmado.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue <> "-1" Then
|
|
Row("CveSeccion") = GvDatosArmado.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero()
|
|
' End If
|
|
'If GvDatosArmado.Rows(index2).FCTextBox("TxtCaducidad").Text <> "" Then
|
|
Row("FechaCaducidad") = GvDatosArmado.Rows(index2).FCTextBox("TxtCaducidad").Text
|
|
'End If
|
|
index2 += 1
|
|
Next
|
|
|
|
DtDatosArmado.AcceptChanges()
|
|
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, Button)).NamingContainer, GridViewRow)
|
|
Dim Index As Integer = gvRow.RowIndex
|
|
Dim Cantidad As String = HdnCantidadMovimiento.Value
|
|
Dim drOriginal As DataRow = DtDatosArmado.Rows(Index)
|
|
Dim drNew As DataRow = DtDatosArmado.NewRow
|
|
|
|
drNew.ItemArray = drOriginal.ItemArray
|
|
|
|
drOriginal("Cantidad") = (drOriginal("Cantidad").ToString().ToDouble - Cantidad.ToDouble)
|
|
|
|
'Dim CantidadFOriginal As Double = drOriginal("CantidadF").ToString().ToDouble
|
|
'drOriginal("CantidadF") = (drOriginal("CantidadF").ToString().ToDouble - Cantidad.ToDouble)
|
|
|
|
'Dim CantidadSOriginal As Double = drOriginal("CantidadS").ToString().ToDouble
|
|
'drOriginal("CantidadS") = (CantidadSOriginal * drOriginal("CantidadF").ToString().ToDouble) / CantidadFOriginal
|
|
|
|
'Dim CantidadSeleccionadaOriginal As Double = drOriginal("CantidadSeleccionada").ToString().ToDouble
|
|
'drOriginal("CantidadSeleccionada") = If(CantidadSeleccionadaOriginal > drOriginal("CantidadF").ToString().ToDouble, drOriginal("CantidadF").ToString().ToDouble, CantidadSeleccionadaOriginal)
|
|
|
|
'CantidadSeleccionadaOriginal = CantidadSeleccionadaOriginal - drOriginal("CantidadF").ToString().ToDouble
|
|
|
|
'Dim CostoIndirectoOriginal As Double = dr1("CostoIndirecto").ToString().ToDouble
|
|
'dr1("CostoIndirecto") = (CostoIndirectoOriginal * dr1("CantidadF").ToString().ToDouble) / CantidadFOriginal
|
|
'Dim CostoIndirectoExtranjeroOriginal As Double = dr1("CostoIndirectoExtranjero").ToString().ToDouble
|
|
'dr1("CostoIndirectoExtranjero") = (CostoIndirectoExtranjeroOriginal * dr1("CantidadF").ToString().ToDouble) / CantidadFOriginal
|
|
|
|
DtDatosArmado.AcceptChanges()
|
|
|
|
drNew("Cantidad") = Cantidad.ToDecimal
|
|
'drNew("CantidadF") = Cantidad.ToDouble
|
|
'drNew("CantidadS") = (CantidadSOriginal * drNew("CantidadF").ToString().ToDouble) / CantidadFOriginal
|
|
'drNew("CantidadSeleccionada") = If(CantidadSeleccionadaOriginal > 0, CantidadSeleccionadaOriginal, 0)
|
|
'drNew("Seleccionado") = If(CantidadSeleccionadaOriginal > 0, True, False)
|
|
'dr("CostoIndirecto") = (CostoIndirectoOriginal * dr("CantidadF").ToString().ToDouble) / CantidadFOriginal
|
|
'dr("CostoIndirectoExtranjero") = (CostoIndirectoExtranjeroOriginal * dr("CantidadF").ToString().ToDouble) / CantidadFOriginal
|
|
DtDatosArmado.Rows.InsertAt(drNew, Index)
|
|
DtDatosArmado.AcceptChanges()
|
|
|
|
index2 = 1
|
|
For Each Row As DataRow In DtDatosArmado.Rows
|
|
Row("Consec") = index2
|
|
index2 += 1
|
|
Next
|
|
DtDatosArmado.AcceptChanges()
|
|
|
|
|
|
GvDatosArmado.DataSource = DtDatosArmado
|
|
GvDatosArmado.DataBind()
|
|
|
|
|
|
index2 = 0
|
|
For Each Row As DataRow In DtDatosArmado.Rows
|
|
'GvDatosArmado.Rows(index2).FCCheckBox("cbInv").Checked = CBool(Row("Seleccionado"))
|
|
'If Row("CantidadSeleccionada").ToString() <> "" Then
|
|
' GvDatosArmado.Rows(index2).FCTextBox("TbCantidadF").Text = Row("CantidadSeleccionada").ToString()
|
|
'End If
|
|
If Row("Lote").ToString() <> "" Then
|
|
GvDatosArmado.Rows(index2).FCTextBox("TxtLote").Text = Row("Lote").ToString()
|
|
End If
|
|
If Row("CveSeccion").ToString() <> "" Then
|
|
GvDatosArmado.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue = Row("CveSeccion").ToString()
|
|
End If
|
|
If Row("FechaCaducidad").ToString() <> "" Then
|
|
GvDatosArmado.Rows(index2).FCTextBox("TxtCaducidad").Text = Row("FechaCaducidad").ToString().ToDate.ToShortDateString
|
|
End If
|
|
index2 += 1
|
|
Next
|
|
|
|
UpDatosArmado.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " GV DESARMADO "
|
|
Protected Sub GvDatosDesarmado_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosDesarmado.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If CBool(e.Row.DBCampo("AplicaSerie")) Then
|
|
e.Row.FCButton("BtnSerie").Visible = True
|
|
e.Row.FCButton("BtnSerie").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°2", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PS"), e.Row.DBCampo("Cantidad"), e.Row.DBCampo("Consec"))
|
|
Else
|
|
e.Row.FCButton("BtnSerie").Visible = False
|
|
End If
|
|
If e.Row.DataKey("AplicaSeccion") = "False" Then
|
|
e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = False
|
|
Else
|
|
CargaSeccionesAlmacen(e.Row.FCDropDownList("DdlSeccionAlmacen"), DdlAlmacenDesarmado.SelectedValue.ToEntero, e.Row.DBCampo("CvePS").ToEntero, UsuarioActual.CveEmpresa)
|
|
End If
|
|
|
|
Dim DvFechaCaducidad As HtmlGenericControl = TryCast(e.Row.FindControl("DvFechaCaducidad"), HtmlGenericControl)
|
|
|
|
If e.Row.DataKey("AplicaCaducidad") = "True" Then
|
|
'e.Row.FCTextBox("TxtCaducidad").Visible = True
|
|
'e.Row.FCLinkButton("LnkCaducidad").Visible = True
|
|
|
|
'e.Row.FCTextBox("TxtCaducidad").ReadOnly = False
|
|
''CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = True
|
|
'e.Row.FCTextBox("TxtCaducidad").Enabled = True
|
|
DvFechaCaducidad.Visible = True
|
|
Else
|
|
'e.Row.FCTextBox("TxtCaducidad").Visible = False
|
|
'e.Row.FCLinkButton("LnkCaducidad").Visible = False
|
|
'e.Row.FCTextBox("TxtCaducidad").Enabled = True
|
|
|
|
'e.Row.FCTextBox("TxtCaducidad").ReadOnly = True
|
|
''CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = False
|
|
DvFechaCaducidad.Visible = False
|
|
End If
|
|
|
|
|
|
|
|
'If e.Row.DataKey("AplicaCaducidad") = "True" Then
|
|
' e.Row.FCTextBox("TxtCaducidad").Visible = True
|
|
' e.Row.FCLinkButton("LnkCaducidad").Visible = True
|
|
|
|
' e.Row.FCTextBox("TxtCaducidad").ReadOnly = False
|
|
' CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = True
|
|
' e.Row.FCTextBox("TxtCaducidad").Enabled = True
|
|
'Else
|
|
' e.Row.FCTextBox("TxtCaducidad").Visible = False
|
|
' e.Row.FCLinkButton("LnkCaducidad").Visible = False
|
|
' e.Row.FCTextBox("TxtCaducidad").Enabled = True
|
|
|
|
' e.Row.FCTextBox("TxtCaducidad").ReadOnly = True
|
|
' CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = False
|
|
'End If
|
|
|
|
e.Row.FCTextBox("TxtLote").Visible = e.Row.DataKey("AplicaLote") = "True"
|
|
|
|
e.Row.FCTextBox("TxtCosto").Attributes.Add("onkeyup", "SumaValores();")
|
|
|
|
|
|
e.Row.FCButton("BtnDividir").Attributes.Add("onclick", String.Format("Dividir('{0}');", e.Row.FCTextBox("TxtDividir").ClientID))
|
|
e.Row.FCButton("BtnDividir").CommandArgument = e.Row.RowIndex.ToString()
|
|
e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCButton("BtnDividir").ClientID))
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub DividirDesarmado(sender As Object, e As EventArgs)
|
|
Dim index2 As Integer = 0
|
|
|
|
If Not DtDatosDesArmado.Columns.Contains("Lote") Then
|
|
DtDatosDesArmado.Columns.Add("Lote", GetType(String))
|
|
End If
|
|
|
|
If Not DtDatosDesArmado.Columns.Contains("CveSeccion") Then
|
|
DtDatosDesArmado.Columns.Add("CveSeccion", GetType(Integer))
|
|
End If
|
|
|
|
If Not DtDatosDesArmado.Columns.Contains("FechaCaducidad") Then
|
|
DtDatosDesArmado.Columns.Add("FechaCaducidad", GetType(String))
|
|
End If
|
|
|
|
DtDatosDesArmado.AcceptChanges()
|
|
|
|
For Each Row As DataRow In DtDatosDesArmado.Rows
|
|
Row("Lote") = GvDatosDesarmado.Rows(index2).FCTextBox("TxtLote").Text
|
|
Row("CveSeccion") = GvDatosDesarmado.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero()
|
|
Row("FechaCaducidad") = GvDatosDesarmado.Rows(index2).FCTextBox("TxtCaducidad").Text
|
|
index2 += 1
|
|
Next
|
|
|
|
DtDatosDesArmado.AcceptChanges()
|
|
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, Button)).NamingContainer, GridViewRow)
|
|
Dim Index As Integer = gvRow.RowIndex
|
|
Dim Cantidad As String = HdnCantidadMovimiento.Value
|
|
Dim drOriginal As DataRow = DtDatosDesArmado.Rows(Index)
|
|
Dim drNew As DataRow = DtDatosDesArmado.NewRow
|
|
|
|
drNew.ItemArray = drOriginal.ItemArray
|
|
|
|
drOriginal("Cantidad") = (drOriginal("Cantidad").ToString().ToDouble - Cantidad.ToDouble)
|
|
|
|
|
|
|
|
DtDatosDesArmado.AcceptChanges()
|
|
|
|
drNew("Cantidad") = Cantidad.ToDecimal
|
|
|
|
DtDatosDesArmado.Rows.InsertAt(drNew, Index)
|
|
DtDatosDesArmado.AcceptChanges()
|
|
|
|
index2 = 1
|
|
For Each Row As DataRow In DtDatosDesArmado.Rows
|
|
Row("Consec") = index2
|
|
index2 += 1
|
|
Next
|
|
DtDatosDesArmado.AcceptChanges()
|
|
|
|
|
|
GvDatosDesarmado.DataSource = DtDatosDesArmado
|
|
GvDatosDesarmado.DataBind()
|
|
|
|
|
|
index2 = 0
|
|
For Each Row As DataRow In DtDatosDesArmado.Rows
|
|
|
|
If Row("Lote").ToString() <> "" Then
|
|
GvDatosDesarmado.Rows(index2).FCTextBox("TxtLote").Text = Row("Lote").ToString()
|
|
End If
|
|
If Row("CveSeccion").ToString() <> "" Then
|
|
GvDatosDesarmado.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue = Row("CveSeccion").ToString()
|
|
End If
|
|
If Row("FechaCaducidad").ToString() <> "" Then
|
|
GvDatosDesarmado.Rows(index2).FCTextBox("TxtCaducidad").Text = Row("FechaCaducidad").ToString().ToDate.ToShortDateString
|
|
End If
|
|
index2 += 1
|
|
Next
|
|
|
|
UpDatosDesarmado.Update()
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " SERIE LOTE "
|
|
Private Sub CreaDtDetalle()
|
|
If DtDatosDetalle Is Nothing Then
|
|
DtDatosDetalle = New DataTable
|
|
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("Serie", GetType(String))
|
|
DtDatosDetalle.Columns.Add("SeriePaquete", GetType(String))
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnSerie_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c)
|
|
|
|
LbProducto.Text = Argumentos(2)
|
|
LbCantidad.Text = Argumentos(3).FormatoNumero
|
|
|
|
CveConsecSerieLote = Argumentos(4).ToEntero
|
|
CvePSSerieLote = Argumentos(0).ToEntero
|
|
CveUMSerieLote = Argumentos(1).ToEntero
|
|
|
|
RegistraScript("$('#DivSerie').modal('show')")
|
|
CargaSerie(Argumentos(5).ToEntero)
|
|
|
|
End Sub
|
|
Private Sub CargaSerie(Tipo As Integer)
|
|
|
|
GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote), "Consec DESC")
|
|
GvSerie.DataBind()
|
|
|
|
'VALIDA QUE SIGA AGREGANDO
|
|
If DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote)).Rows.Count = LbCantidad.Text.ToEntero Then
|
|
BtnAgregarPS.Enabled = False
|
|
If Tipo = 2 Then
|
|
RegistraScript("$('#DivSerie').modal('hide')")
|
|
End If
|
|
Else
|
|
BtnAgregarPS.Enabled = True
|
|
End If
|
|
|
|
'SERIE LOTE RECOMENDADO
|
|
Dim DtSerieLote As New DataTable
|
|
Dim VariableCampoSerie = ""
|
|
If TipoMovimiento = 1 Then
|
|
Dim ObjInventarios As New ClsInventarios
|
|
If ObjInventarios.SerieRecomendadoGet(CvePSSerieLote, UsuarioActual.CveEmpresa, If(TipoMovimiento = 1, CveAlmacenArmado, CveAlmacenDesarmado)) Then
|
|
DtSerieLote = ObjInventarios.DtResultados
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
VariableCampoSerie = "Serie"
|
|
Else
|
|
DtSerieLote = If(DtExistenciasDesarmado IsNot Nothing, DtExistenciasDesarmado.Copy, Nothing)
|
|
VariableCampoSerie = "SeriePS"
|
|
End If
|
|
|
|
'SERIE LOTE RECOMENDADO - QUITA YA COMPLETADOS EN EL CLIENTE
|
|
If DtSerieLote IsNot Nothing AndAlso DtSerieLote.Rows.Count > 0 Then
|
|
'CALCULA YA COMPLETADOS
|
|
DtSerieLote.Columns.Add("CantidadSeleccionada", GetType(Integer))
|
|
Dim DrsRemove As New List(Of DataRow)
|
|
For Each dr As DataRow In DtSerieLote.Rows
|
|
dr("CantidadSeleccionada") = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND Serie = '{1}'", CveConsecSerieLote, dr(VariableCampoSerie).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)(VariableCampoSerie))
|
|
LbSerieRecomendado.Text = Mensaje.ToString 'String.Format("Serie / Lote Recomendado: <b>{0}</b>, Caducicdad: <b>{1}</b>", ObjInventarios.DtResultados.Rows(0)("Serie"), ObjInventarios.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString)
|
|
Else
|
|
LbSerieRecomendado.Text = "No se encontro ningun Serie/Lote."
|
|
End If
|
|
Else
|
|
LbSerieRecomendado.Text = "No se encontro ningun Serie/Lote."
|
|
End If
|
|
If DtSerieLote IsNot Nothing Then DtSerieLote.Dispose()
|
|
UpSerie.Update()
|
|
|
|
|
|
End Sub
|
|
Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs)
|
|
AgregaSerieLote(TxtSerie.Text.Trim, 1)
|
|
End Sub
|
|
Private Sub AgregaSerieLote(Serie As String, Tipo As Integer)
|
|
|
|
If Serie.Trim = "" Then
|
|
Alert("El campo Serie es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
Dim SeriesArreglo = Serie.Split(";"c)
|
|
|
|
'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))
|
|
|
|
For Each Serie In SeriesArreglo
|
|
DtDuplicado = DtDatosDetalle.FiltraParametros($"ConsecId = {CveConsecSerieLote} AND Serie = '{Serie}'")
|
|
If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then
|
|
MensajeAlert.Append($"<br/> El numero de Serie <b>""{Serie}""</b> proporcionado ya se encuentra ingresado.")
|
|
End If
|
|
|
|
DtDuplicado = DtSeriesNuevas.FiltraParametros($"Serie = '{Serie}'")
|
|
If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then
|
|
MensajeAlert.Append($"<br/> El numero de Serie <b>""{Serie}""</b> proporcionado se encuentra duplicado.")
|
|
End If
|
|
|
|
Dim Row = DtSeriesNuevas.NewRow
|
|
Row("Serie") = Serie
|
|
DtSeriesNuevas.Rows.Add(Row)
|
|
Next
|
|
|
|
If MensajeAlert.ToString <> "" Then
|
|
Alert(MensajeAlert.ToString, TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
Dim MensajeSinExistencias As New StringBuilder
|
|
Dim ObjInventarios As New ClsInventarios
|
|
For Each Serie In SeriesArreglo
|
|
Dim Row = DtDatosDetalle.NewRow
|
|
|
|
'VERIFICA EXISTENCIAS
|
|
Dim Existencia = 0.0D
|
|
If TipoMovimiento = 1 Then
|
|
Existencia = ObjInventarios.GetExistenciasPS(CvePSSerieLote, CveUMSerieLote, UsuarioActual.CveEmpresa, DdlAlmacenArmado.SelectedValue.ToEntero, FechaMovto:=TxtFechaArmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Serie, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente))
|
|
Else
|
|
Existencia = If(DtExistenciasDesarmado Is Nothing, 0, DtExistenciasDesarmado.FiltraParametros($"CvePS={CvePSSerieLote} AND SeriePS='{Serie}'").Rows.Count.ToString.ToDecimal)
|
|
End If
|
|
|
|
If Existencia < 1 Then
|
|
Alert($"No hay existencia suficiente con la Serie definida <b>""{Serie}""</b>. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia, If(Tipo = 2, "window.setTimeout(Focus,200);", ""))
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
If Tipo = 1 Then
|
|
RegistraScript("$('#DivSerie').modal('show')")
|
|
End If
|
|
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
|
|
|
|
Row("ConsecId") = CveConsecSerieLote
|
|
Row("Consec") = DtDatosDetalle.Rows.Count + 1
|
|
Row("CvePS") = CvePSSerieLote
|
|
Row("CveUM") = CveUMSerieLote
|
|
Row("Serie") = Serie
|
|
|
|
If TipoMovimiento = 2 Then
|
|
Row("SeriePaquete") = DtExistenciasDesarmado.FiltroPrimeroValor("SeriePaquete", $"CvePS={CvePSSerieLote} AND SeriePS='{Serie}'")
|
|
End If
|
|
|
|
DtDatosDetalle.Rows.Add(Row)
|
|
Next
|
|
ObjInventarios.Dispose()
|
|
|
|
If Tipo = 1 Then
|
|
TxtSerie.Text = ""
|
|
End If
|
|
|
|
CargaSerie(2)
|
|
|
|
If MensajeAlert.ToString <> "" Then
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Else
|
|
If MensajeSinExistencias.ToString <> "" Then
|
|
Alert($"Las siguientes Series no cuentan con la existencia suficiente por lo cual se omitieron. <br?><br/> {MensajeSinExistencias.ToString}", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvSerie_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSerie.RowDeleting
|
|
DtDatosDetalle.Rows.Remove(DtDatosDetalle.Rows(e.RowIndex))
|
|
CargaSerie(2)
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " SERIE DEL PAQUETE "
|
|
'SERIES ARMADO
|
|
Protected Sub BtnSeriePaquete_Click(sender As Object, e As EventArgs)
|
|
Dim i = 1
|
|
Dim Dt As New DataTable
|
|
Dt.Columns.Add("Row", GetType(Integer))
|
|
Dt.Columns.Add("Serie", GetType(String))
|
|
|
|
'Dim DrPS As DataRow = Nothing
|
|
'DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=_DdlPaqueteArmado.SelectedValue.ToEntero).FiltroPrimero("")
|
|
'Dim AplicaSerie
|
|
|
|
|
|
For Each Row As DataRow In DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CType(sender, LinkButton).CommandArgument.ToEntero)).Rows
|
|
If i > TxtCantidadArmado.Text.ToEntero Then
|
|
Exit For
|
|
End If
|
|
|
|
Dim Row2 = Dt.NewRow
|
|
Row2("Row") = i
|
|
Row2("Serie") = Row("Serie")
|
|
Dt.Rows.Add(Row2)
|
|
|
|
i = i + 1
|
|
Next
|
|
|
|
GvSeriesPaqueteArmado.DataSource = Dt
|
|
GvSeriesPaqueteArmado.DataBind()
|
|
|
|
|
|
|
|
UpSeriesPaqueteArmado.Update()
|
|
End Sub
|
|
|
|
'SERIES DESARMADO
|
|
Private Sub CreaDtSeriesDesarmado()
|
|
If DtSeriesDesarmado Is Nothing Then
|
|
DtSeriesDesarmado = New DataTable
|
|
DtSeriesDesarmado.Columns.Add("Row", GetType(Integer))
|
|
DtSeriesDesarmado.Columns.Add("Serie", GetType(String))
|
|
DtSeriesDesarmado.Columns.Add("Lote", GetType(String))
|
|
DtSeriesDesarmado.Columns.Add("FechaCaducidad", GetType(Date))
|
|
|
|
|
|
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnAgregarSerieDesarmado_Click(sender As Object, e As EventArgs)
|
|
Dim Serie As String = If(AplicaSeriePaquete, TxtSerieDesarmado.Text.Trim, "-1")
|
|
Dim Lote As String = If(AplicaLotePaquete, TxtLoteDesarmado.Text.Trim, "-1")
|
|
Dim FechaCaducidad As Date = If(AplicaCaducidadPaquete, TxtDesarmadoCaducidad.Text.ToDate, MinFecha)
|
|
|
|
'VERIFICA EXISTENCIAS
|
|
Dim ObjInventarios As New ClsInventarios
|
|
Dim CveUMTemp = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePaqueteDesarmado).FiltroPrimeroValor("CveUM").ToEntero
|
|
Dim Existencia = ObjInventarios.GetExistenciasPS(CvePaqueteDesarmado, CveUMTemp, UsuarioActual.CveEmpresa, CveAlmacenDesarmado, FechaMovto:=TxtFechaDesarmado.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Serie:=Serie,
|
|
CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Lote:=Lote, FechaCaducidad:=FechaCaducidad)
|
|
|
|
If Existencia < 1 Then
|
|
Alert($"No hay existencia suficiente con la Serie definida <b>""{Serie}""</b>. Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
|
|
If ObjInventarios.GetPaqueteRelacionSeries(CvePaqueteDesarmado, Serie) Then
|
|
If DtExistenciasDesarmado Is Nothing Then
|
|
DtExistenciasDesarmado = ObjInventarios.DtResultados.Copy
|
|
Else
|
|
DtExistenciasDesarmado.Merge(ObjInventarios.DtResultados)
|
|
End If
|
|
End If
|
|
|
|
ObjInventarios.Dispose()
|
|
|
|
|
|
Dim Row = DtSeriesDesarmado.NewRow
|
|
Row("Row") = DtSeriesDesarmado.MAX("Row").ToEntero + 1
|
|
Row("Serie") = TxtSerieDesarmado.Text.Trim
|
|
Row("Lote") = TxtLoteDesarmado.Text.Trim
|
|
Row("FechaCaducidad") = TxtDesarmadoCaducidad.Text.ToDate
|
|
|
|
DtSeriesDesarmado.Rows.Add(Row)
|
|
|
|
TxtSerieDesarmado.Text = ""
|
|
TxtLoteDesarmado.Text = ""
|
|
TxtDesarmadoCaducidad.Text = ""
|
|
|
|
|
|
If DtSeriesDesarmado.Rows.Count >= TxtCantidadDesarmado.Text.ToEntero Then
|
|
BtnAgregarSerieDesarmado.Enabled = False
|
|
Else
|
|
BtnAgregarSerieDesarmado.Enabled = True
|
|
End If
|
|
|
|
GvSeriesPaqueteDesarmado.DataSource = DtSeriesDesarmado
|
|
GvSeriesPaqueteDesarmado.DataBind()
|
|
UpSeriesPaqueteDesarmado.Update()
|
|
End Sub
|
|
Protected Sub GvSeriesPaqueteDesarmado_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSeriesPaqueteDesarmado.RowDeleting
|
|
Dim SerieEliminada = DtSeriesDesarmado.Rows(e.RowIndex)("Serie").ToString
|
|
DtSeriesDesarmado.Rows.Remove(DtSeriesDesarmado.Rows(e.RowIndex))
|
|
|
|
'ELIMINA EXISTENCIAS DEL PAQUETE
|
|
Dim dtTemp As DataTable = DtExistenciasDesarmado.FiltraParametros($"SeriePaquete<>'{SerieEliminada}'")
|
|
DtExistenciasDesarmado.Clear()
|
|
DtExistenciasDesarmado.Merge(dtTemp)
|
|
|
|
'ELIMINA SERIES DE COMPONENTES DEPENDIENTES DEL PAQUETE ELIMINADO
|
|
dtTemp = DtDatosDetalle.FiltraParametros($"SeriePaquete<>'{SerieEliminada}'")
|
|
DtDatosDetalle.Clear()
|
|
DtDatosDetalle.Merge(dtTemp)
|
|
|
|
dtTemp.Dispose()
|
|
|
|
If DtSeriesDesarmado.Rows.Count >= TxtCantidadDesarmado.Text.ToEntero Then
|
|
BtnAgregarSerieDesarmado.Enabled = False
|
|
Else
|
|
BtnAgregarSerieDesarmado.Enabled = True
|
|
End If
|
|
|
|
GvSeriesPaqueteDesarmado.DataSource = DtSeriesDesarmado
|
|
GvSeriesPaqueteDesarmado.DataBind()
|
|
|
|
UpSeriesPaqueteDesarmado.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
End Class
|