1748 lines
76 KiB
VB.net
1748 lines
76 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Partial Class Inventarios_Consignaciones
|
|
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 DtRemisiones() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtRemisiones"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtRemisiones") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Public Property DtRecepcion() As DataTable
|
|
Get
|
|
|
|
|
|
If ViewState("DtRecepcion") Is Nothing Then
|
|
ViewState("DtRecepcion") = New DataTable
|
|
End If
|
|
|
|
|
|
Return CType(ViewState("DtRecepcion"), DataTable)
|
|
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtRecepcion") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property CveConsignacion() As Integer
|
|
Get
|
|
Return ViewState("CveConsignacion").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveConsignacion") = value
|
|
End Set
|
|
End Property
|
|
Public Property SoloLectura() As Boolean
|
|
Get
|
|
Return CBool(ViewState("SoloLectura").ToString)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("SoloLectura") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
|
|
InicializaValores()
|
|
|
|
If Request("CveConsignacion") IsNot Nothing AndAlso Request("CveConsignacion").ToString.ToEntero > 0 Then
|
|
CargaMovimiento(Request("CveConsignacion").ToString.ToEntero)
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#Region "Inicializa Valores"
|
|
|
|
Private Sub InicializaValores()
|
|
CveConsignacion = -1
|
|
|
|
CargaCombos()
|
|
CargaDatosTraspaso()
|
|
CargaDatosRecepcionTraspaso()
|
|
CreaDT()
|
|
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
TxtFechaTraspaso.Text = Now.ToShortDateString
|
|
TxtFechaDevolucion.Text = Now.ToShortDateString
|
|
SoloLectura = False
|
|
|
|
'Carga Productos
|
|
DdlProducto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
|
|
DdlProducto.ddlWS.Attributes.Add("data-cveclasificacion", "-1")
|
|
DdlProducto.SelectedText = ""
|
|
DdlProducto.SelectedValue = "-1"
|
|
DdlProducto.ddl.Visible = False
|
|
|
|
Else
|
|
DdlProducto.ddl.Items.Clear()
|
|
DdlProducto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=-1)
|
|
DdlProducto.ddl.DataBind()
|
|
DdlProducto.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1"))
|
|
DdlProducto.ddlWS.Visible = False
|
|
End If
|
|
|
|
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("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("CveAF", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("PS")
|
|
dt.Columns.Add("PSCodigo")
|
|
dt.Columns.Add("PU", Type.GetType("System.Double"))
|
|
dt.Columns.Add("PUExtranjero", Type.GetType("System.Double"))
|
|
dt.Columns.Add("Total", Type.GetType("System.Double"))
|
|
|
|
dt.Columns.Add("CveClasificacion", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("EstatusExistencia")
|
|
dt.Columns.Add("CveMovimientoDetalle")
|
|
|
|
dt.Columns.Add("CveSeccionAlmacen", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("SeccionAlmacen")
|
|
dt.Columns.Add("Serie", Type.GetType("System.String"))
|
|
dt.Columns.Add("Lote", Type.GetType("System.String"))
|
|
dt.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime"))
|
|
|
|
dt.Columns.Add("CveAlmacen")
|
|
dt.Columns.Add("Almacen")
|
|
|
|
GvDatos.DataSource = dt
|
|
GvDatos.DataBind()
|
|
|
|
DtMovimientos = dt
|
|
|
|
End Sub
|
|
Private Sub CargaCombos()
|
|
|
|
'Llenar Clasificaciones
|
|
'If UsuarioActual.CveEmpresa = 66 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()
|
|
|
|
|
|
'Llena unidades de medida
|
|
DdlUnidad.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
|
|
DdlUnidad.DataBind()
|
|
|
|
'Llena Almacenes
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4)
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
'Llena AlmacenesFiltro
|
|
DdlAlmacenFiltro.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4)
|
|
DdlAlmacenFiltro.DataBind()
|
|
DdlAlmacenFiltro.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlProveedor.setEsWebService(True)
|
|
DdlProveedor.Attributes.Add("data-metodo", "getproveedores")
|
|
DdlProveedor.SelectedValue = "-1"
|
|
DdlProveedor.SelectedText = "Seleccione el Proveedor"
|
|
|
|
DdlProveedorFiltro.setEsWebService(True)
|
|
DdlProveedorFiltro.Attributes.Add("data-metodo", "getproveedores")
|
|
DdlProveedorFiltro.SelectedValue = "-1"
|
|
DdlProveedorFiltro.SelectedText = "Seleccione el Proveedor"
|
|
|
|
''Llenar el dropdownlist de Productos y servicios
|
|
'If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
|
|
' DdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
|
' DdlProducto.DataBind()
|
|
' DdlProducto.Items.Insert(0, New ListItem("----", "-1"))
|
|
' DdlProductows.Visible = False
|
|
'Else
|
|
' DdlProducto.Visible = False
|
|
'End If
|
|
|
|
|
|
|
|
|
|
|
|
DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1)
|
|
DdlSeccionAlmacen.DataBind()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " Carga Registrada "
|
|
Private Sub CargaMovimiento(CveConsignacion As Integer)
|
|
'MODO READ ONLY
|
|
SoloLectura = True
|
|
Bloquea(True)
|
|
PrendeDevolucion(False)
|
|
PrendeTraspaso(False)
|
|
Limpia()
|
|
BtnConsultar.Visible = False
|
|
LiProveedor.Visible = True
|
|
LiAlmacen.Visible = True
|
|
LiRemision.Visible = True
|
|
|
|
CargaDatos(CveConsignacion)
|
|
|
|
GvDatos.Columns(1).Visible = False
|
|
TdCantidad.Visible = False
|
|
ThCantidad.Visible = False
|
|
LtCantidad.Text = "Cantidad"
|
|
|
|
DdlProveedorFiltro.SelectedValue = DdlProveedor.SelectedValue
|
|
DdlProveedorFiltro.SelectedText = DdlProveedor.SelectedText
|
|
DdlProveedorFiltro_selectedindexchange(DdlProveedorFiltro, EventArgs.Empty)
|
|
DdlRemisiones.SelectedValueExist(CveConsignacion)
|
|
|
|
DdlProveedorFiltro.Enabled = False
|
|
DdlRemisiones.Enabled = False
|
|
DdlAlmacenFiltro.Enabled = False
|
|
DdlConcepto.Enabled = False
|
|
|
|
BtnNuevo.Visible = True
|
|
|
|
UpEncabezado.Update()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs)
|
|
|
|
DdlProveedorFiltro.Enabled = True
|
|
DdlRemisiones.Enabled = True
|
|
DdlAlmacenFiltro.Enabled = True
|
|
DdlConcepto.Enabled = True
|
|
|
|
BtnNuevo.Visible = False
|
|
DdlConcepto_SelectedIndexChanged(DdlConcepto, EventArgs.Empty)
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " CARGA CONSIGNACION "
|
|
|
|
Protected Sub DdlConcepto_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
SoloLectura = False
|
|
|
|
If DdlConcepto.SelectedValue.ToEntero = 10 Then
|
|
TrProveedor.Visible = True
|
|
TrSerieFolio.Visible = True
|
|
|
|
''PU Y Total
|
|
ThPU.Visible = True
|
|
ThTotal.Visible = True
|
|
TdPU.Visible = True
|
|
TdTotal.Visible = True
|
|
GvDatos.Columns(5).Visible = True
|
|
GvDatos.Columns(6).Visible = True
|
|
|
|
'Devolución
|
|
BtnConsultar.Visible = False
|
|
LiProveedor.Visible = False
|
|
LiAlmacen.Visible = False
|
|
LiRemision.Visible = False
|
|
|
|
CveConsignacion = -1
|
|
|
|
Bloquea(False)
|
|
PrendeDevolucion(False)
|
|
PrendeTraspaso(False)
|
|
Limpia()
|
|
|
|
CreaDT()
|
|
|
|
GvDatos.Columns(1).Visible = False
|
|
|
|
ElseIf DdlConcepto.SelectedValue.ToEntero = 11 Then
|
|
TrProveedor.Visible = False
|
|
TrSerieFolio.Visible = False
|
|
|
|
''PU Y Total
|
|
ThPU.Visible = False
|
|
ThTotal.Visible = False
|
|
TdPU.Visible = False
|
|
TdTotal.Visible = False
|
|
GvDatos.Columns(5).Visible = False
|
|
GvDatos.Columns(6).Visible = False
|
|
|
|
'Devolución
|
|
BtnConsultar.Visible = False
|
|
LiProveedor.Visible = False
|
|
LiAlmacen.Visible = False
|
|
LiRemision.Visible = False
|
|
|
|
GvDatos.Columns(1).Visible = True
|
|
|
|
ElseIf DdlConcepto.SelectedValue.ToEntero = 12 Or DdlConcepto.SelectedValue.ToEntero = 8 Then
|
|
|
|
Bloquea(True)
|
|
PrendeDevolucion(False)
|
|
PrendeTraspaso(False)
|
|
Limpia()
|
|
|
|
BtnConsultar.Visible = True
|
|
LiProveedor.Visible = True
|
|
LiAlmacen.Visible = True
|
|
LiRemision.Visible = True
|
|
|
|
|
|
GvDatos.Columns(1).Visible = True
|
|
|
|
End If
|
|
|
|
UpGenerales.Update()
|
|
UpDatos.Update()
|
|
UpTipoCambio.Update()
|
|
End Sub
|
|
|
|
Protected Sub DdlProveedorFiltro_selectedindexchange(sender As Object, e As EventArgs)
|
|
CargaDdlRemisiones()
|
|
End Sub
|
|
Private Sub CargaDdlRemisiones()
|
|
Dim ObjInventarios As New ClsInventarios
|
|
|
|
If ObjInventarios.GetConsignacionesPendientes(DdlProveedorFiltro.SelectedValue.ToEntero, 2, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
DtRemisiones = ObjInventarios.DtResultados
|
|
End If
|
|
|
|
ObjInventarios.Dispose()
|
|
CargaRemisiones()
|
|
End Sub
|
|
'Protected Sub DdlAlmacenFiltro_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
' CargaRemisiones()
|
|
'End Sub
|
|
Private Sub CargaRemisiones()
|
|
|
|
'Dim DtTemp As New DataTable
|
|
'If DdlAlmacenFiltro.SelectedValue.ToEntero > 0 Then
|
|
' DtTemp = DtRemisiones.FiltraParametros(String.Format("CveAlmacen = {0}", DdlAlmacenFiltro.SelectedValue.ToEntero))
|
|
'Else
|
|
' DtTemp = DtRemisiones.FiltraParametros("", "", {"CveConsignacion", "Consignacion"})
|
|
'End If
|
|
|
|
DdlRemisiones.DataSource = DtRemisiones.FiltraParametros("", "", {"CveConsignacion", "Consignacion"})
|
|
DdlRemisiones.DataBind()
|
|
DdlRemisiones.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
UpEncabezado.Update()
|
|
End Sub
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
|
CargaDatos(DdlRemisiones.SelectedValue.ToEntero)
|
|
End Sub
|
|
Private Sub CargaDatos(CveConsignacionTemp As Integer)
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
If ObjInventario.ConsignacionesDetalle(CveConsignacionTemp, DdlAlmacenFiltro.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
DtMovimientos = ObjInventario.DtResultados
|
|
Else
|
|
DtMovimientos = Nothing
|
|
Alert("Ocurrió un error al consultar la consignación. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
|
|
If DtMovimientos IsNot Nothing AndAlso DtMovimientos.Rows.Count > 0 Then
|
|
DtMovimientos.Columns.Add("EstatusExistencia")
|
|
|
|
CveConsignacion = DdlRemisiones.SelectedValue.ToEntero
|
|
DdlProveedor.SelectedValue = DtMovimientos.Rows(0)("CveProveedor").ToString
|
|
TxtFolio.Text = DtMovimientos.Rows(0)("SerieFolio").ToString
|
|
TxtFecha.Text = DtMovimientos.Rows(0)("Fecha").ToString.ToDate.ToShortDateString
|
|
|
|
DdlAlmacen.SelectedValueExist(DtMovimientos.Rows(0)("CveAlmacenConsignacion").ToString)
|
|
|
|
TxtObservaciones.Text = DtMovimientos.Rows(0)("Observaciones").ToString
|
|
|
|
DdlMoneda.SelectedValue = DtMovimientos.Rows(0)("CveMoneda").ToString
|
|
TxtTipoCambio.Text = DtMovimientos.Rows(0)("TipoCambio").ToString.FormatoNumero
|
|
DdlMoneda_SelectedIndexChanged(DdlMoneda, EventArgs.Empty)
|
|
|
|
Bloquea(True)
|
|
|
|
If DdlConcepto.SelectedValue = "12" Then
|
|
PrendeDevolucion(True)
|
|
ElseIf DdlConcepto.SelectedValue = "8" Then
|
|
PrendeTraspaso(True)
|
|
End If
|
|
|
|
GvDatos.DataSource = DtMovimientos.FiltraParametros("", "CveAlmacen")
|
|
GvDatos.DataBind()
|
|
Else
|
|
If DtMovimientos IsNot Nothing AndAlso DtMovimientos.Rows.Count = 0 Then
|
|
Alert("No hay productos disponibles para devolución o traspaso.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
Alert("Ocurrió un Error al consultar la consignación. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
GvDatos.DataSource = Nothing
|
|
GvDatos.DataBind()
|
|
|
|
End If
|
|
|
|
UpDatos.Update()
|
|
UpGenerales.Update()
|
|
UpTipoCambio.Update()
|
|
End Sub
|
|
Private Sub Bloquea(Accion As Boolean)
|
|
'TRUE: Prende, bloquea todo
|
|
'FALSE: Apaga, habilita todo
|
|
|
|
DdlProveedor.Enabled = Not Accion
|
|
TxtFolio.Enabled = Not Accion
|
|
TxtFecha.Enabled = Not Accion
|
|
DdlAlmacen.Enabled = Not Accion
|
|
TxtObservaciones.Enabled = Not Accion
|
|
DdlMoneda.Enabled = Not Accion
|
|
TxtTipoCambio.Enabled = Not Accion
|
|
BtnAplicarTC.Enabled = Not Accion
|
|
TxtFecha.Enabled = Not Accion
|
|
ImgFecha.Enabled = Not Accion
|
|
|
|
TxtCantidad.Enabled = Not Accion
|
|
'DdlClasificacion.Enabled = Not Accion
|
|
DdlProducto.Enabled = Not Accion
|
|
' DdlProductows.Disabled = Accion
|
|
DdlUnidad.Enabled = Not Accion
|
|
TxtPU.Enabled = Not Accion
|
|
LbAgregar.Visible = Not Accion
|
|
|
|
BtnGuardar.Visible = Not Accion
|
|
|
|
If Not Accion Then
|
|
DdlMoneda.SelectedValueExist(1)
|
|
End If
|
|
|
|
If Accion Then
|
|
GvDatos.Columns(2).Visible = True
|
|
TdCantidad.Visible = True
|
|
ThCantidad.Visible = True
|
|
LtCantidad.Text = "Disponible"
|
|
Else
|
|
GvDatos.Columns(2).Visible = False
|
|
TdCantidad.Visible = False
|
|
ThCantidad.Visible = False
|
|
LtCantidad.Text = "Cantidad"
|
|
End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "GV DATOS"
|
|
Protected Sub GvDatos_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim DbRow As DataRow = Nothing
|
|
DbRow = DtMovimientos.Rows(e.RowIndex)
|
|
|
|
DtMovimientos.Rows.Remove(DbRow)
|
|
GvDatos.DataSource = DtMovimientos
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If CveConsignacion > 0 Then
|
|
e.Row.FCLinkButton("imgE").Visible = False
|
|
e.Row.FCLinkButton("lnkRemove").Visible = False
|
|
e.Row.FCTextBox("TxtCantidadDevolucion").Visible = True
|
|
e.Row.FCTextBox("TxtCantidadDevolucion").Attributes.Add("onkeyup", String.Format("FormatoMoneda(this);LimitaCantidadDevolucion({0},{1})", e.Row.DBCampo("Cantidad").ToString.ToDouble, e.Row.FCTextBox("TxtCantidadDevolucion").ClientID))
|
|
Dim TipoAlmacen = If(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveAlmacen = {0}", e.Row.DBCampo("CveAlmacen"))).Rows(0) IsNot Nothing, GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveAlmacen = {0}", e.Row.DBCampo("CveAlmacen"))).Rows(0)("CveTipoAlmacen").ToString.ToEntero, 0)
|
|
If TipoAlmacen = 3 Then
|
|
e.Row.FCTextBox("TxtCantidadDevolucion").Enabled = False
|
|
End If
|
|
End If
|
|
|
|
If e.Row.DBCampo("EstatusExistencia").ToEntero < 0 Then
|
|
e.Row.Cells(0).BackColor = Drawing.Color.Red
|
|
End If
|
|
|
|
If SoloLectura Then
|
|
e.Row.FCLinkButton("imgE").Visible = False
|
|
e.Row.FCLinkButton("lnkRemove").Visible = False
|
|
End If
|
|
|
|
If e.Row.RowState = DataControlRowState.Edit Then
|
|
'Llena UM
|
|
e.Row.FCDropDownList("DdlUnidad").DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
|
|
e.Row.FCDropDownList("DdlUnidad").DataBind()
|
|
e.Row.FCDropDownList("DdlUnidad").SelectedValue = e.Row.DBCampo("CveUM")
|
|
|
|
'Llenar clasificaciones
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
e.Row.FCDropDownList("DdlClasificacion").DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion")
|
|
Else
|
|
e.Row.FCDropDownList("DdlClasificacion").DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion")
|
|
End If
|
|
'DdlClasificacion.DataBind()
|
|
e.Row.FCDropDownList("DdlClasificacion").DataBind()
|
|
e.Row.FCDropDownList("DdlClasificacion").SelectedValue = e.Row.DBCampo("CveClasificacion")
|
|
|
|
'Llena PS
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
|
|
e.Row.FCHiddenField("HFProducto").Value = e.Row.DBCampo("CvePS")
|
|
e.Row.FCHiddenField("HFTProducto").Value = e.Row.DBCampo("PS")
|
|
Dim sDdlProductows = String.Format("{0}{1}", "#", e.Row.FindControl("DdlProductows").ClientID)
|
|
Dim sDdlProducto = String.Format("{0}{1}", "#", e.Row.FCDropDownList("DdlProducto").ClientID)
|
|
Dim sHFProducto = String.Format("{0}{1}", "#", e.Row.FCHiddenField("HFProducto").ClientID)
|
|
Dim sHFTProducto = String.Format("{0}{1}", "#", e.Row.FCHiddenField("HFTProducto").ClientID)
|
|
Dim sMyhidenbutton = String.Format("{0}{1}", "#", e.Row.FCButton("myhidenbutton").ClientID)
|
|
|
|
e.Row.FindControl("DdlProductows").Visible = True
|
|
e.Row.FCDropDownList("DdlProducto").Visible = False
|
|
RegistraScript(String.Format("Asigna1052('{0}','{1}','{2}','{3}','{4}')", sDdlProductows, sDdlProducto, sHFProducto, sHFTProducto, sMyhidenbutton))
|
|
Else
|
|
e.Row.FindControl("DdlProductows").Visible = False
|
|
e.Row.FCDropDownList("DdlProducto").Visible = True
|
|
e.Row.FCDropDownList("DdlProducto").DataSource = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="CveClasificacion")
|
|
e.Row.FCDropDownList("DdlProducto").DataBind()
|
|
e.Row.FCDropDownList("DdlProducto").SelectedValue = e.Row.DBCampo("CvePS")
|
|
End If
|
|
|
|
e.Row.FCLabel("LbTotal").Text = (e.Row.DBCampo("Cantidad").ToDecimal * e.Row.DBCampo("PU").ToDecimal).ToString
|
|
e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", String.Format("RecalculaEdit(this,{0},{1});", e.Row.FCTextBox("TxtPU").ClientID, e.Row.FCLabel("LbTotal").ClientID))
|
|
e.Row.FCTextBox("TxtPU").Attributes.Add("onkeyup", String.Format("RecalculaEdit({0},this,{1});", e.Row.FCTextBox("TxtCantidad").ClientID, e.Row.FCLabel("LbTotal").ClientID))
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvDatos.RowEditing
|
|
GvDatos.EditIndex = e.NewEditIndex
|
|
|
|
GvDatos.DataSource = DtMovimientos
|
|
GvDatos.DataBind()
|
|
End Sub
|
|
Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
|
|
Dim dr = GvDatos.Rows(e.RowIndex)
|
|
|
|
|
|
Dim Cantidad = dr.FCTextBox("TxtCantidad").Text.ToDouble
|
|
Dim CveUM = dr.FCDropDownList("DdlUnidad").SelectedValue.ToEntero
|
|
Dim CveClasificacion = dr.FCDropDownList("DdlClasificacion").SelectedValue.ToEntero
|
|
Dim PU = dr.FCTextBox("TxtPU").Text.ToDouble
|
|
Dim No = dr.DataKey("No").ToEntero
|
|
Dim CvePS As Integer
|
|
Dim PS As String
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then
|
|
PS = dr.FCHiddenField("HFTProducto").Value
|
|
CvePS = dr.FCHiddenField("HFProducto").Value.ToEntero
|
|
Else
|
|
PS = dr.FCDropDownList("DdlProducto").SelectedItem.Text
|
|
CvePS = dr.FCDropDownList("DdlProducto").SelectedValue.ToEntero
|
|
End If
|
|
|
|
Dim Drs As DataRow() = DtMovimientos.Select(String.Format("No = {0}", No))
|
|
|
|
If Drs.Count = 1 Then
|
|
Drs(0)("Cantidad") = Cantidad
|
|
Drs(0)("CveUM") = CveUM
|
|
Drs(0)("CveClasificacion") = CveClasificacion
|
|
Drs(0)("CvePS") = CvePS
|
|
Drs(0)("PS") = PS
|
|
Drs(0)("EstatusExistencia") = "1"
|
|
|
|
Drs(0)("PU") = PU
|
|
Drs(0)("PUExtranjero") = PU
|
|
Drs(0)("Total") = Cantidad * PU
|
|
End If
|
|
|
|
DtMovimientos.AcceptChanges()
|
|
GvDatos.EditIndex = -1
|
|
|
|
GvDatos.DataSource = DtMovimientos
|
|
GvDatos.DataBind()
|
|
LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero
|
|
UpDatos.Update()
|
|
|
|
End Sub
|
|
Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
|
|
GvDatos.EditIndex = -1
|
|
GvDatos.DataSource = DtMovimientos
|
|
GvDatos.DataBind()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
'ACCIONES PRINCIPALES
|
|
#Region "AGREGAR Y GUARDAR,, ENTRADA CONSIGNACION"
|
|
Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
|
AddNew()
|
|
End Sub
|
|
Protected Sub AddNew()
|
|
Dim PSSelected As Integer = DdlProducto.SelectedValue.ToEntero
|
|
|
|
If PSSelected > 0 Then
|
|
|
|
Dim Valido As Boolean = True
|
|
|
|
'VALIDA EXISTENCIA
|
|
If DdlConcepto.SelectedValue = "11" Then
|
|
Dim Inv As New ClsInventarios
|
|
Dim Existencia As Double = Inv.GetExistenciasPS(PSSelected, DdlUnidad.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"))
|
|
Inv.Dispose()
|
|
|
|
If Existencia - TxtCantidad.Text.ToDouble < 0 Then
|
|
If Existencia <= 0 Then
|
|
Alert("No hay existencia del producto", TipoMensaje.MsgError)
|
|
Else
|
|
Alert(String.Format("Solo hay en existencia {0}", Existencia), TipoMensaje.MsgError)
|
|
End If
|
|
Valido = False
|
|
End If
|
|
End If
|
|
|
|
If Valido Then
|
|
Dim CveClasificacion As Integer
|
|
Dim PSCodigo = ""
|
|
|
|
Dim CveSeccionAlmacen As Integer = DdlSeccionAlmacen.SelectedValue.ToEntero
|
|
Dim SeccionAlmacen As String = DdlSeccionAlmacen.SelectedItem.Text
|
|
Dim Serie As String = If(TxtSerie.Text = "", "", TxtSerie.Text)
|
|
Dim Lote As String = If(TxtLote.Text = "", "", TxtLote.Text)
|
|
Dim Caducidad As String = If(TxtCaducidad.Text = "", MinFecha.ToShortDateString, TxtCaducidad.Text)
|
|
|
|
Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=PSSelected).FiltroPrimero("")
|
|
|
|
If dr IsNot Nothing Then
|
|
CveClasificacion = dr("CveClasificacion").ToString.ToEntero
|
|
PSCodigo = dr("PSCodigo").ToString
|
|
Else
|
|
Valido = False
|
|
End If
|
|
|
|
If Valido Then
|
|
Dim registro As DataRow = DtMovimientos.NewRow
|
|
registro.Item("Cantidad") = TxtCantidad.Text.ToDouble
|
|
registro.Item("CveUM") = DdlUnidad.SelectedValue.ToEntero
|
|
registro.Item("UnidadMedida") = DdlUnidad.SelectedItem.Text
|
|
registro.Item("CvePS") = PSSelected
|
|
registro.Item("PS") = DdlProducto.txtText.Value
|
|
registro.Item("PSCodigo") = PSCodigo
|
|
registro.Item("CveClasificacion") = CveClasificacion
|
|
registro.Item("EstatusExistencia") = "1"
|
|
|
|
registro.Item("PU") = TxtPU.Text.ToDouble
|
|
registro.Item("PUExtranjero") = TxtPU.Text.ToDouble
|
|
registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen
|
|
registro.Item("SeccionAlmacen") = SeccionAlmacen
|
|
registro.Item("Serie") = Serie
|
|
registro.Item("Lote") = Lote
|
|
registro.Item("FechaCaducidad") = Caducidad
|
|
registro.Item("Total") = TxtCantidad.Text.ToDouble * TxtPU.Text.ToDouble
|
|
|
|
|
|
DtMovimientos.Rows.Add(registro)
|
|
|
|
GvDatos.DataSource = DtMovimientos
|
|
GvDatos.DataBind()
|
|
|
|
|
|
If DtMovimientos IsNot Nothing AndAlso DtMovimientos.Rows.Count > 0 Then
|
|
GvDatos.Columns(7).Visible = DtMovimientos.MAX("CveSeccionAlmacen").ToEntero > 0
|
|
GvDatos.Columns(8).Visible = DtMovimientos.MAX("Serie") <> ""
|
|
GvDatos.Columns(9).Visible = DtMovimientos.MAX("Lote") <> ""
|
|
GvDatos.Columns(10).Visible = DtMovimientos.MAX("FechaCaducidad").ToDate > MinFecha
|
|
|
|
End If
|
|
|
|
TxtCantidad.Text = ""
|
|
TxtPU.Text = ""
|
|
LbTotal.Text = ""
|
|
|
|
LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero
|
|
|
|
UpDatos.Update()
|
|
Else
|
|
Alert("Ocurrió una incongruencia con los Productos/Servicios. Favor de comunicarse con Sistemas.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
Else
|
|
Alert("Debe seleccionar un Producto/Servicio.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
|
If DdlConcepto.SelectedValue = "10" And (DdlProveedor.SelectedValue = "-1" Or TxtFolio.Text = "") Then
|
|
Alert("Los campos 'Proveedor' y 'Serie-Folio' son obligatorios.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If GvDatos.Rows.Count > 0 Then
|
|
|
|
'VALIDA ESTATUS EXISTENCIA
|
|
If DdlConcepto.SelectedValue = "11" Then
|
|
For Each dr As DataRow In DtMovimientos.Rows
|
|
If dr("EstatusExistencia").ToString = "-1" Then
|
|
Alert("Tiene que rectificar los movimientos con error.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
Dim CveMovimiento = 0
|
|
Dim Folio = 0
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim TextoError = ""
|
|
Dim Fecha As Date = TxtFecha.Text.ToDate
|
|
Dim ErrorExistencia = False
|
|
Dim TextoExistencia As StringBuilder = New StringBuilder
|
|
|
|
|
|
'VALIDA LA EXISTENCIA DEL ALMACEN DE ORIGEN
|
|
If DdlConcepto.SelectedValue = "11" Then
|
|
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.ToDateTime.ToString("yyyy/MM/dd HH:mm"))
|
|
|
|
If Existencia - dr("Cantidad").ToString.ToDouble < 0 Then
|
|
ErrorExistencia = True
|
|
dr("EstatusExistencia") = "-1"
|
|
dr("Cantidad") = Existencia
|
|
TextoExistencia.AppendFormat("- #{0} {1}<br/>", dr("No").ToString, dr("PS").ToString)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
|
|
'AGREGAMOS CONSIGNACION
|
|
If Not ErrorExistencia Then
|
|
ObjInventario.IniciaTransacSQL() 'Inicia la transacción
|
|
Dim CveConsignacion = -1
|
|
|
|
If DdlConcepto.SelectedValue = "10" Then
|
|
CveConsignacion = ObjInventario.AddConsignaciones(DdlProveedor.SelectedValue.ToEntero, -1, TxtFolio.Text, TxtFecha.Text.ToDate, UsuarioActual.CveUsuario)
|
|
End If
|
|
|
|
If (DdlConcepto.SelectedValue = "10" And CveConsignacion > 0) Or DdlConcepto.SelectedValue = "11" Then
|
|
|
|
'AGREGAMOS MOVIMIENTO
|
|
Folio = ObjInventario.GetFolioSiguiente(DdlConcepto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa)
|
|
CveMovimiento = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, DdlConcepto.SelectedValue.ToEntero, DdlMoneda.SelectedValue.ToEntero, Fecha, Folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveConsignacion:=CveConsignacion, Observaciones:=TxtObservaciones.Text, TipoCambio:=If(DdlMoneda.SelectedValue.ToEntero <> 1, TxtTipoCambio.Text.ToDouble, -1))
|
|
|
|
'AGREGAMOS MOVTOS DETALLE
|
|
If CveMovimiento > 0 Then
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=TxtSerie.Text, Lote:=TxtLote.Text, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, PUTC:=If(DdlMoneda.SelectedValue.ToEntero <> 1, Dr("PUExtranjero").ToString.ToDecimal, -1)) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos"
|
|
Exit For
|
|
End If
|
|
Next
|
|
Else
|
|
TextoError = "No se pudo generar el movimiento correctamente"
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
Else
|
|
TextoError = "No se pudo generar la consignación. Por favor vuelva a intentar."
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
|
|
If Not ErrorMovInv Then
|
|
|
|
|
|
|
|
Dim ImportePrePoliza As Decimal = DtMovimientos.SUMD("Total")
|
|
|
|
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL)
|
|
|
|
Dim Concepto As String = "Consig"
|
|
Dim CvePrePoliza = ObjConta.AddPrePolizas("Entrada/Consignacion", 53, ImportePrePoliza, ImportePrePoliza, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImportePrePoliza, "Entrada por Consignacion", 68, "Entrada por Consignacion", Fecha, -1, -1, CveVenta:=-1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ImportePrePoliza, CveSubProyecto:=-1, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImportePrePoliza, "Entrada por Consignacion", 337, "Entrada por Consignacion", Fecha, -1, -1, CveVenta:=-1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ImportePrePoliza, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 6) Then
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
GuardaLogAD($"Consig | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
|
|
If Not ErrorMovInv Then
|
|
ObjInventario.Commit()
|
|
|
|
Limpia()
|
|
|
|
Dim Msg As New StringBuilder
|
|
Msg.AppendFormat(If(DdlConcepto.SelectedValue = "10", "Se realizo con exito la consignación. <br/>", "Se realizo con exito la salida de consignación"))
|
|
Msg.AppendFormat("<br/> <a class=""Texto"" target='_blank' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}""><b>Folio: {1}</b></a> ", CveMovimiento, Folio)
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
Else
|
|
ObjInventario.RollBack()
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
Else
|
|
Alert(TextoExistencia.ToString, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
'SI OCURRIO UN ERROR EN LA EXISTENCIA RECARGAMOS EL GRID PARA COLOREAR LOS DETALLES CON ERROR
|
|
If ErrorExistencia Then
|
|
GvDatos.DataSource = DtMovimientos
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
|
|
Else
|
|
Alert("No hay movimientos.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
Private Sub Limpia()
|
|
'Limpia
|
|
DtMovimientos.Clear()
|
|
GvDatos.DataSource = DtMovimientos
|
|
GvDatos.DataBind()
|
|
|
|
DdlProveedor.SelectedValue = "-1"
|
|
TxtFolio.Text = ""
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
TxtObservaciones.Text = ""
|
|
DdlMoneda.SelectedValueExist(1)
|
|
DdlMoneda_SelectedIndexChanged(DdlMoneda, EventArgs.Empty)
|
|
|
|
TxtCantidad.Text = ""
|
|
'DdlClasificacion.SelectedValueExist(-1)
|
|
|
|
DdlProducto.txtText.Value = ""
|
|
DdlProducto.txtValue.Value = ""
|
|
|
|
'DdlProductows.Items.Clear()
|
|
'DdlProductows.DataBind()
|
|
TxtPU.Text = ""
|
|
|
|
'DEVOLUCION
|
|
TxtFechaDevolucion.Text = Now.ToShortDateString
|
|
TxtObservacionesDevolucion.Text = ""
|
|
|
|
'Traspaso
|
|
TxtResponsable.Text = ""
|
|
TxtFecha.Text = ""
|
|
TxtObservaciones.Text = ""
|
|
TxtCantidad.Text = ""
|
|
ChkTransitorio.Checked = False
|
|
|
|
TxtFechaTraspaso.Text = Now.ToShortDateString
|
|
DdlAlmacenDestino.SelectedValueExist("-1")
|
|
TxtObservacionesTraspaso.Text = ""
|
|
ChkTransitorio.Checked = False
|
|
TrTraspaso1.Visible = False
|
|
TrTraspaso2.Visible = False
|
|
|
|
UpDatos.Update()
|
|
UpTipoCambio.Update()
|
|
UpGenerales.Update()
|
|
UpTraspaso.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " DEVOLUCIONES "
|
|
Protected Sub BtnDevolucion_Click(sender As Object, e As EventArgs)
|
|
Dim ObjInventario As New ClsInventarios
|
|
ObjInventario.IniciaTransacSQL() 'Inicia la transacción
|
|
|
|
Dim CveMovimiento = 0
|
|
Dim Folio = 0
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim TextoError = ""
|
|
Dim Fecha As Date = TxtFechaDevolucion.Text.ToDate
|
|
Dim ErrorExistencia = False
|
|
Dim TextoExistencia As New StringBuilder
|
|
Dim CveMovtos As New List(Of Integer)
|
|
Dim Folios As New List(Of Integer)
|
|
Dim MovimientosRealizados = 0
|
|
|
|
Dim ConceptoDevolucion = 12
|
|
Dim CveAlmacen = -1
|
|
Dim MovtoNew = False
|
|
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble > 0 Then
|
|
|
|
If CveAlmacen = -1 Or CveAlmacen <> Gvr.DataKey("CveAlmacen").ToString.ToEntero Then
|
|
CveAlmacen = Gvr.DataKey("CveAlmacen").ToString.ToEntero
|
|
MovtoNew = True
|
|
End If
|
|
|
|
'AGREGAMOS MOVIMIENTO
|
|
If MovtoNew Then
|
|
Folio = ObjInventario.GetFolioSiguiente(ConceptoDevolucion, UsuarioActual.CveEmpresa)
|
|
CveMovimiento = ObjInventario.AddMovimiento(CveAlmacen, ConceptoDevolucion, DdlMoneda.SelectedValue.ToEntero, Fecha, Folio, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveConsignacion:=CveConsignacion, Observaciones:=TxtObservacionesDevolucion.Text.Trim, Modulo:="Consig")
|
|
End If
|
|
|
|
If CveMovimiento > 0 Then
|
|
If MovtoNew Then
|
|
CveMovtos.Add(CveMovimiento)
|
|
Folios.Add(Folio)
|
|
MovtoNew = False
|
|
End If
|
|
Else
|
|
TextoError = "No se pudo generar el movimiento correctamente"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
'AGREGAMOS MOVTOS DETALLE
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDecimal, -1, -1, Gvr.DataKey("Serie").ToString, Gvr.DataKey("Lote").ToString) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un Error al guardar los movimientos"
|
|
Exit For
|
|
Else
|
|
|
|
|
|
Dim ImportePrePoliza As Decimal = Gvr.DataKey("PU").ToString.ToDecimal * Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDecimal
|
|
|
|
Dim MovAlmacen As Boolean = True
|
|
|
|
Dim OrigenMov As Integer = GlobalDTInvConceptos.FiltroPrimeroValor("Origen", "CveConcepto = " & ConceptoDevolucion).ToEntero
|
|
|
|
If OrigenMov = 1 Then
|
|
MovAlmacen = True
|
|
Else
|
|
MovAlmacen = False
|
|
End If
|
|
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL)
|
|
|
|
Dim Concepto As String = "Consig"
|
|
Dim CvePrePoliza = ObjConta.AddPrePolizas("Consig", 74, ImportePrePoliza, ImportePrePoliza, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not MovAlmacen, ImportePrePoliza, "Consig", 68, "Consig", Fecha, -1, -1, CveVenta:=-1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ImportePrePoliza, CveSubProyecto:=-1, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, MovAlmacen, ImportePrePoliza, "Consig", 337, "Consig", Fecha, -1, -1, CveVenta:=-1, CveMovimientoAlmacen:=CveMovimiento, ImporteMX:=ImportePrePoliza, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 6) Then
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
GuardaLogAD($"Consig | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
MovimientosRealizados += 1
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
Next
|
|
|
|
|
|
If Not MovimientosRealizados > 0 Then
|
|
TextoError = "No hay ningun movimiento ha realizar. Por favor verifique los datos y vuelva a intentar."
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
'falta generar la prepoliza
|
|
|
|
ObjInventario.Commit()
|
|
Dim Msg As New StringBuilder
|
|
Msg.AppendFormat("Se realizo con exito la devolución de consignación")
|
|
For i = 0 To CveMovtos.Count - 1
|
|
Msg.AppendFormat("<br/> <a Class=""Texto"" target='_blank' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}""><b>Folio: {1}</b></a> ", CveMovtos(i), Folios(i))
|
|
Msg.AppendFormat("<a target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovtos(i)))) 'onclick='ImprimirTraslado()'
|
|
Next
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
'Dim ObjSisMail As New ClsSisMail
|
|
'ObjSisMail.SendMail(UsuarioActual.Empresa, "ing.israelpina@hotmail.com", "DEVOLUCION ALMACEN", Msg.ToString, "rene.molina@adsistemas.mx")
|
|
|
|
|
|
Limpia()
|
|
PrendeDevolucion(False)
|
|
PrendeTraspaso(False)
|
|
Bloquea(False)
|
|
Else
|
|
ObjInventario.RollBack()
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub PrendeDevolucion(Accion As Boolean)
|
|
'TRUE: Prende, bloquea todo
|
|
'FALSE: Apaga, habilita todo
|
|
|
|
RowObservacionesDevolucion.Visible = Accion
|
|
BtnDevolucion.Visible = Accion
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " TRASPASO ALMACEN CONSIGNACION "
|
|
Private Sub PrendeTraspaso(Accion As Boolean)
|
|
'TRUE: Prende, bloquea todo
|
|
'FALSE: Apaga, habilita todo
|
|
|
|
DivTraspaso.Visible = Accion
|
|
BtnTraspaso.Visible = Accion
|
|
|
|
UpTraspaso.Update()
|
|
End Sub
|
|
Private Sub CargaDatosTraspaso()
|
|
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoAlmacen IN (1,4) AND Estatus = 'Activo'")
|
|
'DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4)
|
|
DdlAlmacenDestino.DataBind()
|
|
DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlAlmacenTransitorio.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3)
|
|
DdlAlmacenTransitorio.DataBind()
|
|
DdlAlmacenTransitorio.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
End Sub
|
|
Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs)
|
|
If ChkTransitorio.Checked Then
|
|
TrTraspaso1.Visible = True
|
|
TrTraspaso2.Visible = True
|
|
Else
|
|
TrTraspaso1.Visible = False
|
|
TrTraspaso2.Visible = False
|
|
End If
|
|
|
|
UpTraspaso.Update()
|
|
End Sub
|
|
Protected Sub BtnTraspaso_Click(sender As Object, e As EventArgs)
|
|
|
|
If ChkTransitorio.Checked Then
|
|
If TxtResponsable.Text.Trim = "" Then
|
|
Alert("Debe seleccionar un responsable para el traspaso transitorio.", TipoMensaje.MsgAdvertencia)
|
|
If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);")
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlAlmacenTransitorio.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Debe seleccionar un almacen transitorio.", TipoMensaje.MsgAdvertencia)
|
|
If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);")
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL)
|
|
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim TextoError = ""
|
|
Dim Fecha As Date = TxtFechaTraspaso.Text.ToDate
|
|
Dim MovimientosRealizados = 0
|
|
|
|
|
|
'AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN
|
|
Dim MovtoNew = False
|
|
Dim CveAlmacen = -1
|
|
Dim CveMovimientoSalida = 0
|
|
Dim FolioSalida = 0
|
|
Dim CveMovtosSalida As New List(Of Integer)
|
|
Dim FoliosSalida As New List(Of Integer)
|
|
For Each Gvr As GridViewRow In GvDatos.Rows
|
|
If Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble > 0 Then
|
|
|
|
If CveAlmacen = -1 Or CveAlmacen <> Gvr.DataKey("CveAlmacen").ToString.ToEntero Then
|
|
CveAlmacen = Gvr.DataKey("CveAlmacen").ToString.ToEntero
|
|
MovtoNew = True
|
|
End If
|
|
|
|
'Dim FechaCompra = "31/12/2015".ToDate
|
|
'Dim FechaActual = "1/01/2016".ToDate
|
|
'Dim DiaCierre = 7 'UsuarioActual.Empresa.Funcionalidad(115).ToEntero
|
|
|
|
'Dim Mes = DateDiff(DateInterval.Month, "31/12/2015".ToDate, "1/01/2016".ToDate).ToEntero
|
|
|
|
'If Month(FechaCompra) < Month(FechaActual) And Day(FechaActual) >= DiaCierre Then
|
|
' Alert("Error", TipoMensaje.MsgError)
|
|
'End If
|
|
|
|
'AGREGAMOS MOVIMIENTO
|
|
If MovtoNew Then
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacen, 26, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservacionesTraspaso.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, CveConsignacion:=CveConsignacion)
|
|
FolioSalida = ObjInventario.Folio
|
|
End If
|
|
|
|
If CveMovimientoSalida > 0 Then
|
|
If MovtoNew Then
|
|
CveMovtosSalida.Add(CveMovimientoSalida)
|
|
FoliosSalida.Add(FolioSalida)
|
|
MovtoNew = False
|
|
End If
|
|
Else
|
|
TextoError = "No se pudo generar el movimiento de salida correctamente"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
'AGREGAMOS MOVTOS DETALLE
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDecimal, -1, -1, "", "") Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un Error al guardar los movimientos detalle de la salida"
|
|
Exit For
|
|
Else
|
|
MovimientosRealizados += 1
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
''VIEJO
|
|
''AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN
|
|
'CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 8, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
'FolioSalida = ObjInventario.Folio
|
|
'If CveMovimientoSalida <= 0 Then
|
|
' TextoError = "No se pudo generar el movimiento de salida correctamente"
|
|
' ErrorMovInv = True
|
|
'Else
|
|
' For Each Gvr As GridViewRow In GvDatos.Rows
|
|
' If Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble > 0 Then
|
|
' If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Gvr.FCTextBox("TxtCantidadDevolucion").Text.ToString.ToDouble, Gvr.DataKey("CveUM").ToString.ToEntero, Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("PU").ToString.ToDouble, -1, -1, "", "", Gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero) Then
|
|
' ErrorMovInv = True
|
|
' TextoError = "Ocurrió un error al guardar los movimientos"
|
|
' Exit For
|
|
' End If
|
|
' MovimientosRealizados += 1
|
|
' End If
|
|
' Next
|
|
'End If
|
|
|
|
|
|
'AGREGAMOS LA ENTRADA
|
|
Dim CveMovimientoEntrada = 0
|
|
Dim FolioEntrada = 0
|
|
Dim CveMovtosEntrada As New List(Of Integer)
|
|
Dim FoliosEntrada As New List(Of Integer)
|
|
Dim TipoAlmacenEntrada = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = { DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero
|
|
Dim TipoMovimiento = If(ChkTransitorio.Checked And TipoAlmacenEntrada <> 1, 2, 9)
|
|
Dim AlmacenEntrada = -1
|
|
If Not ErrorMovInv Then
|
|
For i = 0 To CveMovtosSalida.Count - 1
|
|
AlmacenEntrada = If(ChkTransitorio.Checked And TipoAlmacenEntrada <> 1, DdlAlmacenTransitorio.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero)
|
|
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(AlmacenEntrada, TipoMovimiento, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservacionesTraspaso.Text.Trim, Recibio:=If(ChkTransitorio.Checked And TipoAlmacenEntrada <> 1, TxtResponsable.Text.Trim, "-1"),
|
|
CveAlmacenDestino:=If(ChkTransitorio.Checked And TipoAlmacenEntrada <> 1, DdlAlmacenDestino.SelectedValue.ToEntero, -1), CveMovimientoRelacionado:=CveMovimientoSalida, CveConsignacion:=CveConsignacion)
|
|
FolioEntrada = ObjInventario.Folio
|
|
|
|
If CveMovimientoEntrada <= 0 Then
|
|
TextoError = "No se pudo generar el movimiento de entrada correctamente"
|
|
ErrorMovInv = True
|
|
Exit For
|
|
Else
|
|
|
|
CveMovtosEntrada.Add(CveMovimientoEntrada)
|
|
FoliosEntrada.Add(FolioEntrada)
|
|
|
|
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.ToDecimal, Dr("CveAF").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
'SI TUBO ERROR EN EL FOR DE LOS DETALLES
|
|
If ErrorMovInv Then
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
End If
|
|
|
|
''VIEJO
|
|
''AGREGAMOS LA ENTRADA
|
|
'If Not ErrorMovInv Then
|
|
' AlmacenEntrada = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero)
|
|
|
|
' CveMovimientoEntrada = ObjInventario.AddMovimiento(AlmacenEntrada, TipoMovimiento, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, -1, -1,
|
|
' Observaciones:=TxtObservacionesTraspaso.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, "-1"),
|
|
' CveAlmacenDestino:=If(ChkTransitorio.Checked, DdlAlmacenDestino.SelectedValue.ToEntero, -1), CveMovimientoRelacionado:=CveMovimientoSalida, CveConsignacion:=CveConsignacion)
|
|
' FolioEntrada = ObjInventario.Folio
|
|
|
|
' If CveMovimientoEntrada <= 0 Then
|
|
' TextoError = "No se pudo generar el movimiento de entrada correctamente"
|
|
' ErrorMovInv = 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) Then
|
|
' ErrorMovInv = True
|
|
' TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
|
|
' End If
|
|
' End If
|
|
'End If
|
|
If Not ErrorMovInv And AlmacenEntrada > 0 Then
|
|
Dim TipoAlmacenOrigen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {AlmacenEntrada}").ToEntero
|
|
If TipoAlmacenOrigen = 1 Then
|
|
Dim TipoMovto = 1
|
|
Dim CveMovimientoCI = CveMovimientoEntrada
|
|
Dim CveAlmacenCI = AlmacenEntrada
|
|
Dim DtCostos As DataTable = Nothing
|
|
Dim ValorInventario As Decimal = 0
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
|
|
DtCostos = ObjInventario.DtResultados
|
|
Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
|
|
Dim IdCtaContable As Integer = 0
|
|
Dim CveCuenta As Integer = 0
|
|
If tmpCostos.Rows.Count > 0 Then
|
|
Dim Concepto As String = $"Traspaso: {ObjInventario.Folio} - {TxtObservaciones.Text}"
|
|
Dim CvePrePoliza = ObjConta.AddPrePolizas("Inv/Traspáso", 53, DtCostos.SUM("Total") * TipoMovto, DtCostos.SUM("Total") * TipoMovto, 1, TxtFecha.Text.ToDate, $"Traspaso: {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CvePrePoliza > 0 Then
|
|
For Each RowInv As DataRow In tmpCostos.Rows
|
|
ValorInventario = DtCostos.SUM("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").ToString.ToDecimal
|
|
IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGasto", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
|
|
CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorInventario * TipoMovto, Concepto, 69, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoCI, ImporteMX:=ValorInventario * TipoMovto, CveCuenta:=CveCuenta) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen={CveAlmacenCI}").ToEntero
|
|
'CveCuenta = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen={CveAlmacenCI}").ToEntero
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, DtCostos.SUM("Total").ToDecimal * TipoMovto, Concepto, 68, Concepto, TxtFecha.Text.ToDate, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoCI, ImporteMX:=DtCostos.SUM("Total").ToDecimal * TipoMovto) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If Not ErrorMovInv Then
|
|
ObjInventario.Commit()
|
|
Dim Mensaje As StringBuilder = New StringBuilder
|
|
|
|
Mensaje.Append("Se realizó con éxito el traspaso.")
|
|
|
|
Mensaje.Append("<br/><br/> Folio(s) de Salida: <br/>")
|
|
For i = 0 To CveMovtosSalida.Count - 1
|
|
Mensaje.AppendFormat("<ul><li> <b><a href = ""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" class=""texto"" target=""_blank"" >{1}</a></b> ", CveMovtosSalida(i), FoliosSalida(i))
|
|
Mensaje.AppendFormat(" <a target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a></li></ul>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovtosSalida(i))))
|
|
Next
|
|
|
|
If Not ChkTransitorio.Checked Then
|
|
Mensaje.Append("<br/><br/> Folio(s) de Entrada: <br/>")
|
|
For i = 0 To CveMovtosEntrada.Count - 1
|
|
Mensaje.AppendFormat("<ul><li> <b><a href = ""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" class=""texto"" target=""_blank"" >{1}</a></b> ", CveMovtosEntrada(i), FoliosEntrada(i))
|
|
Mensaje.AppendFormat(" <a target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a></li></ul>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovtosEntrada(i))))
|
|
Next
|
|
End If
|
|
|
|
'Dim ObjSisMail As New ClsSisMail
|
|
'ObjSisMail.SendMail(UsuarioActual.Empresa, "ing.israelpina@hotmail.com", "TRASPASO ALMACEN", Mensaje.ToString, "rene.molina@adsistemas.mx")
|
|
|
|
Alert(Mensaje.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
Limpia()
|
|
PrendeDevolucion(False)
|
|
PrendeTraspaso(False)
|
|
Bloquea(False)
|
|
Else
|
|
ObjInventario.RollBack()
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " RECEPCION TRASPASO CONSIGNACION "
|
|
Private Sub CargaDatosRecepcionTraspaso()
|
|
DdlAlmacenRecepcion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4)
|
|
DdlAlmacenRecepcion.DataBind()
|
|
DdlAlmacenRecepcion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlAlmacenTransitorioRecepcion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3)
|
|
DdlAlmacenTransitorioRecepcion.DataBind()
|
|
DdlAlmacenTransitorioRecepcion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
Protected Sub BtnCargaTransitorios_Click(sender As Object, e As EventArgs)
|
|
CargaRecepcion()
|
|
End Sub
|
|
Private Sub CargaRecepcion()
|
|
Dim ObjInventarios As New ClsInventarios
|
|
|
|
DtRecepcion = New DataTable
|
|
|
|
If ObjInventarios.GetMovimientosTransitorios(DdlAlmacenRecepcion.SelectedValue.ToEntero, 4, DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero, -1, If(TxtFolioRecepcion.Text = "", -1, TxtFolioRecepcion.Text.ToEntero), UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
|
|
DtRecepcion = ObjInventarios.DtResultados
|
|
Else
|
|
Alert("Ocurrió un error al consultar los movimientos transitorios. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
|
|
If DtRecepcion IsNot Nothing Then
|
|
GvDatosRecepcion.DataSource = DtRecepcion
|
|
GvDatosRecepcion.DataBind()
|
|
End If
|
|
|
|
If TxtFolioRecepcion.Text = "" Then
|
|
BtnRecibir.Visible = False
|
|
Else
|
|
BtnRecibir.Visible = True
|
|
End If
|
|
|
|
|
|
UpDatosRecepcion.Update()
|
|
End Sub
|
|
|
|
Protected Sub GvDatosRecepcion_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosRecepcion.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If TxtFolioRecepcion.Text = "" Then
|
|
e.Row.FCCheckBox("Chk").Visible = False
|
|
e.Row.FCTextBox("TxtCantidad").Enabled = False
|
|
End If
|
|
|
|
'Cuando es titulo
|
|
If e.Row.DBCampo("PS").ToString.Trim = "" Then
|
|
e.Row.CssClass = "Totales"
|
|
|
|
e.Row.FCCheckBox("Chk").Visible = False
|
|
e.Row.FCTextBox("TxtCantidad").Visible = False
|
|
|
|
e.Row.Cells(1).Text = String.Format("Folio: <a class=""texto"" style=""color:white;"" target='_blank' href='/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}'>{0}</a> ", e.Row.DBCampo("FolioSalida"), e.Row.DBCampo("CveMovimientoSalida"))
|
|
e.Row.Cells(2).Text = String.Format("{0}", e.Row.DBCampo("FechaMovto").ToString.ToDate.ToShortDateString)
|
|
e.Row.Cells(5).Text = String.Format("Almacen: {0} Responsable: {1}", e.Row.DBCampo("AlmacenDestino"), e.Row.DBCampo("Recibio"))
|
|
|
|
Else
|
|
e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", String.Format("LimitaCantidad(this,{0});", e.Row.DBCampo("Cantidad")))
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnRecibir_Click(sender As Object, e As EventArgs)
|
|
If GvDatosRecepcion.Rows.Count > 0 Then
|
|
|
|
'Valida Movimientos
|
|
Dim ValidaMovtos = 0.0
|
|
For Each gvr As GridViewRow In GvDatosRecepcion.Rows
|
|
If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 Then
|
|
ValidaMovtos += gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal
|
|
End If
|
|
Next
|
|
|
|
If Not ValidaMovtos > 0 Then
|
|
Alert("No hay movimientos que realizar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
Dim CveMovimientoSalida As Integer = 0
|
|
Dim CveMovimientoEntrada As Integer = 0
|
|
Dim Folio = 0
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim TextoError = ""
|
|
|
|
'REGISTRA LA SALIDA Y ENTRADA (TRASPASO)
|
|
ObjInventario.IniciaTransacSQL() 'Inicia la transacción
|
|
Dim Fecha As Date = TxtFechaRecepcion.Text.ToDate
|
|
|
|
'AGREGAMOS LA SALIDA
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacen").ToEntero, 3, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, CveConsignacion:=GvDatosRecepcion.Rows(0).DataKey("CveConsignacion").ToEntero)
|
|
|
|
If CveMovimientoSalida <= 0 Then
|
|
TextoError = "No se pudo generar el movimiento de salida correctamente"
|
|
ErrorMovInv = True
|
|
Else
|
|
|
|
Dim CveMovimientoDetalleEntrada As Integer = 0
|
|
For Each gvr As GridViewRow In GvDatosRecepcion.Rows
|
|
If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 Then
|
|
'Try
|
|
' CveMovimientodetalleEntrada = gvr.DataKey("CveMovimiento").ToString.ToEntero
|
|
'Catch ex As Exception
|
|
|
|
'End Try
|
|
CveMovimientoDetalleEntrada = gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, gvr.DataKey("PU").ToString.ToDecimal, gvr.DataKey("CveAF").ToString.ToEntero, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
|
|
'AGREGAMOS LA ENTRADA
|
|
If Not ErrorMovInv Then
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, 9, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservacionesRecepcion.Text.Trim, Recibio:=TxtRecibio.Text, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, CveConsignacion:=GvDatosRecepcion.Rows(0).DataKey("CveConsignacion").ToEntero)
|
|
Folio = ObjInventario.Folio
|
|
|
|
If CveMovimientoEntrada <= 0 Then
|
|
TextoError = "No se pudo generar el movimiento de entrada correctamente"
|
|
ErrorMovInv = 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.ToDecimal, Dr("CveAF").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
'AGREGAMOS LA ENTRADA VIEJO
|
|
'If Not ErrorMovInv Then
|
|
' 'Folio = ObjInventario.GetFolioSiguiente(9, UsuarioActual.CveEmpresa)
|
|
' CveMovimientoEntrada = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero, 9, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1)
|
|
|
|
' If CveMovimientoEntrada <= 0 Then
|
|
' TextoError = "No se pudo generar el movimiento de entrada correctamente"
|
|
' ErrorMovInv = 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) Then
|
|
' ErrorMovInv = True
|
|
' TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
|
|
' End If
|
|
|
|
' End If
|
|
'End If
|
|
|
|
|
|
|
|
|
|
|
|
If Not ErrorMovInv Then
|
|
|
|
|
|
|
|
Dim ImportePrePoliza As Decimal = DtRecepcion.SUMD("Importe", "CveMovimientoDetalle > 0")
|
|
|
|
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL)
|
|
|
|
Dim Concepto As String = "Recepcion Traspaso"
|
|
Dim CvePrePoliza = ObjConta.AddPrePolizas("Recepcion/Consignacion", 53, ImportePrePoliza, ImportePrePoliza, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImportePrePoliza, "Recepcion Traspaso", 68, "Recepcion Traspaso", Fecha, -1, -1, CveVenta:=-1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=ImportePrePoliza, CveSubProyecto:=-1, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImportePrePoliza, "Recepcion Traspason", 68, "Recepcion Traspaso", Fecha, -1, -1, CveVenta:=-1, CveMovimientoAlmacen:=CveMovimientoSalida, ImporteMX:=ImportePrePoliza, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 6) Then
|
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
|
GuardaLogAD($"Consig | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
|
|
If Not ErrorMovInv Then
|
|
ObjInventario.Commit()
|
|
|
|
TxtRecibio.Text = ""
|
|
TxtFechaRecepcion.Text = Now.ToShortDateString
|
|
TxtObservacionesRecepcion.Text = ""
|
|
|
|
Dim Mensaje As StringBuilder = New StringBuilder
|
|
Mensaje.AppendFormat("Se realizo con exito la recepción. <br/> Folio de Entrada: <b>{0}</b>", Folio)
|
|
Mensaje.AppendFormat("<br/><a target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) 'onclick='ImprimirTraslado()'
|
|
Alert(Mensaje.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
GvDatosRecepcion.DataBind()
|
|
UpDatosRecepcion.Update()
|
|
Else
|
|
ObjInventario.RollBack()
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
End If
|
|
ObjInventario.Dispose()
|
|
CargaRecepcion()
|
|
Else
|
|
Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia)
|
|
If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);")
|
|
End If
|
|
End Sub
|
|
|
|
'Protected Sub BtnImprimirTraspaso_Click(sender As Object, e As EventArgs) Handles BtnImprimirTraspaso.Click
|
|
' Dim params As New List(Of ReportParameter)
|
|
' params.Add(New ReportParameter("SubProyecto", DdlAlmacenDestino.SelectedItem.ToString))
|
|
' params.Add(New ReportParameter("Folio", FolioTraspaso.ToString))
|
|
' params.Add(New ReportParameter("Fecha", TxtFecha.Text))
|
|
' params.Add(New ReportParameter("Observaciones", TxtObservaciones.Text))
|
|
' params.Add(New ReportParameter("NombreEntrego", UsuarioActual.Nombre))
|
|
' params.Add(New ReportParameter("NombreTraslado", TxtResponsable.Text))
|
|
' params.Add(New ReportParameter("NombreRecibio", ""))
|
|
' ImprimirPDF(String.Format("{0}Formatos\Traslado.rdlc", UsuarioActual.Empresa.Ruta), DtTraslado, params, "Reporte Traslado", RDSName:="DsInventarios")
|
|
'End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
#Region "DDL CLASIFICACION"
|
|
'Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged
|
|
' ChangeDdlProducto()
|
|
'End Sub
|
|
'Private Sub ChangeDdlProducto()
|
|
' If UsuarioActual.Empresa.Funcionalidad(105) = "" Then
|
|
' DdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero)
|
|
' DdlProducto.DataBind()
|
|
' DdlProducto.Items.Insert(0, New ListItem("----", "-1"))
|
|
' End If
|
|
' HFProducto.Value = ""
|
|
' HFTProducto.Value = ""
|
|
'End Sub
|
|
|
|
'Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto.SelectedIndexChanged
|
|
' ElProductoChange()
|
|
'End Sub
|
|
'Protected Sub HFProducto_ValueChanged(sender As Object, e As EventArgs) Handles HFProducto.ValueChanged
|
|
' ElProductoChange()
|
|
'End Sub
|
|
Private Sub ElProductoChange()
|
|
|
|
|
|
DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto.txtValue.Value.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
DdlUnidad.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Protected Sub DdlClasificacion_GV(sender As Object, e As System.EventArgs)
|
|
Dim pDdlClasificacion As DropDownList = CType(sender, DropDownList)
|
|
Dim pDdlProducto As DropDownList = CType(pDdlClasificacion.NamingContainer.FindControl("DdlProducto"), DropDownList)
|
|
|
|
If pDdlClasificacion.SelectedValue = "-1" Then
|
|
pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
|
pDdlProducto.DataBind()
|
|
Else
|
|
pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=pDdlClasificacion.SelectedValue.ToEntero)
|
|
pDdlProducto.DataBind()
|
|
End If
|
|
End Sub
|
|
Private Function isWhitFamily() As Boolean
|
|
Return (UsuarioActual.CveEmpresa = 66)
|
|
End Function
|
|
'Protected Sub DdlProducto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProducto.SelectedIndexChanged
|
|
' If Not DdlProducto.SelectedValue = "" Then
|
|
' 'If DtPS.FiltraParametros( string.Format("CvePS = {0} AND Inv_CveMetodoInventario = 3 ",DdlProducto.SelectedValue)).Rows.Count > 0 Then
|
|
' ' LblSerieLote.Visible = True
|
|
' ' TxtnSerieLote.Visible = True
|
|
' 'Else
|
|
' ' LblSerieLote.Visible = False
|
|
' ' TxtnSerieLote.Visible = False
|
|
' 'End If
|
|
' End If
|
|
' Dim dtpse As DataTable
|
|
' dtpse = GlobalDTProductosServiciosEquivalencias(DdlProducto.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
' 'dtpse.Columns("UM").ColumnName = "UnidadMedida"
|
|
' 'dtpse.Columns("CveUM").ColumnName = "CveUnidadMedida"
|
|
' DdlUnidad.DataSource = dtpse
|
|
' DdlUnidad.DataBind()
|
|
|
|
|
|
'End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " TIPO DE CAMBIO "
|
|
Protected Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
Select Case DdlMoneda.SelectedValue.ToEntero
|
|
Case 1
|
|
TrTC1.Visible = False
|
|
TrTC2.Visible = False
|
|
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
|
|
'CUANDO VIENE DE DB SIN PUEXTRANJERO
|
|
If Not Dr("PUExtranjero").ToString.ToDecimal > 0 Then
|
|
Exit For
|
|
End If
|
|
|
|
Dr("PU") = Dr("PUExtranjero")
|
|
Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble
|
|
Next
|
|
|
|
GvDatos.DataSource = DtMovimientos
|
|
GvDatos.DataBind()
|
|
|
|
LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero
|
|
|
|
UpDatos.Update()
|
|
|
|
VerPuExtranjero(False)
|
|
Case 2
|
|
TrTC1.Visible = True
|
|
TrTC2.Visible = True
|
|
VerPuExtranjero(True)
|
|
|
|
LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero
|
|
|
|
End Select
|
|
End Sub
|
|
Protected Sub BtnAplicarTC_Click(sender As Object, e As EventArgs)
|
|
For Each Dr As DataRow In DtMovimientos.Rows
|
|
Dr("PU") = Dr("PUExtranjero").ToString.ToDouble * TxtTipoCambio.Text.ToDouble
|
|
Dr("Total") = Dr("PU").ToString.ToDouble * Dr("Cantidad").ToString.ToDouble
|
|
Next
|
|
|
|
GvDatos.DataSource = DtMovimientos
|
|
GvDatos.DataBind()
|
|
|
|
LtTotal.Text = DtMovimientos.SUM("Total", "").ToString.FormatoNumero
|
|
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Sub VerPuExtranjero(Accion As Boolean)
|
|
|
|
ThPUExtranjero.Visible = Accion
|
|
TdPUExtranjero.Visible = Accion
|
|
GvDatos.Columns(6).Visible = Accion
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "Columnas Opcionales en PS"
|
|
|
|
|
|
Protected Sub DdlProducto_selectedindexchange(sender As Object, e As EventArgs)
|
|
If DdlProducto.SelectedValue.ToEntero > 0 Then
|
|
Dim drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto.SelectedValue.ToEntero).FiltroPrimero("")
|
|
|
|
If drp IsNot Nothing Then
|
|
Dim AplicaSerie As Boolean = CBool(drp("AplicaSerie"))
|
|
Dim AplicaSeccion As Boolean = CBool(drp("AplicaSeccion"))
|
|
Dim AplicaLote As Boolean = CBool(drp("AplicaLote"))
|
|
Dim AplicaCaducidad As Boolean = CBool(drp("AplicaCaducidad"))
|
|
'activa Serie
|
|
ThSerie.Visible = AplicaSerie
|
|
TrSerie.Visible = AplicaSerie
|
|
|
|
'activa seccion
|
|
ThSeccion.Visible = AplicaSeccion
|
|
TrSeccion.Visible = AplicaSeccion
|
|
|
|
'activa lote
|
|
ThLote.Visible = AplicaLote
|
|
TrLote.Visible = AplicaLote
|
|
|
|
'activa caducidad
|
|
ThCaducidad.Visible = AplicaCaducidad
|
|
TrCaducidad.Visible = AplicaCaducidad
|
|
|
|
Else
|
|
TxtSerie.Visible = False
|
|
End If
|
|
UpDatos.Update()
|
|
End If
|
|
ElProductoChange()
|
|
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
|
|
End Class
|