1204 lines
53 KiB
VB.net
1204 lines
53 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Partial Class Inventarios_ResguardoMaterial
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
Public Property DtMovimientos() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientos") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtMovimientosLiberacion() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientosLiberacion"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientosLiberacion") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Public Property CveAlmacenLiberación() As Integer
|
|
Get
|
|
Return ViewState("CveAlmacenLiberación").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAlmacenLiberación") = value
|
|
End Set
|
|
End Property
|
|
Public Property CvePersonalLiberacion() As Integer
|
|
Get
|
|
Return ViewState("CvePersonalLiberacion").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePersonalLiberacion") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveClienteLiberacion() As Integer
|
|
Get
|
|
Return ViewState("CveClienteLiberacion").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveClienteLiberacion") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveProveedorLiberacion() As Integer
|
|
Get
|
|
Return ViewState("CveProveedorLiberacion").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveProveedorLiberacion") = value
|
|
End Set
|
|
End Property
|
|
Public Property FechaLiberacion As String
|
|
Get
|
|
Return ViewState("FechaLiberacion").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("FechaLiberacion") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Public Property EsSurtidoUniforme As Boolean
|
|
Get
|
|
If ViewState("EsSurtidoUniforme") Is Nothing Then
|
|
Return False
|
|
|
|
Else
|
|
Return Boolean.Parse(ViewState("EsSurtidoUniforme").ToString)
|
|
End If
|
|
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsSurtidoUniforme") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DtSeccionAlmacen As DataTable
|
|
Get
|
|
Return CType(ViewState("DtSeccionAlmacen"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtSeccionAlmacen") = value
|
|
End Set
|
|
End Property
|
|
Private Property IndexSeccionAlmacen As Integer
|
|
Get
|
|
Return CType(ViewState("IndexSeccionAlmacen"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IndexSeccionAlmacen") = value
|
|
End Set
|
|
End Property
|
|
Private Property CantidadTotal As Decimal
|
|
Get
|
|
Return CType(ViewState("CantidadTotal"), Decimal)
|
|
End Get
|
|
Set(value As Decimal)
|
|
ViewState("CantidadTotal") = value
|
|
End Set
|
|
End Property
|
|
Private Property CvePS As Integer
|
|
Get
|
|
Return CType(ViewState("CvePS"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePS") = value
|
|
End Set
|
|
End Property
|
|
Private Property TipoSeccionAlmacen As Integer
|
|
Get
|
|
Return CType(ViewState("TipoSeccionAlmacen"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoSeccionAlmacen") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
|
|
If Not Request.QueryString("EsSurtidoUniforme") Is Nothing Then
|
|
EsSurtidoUniforme = If(Request.QueryString("EsSurtidoUniforme").ToString = "1", True, False)
|
|
End If
|
|
|
|
|
|
InicializaValores()
|
|
|
|
If Not Request.QueryString("CvePersonal") Is Nothing Then
|
|
Try
|
|
Dim CvePersonal As Integer = Request.QueryString("CvePersonal").ToString.ToEntero
|
|
OcultarControles(CvePersonal)
|
|
Catch ex As Exception
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OcultarControles(CvePersonal As Integer)
|
|
|
|
DdlPersonal.SelectedValueExist(CvePersonal)
|
|
DdlPersonal.Enabled = False
|
|
DVTipo.Visible = False
|
|
End Sub
|
|
|
|
#Region " INICIALIZA VALORES "
|
|
Private Sub InicializaValores()
|
|
CreaDT()
|
|
CargaCombos()
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
TxtFechaLiberacion.Text = Now.ToShortDateString
|
|
GvM.Columns(6).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1"
|
|
GvMLiberacion.Columns(7).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1"
|
|
|
|
GvM.DataBind()
|
|
|
|
CantidadTotal = 0
|
|
IndexSeccionAlmacen = 0
|
|
CvePS = 0
|
|
CreaDtSeccionAlmacen()
|
|
CargaDdlAlmacen()
|
|
TipoSeccionAlmacen = 0
|
|
|
|
End Sub
|
|
|
|
Protected Sub CreaDT()
|
|
Dim dt As New DataTable
|
|
|
|
Dim column As DataColumn = New DataColumn("No")
|
|
column.DataType = Type.GetType("System.Int32")
|
|
With column
|
|
.AutoIncrement = True
|
|
.AutoIncrementSeed = 1
|
|
.AutoIncrementStep = 1
|
|
End With
|
|
dt.Columns.Add(column)
|
|
dt.Columns.Add("CveMovimiento", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("CveMovimientoDetalle", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("Cantidad", Type.GetType("System.Double"))
|
|
dt.Columns.Add("CveUM", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("UnidadMedida")
|
|
dt.Columns.Add("CvePS", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("PS")
|
|
dt.Columns.Add("Estatus")
|
|
dt.Columns.Add("Codigo")
|
|
dt.Columns.Add("SerieLote")
|
|
dt.Columns.Add("Observaciones")
|
|
dt.Columns.Add("CvePersonal", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("Checado", Type.GetType("System.Boolean"))
|
|
|
|
DtMovimientos = dt
|
|
|
|
CargaGvM()
|
|
|
|
End Sub
|
|
Private Sub CargaCombos()
|
|
|
|
DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
|
|
DdlPersonal.DataBind()
|
|
DdlPersonal.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlPersonalLiberacion.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
|
|
DdlPersonalLiberacion.DataBind()
|
|
DdlPersonalLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
DdlCliente.DataBind()
|
|
DdlCliente.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlClienteLiberacion.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
DdlClienteLiberacion.DataBind()
|
|
DdlClienteLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlProveedor.setEsWebService(True)
|
|
DdlProveedor.Attributes.Add("data-metodo", "getproveedores")
|
|
DdlProveedor.SelectedValue = "-1"
|
|
DdlProveedor.SelectedText = "Seleccione"
|
|
|
|
DdlProveedorLiberacion.setEsWebService(True)
|
|
DdlProveedorLiberacion.Attributes.Add("data-metodo", "getproveedores")
|
|
DdlProveedorLiberacion.SelectedValue = "-1"
|
|
DdlProveedorLiberacion.SelectedText = "Seleccione"
|
|
|
|
If isWhitFamily() Then
|
|
DdlClasificacion.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion")
|
|
Else
|
|
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion")
|
|
End If
|
|
DdlClasificacion.DataBind()
|
|
|
|
|
|
|
|
If EsSurtidoUniforme Then
|
|
'RESGUARDO
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (19)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
'Almacen Destino
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 20)
|
|
DdlAlmacenDestino.DataBind()
|
|
DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
'LIBERACION
|
|
DdlAlmacenLiberacion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 20)
|
|
DdlAlmacenLiberacion.DataBind()
|
|
DdlAlmacenLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
''Almacen Destino
|
|
Else
|
|
'RESGUARDO
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) '.FiltraParametros("CveTipoAlmacen IN (1,2)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
'Almacen Destino
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 8)
|
|
DdlAlmacenDestino.DataBind()
|
|
DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
|
|
'LIBERACION
|
|
DdlAlmacenLiberacion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 8)
|
|
DdlAlmacenLiberacion.DataBind()
|
|
DdlAlmacenLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
|
|
''Almacen Destino
|
|
DdlAlmacenDestinoLiberacion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) '.FiltraParametros("CveTipoAlmacen IN (1,2)")
|
|
DdlAlmacenDestinoLiberacion.DataBind()
|
|
DdlAlmacenDestinoLiberacion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
CargaPS()
|
|
End Sub
|
|
Private Sub CargaPS()
|
|
DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
If DdlProducto2.UsaWebService Then
|
|
DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios")
|
|
DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue.ToString)
|
|
End If
|
|
If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then
|
|
DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
|
DdlProducto2.DataBind()
|
|
End If
|
|
|
|
VerificaProducto()
|
|
End Sub
|
|
Private Function isWhitFamily() As Boolean
|
|
Return (UsuarioActual.CveEmpresa = 66)
|
|
End Function
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " RESGUARDO "
|
|
|
|
|
|
#Region " FUNCIONALIDAD 105 - CLASIFICACION PS"
|
|
Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged
|
|
CargaProductosPorClasificacion()
|
|
End Sub
|
|
Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange
|
|
VerificaProducto()
|
|
End Sub
|
|
Private Sub CargaProductosPorClasificacion()
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "" Then
|
|
'Dim filtro As String = ""
|
|
'If Not (DdlClasificacion.SelectedValue = "-1") Then
|
|
|
|
' If isWhitFamily() Then
|
|
' 'filtro = String.Format("CveSubFamilia={0}", DdlClasificacion.SelectedValue)
|
|
' Else
|
|
' filtro = String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue)
|
|
' End If
|
|
'End If
|
|
DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltraParametros("", "PSCodigo")
|
|
DdlProducto2.DataBind()
|
|
DdlProducto2.ddl.Items.Insert(0, New ListItem("----", "-1"))
|
|
Else
|
|
'If isWhitFamily() Then
|
|
' 'DdlProducto2.ddlWS.Attributes.Add("data-idSubFamilia", DdlClasificacion.SelectedValue)
|
|
'Else
|
|
DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue)
|
|
'End If
|
|
End If
|
|
End Sub
|
|
Private Sub VerificaProducto()
|
|
If DdlProducto2.SelectedValue.ToEntero > 0 Then
|
|
If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltraParametros("Inv_CveMetodoInventario = 5", "PS").Rows.Count > 0 Then
|
|
ThSerieLote.Visible = True
|
|
TrSerieLote.Visible = True
|
|
TxtnSerieLote.Visible = True
|
|
GvM.Columns(4).Visible = True
|
|
Else
|
|
TxtnSerieLote.Visible = False
|
|
End If
|
|
End If
|
|
|
|
'If (1.Contiene("3", "7", "8", "11")) Then
|
|
' Dim objinv As New ClsInventarios
|
|
' If objinv.GetExistenciasPS(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm")) Then
|
|
' DdlUnidad.DataSource = objinv.DtResultados.FiltraParametros("", "UnidadMedida", {"CveUnidadMedida", "UnidadMedida"})
|
|
' If objinv.DtResultados.Rows.Count = 0 Then
|
|
' Alert("No hay existencias de este producto", TipoMensaje.MsgAdvertencia)
|
|
' End If
|
|
' End If
|
|
' objinv.Dispose()
|
|
'Else
|
|
' DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1)
|
|
'End If
|
|
|
|
DdlUnidad.Items.Clear()
|
|
DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
DdlUnidad.DataBind()
|
|
UPDatos.Update()
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " EISTENCIAS "
|
|
Private Function GetExistencias(CvePS As Integer, CveUnidadMedida As Integer, CveEmpresa As Integer, CveAlmacen As Integer, Optional SerieLote As String = "-1") As Double
|
|
Dim Inv As New ClsInventarios
|
|
Dim Existencia As Double = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, CveEmpresa, CveAlmacen, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=SerieLote)
|
|
Inv.Dispose()
|
|
Return Existencia
|
|
End Function
|
|
#End Region
|
|
|
|
|
|
#Region " AGREGAR "
|
|
Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
|
AgregaProducto()
|
|
LimpiarAgregar()
|
|
End Sub
|
|
Protected Sub AgregaProducto()
|
|
Dim PSSelected As Integer = DdlProducto2.SelectedValue.ToEntero
|
|
If DdlAlmacen.SelectedValue.ToEntero <= 0 Then Alert("Seleccione un almacen", TipoMensaje.MsgInformacion) : Exit Sub
|
|
If PSSelected > 0 Then
|
|
If TxtnSerieLote.Visible Then
|
|
If TxtnSerieLote.Text = "" Then
|
|
Alert("Serie-Lote es necesario", TipoMensaje.MsgAdvertencia)
|
|
Return
|
|
End If
|
|
End If
|
|
Dim Valido As Boolean = True
|
|
Dim cantidadd As Double = txtCantidad.Text.ToDouble
|
|
Dim Existencia As Double = GetExistencias(PSSelected, DdlUnidad.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, If(TxtnSerieLote.Visible, TxtnSerieLote.Text, "-1").ToString)
|
|
If Existencia - txtCantidad.Text.ToDouble < 0 Then
|
|
If Existencia <= 0 Then
|
|
Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
Alert(String.Format("Solo hay en existencia: {0}", Existencia), TipoMensaje.MsgAdvertencia)
|
|
If Not UsuarioActual.TienePermisoProceso(114) Then
|
|
cantidadd = Existencia
|
|
End If
|
|
End If
|
|
Valido = False
|
|
'Valido = If(UsuarioActual.TienePermisoProceso(114), True, False)
|
|
End If
|
|
If Valido Then
|
|
Dim CveClasificacion As Integer
|
|
Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=PSSelected).FiltroPrimero("", "PS")
|
|
If dr IsNot Nothing Then CveClasificacion = dr("CveClasificacion").ToString.ToEntero
|
|
|
|
Dim registro As DataRow = DtMovimientos.NewRow
|
|
registro.Item("Cantidad") = cantidadd
|
|
registro.Item("CveUM") = DdlUnidad.SelectedValue.ToEntero
|
|
registro.Item("UnidadMedida") = DdlUnidad.SelectedItem.Text
|
|
registro.Item("CvePS") = PSSelected
|
|
registro.Item("PS") = DdlProducto2.SelectedText
|
|
registro.Item("Estatus") = ""
|
|
registro.Item("SerieLote") = TxtnSerieLote.Text
|
|
registro.Item("Observaciones") = TxtObservacionesdetalle.Text
|
|
DtMovimientos.Rows.Add(registro)
|
|
CargaGvM()
|
|
|
|
txtCantidad.Text = ""
|
|
txtCantidad.Focus()
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
Private Sub LimpiarAgregar()
|
|
DdlClasificacion.SelectedValue = "-1"
|
|
txtCantidad.Text = ""
|
|
TxtObservacionesdetalle.Text = ""
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " GvM "
|
|
Private Sub CargaGvM()
|
|
|
|
ThSerieLote.Visible = False
|
|
TrSerieLote.Visible = False
|
|
TxtnSerieLote.Visible = False
|
|
GvM.Columns(4).Visible = False
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
If Dr("SerieLote").ToString <> "" Then
|
|
ThSerieLote.Visible = True
|
|
TrSerieLote.Visible = True
|
|
GvM.Columns(4).Visible = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
GvM.DataSource = DtMovimientos
|
|
GvM.DataBind()
|
|
End Sub
|
|
|
|
Private Sub GvM_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvM.RowDeleting
|
|
Dim DbRow As DataRow = Nothing
|
|
DbRow = DtMovimientos.Rows(e.RowIndex)
|
|
DtMovimientos.Rows.Remove(DbRow)
|
|
|
|
GvM.EditIndex = -1
|
|
CargaGvM()
|
|
End Sub
|
|
|
|
Protected Sub GvM_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {e.Row.RowIndex}").SUMD("CantidadSeccionAlmacen") > 0 Then
|
|
e.Row.FCLinkButton("lnkRemove").Visible = False
|
|
e.Row.FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen"
|
|
End If
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " NUEVO "
|
|
Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs)
|
|
LimpiarMovimiento()
|
|
End Sub
|
|
Private Sub LimpiarMovimiento()
|
|
DtMovimientos.Clear()
|
|
CargaGvM()
|
|
|
|
BtnGuardarResguardo.Visible = True
|
|
|
|
DdlAlmacen.SelectedValue = "-1"
|
|
DdlAlmacenDestino.SelectedValue = "-1"
|
|
DtSeccionAlmacen.Rows.Clear()
|
|
|
|
TxtObservaciones.Text = ""
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
DdlPersonal.SelectedIndex = 0
|
|
LimpiarAgregar()
|
|
UPDatos.Update()
|
|
UpGenerales.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " LIBERACION "
|
|
|
|
|
|
#Region " GV DATOS LIBERACION "
|
|
Protected Sub GvMLiberacion_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
e.Row.FCLabel("LblCantidad").Text = e.Row.FCLabel("LblCantidad").Text.FormatoNumero(2)
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvMLiberacion_RowCreated(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim Index = e.Row.RowIndex
|
|
e.Row.FCTextBox("TxtCantidad").Attributes.Add("onKeyUp", String.Format("ValidarCantidad({0});", Index))
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA RESGUARDOS PARA LIBERACION "
|
|
|
|
Protected Sub BtnVerificarExistencias_Click(sender As Object, e As EventArgs)
|
|
If Not DdlProveedorLiberacion.SelectedValue.ToEntero > 0 AndAlso DdlTipo.SelectedValue.ToEntero = 3 Then
|
|
Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not DdlPersonalLiberacion.SelectedValue.ToEntero > 0 AndAlso DdlTipo.SelectedValue.ToEntero = 1 Then
|
|
Alert("Tiene que seleccionar un personal.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not DdlClienteLiberacion.SelectedValue.ToEntero > 0 AndAlso DdlTipo.SelectedValue.ToEntero = 2 Then
|
|
Alert("Tiene que seleccionar un cliente.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
CargaResguardos()
|
|
End Sub
|
|
|
|
Private Sub CargaResguardos()
|
|
Dim ObjInventario As New ClsInventarios()
|
|
Dim Existencias As Double = 0
|
|
|
|
If ObjInventario.GetMovimientosDetallePorPersonal(DdlPersonalLiberacion.SelectedValue.ToEntero, DdlAlmacenLiberacion.SelectedValue.ToEntero, DdlClienteLiberacion.SelectedValue.ToEntero, DdlProveedorLiberacion.SelectedValue.ToEntero) Then
|
|
DtMovimientosLiberacion = ObjInventario.DtResultados
|
|
|
|
DtMovimientosLiberacion.Columns("No").AutoIncrement = True
|
|
DtMovimientosLiberacion.Columns("No").AutoIncrementSeed = DtMovimientosLiberacion.Rows.Count + 1
|
|
DtMovimientosLiberacion.Columns("No").AutoIncrementStep = 1
|
|
|
|
Dim keys(1) As DataColumn
|
|
keys(0) = DtMovimientosLiberacion.Columns("No")
|
|
DtMovimientosLiberacion.PrimaryKey = keys
|
|
|
|
CargaGvMLiberacion()
|
|
If DdlPersonalLiberacion.SelectedValue.ToEntero <> -1 Then
|
|
LblTipo.InnerText = "Personal/Responsable:"
|
|
LbTipoLiberacion.Text = DdlPersonalLiberacion.SelectedItem.Text
|
|
End If
|
|
If DdlProveedorLiberacion.SelectedValue.ToEntero <> -1 Then
|
|
LblTipo.InnerText = "Proveedor:"
|
|
LbTipoLiberacion.Text = DdlProveedorLiberacion.SelectedText
|
|
End If
|
|
If DdlClienteLiberacion.SelectedValue.ToEntero <> -1 Then
|
|
LblTipo.InnerText = "Cliente:"
|
|
LbTipoLiberacion.Text = DdlClienteLiberacion.SelectedItem.Text
|
|
End If
|
|
CvePersonalLiberacion = DdlPersonalLiberacion.SelectedValue.ToEntero
|
|
CveClienteLiberacion = DdlClienteLiberacion.SelectedValue.ToEntero
|
|
CveProveedorLiberacion = DdlProveedorLiberacion.SelectedValue.ToEntero
|
|
LbAlmacenLiberacion.Text = DdlAlmacenLiberacion.SelectedItem.Text
|
|
CveAlmacenLiberación = DdlAlmacenLiberacion.SelectedValue.ToEntero
|
|
LbFechaLiberacion.Text = TxtFechaLiberacion.Text
|
|
FechaLiberacion = TxtFechaLiberacion.Text
|
|
BtnGuardarLiberacion.Visible = True
|
|
|
|
DtSeccionAlmacen.Rows.Clear()
|
|
|
|
UpGeneralesLibreacion.Update()
|
|
Else
|
|
Alert("Ocurrió un error al cargar los resguardos del personal. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjInventario.Dispose()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaGvMLiberacion()
|
|
GvM.Columns(5).Visible = False
|
|
For Each Dr As DataRow In DtMovimientosLiberacion.Rows
|
|
If Dr("SerieLote").ToString <> "" Then
|
|
GvM.Columns(5).Visible = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
GvMLiberacion.DataSource = DtMovimientosLiberacion
|
|
GvMLiberacion.DataBind()
|
|
UpGridLiberacion.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " LIMPIAR LIBERACION "
|
|
Private Sub LimpiarLiberacion()
|
|
LbTipoLiberacion.Text = ""
|
|
LblTipo.InnerText = ""
|
|
CvePersonalLiberacion = -1
|
|
CveClienteLiberacion = -1
|
|
CveProveedorLiberacion = -1
|
|
LbAlmacenLiberacion.Text = ""
|
|
CveAlmacenLiberación = -1
|
|
LbFechaLiberacion.Text = ""
|
|
FechaLiberacion = ""
|
|
BtnGuardarLiberacion.Visible = False
|
|
DtSeccionAlmacen.Rows.Clear()
|
|
|
|
DdlAlmacenDestinoLiberacion.SelectedValue = "-1"
|
|
TxtObservacionesLiberacion.Text = ""
|
|
|
|
DtMovimientosLiberacion.Clear()
|
|
CargaGvMLiberacion()
|
|
|
|
UpGeneralesLibreacion.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " GUARDAR "
|
|
Protected Sub BtnGuardarResguardo_Click(sender As Object, e As EventArgs) Handles BtnGuardarResguardo.Click
|
|
|
|
If Not GvM.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 Not DdlProveedor.SelectedValue.ToEntero > 0 And DivProveedor.Visible Then
|
|
Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'VALIDA LA EXISTENCIA DEL ALMACEN
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ErrorExistencia = False
|
|
Dim TextoExistencia As StringBuilder = New StringBuilder
|
|
Dim Existencia As Double
|
|
TextoExistencia.Append("Los siguiente productos se ajustaron por falta de exitencia:<br/>")
|
|
For Each dr As DataRow In DtMovimientos.Rows
|
|
Existencia = ObjInventario.GetExistenciasPS(dr("CvePS").ToString.ToEntero, dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), SerieLote:=If(dr("SerieLote").ToString = "", "-1", dr("SerieLote").ToString))
|
|
Existencia -= DtMovimientos.SUM("Cantidad", $"CvePS = {dr("CvePS").ToString.ToEntero} AND CveUM = {dr("CveUM").ToString.ToEntero} {If(dr("SerieLote").ToString <> "-1", $" AND SerieLote = '{dr("SerieLote").ToString}'", "")}")
|
|
|
|
If Existencia < 0 Then
|
|
ErrorExistencia = True
|
|
dr("Cantidad") = Existencia
|
|
TextoExistencia.AppendFormat("- #{0} {1}<br/>", dr("No").ToString, dr("PS").ToString)
|
|
End If
|
|
Next
|
|
ObjInventario.Dispose()
|
|
|
|
If ErrorExistencia Then
|
|
Alert(TextoExistencia.ToString, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
Dim TotalCantidad As Double = DtMovimientos.SUMD("Cantidad")
|
|
If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then
|
|
If TotalCantidad <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 1").SUMD("CantidadSeccionAlmacen") Then
|
|
Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
Guardar(23)
|
|
|
|
End Sub
|
|
Protected Sub BtnGuardarLiberacion_Click(sender As Object, e As EventArgs)
|
|
|
|
If Not DdlProveedorLiberacion.SelectedValue.ToEntero > 0 And DivProveedorLiberacion2.Visible Then
|
|
Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not GvMLiberacion.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
|
|
|
|
Dim TieneError = True
|
|
Dim TotalCantidad As Decimal = 0
|
|
For Each Gvr As GridViewRow In GvMLiberacion.Rows
|
|
If Gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then
|
|
TieneError = False
|
|
Exit For
|
|
Else
|
|
TotalCantidad += Gvr.FCTextBox("TxtCantidad").Text.ToDecimal
|
|
End If
|
|
Next
|
|
|
|
If TieneError Then
|
|
Alert("Se debe seleccionar por lo menos una cantidad de los resguardos para generar la liberación. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then
|
|
If TotalCantidad <> DtSeccionAlmacen.FiltraParametros("TipoSeccionAlmacen = 2").SUMD("CantidadSeccionAlmacen") Then
|
|
Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
Guardar(24)
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub Guardar(Concepto As Integer)
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) 'Inicia la transacción
|
|
Dim TieneError = False
|
|
Dim MensajeError As String = ""
|
|
Dim ImporteConcepto = 0.0
|
|
|
|
Dim CveMovimientoSalida = 0
|
|
Dim FolioSalida = 0
|
|
Dim CveMovimientoEntrada = 0
|
|
Dim FolioEntrada = 0
|
|
|
|
'Para Campos Nuevos AF y OC
|
|
Dim SubProyecto = -1
|
|
Dim ActivoFijo = -1
|
|
|
|
Dim CveProveedor = -1
|
|
Dim CveCliente = -1
|
|
Dim CvePersonal = -1
|
|
|
|
If RbTipoCliente.Checked Then CveCliente = DdlCliente.SelectedValue.ToEntero
|
|
If RbTipoProveedor.Checked Then CveProveedor = DdlProveedor.SelectedValue.ToEntero
|
|
If RbTipoPersonal.Checked Then CvePersonal = DdlPersonal.SelectedValue.ToEntero
|
|
|
|
Dim Fecha = If(Concepto = 23, TxtFecha.Text.ToDate, FechaLiberacion.ToDate)
|
|
|
|
Select Case (Concepto)
|
|
Case 23 ' Resguardo
|
|
|
|
'SALIDA ORIGEN
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 24, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservaciones.Text, CvePersonal:=CvePersonal, CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, CveCliente:=CveCliente, CveProveedor:=CveProveedor)
|
|
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 Cont As Integer = 0
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then
|
|
MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar."
|
|
TieneError = True
|
|
Exit For
|
|
Else
|
|
If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
|
|
For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows
|
|
If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
Cont += 1
|
|
Next
|
|
|
|
Cont = 0
|
|
If Not TieneError Then
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenDestino.SelectedValue.ToEntero, 2, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservaciones.Text, CvePersonal:=CvePersonal, CveMovimientoRelacionado:=CveMovimientoSalida, CveCliente:=CveCliente, CveProveedor:=CveProveedor)
|
|
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
|
|
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, Dr("Observaciones").ToString) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
Else
|
|
If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
|
|
For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 1").Rows
|
|
If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
Cont += 1
|
|
Next
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Case 24 'LIBERACION
|
|
|
|
|
|
'SALIDA ORIGEN - RESGUARDO
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenLiberación, 3, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservacionesLiberacion.Text, CvePersonal:=CvePersonalLiberacion, CveAlmacenDestino:=DdlAlmacenDestinoLiberacion.SelectedValue.ToEntero, CveProveedor:=CveProveedorLiberacion, CveCliente:=CveClienteLiberacion, MovimientoFijo:=True)
|
|
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 Cont As Integer = 0
|
|
For Each Gvr As GridViewRow In GvMLiberacion.Rows
|
|
If Gvr.FCTextBox("TxtCantidad").Text.ToDouble > 0 Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidad").Text.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDouble, -1, -1, Gvr.DataKey("SerieLote").ToString, Gvr.DataKey("Observaciones").ToString) Then
|
|
MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar."
|
|
TieneError = True
|
|
Exit For
|
|
Else
|
|
If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
|
|
For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 2").Rows
|
|
If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
End If
|
|
Cont += 1
|
|
Next
|
|
|
|
|
|
If Not TieneError Then
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(DdlAlmacenDestinoLiberacion.SelectedValue.ToEntero, 23, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, SubProyecto, ActivoFijo, Observaciones:=TxtObservacionesLiberacion.Text, CvePersonal:=CvePersonalLiberacion, CveMovimientoRelacionado:=CveMovimientoSalida, CveProveedor:=CveProveedorLiberacion, CveCliente:=CveClienteLiberacion, MovimientoFijo:=True)
|
|
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
|
|
Cont = 0
|
|
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, Dr("Observaciones").ToString) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
Else
|
|
If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then
|
|
For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont} AND TipoSeccionAlmacen = 2").Rows
|
|
If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then
|
|
TieneError = True
|
|
MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar."
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
Cont += 1
|
|
Next
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
End Select
|
|
|
|
If Not TieneError Then
|
|
TieneError = Not AgregarAgenda(ObjEventos, FolioEntrada, FolioSalida)
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
Dim Msg As New StringBuilder
|
|
If Concepto = 23 Then
|
|
Msg.AppendFormat("<br/>Resguardo con 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 Resguardo</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
|
|
|
|
Msg.AppendFormat("<br/><br/><br/>El Movimiento de control se registro con el Folio: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a></b>", CveMovimientoEntrada, FolioEntrada)
|
|
Else
|
|
Msg.AppendFormat("<br/>Liberación de Resguardo con 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 liberación de Resguardo</a> ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada)))
|
|
|
|
Msg.AppendFormat("<br/><br/><br/>El Movimiento de control se registro con el Folio: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a></b>", CveMovimientoSalida, FolioSalida)
|
|
End If
|
|
|
|
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
'Limpia Valores cuando inserta de campos especiales
|
|
If UsuarioActual.CveEmpresa = 66 Then
|
|
DdlSubProyecto.SelectedValueExist("-1")
|
|
End If
|
|
|
|
ObjInventario.Commit()
|
|
|
|
If Concepto = 23 Then
|
|
LimpiarMovimiento()
|
|
Else
|
|
LimpiarLiberacion()
|
|
End If
|
|
|
|
UPDatos.Update()
|
|
Else
|
|
Alert(MensajeError, TipoMensaje.MsgError)
|
|
ObjInventario.RollBack()
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
ObjEventos.Dispose()
|
|
End Sub
|
|
Private Function AgregarAgenda(ByRef ObjEventos As ClsOIEventos, FolioEntrada As Integer, FolioSalida As Integer) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
Dim RecurrenciaTipo = 0, Frecuencia = -1, DiasSemana = "-1", Dias = -1, Mes = -1, RecurrenciaFin = "-1", CveAgendaTipo = 4, Prioridad = 3, CveTipoEvento = 2, Importe = -1
|
|
|
|
Dim Asunto As String = $"Vencimiento de Resguardo de Material. FolioEntrada:{FolioEntrada}, FolioSalida:{FolioSalida}"
|
|
Dim Descripcion As String = TxtObservaciones.Text.Trim()
|
|
Dim Fecha As DateTime = TxtFechaVigencia.Text.Trim().ToDateTime()
|
|
Dim FechaI As DateTime = Fecha
|
|
Dim FechaF As DateTime = Fecha.AddHours(22)
|
|
If Fecha > MinFecha Then
|
|
TieneError = Not ObjEventos.AddEventoAgenda(CveAgendaTipo, Asunto, Descripcion, Prioridad, FechaI, FechaF, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
|
|
RecurrenciaTipo:=RecurrenciaTipo, Frecuencia:=Frecuencia, DiasSemana:=DiasSemana, Dia:=Dias, Mes:=Mes, RecurrenciaFin:=RecurrenciaFin, CveTipoEvento:=CveTipoEvento, Importe:=Importe)
|
|
|
|
End If
|
|
|
|
Return Not TieneError
|
|
End Function
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "TIPOS"
|
|
|
|
Protected Sub RbTipo_CheckedChanged(sender As Object, e As EventArgs)
|
|
DivCliente.Visible = False
|
|
DivPersonal.Visible = False
|
|
DivProveedor.Visible = False
|
|
If RbTipoCliente.Checked Then DivCliente.Visible = True
|
|
If RbTipoPersonal.Checked Then DivPersonal.Visible = True
|
|
If RbTipoProveedor.Checked Then DivProveedor.Visible = True
|
|
UpGenerales.Update()
|
|
End Sub
|
|
|
|
Protected Sub DdlTipo_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
DdlPersonalLiberacion.SelectedIndex = 0
|
|
DdlProveedorLiberacion.SelectedValue = "-1"
|
|
DdlProveedorLiberacion.SelectedText = "Seleccione"
|
|
DdlClienteLiberacion.SelectedIndex = 0
|
|
DivPersonalLiberacion.Visible = False
|
|
DivPersonalLiberacion2.Visible = False
|
|
DivClienteLiberacion.Visible = False
|
|
DivClienteLiberacion2.Visible = False
|
|
DivProveedorLiberacion.Visible = False
|
|
DivProveedorLiberacion2.Visible = False
|
|
If DdlTipo.SelectedValue.ToEntero = 1 Then
|
|
DivPersonalLiberacion.Visible = True
|
|
DivPersonalLiberacion2.Visible = True
|
|
End If
|
|
If DdlTipo.SelectedValue.ToEntero = 2 Then
|
|
DivClienteLiberacion.Visible = True
|
|
DivClienteLiberacion2.Visible = True
|
|
End If
|
|
If DdlTipo.SelectedValue.ToEntero = 3 Then
|
|
DivProveedorLiberacion.Visible = True
|
|
DivProveedorLiberacion2.Visible = True
|
|
End If
|
|
UpFiltraLiberacion.Update()
|
|
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("CveSeccionAlmacenOrigen", GetType(Integer))
|
|
DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenDestino", GetType(Integer))
|
|
DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer))
|
|
DtSeccionAlmacen.Columns.Add("SeccionAlmacenOrigen", GetType(String))
|
|
DtSeccionAlmacen.Columns.Add("SeccionAlmacenDestino", GetType(String))
|
|
DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer))
|
|
DtSeccionAlmacen.Columns.Add("TipoSeccionAlmacen", GetType(Integer))
|
|
End Sub
|
|
Private Sub CargaDdlAlmacen()
|
|
DdlSeccionAlmacenOrigen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlSeccionAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSeccionAlmacenOrigen.DataBind()
|
|
|
|
DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSeccionAlmacenDestino.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 origen.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'If Not DdlAlmacenDestino.SelectedValue.ToEntero > 0 AndAlso Not ChkTransitorio.Checked Then
|
|
' Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
'End If
|
|
|
|
GvSeccion.Columns(2).Visible = True
|
|
DivSeccionAlmacenDestino.Visible = True
|
|
|
|
DivSeccionAlmacenOrigen.Visible = True
|
|
GvSeccion.Columns(1).Visible = True
|
|
|
|
CantidadTotal = gvRow.DataKey("Cantidad").ToDecimal
|
|
IndexSeccionAlmacen = gvRow.RowIndex
|
|
CvePS = gvRow.DataKey("CvePS").ToEntero
|
|
TipoSeccionAlmacen = 1
|
|
CargaSeccionAlmacen()
|
|
RegistraScript("$('#DModalSeccionAlmacen').modal()")
|
|
End Sub
|
|
|
|
Protected Sub LnkSeccionAlmacenDestino_Click(sender As Object, e As EventArgs)
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
|
|
If Not DdlAlmacenLiberacion.SelectedValue.ToEntero > 0 Then
|
|
Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen destino.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
DivSeccionAlmacenOrigen.Visible = True
|
|
DivSeccionAlmacenDestino.Visible = True
|
|
GvSeccion.Columns(1).Visible = True
|
|
GvSeccion.Columns(2).Visible = True
|
|
|
|
CantidadTotal = gvRow.FCTextBox("TxtCantidad").Text.ToDecimal
|
|
IndexSeccionAlmacen = gvRow.RowIndex
|
|
CvePS = gvRow.DataKey("CvePS").ToEntero
|
|
TipoSeccionAlmacen = 2
|
|
CargaSeccionAlmacen()
|
|
RegistraScript("$('#DModalSeccionAlmacen').modal()")
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaSeccionAlmacen()
|
|
Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").SUMD("CantidadSeccionAlmacen")
|
|
GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}")
|
|
GvSeccion.DataBind()
|
|
|
|
TxtCantidadSeccion.Text = ""
|
|
DdlSeccionAlmacenOrigen.SelectedIndex = 0
|
|
DdlSeccionAlmacenDestino.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 TipoSeccionAlmacen = 1 Then
|
|
If CantidadTotalSeccion > 0 Then
|
|
GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = False
|
|
GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").ToolTip = "Cuenta con sección almacen"
|
|
Else
|
|
GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").Visible = True
|
|
GvM.Rows(IndexSeccionAlmacen).FCLinkButton("lnkRemove").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
|
|
UpGenerales.Update()
|
|
|
|
ElseIf TipoSeccionAlmacen = 2 Then
|
|
If CantidadTotalSeccion > 0 Then
|
|
GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = False
|
|
GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = "Cuenta con sección almacen"
|
|
Else
|
|
GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").Enabled = True
|
|
GvMLiberacion.Rows(IndexSeccionAlmacen).FCTextBox("TxtCantidad").ToolTip = ""
|
|
End If
|
|
If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then
|
|
DdlAlmacenLiberacion.Enabled = False
|
|
DdlAlmacenLiberacion.ToolTip = "Cuenta con sección almacen"
|
|
Else
|
|
DdlAlmacenLiberacion.Enabled = True
|
|
DdlAlmacenLiberacion.ToolTip = ""
|
|
End If
|
|
UpGridLiberacion.Update()
|
|
UpFiltraLiberacion.Update()
|
|
End If
|
|
|
|
UpModalSeccionAlmacen.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(DdlSeccionAlmacenOrigen.SelectedValue.ToEntero, If(TipoSeccionAlmacen = 1, DdlAlmacen.SelectedValue.ToEntero, DdlAlmacenLiberacion.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 CveSeccionAlmacenOrigen = {DdlSeccionAlmacenOrigen.SelectedValue} AND TipoSeccionAlmacen = {TipoSeccionAlmacen}").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("CveSeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedValue.ToEntero
|
|
Row("SeccionAlmacenOrigen") = DdlSeccionAlmacenOrigen.SelectedItem.Text
|
|
Row("CveSeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedValue.ToEntero
|
|
Row("SeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedItem.Text
|
|
Row("CvePS") = CvePS
|
|
Row("Consec") = DtSeccionAlmacen.Rows.Count + 1
|
|
Row("TipoSeccionAlmacen") = TipoSeccionAlmacen
|
|
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
|
|
|
|
|
|
|
|
|
|
End Class
|