3391 lines
178 KiB
VB.net
3391 lines
178 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.IO
|
|
Imports Extensiones
|
|
Imports GemBox.Spreadsheet
|
|
|
|
Partial Class Inventarios_TraspasoAlmacen
|
|
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
|
|
|
|
Private Property DtTraslado As DataTable
|
|
Get
|
|
Return CType(ViewState("DtTraslado"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtTraslado") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveAlmacenTransitorio As Integer
|
|
Get
|
|
Return CType(ViewState("CveAlmacenTransitorio"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAlmacenTransitorio") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveAlmacenDestino As Integer
|
|
Get
|
|
Return CType(ViewState("CveAlmacenDestino"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAlmacenDestino") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveUsuarioResponsable As Integer
|
|
Get
|
|
Return CType(ViewState("CveUsuarioResponsable"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUsuarioResponsable") = value
|
|
End Set
|
|
End Property
|
|
Private Property CvePSSerie As Integer
|
|
Get
|
|
Return CType(ViewState("CvePSSerie"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePSSerie") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveUMSerie As Integer
|
|
Get
|
|
Return CType(ViewState("CveUMSerie"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUMSerie") = value
|
|
End Set
|
|
End Property
|
|
Private Property CargadoDeMov As Boolean
|
|
Get
|
|
Return CType(ViewState("CargadoDeMov"), Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("CargadoDeMov") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveMovimientoSalida As Integer
|
|
Get
|
|
Return CType(ViewState("CveMovimientoSalida"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMovimientoSalida") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveMov As Integer
|
|
Get
|
|
Return CType(ViewState("CveMov"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMov") = value
|
|
End Set
|
|
End Property
|
|
Private Property ObjFactura As Modelos.Factura
|
|
Get
|
|
Return CType(ViewState("ObjFactura"), Modelos.Factura)
|
|
End Get
|
|
Set(value As Modelos.Factura)
|
|
ViewState("ObjFactura") = value
|
|
End Set
|
|
End Property
|
|
Private Property Folio As Integer
|
|
Get
|
|
Return CType(ViewState("Folio"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("Folio") = value
|
|
End Set
|
|
End Property
|
|
Private Property MensajeAlert As StringBuilder
|
|
Get
|
|
Return CType(ViewState("MensajeAlert"), StringBuilder)
|
|
End Get
|
|
Set(value As StringBuilder)
|
|
ViewState("MensajeAlert") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveMovimientoTimbrado As Integer
|
|
Get
|
|
Return CType(ViewState("CveMovimientoTimbrado"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMovimientoTimbrado") = 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
|
|
Private Property FolioBusqueda As Integer
|
|
Get
|
|
Return CType(ViewState("FolioBusqueda"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("FolioBusqueda") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property ArchivoBitacora As String
|
|
Get
|
|
Return CType(ViewState("ArchivoBitacora"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ArchivoBitacora") = 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
|
|
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
CEFecha.EndDate = Now.AddDays(-1)
|
|
RVFecha.MaximumValue = Now.ToShortDateString
|
|
|
|
TxtFechaRecepcion.Text = Now.ToShortDateString
|
|
CEFechaRecepcion.EndDate = Now.AddDays(-1)
|
|
RVFechaRecepcion.MaximumValue = Now.ToShortDateString
|
|
Folio = 0
|
|
CveMovimientoTimbrado = -1
|
|
ArchivoBitacora = UsuarioActual.Empresa.Ruta & "Temp\Traspaso_" & UsuarioActual.CveUsuario & ".xml"
|
|
|
|
If UsuarioActual.CveEmpresa = 119 Then
|
|
divGastoIndirecto.Visible = False
|
|
LblGastoIndirecto.Visible = False
|
|
DivResponsable.Visible = False
|
|
End If
|
|
|
|
CargaCombos()
|
|
CreaDT()
|
|
AlmacenTransitorioDefaults()
|
|
|
|
If Request("CveEntrada") IsNot Nothing AndAlso Request("CveEntrada").ToString.ToEntero > 0 Then
|
|
CargaMovimiento(Request("CveEntrada").ToString.ToEntero)
|
|
End If
|
|
|
|
If Request("CveFolioGarantia") IsNot Nothing AndAlso Request("CveFolioGarantia").ToString.ToEntero > 0 Then
|
|
CargaMovimientoGarantia(Request("CveFolioGarantia").ToString.ToEntero)
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then
|
|
DivCodigoSeriePS.Visible = True
|
|
Else
|
|
DivCodigoSeriePS.Visible = False
|
|
End If
|
|
If ChkTransitorio.Checked Then
|
|
RegistraScript(" $('#DivGastoIndirecto').show(0); ")
|
|
DivResponsable.Visible = True
|
|
DivTransitorio2.Visible = True
|
|
End If
|
|
|
|
'If UsuarioActual.CveEmpresa.Contiene(141, 152, 158, 159, 160, 161, 162, 163) Then
|
|
' ChkEmitirTimbrado.Visible = False
|
|
' divEmitir.Visible = False
|
|
'End If
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(1, 2, 119, 140) Then
|
|
|
|
ChkEmitirCartaPorte.Visible = True
|
|
|
|
End If
|
|
|
|
CantidadTotal = 0
|
|
CvePS = 0
|
|
TipoSeccionAlmacen = 0
|
|
Dim PermisoEspecialCambioFecha As Boolean = False
|
|
If UsuarioActual.CveUsuario.Contiene(100, 1937) Then PermisoEspecialCambioFecha = True
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(281).ToEntero = 1 And Not PermisoEspecialCambioFecha Then
|
|
TxtFecha.Enabled = False
|
|
ImgFecha.Visible = False
|
|
TxtFechaRecepcion.Enabled = False
|
|
ImgFechaRecepcion.Visible = False
|
|
End If
|
|
|
|
Else
|
|
If ChkTransitorio.Checked Then
|
|
RegistraScript(" $('#DivGastoIndirecto').show(0); ")
|
|
DivResponsable.Visible = True
|
|
DivTransitorio2.Visible = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#Region "CARGA DATOS"
|
|
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("UM")
|
|
dt.Columns.Add("CvePS", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("CveAF", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("PS")
|
|
dt.Columns.Add("Observaciones")
|
|
dt.Columns.Add("CveSeccionAlmacen", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("SeccionAlmacen")
|
|
dt.Columns.Add("CveSeccionAlmacenDestino", Type.GetType("System.Int32"))
|
|
dt.Columns.Add("SeccionAlmacenDestino")
|
|
dt.Columns.Add("Serie")
|
|
dt.Columns.Add("Lote")
|
|
dt.Columns.Add("FechaCaducidad", Type.GetType("System.DateTime"))
|
|
|
|
'dt.Columns.Add("PU", 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("TotalImporte", Type.GetType("System.Double"))
|
|
dt.Columns.Add("PU", Type.GetType("System.Double"))
|
|
dt.Columns.Add("Descuento", Type.GetType("System.Double"))
|
|
dt.Columns.Add("SATClaveUM")
|
|
dt.Columns.Add("SATClaveProdServ")
|
|
dt.Columns.Add("Noidentificacion")
|
|
dt.Columns.Add("CuentaPredial")
|
|
dt.Columns.Add("Obs")
|
|
dt.Columns.Add("ImporteIVA", Type.GetType("System.Double"))
|
|
dt.Columns.Add("PorcentajeIVA", Type.GetType("System.Double"))
|
|
dt.Columns.Add("ClaveMaterialPeligroso")
|
|
dt.Columns.Add("ClaveEmbalaje")
|
|
dt.Columns.Add("Embalaje")
|
|
dt.Columns.Add("PesoKg", Type.GetType("System.Decimal"))
|
|
|
|
dt.TableName = "TablaTraspaso"
|
|
|
|
DtMovimientos = dt
|
|
|
|
CargaGvDatos()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaMovimiento(CveMovimiento As Integer)
|
|
Dim Mov As New ClsInventarios
|
|
|
|
If Mov.GetMovimientos(CveMovimiento, 2, -1, UsuarioActual.CveEmpresa) Then
|
|
If Mov.DtResultados.Rows.Count = 1 Then
|
|
DivMov.Visible = True
|
|
ltlFolio.Text = Mov.DtResultados(0)("Folio").ToString
|
|
ltlFecha.Text = Mov.DtResultados(0)("FechaMovto").ToString.ToDate.ToShortDateString
|
|
|
|
If Mov.CveCompra > 0 Then
|
|
hplRef.NavigateUrl = $"/Compras/Compras.aspx?CveCompra={Mov.CveCompra}"
|
|
lblCompraRef.Visible = True
|
|
hplRef.Visible = True
|
|
Else
|
|
hplRef.Visible = False
|
|
lblCompraRef.Visible = False
|
|
End If
|
|
|
|
CargadoDeMov = True
|
|
|
|
If (DdlAlmacenOrigen.Items.FindByValue(Mov.CveAlmacen.ToString()) Is Nothing) Then
|
|
Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", Mov.CveAlmacen))
|
|
If dr IsNot Nothing Then
|
|
DdlAlmacenOrigen.Items.Insert(0, New ListItem(dr("Almacen").ToString, dr("CveAlmacen").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString
|
|
DdlAlmacenOrigen.Enabled = False
|
|
End If
|
|
Else
|
|
DdlAlmacenOrigen.SelectedValue = Mov.CveAlmacen.ToString
|
|
End If
|
|
DdlAlmacenOrigen.Enabled = False
|
|
|
|
'If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {Mov.CveAlmacenDestino}").ToEntero = 16 Then
|
|
' CveMov = CveMovimiento
|
|
' LnkEnviarMail.Attributes.Add("onclick", "$('#ModalDivMail').modal();")
|
|
' LnkEnviarMail.Visible = True
|
|
'End If
|
|
|
|
If Mov.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
DtMovimientos = Mov.DtResultados.DefaultView.ToTable("Cantidad, CveUM, CvePS, CveAF, PS, Serie, CveSeccionAlmacen, CveClasificacion, EstatusExistencia")
|
|
CargaGvDatos()
|
|
End If
|
|
|
|
Else
|
|
Alert("El movimiento solicitado no existe. ", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
Else
|
|
Alert("Ocurrió un error al cargar el movimiento a traspasar. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
Mov.Dispose()
|
|
UpMov.Update()
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub CargaMovimientoGarantia(CveFolioGarantia As Integer)
|
|
Using ObjAcum As New ClsAcumuladores
|
|
If ObjAcum.GetFoliosGarantiasDetalle(CveFolioGarantia, CveEstatusConsecutivo:=1) Then
|
|
''carga
|
|
Dim dra As DataRow = ObjAcum.DtResultados(0)
|
|
DivMov.Visible = True
|
|
ltlFolio.Text = dra("FolioGarantia").ToString
|
|
Dim CveSub As Integer = dra("CveSubProyecto").ToString.ToEntero
|
|
lblCompraRef.Visible = False
|
|
hplRef.Visible = False
|
|
TxtObservaciones.Text = "Folio Garantia: " & dra("FolioGarantia").ToString
|
|
|
|
'If Mov.CveCompra > 0 Then
|
|
' hplRef.NavigateUrl = $"/Compras/Compras.aspx?CveCompra={Mov.CveCompra}"
|
|
' lblCompraRef.Visible = True
|
|
' hplRef.Visible = True
|
|
'Else
|
|
' hplRef.Visible = False
|
|
' lblCompraRef.Visible = False
|
|
'End If
|
|
ChkTransitorio.Enabled = False
|
|
DdlAlmacenOrigen.Enabled = True
|
|
DdlAlmacenOrigen.Items.Clear()
|
|
DdlAlmacenOrigen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6).FiltraParametros(String.Format("CveSubProyecto={0}", CveSub))
|
|
DdlAlmacenOrigen.DataBind()
|
|
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa, 21).FiltraParametros(String.Format("CveSubProyecto={0}", CveSub))
|
|
DdlAlmacenDestino.DataBind()
|
|
|
|
CargadoDeMov = True
|
|
|
|
Dim dtt As DataTable = ObjAcum.DtResultados.FiltraParametros("", DistinctColumns:={"CvePS", "PS", "CveUM", "UnidadMedida", "Codigo"})
|
|
|
|
For Each drr As DataRow In dtt.Rows
|
|
Dim dr As DataRow = DtMovimientos.NewRow
|
|
dr("CvePS") = drr("CvePS")
|
|
dr("PS") = String.Format("{0} - {1}", drr("Codigo"), drr("PS"))
|
|
dr("CveUM") = drr("CveUM")
|
|
dr("UnidadMedida") = drr("UnidadMedida")
|
|
dr("Cantidad") = ObjAcum.DtResultados.COUNT("CvePS", "CvePS = " & drr("CvePS").ToString)
|
|
DtMovimientos.Rows.Add(dr)
|
|
Next
|
|
|
|
CargaGvDatos()
|
|
End If
|
|
End Using
|
|
|
|
UpMov.Update()
|
|
End Sub
|
|
|
|
|
|
Private Sub AlmacenTransitorioDefaults()
|
|
ChkTransitorio.Checked = UsuarioActual.Empresa.Funcionalidad(154).ToString.ToEntero > 0
|
|
ChkTransitorio.Enabled = Not UsuarioActual.Empresa.Funcionalidad(154).ToString.ToEntero > 0
|
|
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 Almacen Origen
|
|
CargaAlmacenOrigen()
|
|
'DdlAlmacenOrigen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
'Dim dtAlm As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1)
|
|
'dtAlm.Merge(GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 2))
|
|
|
|
'Llena Almacen Destino, todos los almacenes destino,
|
|
'Dim CveSubP As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenOrigen.SelectedValue.ToEntero).FiltroPrimeroValor("CveSubProyecto", "").ToEntero
|
|
|
|
|
|
'DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveTipoAlmacen NOT IN (3,4,9,10,11,24) AND Estatus = 'Activo' AND CveSubProyecto = {0}", CveSubP))
|
|
''DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen <> 4")
|
|
'DdlAlmacenDestino.DataBind()
|
|
'DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
CargaAlmacenDestino()
|
|
|
|
'Llena Almacen Transitorio
|
|
DdlAlmacenTransitorio.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3)
|
|
DdlAlmacenTransitorio.DataBind()
|
|
'DdlAlmacenTransitorio.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
'Llena Almacen Recepcion
|
|
DdlAlmacenRecepcion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (3,4,9,10,11,24)")
|
|
DdlAlmacenRecepcion.DataBind()
|
|
DdlAlmacenRecepcion.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
'Llena Almacen Transitorio Recepcion
|
|
DdlAlmacenTransitorioRecepcion.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3)
|
|
DdlAlmacenTransitorioRecepcion.DataBind()
|
|
DdlAlmacenTransitorioRecepcion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
''Llena Almacen Recibe
|
|
'DdlAlmacenRecibe.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
'DdlAlmacenRecibe.DataBind()
|
|
|
|
'Llena Unidaddes Medida
|
|
'DdlUnidad.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
|
|
'DdlUnidad.DataBind()
|
|
|
|
'Llena Choferes
|
|
|
|
DdlChofer.DataSource = GlobalDTChoferes(UsuarioActual.CveEmpresa)
|
|
DdlChofer.DataBind()
|
|
|
|
DdlChofer.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
TxtFechaEntrega.Text = Now.ToShortDateString
|
|
TxtFechaLlegada.Text = Now.ToShortDateString
|
|
|
|
'Llena Responsables Transitorio
|
|
'DdlResponsable.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
|
|
'DdlResponsable.DataBind()
|
|
'DdlResponsable.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
'Llena Responsables Transitorio recepcion
|
|
'DdlResponsableRecepcion.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
|
|
'DdlResponsableRecepcion.DataBind()
|
|
'DdlResponsableRecepcion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
'Llenar el dropdownlist de Productos y servicios
|
|
|
|
'If UsuarioActual.Empresa.Funcionalidad(105) = "" Then
|
|
|
|
' DdlProducto.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa)
|
|
' DdlProducto.DataBind()
|
|
' DdlProducto.Items.Insert(0, New ListItem("----", "-1"))
|
|
' DdlProductows.Visible = False
|
|
'Else
|
|
' DdlProducto.Visible = False
|
|
'End If
|
|
|
|
CargaPS()
|
|
|
|
'Folio
|
|
SiguienteFolio(If(ChkTransitorio.Checked, 9, 8))
|
|
|
|
'DdlProducto.DataBind()
|
|
CargarCamiones()
|
|
End Sub
|
|
Private Sub CargaAlmacenOrigen()
|
|
DdlAlmacenOrigen.Enabled = True
|
|
DdlAlmacenOrigen.Items.Clear()
|
|
DdlAlmacenOrigen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen NOT IN (3,4,9,10,11,24)")
|
|
DdlAlmacenOrigen.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
|
|
DdlAlmacenOrigen.SelectedValue = "-1"
|
|
DdlAlmacenOrigen.DataBind()
|
|
DdlAlmacenOrigen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
|
End Sub
|
|
Private Sub CargaPS()
|
|
'DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
'If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then
|
|
' DdlProducto2.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa)
|
|
' DdlProducto2.DataBind()
|
|
'End If
|
|
|
|
Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False)
|
|
DdlProducto2.setEsWebService(EsWS)
|
|
|
|
If DdlProducto2.UsaWebService Then
|
|
'DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue)
|
|
If UsuarioActual.Empresa.Funcionalidad(141) = "1" Then
|
|
DdlProducto2.ddlWS.Attributes.Add("data-pagina", "inv/traspaso")
|
|
DdlProducto2.ddlWS.Attributes.Add("Data-onresult", "CargaExistenciaAlmacenes")
|
|
CargaExistenciasSucursal()
|
|
DdlAlmacenOrigen.AutoPostBack = True
|
|
End If
|
|
'ElseIf Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then
|
|
' DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltraParametros("CveTipoPS = 2")
|
|
' DdlProducto2.DataBind()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaExistenciasSucursal()
|
|
DdlProducto2.Attributes.Remove("Data-cvesubproyecto")
|
|
DdlProducto2.Attributes.Add("Data-cvesubproyecto", GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}"))
|
|
End Sub
|
|
Private Sub SiguienteFolio(CveConcepto As Integer)
|
|
'Dim Inv As New ClsInventarios
|
|
'Dim Folio As Integer = Inv.GetFolioSiguiente(CveConcepto, UsuarioActual.CveEmpresa)
|
|
'Inv.Dispose()
|
|
|
|
'TxtFolio.Text = Folio.ToString
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " AGREGAR "
|
|
Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
|
BtnAgregarPS(txtCantidad.Text.ToDecimal)
|
|
End Sub
|
|
Protected Sub BtnSerieAddNew_Click(sender As Object, e As EventArgs)
|
|
BtnAgregarPS(1)
|
|
End Sub
|
|
Private Sub BtnAgregarPS(Cantidad As Decimal)
|
|
Dim CveProducto As Integer = DdlProducto2.SelectedValue.ToEntero
|
|
Dim FuncionalidadSinSerie = True
|
|
|
|
If CveProducto > 0 Then
|
|
If TxtnSerie.Visible Then
|
|
Cantidad = 1
|
|
If String.IsNullOrEmpty(TxtnSerie.Text.Trim()) OrElse String.IsNullOrWhiteSpace(TxtnSerie.Text.Trim()) Then
|
|
Alert("Serie es necesario.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
Exit Sub
|
|
End If
|
|
If txtCantidad.Text.ToDouble > 1 Then
|
|
FuncionalidadSinSerie = False
|
|
End If
|
|
End If
|
|
Dim DrPS As DataRow = Nothing
|
|
|
|
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CveProducto).FiltroPrimero("") ' Estado = -1
|
|
|
|
If DrPS IsNot Nothing Then
|
|
|
|
If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then
|
|
'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
|
|
If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then
|
|
Alert(String.Format("El producto se vende solo en cantidades de {0:#,###.####}", DrPS("VentaMinima")))
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If DrPS("AplicaCaducidad").ToString = "True" Then
|
|
If Not ChkSugiereFechaCaducidad.Checked AndAlso (TxtnFechaCaducidad.Text = "" OrElse TxtnLote.Text = "") Then
|
|
Alert("Falta Especificar lote/Fecha del producto", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If DrPS("AplicaCaducidad").ToString = "True" AndAlso ChkSugiereFechaCaducidad.Checked Then
|
|
|
|
Dim ObjInventarios As New ClsInventarios
|
|
If ObjInventarios.GetExistenciasCaducidad(CveProducto, DdlAlmacenOrigen.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue) Then
|
|
Dim dtt As DataTable = ObjInventarios.DtResultados
|
|
|
|
If Cantidad > dtt.SUMD("Cantidad") Then
|
|
Alert("No se cuenta con la cantidad requerida")
|
|
Else
|
|
'recorro las existencias para tomar la cantidad
|
|
Dim i As Decimal = 0
|
|
Dim CantidadRestante As Decimal = Cantidad
|
|
For Each drr As DataRow In dtt.Rows
|
|
If drr("Cantidad").ToString.ToDecimal < CantidadRestante Then
|
|
i = drr("Cantidad").ToString.ToDecimal
|
|
Else
|
|
i = CantidadRestante
|
|
End If
|
|
AgregarPS(i, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Lote:=drr("Lote").ToString, FechaCaducidad:=drr("FechaCaducidad").ToString.ToDate, CveSeccionAlmacenDestino:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Limpia:=FuncionalidadSinSerie)
|
|
CantidadRestante -= i
|
|
If CantidadRestante <= 0 Then Exit For
|
|
Next
|
|
End If
|
|
|
|
End If
|
|
|
|
ObjInventarios.Dispose()
|
|
|
|
Else
|
|
|
|
'codigo temporal
|
|
Dim tLote As String
|
|
Dim tCaducidad As Date
|
|
|
|
tLote = If(TxtnLote.Visible, TxtnLote.Text, "-1")
|
|
tCaducidad = If(TxtnFechaCaducidad.Visible, TxtnFechaCaducidad.Text.ToDate, MinFecha)
|
|
|
|
Dim tSerie As String = If(TxtnSerie.Visible, TxtnSerie.Text, "-1").Trim
|
|
|
|
Dim Valido = ValidaExistencia(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedValue.ToEntero, tSerie, tLote, tCaducidad)
|
|
|
|
If Valido Then
|
|
AgregarPS(Cantidad, CveProducto, DdlUnidad.SelectedValue.ToEntero, TxtnObservaciones.Text, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(TxtnSerie.Visible, TxtnSerie.Text, ""), Lote:=If(tLote = "-1", "", tLote), FechaCaducidad:=tCaducidad, CveSeccionAlmacenDestino:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Limpia:=FuncionalidadSinSerie)
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
Private Function ValidaExistencia(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, CveSeccionAlmacen As Integer, Serie As String, Lote As String, FechaCaducidad As Date) As Boolean
|
|
Dim Retorno = True
|
|
|
|
Dim ExistenciaEspecificada As Decimal
|
|
Dim PendienteporSurtir As Decimal
|
|
Dim CantidadEnGrid As Decimal = DtMovimientos.SUMD("Cantidad", $"CvePS = {CvePS} AND CveUM = {CveUnidadMedida} {If(Serie <> "-1", $" AND Serie = '{Serie}'", "")}")
|
|
Dim Existencia As Decimal
|
|
|
|
Dim Inv As New ClsInventarios
|
|
If Inv.GetExistenciasProducto(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm")) Then
|
|
'si hay existencia en almacen costeado, lo tengo que sacar
|
|
Existencia = Inv.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
|
|
PendienteporSurtir = Inv.DtResultados.FiltroPrimeroValor("PendientePorSurtir", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
|
|
End If
|
|
'Existencia= Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), PendientePorSurtir:=1)
|
|
|
|
If Existencia >= Cantidad Then
|
|
'la primera vez valida, que la existencia global, cumpla, considerando lo pendiente por surtir
|
|
'las segunda consulta, que tenga existencia, ya con los parametros especificos
|
|
If (FechaCaducidad > MinFecha OrElse Not Serie.Contiene("", "-1") OrElse Not Lote.Contiene("", "-1")) Then
|
|
If Inv.GetExistenciasProducto(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, Caducidad:=FechaCaducidad) Then
|
|
'aqui se toma la COLUMNA Existencia, porque ya está validado que hay existencia suficiente para surtir, considerando lo pendiente por surtir, entonces se asume no se tomará la serie/lote
|
|
ExistenciaEspecificada = Inv.DtResultados.FiltroPrimeroValor("Existencia", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
|
|
End If
|
|
'ExistenciaEspecificada = Inv.GetExistenciasPS(CvePS, CveUnidadMedida, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, PendientePorSurtir:=-1)
|
|
Dim StrB As New StringBuilder
|
|
StrB.AppendFormat("CvePS = {0} AND CveUM = {1} ", CvePS, CveUnidadMedida)
|
|
If Not Serie.Contiene("", "-1") Then StrB.AppendFormat(" AND Serie = '{0}' ", Serie)
|
|
If Not Lote.Contiene("", "-1") Then StrB.AppendFormat(" AND Lote = '{0}' ", Lote)
|
|
If FechaCaducidad.ToDate > MinFecha Then StrB.AppendFormat(" AND FechaCaducidad = '{0}' ", FechaCaducidad.ToShortDateString)
|
|
Dim CantidadEspecificaEnGrid As Decimal = DtMovimientos.SUMD("Cantidad", StrB.ToString)
|
|
|
|
If ExistenciaEspecificada - Cantidad - CantidadEspecificaEnGrid < 0 Then
|
|
Alert(String.Format("Solo hay en existencia: {0:#,###.##}", ExistenciaEspecificada), TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
Retorno = False
|
|
End If
|
|
Else
|
|
ExistenciaEspecificada = Existencia
|
|
If Existencia - Cantidad - CantidadEnGrid < 0 Then
|
|
Alert(String.Format("Solo hay en existencia: {0:#,###.##}", ExistenciaEspecificada), TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
Retorno = False
|
|
End If
|
|
End If
|
|
Else
|
|
Alert("No hay existencia del producto", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
Retorno = False
|
|
End If
|
|
|
|
Inv.Dispose()
|
|
|
|
Return Retorno
|
|
End Function
|
|
Private Sub AgregarPS(Cantidad As Double, CvePS As Integer, CveUnidadMedida As Integer, Optional Observaciones As String = "", Optional CveSeccionAlmacen As Integer = -1, Optional SeccionAlmacen As String = "", Optional Serie As String = "", Optional Lote As String = "", Optional FechaCaducidad As Date = MinFecha, Optional Limpia As Boolean = True, Optional CveSeccionAlmacenDestino As Integer = -1)
|
|
If Cantidad <= 0 Then
|
|
Alert("La cantidad debe ser mayor a cero (0). Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
End If
|
|
|
|
Dim CveClasificacion As Integer
|
|
|
|
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
|
|
|
If ChkEmitirTimbrado.Checked AndAlso ChkEmitirCartaPorte.Checked Then
|
|
If Not ValidaPSSAT(DrPS) Then
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If DrPS IsNot Nothing Then
|
|
CveClasificacion = DrPS("CveClasificacion").ToString.ToEntero
|
|
Dim DrUM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimero($"CveUnidadMedida = {CveUnidadMedida}")
|
|
|
|
Dim registro As DataRow = DtMovimientos.NewRow
|
|
registro.Item("Cantidad") = Cantidad
|
|
registro.Item("CveUM") = CveUnidadMedida
|
|
registro.Item("UM") = DrUM("UnidadMedida")
|
|
registro.Item("UnidadMedida") = DrUM("UnidadMedida")
|
|
registro.Item("CvePS") = CvePS
|
|
registro.Item("PS") = DrPS("PSCodigo")
|
|
registro.Item("Observaciones") = Observaciones
|
|
registro.Item("Serie") = Serie.Trim
|
|
registro.Item("Lote") = Lote
|
|
If FechaCaducidad > MinFecha Then registro.Item("FechaCaducidad") = FechaCaducidad
|
|
registro.Item("CveClasificacion") = CveClasificacion
|
|
registro.Item("CveAF") = -1
|
|
registro.Item("EstatusExistencia") = "1"
|
|
registro.Item("CveSeccionAlmacen") = CveSeccionAlmacen
|
|
registro.Item("SeccionAlmacen") = SeccionAlmacen
|
|
registro.Item("CveSeccionAlmacenDestino") = CveSeccionAlmacenDestino
|
|
|
|
registro.Item("TotalImporte") = 0
|
|
registro.Item("PU") = 0
|
|
registro.Item("Descuento") = 0
|
|
registro.Item("SATClaveUM") = DrPS("SATClaveUnidadMedida")
|
|
registro.Item("SATClaveProdServ") = DrPS("SATClavePS")
|
|
registro.Item("Noidentificacion") = DrPS("Codigo")
|
|
registro.Item("CuentaPredial") = ""
|
|
registro.Item("Obs") = ""
|
|
|
|
registro.Item("ImporteIVA") = 0
|
|
registro.Item("PorcentajeIVA") = 0
|
|
registro("ClaveMaterialPeligroso") = DrPS("ClaveMaterialPeligroso")
|
|
registro("ClaveEmbalaje") = DrPS("ClaveEmbalaje")
|
|
registro("PesoKg") = DrPS("PesoKg")
|
|
|
|
DtMovimientos.Rows.Add(registro)
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
IO.Path.GetDirectoryName(ArchivoBitacora).DirectoryExistsCreate 'verifica que exista la ruta
|
|
ActualizaBitacora()
|
|
End If
|
|
|
|
CargaGvDatos()
|
|
|
|
If Limpia Then
|
|
LimpiaAgregar()
|
|
Else
|
|
txtCantidad.Text = (txtCantidad.Text.ToDouble - 1.0).ToString
|
|
TxtnSerie.Text = ""
|
|
TxtnSerie.Focus()
|
|
End If
|
|
End Sub
|
|
Private Sub ActualizaBitacora(Optional Eliminar As Boolean = False)
|
|
If Not Eliminar Then
|
|
DtMovimientos.WriteXml(ArchivoBitacora, XmlWriteMode.WriteSchema)
|
|
Else
|
|
File.Delete(ArchivoBitacora)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub LimpiaAgregar()
|
|
'DdlClasificacion.SelectedValue = "-1"
|
|
'DdlClasificacion_SelectedIndexChanged(DdlClasificacion, EventArgs.Empty)
|
|
txtCantidad.Text = "1"
|
|
TxtnObservaciones.Text = ""
|
|
TxtnSerie.Text = ""
|
|
'TxtnSerie.Visible = False
|
|
TxtnLote.Text = ""
|
|
TxtnFechaCaducidad.Text = ""
|
|
|
|
txtCantidad.Focus()
|
|
If TxtCodigoPS.Visible Then
|
|
TxtCodigoPS.Focus()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " GUARDAR "
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
|
|
|
If ChkTransitorio.Checked AndAlso ChkEmitirCartaPorte.Checked Then
|
|
If DdlChofer.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Debe de seleccionar un chofer.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
If DdlUnidadCamion.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Debe de seleccionar una unidad.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
'VALIDA ALMACEN ORIGEN Y DESTINO
|
|
If DdlAlmacenOrigen.SelectedValue = DdlAlmacenDestino.SelectedValue Then
|
|
Alert("No se puede realizar un traspaso entre el mismo almacén.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'VALIDA TRANSITORIO
|
|
If ChkTransitorio.Checked Then
|
|
If TxtResponsable.Text.Trim = "" And Not UsuarioActual.CveEmpresa.Contiene(119) Then
|
|
Alert("Debe seleccionar un responsable para el traspaso transitorio.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
If ChkTransitorio.Checked Then DivResponsable.Visible = True : DivTransitorio2.Visible = True
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlAlmacenTransitorio.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Debe seleccionar un almacen transitorio.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
If ChkTransitorio.Checked Then DivResponsable.Visible = True : DivTransitorio2.Visible = True
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlChofer.SelectedValue.ToEntero <= 0 And UsuarioActual.CveEmpresa.Contiene(119) Then
|
|
Alert("Debe seleccionar un Chofer", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
If ChkTransitorio.Checked Then DivResponsable.Visible = True : DivTransitorio2.Visible = True
|
|
Exit Sub
|
|
End If
|
|
|
|
''validaciones de carta porte en productos
|
|
If ChkEmitirTimbrado.Checked AndAlso ChkEmitirCartaPorte.Checked Then
|
|
' Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
|
|
'If Not ValidaPSSAT(DrPS) Then
|
|
' Exit Sub
|
|
'End If
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
Dim DrAlmO, DrAlmD As DataRow
|
|
Dim CveSucursalOrigen, CveSucursalDestino As Integer
|
|
Dim TipoAlmacenOrigen, TipoAlmacenDestino As Integer
|
|
Dim CveSubProyectoOrigen, CveSubProyectoDestino As Integer
|
|
Dim IdCtaContableOrigen, IdCtaContableDestino As Integer
|
|
|
|
Dim CveAlmacenVirtualSalida As Integer = -1
|
|
Dim CveAlmacenVirtualEntrada As Integer = -1
|
|
|
|
DrAlmO = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenOrigen.SelectedValue.ToEntero).FiltroPrimero("")
|
|
DrAlmD = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenDestino.SelectedValue.ToEntero).FiltroPrimero("")
|
|
|
|
If DrAlmO IsNot Nothing AndAlso DrAlmD IsNot Nothing Then
|
|
CveSucursalOrigen = DrAlmO("CveSubProyecto").ToString.ToEntero
|
|
TipoAlmacenOrigen = DrAlmO("CveTipoAlmacen").ToString.ToEntero
|
|
CveSubProyectoOrigen = DrAlmO("CveSubProyecto").ToString.ToEntero
|
|
IdCtaContableOrigen = DrAlmO("IdCtaContable").ToString.ToEntero
|
|
CveAlmacenVirtualSalida = DrAlmO("CveAlmacenVirtual").ToString.ToEntero
|
|
|
|
|
|
CveSucursalDestino = DrAlmD("CveSubProyecto").ToString.ToEntero
|
|
TipoAlmacenDestino = DrAlmD("CveTipoAlmacen").ToString.ToEntero
|
|
CveSubProyectoDestino = DrAlmD("CveSubProyecto").ToString.ToEntero
|
|
IdCtaContableDestino = DrAlmD("IdCtaContable").ToString.ToEntero
|
|
CveAlmacenVirtualEntrada = DrAlmD("CveAlmacenVirtual").ToString.ToEntero
|
|
|
|
End If
|
|
|
|
Dim RealizarMovimientoVirtual As Boolean = False
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso TipoAlmacenOrigen.Contiene(1, 27) Then
|
|
RealizarMovimientoVirtual = True
|
|
End If
|
|
|
|
'SI VA PASAR POR EL ALMACEN TRANSITORIO, DEBE TRASPASAR LOS VIRTUALES AHI PRIMERO
|
|
If ChkTransitorio.Checked Then
|
|
CveAlmacenVirtualEntrada = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenTransitorio.SelectedValue.ToEntero).FiltroPrimero("")("CveAlmacenVirtual").ToString().ToEntero()
|
|
End If
|
|
|
|
'VALIDA ALMACEN DISTINTA SUCURSAL DEBE SER TRANSITORIO
|
|
If Not UsuarioActual.CveEmpresa.Contiene(7, 140) Then '[IPP] EMPRESA VIGILANCIA NO OCUPA TRANSITORIOS - TIENEN MIL SUCURSALES Xd
|
|
If Not ChkTransitorio.Checked Then
|
|
|
|
If Not TipoAlmacenDestino.Contiene(21, 26) Then 'NO SE VALIDA CUANDO EL TIPO DE ALMACEN DESTINO ES DE DEVOLUCION
|
|
If CveSucursalOrigen <> CveSucursalDestino Then
|
|
Alert("Por ser un traspaso entre sucursales es necesario indicar que el traspaso es transitorio.", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'');", "SonidoError")
|
|
ChkTransitorio.Checked = True
|
|
If ChkTransitorio.Checked Then DivResponsable.Visible = True : DivTransitorio2.Visible = True
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
'VALIDA QUE TENGA MOVTOS
|
|
If Not GvDatos.Rows.Count > 0 Then
|
|
Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia)
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
Exit Sub
|
|
End If
|
|
|
|
'VALIDA ESTATUS EXISTENCIA
|
|
For Each dr As DataRow In DtMovimientos.Rows
|
|
If dr("EstatusExistencia").ToString = "-1" Then
|
|
Alert("Tiene que rectificar los movimientos con error.", TipoMensaje.MsgError)
|
|
If ChkTransitorio.Checked Then DivResponsable.Visible = True : DivTransitorio2.Visible = True
|
|
Exit Sub
|
|
End If
|
|
Next
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
'VALIDA LA EXISTENCIA DEL ALMACEN DE ORIGEN
|
|
Dim ErrorExistencia = False
|
|
Dim Serie, Lote As String
|
|
Dim CveSeccionAlmacen As Integer
|
|
Dim FechaCaducidad As Date
|
|
|
|
Dim TextoExistencia As StringBuilder = New StringBuilder
|
|
TextoExistencia.Append("Los siguiente productos no tienen existencia:<br/>")
|
|
|
|
For Each gvr As GridViewRow In GvDatos.Rows
|
|
Dim Existencia As Decimal = 0
|
|
CveSeccionAlmacen = If(gvr.DataKey("CveSeccionAlmacen") = "", -1, gvr.DataKey("CveSeccionAlmacen").ToEntero)
|
|
Serie = If(gvr.DataKey("Serie") = "", "-1", gvr.DataKey("Serie"))
|
|
Lote = If(gvr.DataKey("Lote") = "", "-1", gvr.DataKey("Lote"))
|
|
FechaCaducidad = If(gvr.DataKey("FechaCaducidad") = "", MinFecha, gvr.DataKey("FechaCaducidad").ToDate)
|
|
Dim MsgAdicional As String = ""
|
|
|
|
If ObjInventario.GetExistenciasProducto(gvr.DataKey("CvePS").ToEntero, gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDate.ToString("yyyy/MM/dd 23:59"), CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, Caducidad:=FechaCaducidad) Then
|
|
'si hay existencia en almacen costeado, lo tengo que sacar
|
|
' si tiene serie el producto, debe de
|
|
Existencia = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
|
|
Dim ExistenciaSinPendiente As Decimal = ObjInventario.DtResultados.FiltroPrimeroValor("Existencia", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
|
|
Dim PendienteporSurtir As Decimal = ObjInventario.DtResultados.FiltroPrimeroValor("PendientePorSurtir", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
|
|
|
|
' si la existencia es negativa y tiene serie ó lote, quiere decir que la consulta es específica, y si hay pendientes por surtir. puede generar negativos
|
|
' para asegurarnos que lo pendiente por surtir se pueda surtir con otras series, consultamos de nuevo, pero a nivel producto, para checar existencia
|
|
|
|
If ExistenciaSinPendiente > 0 AndAlso Existencia <= 0 AndAlso PendienteporSurtir > 0 Then
|
|
MsgAdicional = " Pendiente por surtir: " & PendienteporSurtir.FormatoNumero(0)
|
|
If ObjInventario.GetExistenciasProducto(gvr.DataKey("CvePS").ToEntero, gvr.DataKey("CveUM").ToEntero, UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd 23:59")) Then
|
|
'si hay existencia en almacen costeado, lo tengo que sacar
|
|
Existencia = ObjInventario.DtResultados.FiltroPrimeroValor("ExistenciaFinal", String.Format("CveAlmacen = {0}", DdlAlmacenOrigen.SelectedValue)).ToDecimal
|
|
'si la existencia del producto en general, supera a lo pendiente, entonces la serie si se puede sacar.
|
|
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Existencia -= gvr.FCTextBox("TxtCantidad2").Text.ToDecimal()
|
|
|
|
If Existencia < 0 Then
|
|
ErrorExistencia = True
|
|
TextoExistencia.AppendFormat("-<b>#{0}</b> {1} {2} Existencia: <b>{3}</b>{4}<br/>", gvr.DataKey("No"), gvr.DataKey("PS"), If(gvr.DataKey("Serie").ToString().Trim().Length > 0, $" Serie: <b>{gvr.DataKey("Serie")}</b>", ""), (Existencia + gvr.FCTextBox("TxtCantidad2").Text.ToDecimal()), MsgAdicional)
|
|
End If
|
|
Next
|
|
|
|
If ErrorExistencia Then
|
|
ObjInventario.Dispose()
|
|
Alert(TextoExistencia.ToString, TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim TotalCantidad As Decimal = DtMovimientos.SUMD("Cantidad")
|
|
'Inicia la transacción
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
Dim CveMovimientoSalida As Integer = 0
|
|
Dim CveMovimientoEntrada = 0
|
|
Dim IDPoliza As Integer = 0
|
|
Dim FolioSalida = 0
|
|
Dim CveMovimientoVirtualEntrada As Integer = 0
|
|
Dim CveMovimientoVirtualSalida As Integer = 0
|
|
Dim FolioVirtualEntrada As Integer = 0
|
|
Dim FolioVirtualSalida As Integer = 0
|
|
Dim FolioEntrada As Integer = 0
|
|
Dim Fecha As DateTime = TxtFecha.Text.ToDate
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim ErrorAC As Boolean = False
|
|
Dim TextoError = ""
|
|
Dim TipoMovimientoSalida As Integer = 26
|
|
Dim CveAlmacenEntrada As Integer = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, DdlAlmacenDestino.SelectedValue.ToEntero)
|
|
|
|
Dim CveConceptoEntrada As Integer = 27
|
|
If Not ChkTransitorio.Checked Then CveConceptoEntrada = 27 Else CveConceptoEntrada = 9
|
|
|
|
Dim CveFolioGarantia As Integer = IfNull(Request("CveFolioGarantia"), -1).ToString.ToEntero
|
|
|
|
'AGREGAMOS LA SALIDA DEL ALMACEN ORIGEN
|
|
CveMovimientoSalida = ObjInventario.AddMovimiento(DdlAlmacenOrigen.SelectedValue.ToEntero, TipoMovimientoSalida, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservaciones.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, "-1"),
|
|
CveAlmacenDestino:=DdlAlmacenDestino.SelectedValue.ToEntero, GastoIndirecto:=If(ChkTransitorio.Checked And TxtGastoIndirecto.Text.ToDouble > 0, TxtGastoIndirecto.Text, "-1").ToDouble,
|
|
CveChofer:=If(ChkTransitorio.Checked, DdlChofer.SelectedValue.ToEntero, -1), Placa:="", FechaEntrega:=If(ChkTransitorio.Checked, TxtFechaEntrega.Text.Trim.ToDateTime.ToString("dd/MM/yyyy"), "-1"), EspecifUnidad:="",
|
|
ResponsableCarga:="", ResponsableRecibio:="", Identificacion:="", Domicilio:="",
|
|
Telefono:="", Ciudad:="", Licencia:="", Modulo:="TA/G2", CveFolioGarantia:=CveFolioGarantia)
|
|
FolioSalida = ObjInventario.Folio
|
|
Folio = ObjInventario.Folio
|
|
If CveMovimientoSalida <= 0 Then
|
|
TextoError = "Ocurrió un error al generar el movimiento de salida"
|
|
ErrorMovInv = True
|
|
Else
|
|
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, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
Exit For
|
|
End If
|
|
Cont += 1
|
|
Next
|
|
End If
|
|
|
|
'ENTRADA
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenEntrada, CveConceptoEntrada, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservaciones.Text.Trim, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, "-1"),
|
|
CveAlmacenDestino:=If(ChkTransitorio.Checked, DdlAlmacenDestino.SelectedValue.ToEntero, -1), CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="TA/G3", CveFolioGarantia:=CveFolioGarantia)
|
|
FolioEntrada = ObjInventario.Folio
|
|
If CveMovimientoEntrada <= 0 Then
|
|
TextoError = "Ocurrió un error al generar el movimiento de entrada"
|
|
ErrorMovInv = True
|
|
Else
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
Dim Cont As Integer = 0
|
|
Dim dttSalida As DataTable = ObjInventario.DtResultados
|
|
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
Dim CostoEntrada As Decimal = If(TipoAlmacenDestino = 26, 0, Dr("PU").ToString.ToDecimal())
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, CostoEntrada, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=DdlSeccionAlmacenDestino.SelectedValue.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Observaciones:=Dr("Observaciones").ToString) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
End If
|
|
Cont += 1
|
|
Next
|
|
|
|
Dim Concepto As String = TxtObservaciones.Text
|
|
If Concepto = "" Then Concepto = "Traspaso"
|
|
|
|
'AGREGAMOS PREPOLIZAS TRASPASO DIRECTO:
|
|
If Not ErrorMovInv Then
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
Dim importe As Decimal = dttSalida.SUMD("Total").RoundSQL
|
|
Dim Contabilizable As Boolean = False
|
|
|
|
If TipoAlmacenOrigen = 26 AndAlso TipoAlmacenDestino <> 26 Then Contabilizable = True 'IdCtaContableOrigen = IdCtaContableDestino AndAlso
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableOrigen, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
'si el tipo de almacen de entrada es Almacen sin costo, se registra al costo, la salida.
|
|
If TipoAlmacenOrigen <> 26 AndAlso TipoAlmacenDestino = 26 Then
|
|
|
|
Dim tCveClasificacion As Integer = DtMovimientos.MAX("CveClasificacion").ToEntero
|
|
Dim dr As DataRow = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=tCveClasificacion).FiltroPrimero("")
|
|
Dim IdCuentaCostos As Integer = -1
|
|
If dr IsNot Nothing Then IdCuentaCostos = dr("IdCuentaCostos").ToString.ToEntero
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 69, TxtObservaciones.Text, Fecha, IdCuentaCostos, -1, CveClasificacion:=tCveClasificacion, CveSubProyecto:=CveSubProyectoOrigen, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=Contabilizable, ImporteMX:=importe) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
Contabilizable = False
|
|
importe = 0
|
|
End If
|
|
|
|
If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContableDestino, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=Contabilizable, ImporteMX:=importe) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
'VIRTUAL SALIDA/ENTRADA
|
|
If RealizarMovimientoVirtual AndAlso CveMovimientoSalida > 0 AndAlso Not ErrorMovInv Then
|
|
|
|
Dim dtvirtual As DataTable = Nothing
|
|
|
|
If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
|
|
dtvirtual = ObjInventario.DtResultados
|
|
|
|
If dtvirtual.Rows.Count > 0 Then
|
|
'SALIDA VIRTUAL
|
|
CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtualSalida, 37, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="TA/V", CveMovimientoRelacionado:=CveMovimientoSalida, CveAlmacenDestino:=CveAlmacenVirtualEntrada)
|
|
FolioVirtualSalida = ObjInventario.Folio
|
|
Dim Contabilizable As Boolean = False
|
|
Dim Concepto As String = TxtObservaciones.Text
|
|
|
|
If CveMovimientoVirtualSalida > 0 Then
|
|
|
|
For Each RowVirtual As DataRow In dtvirtual.Rows
|
|
Dim CvePS = RowVirtual("CvePS").ToString().ToEntero()
|
|
Dim CantidadUsado As Decimal = RowVirtual("Cantidad").ToString.ToDecimal
|
|
Dim PU As Decimal = RowVirtual("Cargo").ToString().ToDecimal()
|
|
Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero()
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualSalida, CantidadUsado, CveUM, CvePS, PU, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
'ENTRADA VIRTUAL
|
|
Dim importevirtual As Decimal = 0
|
|
CveMovimientoVirtualEntrada = ObjInventario.AddMovimiento(CveAlmacenVirtualEntrada, 36, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Modulo:="TA/S3", CveMovimientoRelacionado:=CveMovimientoEntrada, CveAlmacenDestino:=CveAlmacenVirtualEntrada)
|
|
FolioVirtualEntrada = ObjInventario.Folio
|
|
If CveMovimientoVirtualEntrada > 0 Then
|
|
Dim DtCostosVirtual As DataTable
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtualSalida, UsuarioActual.CveEmpresa) Then
|
|
DtCostosVirtual = ObjInventario.DtResultados
|
|
importevirtual = DtCostosVirtual.SUMD("Total").RoundSQL
|
|
|
|
For Each RowVirtual As DataRow In DtCostosVirtual.Rows
|
|
Dim CvePS = RowVirtual("CvePS").ToString().ToEntero()
|
|
Dim CantidadUsado As Decimal = RowVirtual("Cantidad").ToString.ToDecimal
|
|
Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal()
|
|
Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero()
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
Else
|
|
TextoError = "Ocurrió un error al generar el movimiento de salida virtual"
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TAVirt", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importevirtual, importevirtual, 68, TxtObservaciones.Text, TxtObservaciones.Text, IdCtaContableOrigen, CveMovimientoAlmacen:=CveMovimientoVirtualSalida, Contabilizable:=Contabilizable) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importevirtual, importevirtual, 68, TxtObservaciones.Text, TxtObservaciones.Text, IdCtaContableDestino, CveMovimientoAlmacen:=CveMovimientoVirtualEntrada, Contabilizable:=Contabilizable) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
Else
|
|
TextoError = "Ocurrió un error al generar el movimiento de salida virtual"
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
Dim SerieInsertadaTimbre As String = ""
|
|
Dim FolioInsertadoTimbre As Integer = -1
|
|
Dim CveTimbre As Integer = -1
|
|
If Not ErrorMovInv Then
|
|
|
|
If ChkEmitirTimbrado.Checked Then
|
|
|
|
Dim ObjGral As New ClsGenerales(ObjInventario.IniciaTransacSQL)
|
|
Dim CveSubProyectoTimbre As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveAlmacen = {DdlAlmacenOrigen.SelectedValue}").Rows(0)("CveSubProyecto").ToString.ToEntero
|
|
Dim Fechallegada As DateTime = (TxtFechaLlegada.Text & " 23:59:59").ToDateTime
|
|
|
|
Dim CveEntregaAlmacen As Integer = ObjGral.AddInvEntregaAlmacenRuta(CveSubProyectoTimbre, -1, -1, CveMovimientoSalida, DdlChofer.SelectedValue.ToEntero, DdlUnidadCamion.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, TxtFechaLlegada.Text.ToDate, "T", "", "", MinFecha, 1, 1, TxtDistancia.Text.ToEntero,
|
|
CveConfigAutoTransporte:=DdlConfigAuto.SelectedValue.ToEntero, CveCamionRemolque1:=DdlRemolque1.SelectedValue.ToEntero, CveCamionRemolque2:=DdlRemolque2.SelectedValue.ToEntero)
|
|
|
|
If CveEntregaAlmacen > 0 Then
|
|
CveTimbre = ObjGral.AddGralTimbre("Tra", CveSubProyectoTimbre, TxtFechaEntrega.Text.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEntregaAlmacen:=CveEntregaAlmacen, AplicaCP:=ChkEmitirCartaPorte.Checked)
|
|
|
|
If CveTimbre > 0 Then
|
|
SerieInsertadaTimbre = ObjGral.SerieInsertada
|
|
FolioInsertadoTimbre = ObjGral.FolioInsertado
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
DtTraslado = DtMovimientos.Copy
|
|
|
|
ObjInventario.Commit()
|
|
MensajeAlert = New StringBuilder
|
|
|
|
MensajeAlert.Append("Se realizó con éxito el traspaso.")
|
|
|
|
MensajeAlert.AppendFormat("<br/> Folio de Salida: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{0}</a></b>", FolioSalida, CveMovimientoSalida)
|
|
MensajeAlert.AppendFormat("<br/><a target='_blank' class='Texto' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida)))
|
|
If CveMovimientoVirtualSalida > 0 Then MensajeAlert.AppendFormat("<br/>Folio Virtual: <b><a class='Texto' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{2}</a></b> <br/><a class='Texto' target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Salida Virtual</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtualSalida)), CveMovimientoVirtualSalida, FolioVirtualSalida)
|
|
|
|
If Not ChkTransitorio.Checked Then
|
|
MensajeAlert.AppendFormat("<br/><br/> Folio de Entrada: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{0}</a></b>", FolioEntrada, CveMovimientoEntrada)
|
|
MensajeAlert.AppendFormat("<br/><a target='_blank' class='Texto' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada)))
|
|
If CveMovimientoVirtualEntrada > 0 Then MensajeAlert.AppendFormat("<br/>Folio Virtual: <b><a class='Texto' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{2}</a></b> <br/><a target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Entrada Virtual</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtualEntrada)), CveMovimientoVirtualEntrada, FolioVirtualEntrada)
|
|
|
|
End If
|
|
|
|
If ChkEmitirTimbrado.Checked Then
|
|
CveMovimientoTimbrado = CveMovimientoSalida
|
|
EmitirTimbrado(CveTimbre, CveMovimientoTimbrado)
|
|
End If
|
|
|
|
Alert(MensajeAlert.ToString, TipoMensaje.MsgInformacion, "")
|
|
|
|
If ChkTransitorio.Checked AndAlso UsuarioActual.CveEmpresa.Contiene(72, 80) Then
|
|
RegistraScript(String.Format("AbrirVentana('/General/PopUpPaqueteriasGuias.aspx?CveMovimiento={0}',800,620);", CveMovimientoSalida))
|
|
End If
|
|
LimpiaMovimiento()
|
|
|
|
Else
|
|
ObjInventario.RollBack()
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
End If
|
|
|
|
'SI OCURRIO UN ERROR EN LA EXISTENCIA RECARGAMOS EL GRID PARA COLOREAR LOS DETALLES CON ERROR
|
|
If ErrorExistencia Then
|
|
CargaGvDatos()
|
|
End If
|
|
ObjConta.Dispose()
|
|
ObjInventario.Dispose()
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " NUEVO - LIMPIA "
|
|
Protected Sub BtnNuevo_Click(sender As Object, e As EventArgs)
|
|
LimpiaMovimiento()
|
|
End Sub
|
|
Private Sub LimpiaMovimiento()
|
|
CargaAlmacenOrigen()
|
|
TxtResponsable.Text = ""
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
TxtObservaciones.Text = ""
|
|
txtCantidad.Text = ""
|
|
SiguienteFolio(If(ChkTransitorio.Checked, 9, 8))
|
|
ChkTransitorio.Checked = False
|
|
ChkTransitorio.Enabled = True
|
|
TxtGastoIndirecto.Text = ""
|
|
|
|
DivMov.Visible = False
|
|
CargadoDeMov = False
|
|
|
|
UPDatosAlmacen.Update()
|
|
UpMov.Update()
|
|
|
|
DtMovimientos.Rows.Clear()
|
|
ActualizaBitacora()
|
|
CargaGvDatos()
|
|
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
|
|
' DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero).FiltraParametros("", "PSCodigo")
|
|
' DdlProducto2.DataBind()
|
|
' DdlProducto2.ddl.Items.Insert(0, New ListItem(" ", "-1"))
|
|
' Else
|
|
' DdlProducto2.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacion.SelectedValue)
|
|
' DdlProducto2.SelectedText = ""
|
|
' DdlProducto2.SelectedValue = "-1"
|
|
' End If
|
|
'End Sub
|
|
Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProducto2.selectedindexchange
|
|
ElProductoChange()
|
|
End Sub
|
|
Private Sub ElProductoChange()
|
|
TxtnSerie.Visible = False
|
|
TxtnLote.Visible = False
|
|
TxtnFechaCaducidad.Visible = False
|
|
|
|
If DdlProducto2.SelectedValue.ToEntero > 0 Then
|
|
Dim drP As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlProducto2.SelectedValue.ToEntero).FiltroPrimero("", "PS")
|
|
If drP IsNot Nothing Then
|
|
|
|
ThSeccionAlmacen.Visible = CBool(drP("AplicaSeccion"))
|
|
TdSeccionAlmacen.Visible = CBool(drP("AplicaSeccion"))
|
|
DdlSeccionAlmacen.Visible = CBool(drP("AplicaSeccion"))
|
|
'GvDatos.Columns(5).Visible = CBool(drP("AplicaSeccion"))
|
|
|
|
Dim AplicaSerie As Boolean = CBool(drP("AplicaSerie"))
|
|
|
|
ThSerie.Visible = AplicaSerie
|
|
TdSerie.Visible = AplicaSerie
|
|
TxtnSerie.Visible = AplicaSerie
|
|
'GvDatos.Columns(6).Visible = CBool(drP("AplicaSerie"))
|
|
|
|
TxtnLote.Visible = CBool(drP("AplicaLote"))
|
|
ThLote.Visible = CBool(drP("AplicaLote"))
|
|
TdLote.Visible = CBool(drP("AplicaLote"))
|
|
'GvDatos.Columns(7).Visible = CBool(drP("AplicaLote"))
|
|
|
|
|
|
TxtnFechaCaducidad.Visible = CBool(drP("AplicaCaducidad"))
|
|
ThFechaCaducidad.Visible = CBool(drP("AplicaCaducidad"))
|
|
If Not String.IsNullOrWhiteSpace(UsuarioActual.Empresa.Funcionalidad(147)) Then ThFechaCaducidad.InnerText = UsuarioActual.Empresa.Funcionalidad(147)
|
|
'ThFechaCaducidad.InnerText = If(UsuarioActual.Empresa.Funcionalidad(147) = "Fecha Elaboración", "Fecha Elaboración", "Fecha Caducidad")
|
|
TdFechaCaducidad.Visible = CBool(drP("AplicaCaducidad"))
|
|
'GvDatos.Columns(8).Visible = CBool(drP("AplicaCaducidad"))
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
DdlUnidad.Items.Clear()
|
|
DdlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProducto2.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
DdlUnidad.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Private Function isWhitFamily() As Boolean
|
|
Return (UsuarioActual.CveEmpresa = 66)
|
|
End Function
|
|
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
|
|
|
|
'If pDdlClasificacion.SelectedValue = "-1" Then
|
|
' pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
|
'Else
|
|
' pDdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero)
|
|
'End If
|
|
pDdlProducto.DataBind()
|
|
pDdlProducto.Items.Insert(0, New ListItem("----", "-1"))
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "GV DATOS"
|
|
Private Sub CargaGvDatos()
|
|
EscondeColumnasGVM(DtMovimientos)
|
|
|
|
GvDatos.DataSource = DtMovimientos.FiltraParametros("", "No desc")
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub EscondeColumnasGVM(DtTemp As DataTable)
|
|
|
|
GvDatos.Columns(5).Visible = DtTemp.MAX("Serie").ToString <> ""
|
|
TdSerie.Visible = GvDatos.Columns(5).Visible : ThSerie.Visible = GvDatos.Columns(5).Visible
|
|
GvDatos.Columns(6).Visible = DtTemp.MAX("Lote").ToString <> ""
|
|
TdLote.Visible = GvDatos.Columns(6).Visible : ThLote.Visible = GvDatos.Columns(6).Visible
|
|
GvDatos.Columns(7).HeaderText = If(UsuarioActual.Empresa.Funcionalidad(147) = "Fecha Elaboración", "Fecha Elaboración", "Fecha Caducidad")
|
|
GvDatos.Columns(7).Visible = DtTemp.MAX("FechaCaducidad").ToString.ToDate > MinFecha
|
|
TdFechaCaducidad.Visible = GvDatos.Columns(7).Visible : ThFechaCaducidad.Visible = GvDatos.Columns(7).Visible
|
|
GvDatos.Columns(8).Visible = DtTemp.MAX("CveSeccionAlmacen").ToString.ToEntero > 0
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DBCampo("EstatusExistencia").ToEntero < 0 Then
|
|
e.Row.Cells(0).BackColor = Drawing.Color.Red
|
|
End If
|
|
|
|
If CargadoDeMov Then
|
|
e.Row.FCLiteral("ltlCantidad").Visible = False
|
|
e.Row.FCTextBox("TxtCantidad2").Visible = True
|
|
e.Row.FCTextBox("TxtCantidad2").Attributes.Add("onblur", String.Format("ValidaCantidad(this,{0})", e.Row.DBCampo("Cantidad")))
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
Protected Sub GvPS_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)
|
|
ActualizaBitacora()
|
|
CargaGvDatos()
|
|
End Sub
|
|
|
|
Protected Sub ChkSugiereFechaCaducidad_CheckedChanged(sender As Object, e As EventArgs)
|
|
|
|
TxtnFechaCaducidad.Visible = Not ChkSugiereFechaCaducidad.Checked
|
|
TxtnLote.Visible = Not ChkSugiereFechaCaducidad.Checked
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " TRANSITORIO - RECEPCION "
|
|
|
|
Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs)
|
|
|
|
Dim TipoAlmacenOrigen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenOrigen.SelectedValue.ToEntero}").ToEntero
|
|
Dim TipoAlmacenDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToEntero
|
|
If TipoAlmacenOrigen = 14 Or TipoAlmacenDestino = 14 Then
|
|
ChkTransitorio.Checked = False
|
|
Alert("Un traspaso de consumo interno no puede ser transitorio.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If ChkTransitorio.Checked Then
|
|
'DdlResponsable.SelectedValue = "-1"
|
|
TxtResponsable.Text = ""
|
|
TxtGastoIndirecto.Text = ""
|
|
DivEmitirTransitorio.Visible = True
|
|
RegistraScript(" $('#DivGastoIndirecto').show(100);")
|
|
DivResponsable.Visible = True
|
|
DivTransitorio2.Visible = True
|
|
If UsuarioActual.CveEmpresa.Contiene(119, 140) Then
|
|
ChkEmitirTimbrado.Checked = True
|
|
ChkEmitirCartaPorte.Checked = True
|
|
End If
|
|
Else
|
|
RegistraScript(" $('#DivGastoIndirecto').hide(500);")
|
|
DivResponsable.Visible = False
|
|
DivTransitorio2.Visible = True
|
|
DivEmitirTransitorio.Visible = False
|
|
ChkEmitirTimbrado.Checked = False
|
|
ChkEmitirCartaPorte.Checked = True
|
|
End If
|
|
UpEmitirTransitorio.Update()
|
|
CargaAlmacenDestino()
|
|
|
|
SiguienteFolio(If(ChkTransitorio.Checked, 9, 8))
|
|
End Sub
|
|
Protected Sub BtnCargaTransitorios_Click(sender As Object, e As EventArgs)
|
|
CargaRecepcion()
|
|
End Sub
|
|
Private Sub CargaRecepcion()
|
|
|
|
DivRealizarDevolucion.Visible = False
|
|
ChkRealizarDevolucion.Checked = False
|
|
|
|
Dim CveMovimientoTraspaso As Integer = -1
|
|
|
|
Dim Dtt As DataTable = Nothing
|
|
|
|
FolioBusqueda = If(TxtFolioRecepcion.Text = "", -1, TxtFolioRecepcion.Text.ToEntero)
|
|
|
|
Dim ObjInventarios As New ClsInventarios
|
|
If ObjInventarios.GetMovimientosTransitorios(DdlAlmacenRecepcion.SelectedValue.ToEntero, -1, DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero, -1, FolioBusqueda, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
|
|
Dtt = ObjInventarios.DtResultados.FiltraParametros(String.Format("CveTipoAlmacenDestino <> 4"))
|
|
CveMovimientoTraspaso = Dtt.FiltroPrimeroValor("CveMovimiento").ToEntero
|
|
Else
|
|
Alert("Ocurrió un error al consultar los movimientos transitorios. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Dtt = Nothing
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
|
|
If Dtt IsNot Nothing Then
|
|
|
|
If TxtFolioRecepcion.Text.Trim <> "" Then
|
|
CveMovimientoSalida = Dtt.FiltroPrimeroValor("CveMovimiento", "").ToEntero
|
|
CveAlmacenTransitorio = Dtt.FiltroPrimeroValor("CveAlmacenTransitorio", "").ToEntero
|
|
Else
|
|
CveAlmacenTransitorio = DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero
|
|
End If
|
|
CveAlmacenDestino = DdlAlmacenRecepcion.SelectedValue.ToEntero
|
|
|
|
GvDatosRecepcion.DataSource = Dtt
|
|
GvDatosRecepcion.DataBind()
|
|
|
|
'GvDatosRecepcion.Columns(6).Visible = Dtt.MAX("Serie") <> ""
|
|
GvDatosRecepcion.Columns(7).Visible = Dtt.MAX("AplicaSerie") = "True"
|
|
GvDatosRecepcion.Columns(8).Visible = Dtt.MAX("AplicaLote").ToEntero > 0 'Dtt.MAX("Lote") <> ""
|
|
GvDatosRecepcion.Columns(9).Visible = Dtt.MAX("AplicaCaducidad").ToEntero > 0 'Dtt.MAX("FechaCaducidad").ToDate > MinFecha
|
|
GvDatosRecepcion.Columns(10).Visible = Dtt.MAX("CveSeccionAlmacen").ToEntero > 0
|
|
'Dt.Dispose()
|
|
End If
|
|
|
|
If TxtFolioRecepcion.Text = "" Then
|
|
BtnRecibir.Visible = False
|
|
BtnCancelarTraspaso.Visible = False
|
|
Else
|
|
BtnRecibir.Visible = True
|
|
If UsuarioActual.TienePermisoProceso(290) Then
|
|
BtnCancelarTraspaso.Visible = True
|
|
End If
|
|
|
|
If UsuarioActual.TienePermisoProceso(347) Then
|
|
DivRealizarDevolucion.Visible = True
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
|
|
HplImprimirRecepcion.Visible = True
|
|
HplImprimirRecepcion.NavigateUrl = $"/Compras/PopUpVerFactura.aspx?P={Encripta($"OP=Alm&CveMovimiento={CveMovimientoTraspaso}&EsTransitorio=True&CveAlmacenRecepcion={DdlAlmacenRecepcion.SelectedValue.ToEntero}&CveAlmacenTransitorioRecepcion={DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero}&FolioBusquedaTrasitorio={FolioBusqueda}")}"
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(132) = "1" OrElse UsuarioActual.CveEmpresa = 140 Then
|
|
DivCodigoSeriePSRecepcion.Visible = True
|
|
Else
|
|
DivCodigoSeriePSRecepcion.Visible = False
|
|
End If
|
|
|
|
|
|
UpDatosRecepcion.Update()
|
|
UPDivCodigoSeriePSRecepcion.Update()
|
|
UPDatosAlmacen.Update()
|
|
End Sub
|
|
|
|
Protected Sub GvDatosRecepcion_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosRecepcion.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
e.Row.FCTextBox("TxtCantidad").Visible = True
|
|
|
|
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.FCTextBox("TxtSerie").Visible = False
|
|
|
|
e.Row.Cells(2).Text = String.Format("Folio: <a class='texto' target='_blank' href='/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}'>{0}</a> ", e.Row.DBCampo("FolioSalida"), e.Row.DBCampo("CveMovimientoSalida"))
|
|
e.Row.Cells(3).Text = String.Format("{0}", e.Row.DBCampo("FechaMovto").ToString.ToDate.ToShortDateString)
|
|
e.Row.Cells(5).Text = String.Format("Almacen Origen: {0} Almacen Destino: {1} <br/> Responsable: {2}", e.Row.DBCampo("Almacen"), e.Row.DBCampo("AlmacenDestino"), e.Row.DBCampo("Recibio"))
|
|
|
|
Else
|
|
e.Row.FCTextBox("TxtCantidad").Attributes.Add("onkeyup", String.Format("ValidaCantidad(this,{0});", e.Row.DBCampo("Cantidad")))
|
|
If CBool(e.Row.DBCampo("AplicaSeccion")) AndAlso DdlAlmacenRecepcion.SelectedValue.ToEntero > 0 Then
|
|
|
|
CargaSeccionesAlmacen(e.Row.FCDropDownList("DdlSeccionAlmacen"), DdlAlmacenRecepcion.SelectedValue.ToEntero, e.Row.DBCampo("CvePS").ToEntero, UsuarioActual.CveEmpresa)
|
|
|
|
End If
|
|
|
|
If e.Row.DBCampo("AplicaLote").ToString.Trim = "1" Then
|
|
e.Row.FCTextBox("TxtLote").Visible = True
|
|
e.Row.FCTextBox("TxtLote").ReadOnly = True
|
|
End If
|
|
|
|
If e.Row.DBCampo("AplicaCaducidad").ToString.Trim = "1" Then
|
|
e.Row.FCTextBox("TxtCaducidad").Visible = True
|
|
e.Row.FCTextBox("TxtCaducidad").ReadOnly = True
|
|
End If
|
|
e.Row.FCTextBox("TxtSerie").ReadOnly = True
|
|
|
|
End If
|
|
|
|
'FUNCIONALIDAD PISTOLA DE CODIGOS
|
|
If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" Then
|
|
e.Row.FCTextBox("TxtCantidad").Enabled = False
|
|
If e.Row.DBCampo("CveCategoria") <> "249" Then
|
|
e.Row.FCTextBox("TxtCantidad").Enabled = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnCancelarTraspaso_Click(sender As Object, e As EventArgs)
|
|
If Not GvDatosRecepcion.Rows.Count > 0 Then
|
|
Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim CveMovimientoEntrada As Integer = 0
|
|
Dim tFolio As Integer = 0
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim TextoError As String = ""
|
|
Dim Fecha As Date = TxtFechaRecepcion.Text.ToDate
|
|
Dim CveMovimientoVirtualEntrada As Integer = 0
|
|
Dim CveMovimientoVirtualSalida As Integer = 0
|
|
|
|
Dim CveMovimientoSalidaTransitorio As Integer = 0
|
|
Dim FolioVirtualEntrada As Integer = 0
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
ObjInventario.IniciaTransacSQL()
|
|
Try
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, 27, 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, Modulo:="TA/C")
|
|
If CveMovimientoEntrada <= 0 Then
|
|
TextoError = "No se pudo generar el movimiento"
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
|
|
'AGREGAMOS LA SALIDA
|
|
CveMovimientoSalidaTransitorio = ObjInventario.AddMovimiento(CveAlmacenTransitorio, 8, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero,
|
|
CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/G12")
|
|
|
|
|
|
Dim CvePrePoliza As Integer = -1
|
|
Dim Concepto As String = TxtObservacionesRecepcion.Text
|
|
If Concepto = "" Then Concepto = "Cancelación Traspaso"
|
|
|
|
If Not ErrorMovInv Then
|
|
tFolio = ObjInventario.Folio
|
|
CvePrePoliza = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If CvePrePoliza <= 0 Then
|
|
TextoError = "No se pudo generar la Poliza para la cancelación"
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
If CveMovimientoEntrada <= 0 And Not ErrorMovInv Then
|
|
TextoError = "No se pudo generar el movimiento de entrada correctamente"
|
|
ErrorMovInv = True
|
|
Else
|
|
Dim CveMovimientoDetalleSalida As Integer = 0
|
|
'Dim importe As Double = 0
|
|
|
|
For Each GvRow As GridViewRow In GvDatosRecepcion.Rows
|
|
If GvRow.RowType = DataControlRowType.DataRow Then
|
|
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
|
|
'DEBE CONSIDERAR SOLO LAS FILAS QUE TENGA PRODUCTOS, NO EL TOTALIZADOR
|
|
If CvePS > 0 Then
|
|
CveMovimientoDetalleSalida = GvRow.DataKey("CveMovimientoDetalle").ToEntero
|
|
Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal() 'GvRow.FCTextBox("TxtCantidad").Text.ToString.ToDecimal
|
|
|
|
'If ChkRealizarDevolucion.Checked Then Cantidad = GvRow.FCTextBox("TxtCantidad").Text.ToDecimal
|
|
|
|
Dim PrecioUnitario As Decimal = GvRow.DataKey("PU").ToDecimal
|
|
If CveMovimientoDetalleSalida <= 0 Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
Exit For
|
|
End If
|
|
|
|
Dim cantidadDisponibleValidacion As Decimal = GvRow.DataKey("Cantidad").ToDecimal - GvRow.FCTextBox("TxtCantidad").Text.ToString.ToDecimal
|
|
|
|
If cantidadDisponibleValidacion < 0 Then
|
|
ErrorMovInv = True
|
|
TextoError = $"La cantidad a cancelar del producto '{GvRow.DataKey("Codigo")}-{GvRow.DataKey("PS")}' excede la del traspaso"
|
|
Exit For
|
|
End If
|
|
|
|
If Cantidad > 0 Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, GvRow.DataKey("CveUM").ToEntero, CvePS, PrecioUnitario, -1, -1, Serie:=GvRow.DataKey("Serie"), Lote:=GvRow.DataKey("Lote"), FechaCaducidad:=GvRow.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=CveMovimientoDetalleSalida) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
End If
|
|
'MOV, Alm, Transito
|
|
If GvRow.DataKey("CveMovimientoDetalleTransitorio").ToString.ToEntero > 0 Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaTransitorio, Cantidad, GvRow.DataKey("CveUM").ToEntero, CvePS, PrecioUnitario, CveSeccionAlmacen:=-3, Serie:=GvRow.DataKey("Serie"), Lote:=GvRow.DataKey("Lote").ToString, FechaCaducidad:=GvRow.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=GvRow.DataKey("CveMovimientoDetalleTransitorio").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
Exit For
|
|
End If
|
|
Else
|
|
CveMovimientoSalidaTransitorio = 0
|
|
End If
|
|
End If
|
|
|
|
'importe += Cantidad * PrecioUnitario
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
|
|
'VIRTUAL ENTRADA
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
|
|
|
|
Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero).FiltroPrimeroValor("CveAlmacenVirtual", "").ToEntero()
|
|
Dim CveAlmacenVirtualSalida As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacenTransitorio).FiltroPrimeroValor("CveAlmacenVirtual", "").ToEntero()
|
|
|
|
'SI EL ALMACEN ORIGEN ES DE APOPYO LOGISTICO EL ALMACEN VIRTUAL DEBE SER DE APOYO LOGISTICO
|
|
'Dim CveAlmacenVirtual As Integer = -1
|
|
'If CveTipoAlmacenOrigen = 27 Then
|
|
' CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $" CveTipoAlmacen =25 AND CveSubProyecto={CveSubProyecto}").ToEntero()
|
|
'Else
|
|
' CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $" CveTipoAlmacen =24 AND CveSubProyecto={CveSubProyecto}").ToEntero()
|
|
'End If
|
|
|
|
'VERIFICA SI TIENE ALMACEN VIRTUAL ASIGNADA
|
|
If CveAlmacenVirtual > 0 And CveAlmacenVirtualSalida > 0 Then
|
|
|
|
Dim dtvirtual As DataTable = Nothing
|
|
'Dim importePoliza As Decimal = 0
|
|
|
|
If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoEntrada, UsuarioActual.CveEmpresa, CveMovimientoRelacionado:=CveMovimientoSalida) Then
|
|
dtvirtual = ObjInventario.DtResultados
|
|
If dtvirtual.Rows.Count > 0 Then
|
|
|
|
CveMovimientoVirtualEntrada = ObjInventario.AddMovimiento(CveAlmacenVirtual, 36, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveMovimientoRelacionado:=CveMovimientoEntrada, MovimientoFijo:=True, Modulo:="TA/C2")
|
|
|
|
CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtualSalida, 37, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveMovimientoRelacionado:=CveMovimientoSalidaTransitorio, MovimientoFijo:=True, Modulo:="TA/C3")
|
|
|
|
FolioVirtualEntrada = ObjInventario.Folio
|
|
|
|
For Each RowVirtual As DataRow In dtvirtual.Rows
|
|
Dim CvePS = RowVirtual("CvePS").ToString().ToEntero()
|
|
Dim CantidadUsado As Decimal = RowVirtual("Cantidad").ToString().ToDecimal()
|
|
Dim PU As Decimal = RowVirtual("PUOriginal").ToString().ToDecimal()
|
|
Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero()
|
|
Dim CostoIndirecto As Decimal = RowVirtual("CostoIndirecto").ToString().ToDecimal()
|
|
|
|
|
|
'importePoliza = importePoliza + (CantidadUsado * PU)
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CostoIndirecto:=CostoIndirecto, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualSalida, CantidadUsado, CveUM, CvePS, PU, -1, CostoIndirecto:=CostoIndirecto, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
End If
|
|
|
|
'Else
|
|
' TextoError = "No se pudo registrar el movimiento virtual"
|
|
' ErrorMovInv = True
|
|
End If
|
|
|
|
|
|
If Not ErrorMovInv AndAlso (CveMovimientoSalida > 0 And CveMovimientoVirtualEntrada > 0) Then
|
|
|
|
Dim importePoliza As Decimal = 0
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtualEntrada, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
importePoliza = ObjInventario.DtResultados.SUMD("Total").RoundSQL
|
|
End If
|
|
|
|
Dim CvePrePolizaMovVirtual As Integer = ObjConta.AddPrePolizas("TA/C2|TA/C3", 53, importePoliza, importePoliza, 1, TxtFecha.Text.ToDate, "TA/C2|TA/C3", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CvePrePolizaMovVirtual > 0 Then
|
|
If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePolizaMovVirtual, True, importePoliza, importePoliza, 68, TxtObservacionesRecepcion.Text, TxtObservacionesRecepcion.Text, -1, -1, CveMovimientoAlmacen:=CveMovimientoVirtualSalida, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaMovVirtual, False, importePoliza, importePoliza, 68, TxtObservacionesRecepcion.Text, TxtObservacionesRecepcion.Text, -1, -1, CveMovimientoAlmacen:=CveMovimientoVirtualEntrada, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
'Else
|
|
' TextoError = "La Sucursal no tiene creado un almacen virtual"
|
|
' ErrorMovInv = True
|
|
End If
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
Dim ImporteDecimal As Decimal = 0
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
ImporteDecimal = ObjInventario.DtResultados.SUMD("Total").RoundSQL
|
|
End If
|
|
|
|
Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero)).ToEntero
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteDecimal, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1,
|
|
CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=ImporteDecimal, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al cancelar el traspaso"
|
|
End If
|
|
|
|
If CveMovimientoSalidaTransitorio > 0 Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteDecimal, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1,
|
|
CveMovimientoAlmacen:=CveMovimientoSalidaTransitorio, ImporteMX:=ImporteDecimal, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al cancelar el traspaso"
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un erro al cancelar el traspaso"
|
|
OnError(TextoError, ex)
|
|
End Try
|
|
|
|
If Not ErrorMovInv Then
|
|
ObjInventario.Commit()
|
|
|
|
TxtRecibio.Text = ""
|
|
TxtFechaRecepcion.Text = Now.ToShortDateString
|
|
TxtObservacionesRecepcion.Text = ""
|
|
|
|
Dim Mensaje As StringBuilder = New StringBuilder
|
|
Mensaje.AppendFormat("Se realizo correctamente la cancelación. <br/> Folio de Entrada: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{0}</a></b>", tFolio, CveMovimientoEntrada)
|
|
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()'
|
|
If CveMovimientoVirtualEntrada > 0 Then Mensaje.AppendFormat("<br/>Folio Virtual: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{2}</a></b> <br/><a target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Entrada Virtual</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtualEntrada)), CveMovimientoVirtualEntrada, FolioVirtualEntrada)
|
|
|
|
Alert(Mensaje.ToString, TipoMensaje.MsgInformacion)
|
|
CargaRecepcion()
|
|
DivCodigoSeriePSRecepcion.Visible = False
|
|
|
|
GvDatosRecepcion.DataBind()
|
|
UpDatosRecepcion.Update()
|
|
UPDatosAlmacen.Update()
|
|
Else
|
|
ObjInventario.RollBack()
|
|
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjConta.Dispose()
|
|
ObjInventario.Dispose()
|
|
|
|
|
|
End Sub
|
|
|
|
Private Class MCancelacionTraspaso
|
|
Public Property TieneError As Boolean = False
|
|
Public Property MsgError As String = ""
|
|
Public Property CveMovimientoEntrada As Integer = -1
|
|
Public Property FolioEntrada As Integer = 0
|
|
Public Property CveMovimientoSalidaTransitorio As Integer = -1
|
|
Public Property FolioSalidaTransitorio As Integer = 0
|
|
End Class
|
|
|
|
Private Function CancelarTraspaso(ByRef ObjInventario As ClsInventarios, ByRef ObjConta As ClsContabilidad, CveAlmacenDestino As Integer, Fecha As DateTime) As MCancelacionTraspaso
|
|
Dim Retorno As New MCancelacionTraspaso()
|
|
Dim ErrorMovInv As Boolean = False
|
|
Try
|
|
Dim CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenDestino, 27, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservacionesRecepcion.Text.Trim, Recibio:=TxtRecibio.Text, CveAlmacenDestino:=CveAlmacenDestino,
|
|
CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="TA/C")
|
|
If CveMovimientoEntrada <= 0 Then
|
|
Retorno.MsgError = "No se pudo generar el movimiento"
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
Retorno.CveMovimientoEntrada = CveMovimientoEntrada
|
|
Retorno.FolioEntrada = ObjInventario.Folio
|
|
|
|
'AGREGAMOS LA SALIDA
|
|
Dim CveMovimientoSalidaTransitorio = ObjInventario.AddMovimiento(CveAlmacenTransitorio, 8, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveAlmacenDestino:=CveAlmacenDestino,
|
|
CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/G12")
|
|
|
|
Retorno.CveMovimientoSalidaTransitorio = CveMovimientoSalidaTransitorio
|
|
|
|
Dim CvePrePoliza As Integer = -1
|
|
Dim Concepto As String = TxtObservacionesRecepcion.Text
|
|
If Concepto = "" Then Concepto = "Cancelación Traspaso"
|
|
|
|
If Not ErrorMovInv Then
|
|
Retorno.FolioSalidaTransitorio = ObjInventario.Folio
|
|
CvePrePoliza = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If CvePrePoliza <= 0 Then
|
|
Retorno.MsgError = "No se pudo generar la Poliza para la cancelación"
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
If CveMovimientoEntrada <= 0 And Not ErrorMovInv Then
|
|
Retorno.MsgError = "No se pudo generar el movimiento de entrada correctamente"
|
|
ErrorMovInv = True
|
|
Else
|
|
Dim CveMovimientoDetalleSalida As Integer = 0
|
|
Dim importe As Double = 0
|
|
|
|
Dim Dtt As DataTable = Nothing
|
|
|
|
FolioBusqueda = TxtFolioRecepcion.Text.ToEntero
|
|
|
|
If ObjInventario.GetMovimientosTransitorios(DdlAlmacenRecepcion.SelectedValue.ToEntero, -1, DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero, -1, FolioBusqueda, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
|
|
Dtt = ObjInventario.DtResultados.FiltraParametros(String.Format("CveTipoAlmacenDestino <> 4"))
|
|
Else
|
|
Dtt = Nothing
|
|
End If
|
|
|
|
If Dtt IsNot Nothing Then
|
|
For Each GvRow As DataRow In Dtt.Rows
|
|
Dim CvePS As Integer = GvRow("CvePS").ToString().ToEntero
|
|
'DEBE CONSIDERAR SOLO LAS FILAS QUE TENGA PRODUCTOS, NO EL TOTALIZADOR
|
|
If CvePS > 0 Then
|
|
CveMovimientoDetalleSalida = GvRow("CveMovimientoDetalle").ToString.ToEntero
|
|
Dim Cantidad As Decimal = GvRow("Cantidad").ToString.ToDecimal
|
|
Dim PrecioUnitario As Decimal = GvRow("PU").ToString.ToDecimal
|
|
If CveMovimientoDetalleSalida <= 0 Then
|
|
ErrorMovInv = True
|
|
Retorno.MsgError = "Ocurrió un error al guardar los movimientos de salida"
|
|
Exit For
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, GvRow("CveUM").ToString().ToEntero, CvePS, PrecioUnitario, -1, -1, Serie:=GvRow("Serie").ToString, Lote:=GvRow("Lote").ToString(), FechaCaducidad:=GvRow("FechaCaducidad").ToString().ToDate, CveMovimientoDetalleEntrada:=CveMovimientoDetalleSalida) Then
|
|
ErrorMovInv = True
|
|
Retorno.MsgError = "Ocurrió un error al guardar los movimientos de entrada"
|
|
Exit For
|
|
End If
|
|
'MOV, Alm, Transito
|
|
If GvRow("CveMovimientoDetalleTransitorio").ToString.ToEntero > 0 Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaTransitorio, Cantidad, GvRow("CveUM").ToString.ToEntero, CvePS, PrecioUnitario, CveSeccionAlmacen:=-3, Serie:=GvRow("Serie").ToString, Lote:=GvRow("Lote").ToString, FechaCaducidad:=GvRow("FechaCaducidad").ToString().ToDate, CveMovimientoDetalleEntrada:=GvRow("CveMovimientoDetalleTransitorio").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
Retorno.MsgError = "Ocurrió un error al guardar los movimientos de salida"
|
|
Exit For
|
|
End If
|
|
Else
|
|
CveMovimientoSalidaTransitorio = 0
|
|
End If
|
|
importe += Cantidad * PrecioUnitario
|
|
End If
|
|
Next
|
|
Else
|
|
ErrorMovInv = True
|
|
Retorno.MsgError = "Ocurrió un error al guardar los movimientos de salida"
|
|
End If
|
|
|
|
|
|
'VIRTUAL ENTRADA
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
|
|
|
|
Dim CveAlmacenVirtual As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero).FiltroPrimeroValor("CveAlmacenVirtual", "").ToEntero()
|
|
Dim CveAlmacenVirtualSalida As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacenTransitorio).FiltroPrimeroValor("CveAlmacenVirtual", "").ToEntero()
|
|
|
|
'SI EL ALMACEN ORIGEN ES DE APOPYO LOGISTICO EL ALMACEN VIRTUAL DEBE SER DE APOYO LOGISTICO
|
|
'Dim CveAlmacenVirtual As Integer = -1
|
|
'If CveTipoAlmacenOrigen = 27 Then
|
|
' CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $" CveTipoAlmacen =25 AND CveSubProyecto={CveSubProyecto}").ToEntero()
|
|
'Else
|
|
' CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $" CveTipoAlmacen =24 AND CveSubProyecto={CveSubProyecto}").ToEntero()
|
|
'End If
|
|
|
|
Dim CveMovimientoVirtualEntrada As Integer = -1
|
|
Dim CveMovimientoVirtualSalida As Integer = -1
|
|
|
|
'VERIFICA SI TIENE ALMACEN VIRTUAL ASIGNADA
|
|
If CveAlmacenVirtual > 0 And CveAlmacenVirtualSalida > 0 Then
|
|
|
|
Dim dtvirtual As DataTable = Nothing
|
|
Dim importePoliza As Decimal = 0
|
|
|
|
If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoEntrada, UsuarioActual.CveEmpresa, CveMovimientoRelacionado:=CveMovimientoSalida) Then
|
|
dtvirtual = ObjInventario.DtResultados
|
|
If dtvirtual.Rows.Count > 0 Then
|
|
|
|
CveMovimientoVirtualEntrada = ObjInventario.AddMovimiento(CveAlmacenVirtual, 36, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/C2")
|
|
|
|
CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtualSalida, 37, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveMovimientoRelacionado:=CveMovimientoSalidaTransitorio, Modulo:="TA/C3")
|
|
|
|
Dim FolioVirtualEntrada = ObjInventario.Folio
|
|
|
|
For Each RowVirtual As DataRow In dtvirtual.Rows
|
|
Dim CvePS = RowVirtual("CvePS").ToString().ToEntero()
|
|
Dim CantidadUsado As Decimal = RowVirtual("Cantidad").ToString().ToDecimal()
|
|
Dim PU As Decimal = RowVirtual("PUOriginal").ToString().ToDecimal()
|
|
Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero()
|
|
Dim CostoIndirecto As Decimal = RowVirtual("CostoIndirecto").ToString().ToDecimal()
|
|
|
|
|
|
importePoliza = importePoliza + (CantidadUsado * PU)
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CostoIndirecto:=CostoIndirecto, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualSalida, CantidadUsado, CveUM, CvePS, PU, -1, CostoIndirecto:=CostoIndirecto, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
End If
|
|
|
|
'Else
|
|
' TextoError = "No se pudo registrar el movimiento virtual"
|
|
' ErrorMovInv = True
|
|
End If
|
|
|
|
|
|
If Not ErrorMovInv AndAlso (CveMovimientoSalida > 0 And CveMovimientoVirtualEntrada > 0) Then
|
|
|
|
Dim CvePrePolizaMovVirtual As Integer = ObjConta.AddPrePolizas("TA/C2|TA/C3", 53, importePoliza, importePoliza, 1, TxtFecha.Text.ToDate, "TA/C2|TA/C3", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CvePrePolizaMovVirtual > 0 Then
|
|
If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePolizaMovVirtual, True, importePoliza, importePoliza, 68, TxtObservacionesRecepcion.Text, TxtObservacionesRecepcion.Text, -1, -1, CveMovimientoAlmacen:=CveMovimientoVirtualSalida, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaMovVirtual, False, importePoliza, importePoliza, 68, TxtObservacionesRecepcion.Text, TxtObservacionesRecepcion.Text, -1, -1, CveMovimientoAlmacen:=CveMovimientoVirtualEntrada, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
Else
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
End If
|
|
'Else
|
|
' TextoError = "La Sucursal no tiene creado un almacen virtual"
|
|
' ErrorMovInv = True
|
|
End If
|
|
|
|
End If
|
|
|
|
If Not ErrorMovInv Then
|
|
Dim ImporteDecimal As Decimal = importe.ToDecimal.RoundAD
|
|
Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero)).ToEntero
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteDecimal, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1,
|
|
CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=ImporteDecimal, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
Retorno.MsgError = "Ocurrió un error al cancelar el traspaso"
|
|
End If
|
|
|
|
If CveMovimientoSalidaTransitorio > 0 Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteDecimal, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1,
|
|
CveMovimientoAlmacen:=CveMovimientoSalidaTransitorio, ImporteMX:=ImporteDecimal, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
Retorno.MsgError = "Ocurrió un error al cancelar el traspaso"
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
ErrorMovInv = True
|
|
Retorno.MsgError = "Ocurrió un error al cancelar el traspaso"
|
|
OnError("Ocurrió un erro al cancelar el traspaso", ex)
|
|
End Try
|
|
|
|
Retorno.TieneError = ErrorMovInv
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
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 CveAlmacenSalida As Integer = DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero
|
|
|
|
If CveAlmacenTransitorio <> CveAlmacenSalida Then
|
|
Alert("El almacen transitorio debe coincidir con el del movimiento.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
Dim ObjInventario As New ClsInventarios
|
|
Dim Dtt As DataTable = Nothing
|
|
Dim CveMovimientoEntrada As Integer = 0
|
|
Dim CveMovimientoSalidaTransitorio As Integer = 0
|
|
Dim Folio = 0
|
|
Dim ErrorMovInv As Boolean = False
|
|
Dim TextoError = ""
|
|
Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL())
|
|
|
|
'' verifica que no se halla recibido previamente, si ya se recibió da salida
|
|
If ObjInventario.GetMovimientosTransitorios(CveAlmacenDestino, -1, CveAlmacenTransitorio, -1, FolioBusqueda, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
|
|
Dtt = ObjInventario.DtResultados.FiltraParametros(String.Format("CveTipoAlmacenDestino <> 4"), "", {"CveMovimientoDetalle", "Codigo", "Cantidad"})
|
|
If Dtt IsNot Nothing AndAlso Dtt.FiltraParametros("Cantidad < 0").Rows.Count > 0 Then
|
|
|
|
ObjInventario.Dispose()
|
|
Alert("El traspaso no se ha puede completar, por inconsistencia en las cantidades recibidas")
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
'REGISTRA LA SALIDA Y ENTRADA (TRASPASO)
|
|
ObjInventario.IniciaTransacSQL() 'Inicia la transacción
|
|
Dim Fecha As Date = TxtFechaRecepcion.Text.ToDate
|
|
|
|
Dim CveAlmacenEntrada As Integer = GvDatosRecepcion.Rows(0).DataKey("CveAlmacenDestino").ToEntero
|
|
|
|
|
|
Dim TipoAlmacenDestino As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {CveAlmacenEntrada}").ToEntero()
|
|
Dim TipoAlmacenOrigen As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {CveAlmacenSalida}").ToEntero()
|
|
Dim CveSubProyectoRecibe = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"CveAlmacen = {CveAlmacenEntrada}").ToEntero
|
|
|
|
Dim RealizarMovimientoVirtual As Boolean = False
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
|
|
RealizarMovimientoVirtual = True
|
|
End If
|
|
|
|
'AGREGAMOS LA ENTRADA
|
|
CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenEntrada, 27, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, Modulo:="TA/G1")
|
|
Folio = ObjInventario.Folio
|
|
|
|
'AGREGAMOS LA SALIDA
|
|
CveMovimientoSalidaTransitorio = ObjInventario.AddMovimiento(CveAlmacenSalida, 8, 1, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1,
|
|
Observaciones:=TxtObservacionesRecepcion.Text.Trim, CveAlmacenDestino:=GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/G11")
|
|
|
|
If CveMovimientoSalidaTransitorio <= 0 Then
|
|
TextoError = "No se pudo generar el movimiento de salida correctamente"
|
|
ErrorMovInv = True
|
|
Else
|
|
|
|
Dim CveMovimientoDetalleEntrada As Integer = 0
|
|
Dim Cont As Integer = 0
|
|
For Each gvr As GridViewRow In GvDatosRecepcion.Rows
|
|
|
|
Dim dataRowAux As DataRow = Dtt.FiltroPrimero(String.Format(" CveMovimientoDetalle = '{0}'", If(gvr.DataKey("CveMovimientoDetalle").ToString = "", "0", gvr.DataKey("CveMovimientoDetalle").ToString)))
|
|
Dim cantidadDisponibleValidacion As Decimal = 0
|
|
|
|
If gvr.DataKey("Codigo").ToString IsNot "" Then
|
|
If dataRowAux IsNot Nothing Then
|
|
cantidadDisponibleValidacion = dataRowAux.Item("Cantidad").ToString.ToDecimal - gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal
|
|
Else
|
|
cantidadDisponibleValidacion = -1
|
|
End If
|
|
End If
|
|
|
|
If gvr.FCCheckBox("Chk").Checked AndAlso gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal > 0 AndAlso cantidadDisponibleValidacion >= 0 Then
|
|
CveMovimientoDetalleEntrada = gvr.DataKey("CveMovimientoDetalle").ToString.ToEntero
|
|
|
|
If CveMovimientoDetalleEntrada <= 0 Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
Exit For
|
|
End If
|
|
Dim PrecioEntrada As Decimal = If(TipoAlmacenDestino = 26, 0, gvr.DataKey("PU").ToString.ToDecimal)
|
|
''RMF codigo temporal. por implementación
|
|
Dim tLote As String = gvr.DataKey("Lote").ToString
|
|
Dim tSerie As String = gvr.FCTextBox("TxtSerie").Text 'gvr.DataKey("Serie").ToString
|
|
Dim tFechaCaducidad As Date = gvr.DataKey("FechaCaducidad").ToDate
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, PrecioEntrada, CveAF:=gvr.DataKey("CveAF").ToString.ToEntero, CveSeccionAlmacen:=gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero, Serie:=tSerie, Lote:=tLote, FechaCaducidad:=tFechaCaducidad, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
Exit For
|
|
End If
|
|
'MOV, Alm, Transito
|
|
If gvr.DataKey("CveMovimientoDetalleTransitorio").ToString.ToEntero > 0 Then
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaTransitorio, gvr.FCTextBox("TxtCantidad").Text.ToString.ToDecimal, gvr.DataKey("CveUM").ToString.ToEntero, gvr.DataKey("CvePS").ToString.ToEntero, PrecioEntrada, CveAF:=gvr.DataKey("CveAF").ToString.ToEntero, CveSeccionAlmacen:=-3, Serie:=gvr.DataKey("Serie").ToString, Lote:=gvr.DataKey("Lote").ToString, FechaCaducidad:=gvr.DataKey("FechaCaducidad").ToDate, CveMovimientoDetalleEntrada:=gvr.DataKey("CveMovimientoDetalleTransitorio").ToString.ToEntero) Then
|
|
ErrorMovInv = True
|
|
TextoError = "Ocurrió un error al guardar los movimientos de salida"
|
|
Exit For
|
|
End If
|
|
Else
|
|
CveMovimientoSalidaTransitorio = 0
|
|
End If
|
|
|
|
ElseIf cantidadDisponibleValidacion < 0 Then
|
|
TextoError = String.Format("Se exceden la cantidad disponibles para {0}", gvr.DataKey("PS").ToString)
|
|
ErrorMovInv = True
|
|
End If
|
|
Cont += 1
|
|
Next
|
|
|
|
If Not ErrorMovInv Then
|
|
Dim Concepto As String = TxtObservacionesRecepcion.Text
|
|
If Concepto = "" Then Concepto = "Recepción Traspaso"
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TraspasoAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoEntrada, UsuarioActual.CveEmpresa) Then
|
|
|
|
Dim importe As Decimal = ObjInventario.DtResultados.SUMD("Total").RoundSQL
|
|
Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorioRecepcion.SelectedValue.ToEntero)).ToEntero
|
|
Dim tCveConcepto As Integer = 68
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, tCveConcepto, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoSalidaTransitorio, ImporteMX:=importe, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, ImporteMX:=importe, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
'VIRTUAL ENTRADA
|
|
Dim CveMovimientoVirtualEntrada, CveMovimientoVirtualSalida As Integer
|
|
Dim FolioVirtualEntrada, FolioVirtualSalida As Integer
|
|
If RealizarMovimientoVirtual AndAlso Not ErrorMovInv Then
|
|
|
|
Dim CveAlmacenVirtualSalida As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacenSalida).FiltroPrimeroValor("CveAlmacenVirtual", "").ToEntero()
|
|
Dim CveAlmacenVirtualEntrada As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacenEntrada).FiltroPrimeroValor("CveAlmacenVirtual", "").ToEntero()
|
|
|
|
If CveAlmacenVirtualSalida > 0 Then
|
|
|
|
Dim dtvirtual As DataTable = Nothing
|
|
|
|
If ObjInventario.GetMovimientosDetalleVirtual(CveMovimientoSalidaTransitorio, UsuarioActual.CveEmpresa) Then
|
|
dtvirtual = ObjInventario.DtResultados
|
|
If dtvirtual.Rows.Count > 0 Then
|
|
|
|
CveMovimientoVirtualSalida = ObjInventario.AddMovimiento(CveAlmacenVirtualSalida, 37, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveMovimientoRelacionado:=CveMovimientoSalidaTransitorio, Modulo:="TA/S22")
|
|
FolioVirtualSalida = ObjInventario.Folio
|
|
For Each RowVirtual As DataRow In dtvirtual.Rows
|
|
Dim CvePS = RowVirtual("CvePS").ToString().ToEntero()
|
|
Dim CantidadUsado As Decimal = RowVirtual("Cantidad").ToString().ToDecimal()
|
|
Dim PU As Decimal = RowVirtual("Cargo").ToString().ToDecimal()
|
|
Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero()
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualSalida, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If Not ErrorMovInv Then
|
|
Dim Concepto As String = TxtObservaciones.Text
|
|
If Concepto = "" Then Concepto = "Traspaso"
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/TA22", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtualSalida, UsuarioActual.CveEmpresa) Then
|
|
Dim resultado As DataTable = ObjInventario.DtResultados
|
|
CveMovimientoVirtualEntrada = ObjInventario.AddMovimiento(CveAlmacenVirtualEntrada, 36, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveMovimientoRelacionado:=CveMovimientoEntrada, Modulo:="TA/S23")
|
|
FolioVirtualEntrada = ObjInventario.Folio
|
|
|
|
For Each RowVirtual As DataRow In resultado.Rows
|
|
Dim CvePS = RowVirtual("CvePS").ToString().ToEntero()
|
|
Dim CantidadUsado As Decimal = RowVirtual("Cantidad").ToString().ToDecimal()
|
|
Dim PU As Decimal = RowVirtual("PU").ToString().ToDecimal()
|
|
Dim CveUM As Integer = RowVirtual("CveUM").ToString().ToEntero()
|
|
|
|
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtualEntrada, CantidadUsado, CveUM, CvePS, PU, -1, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
|
ErrorMovInv = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Dim importe As Decimal = resultado.SUMD("Total").RoundSQL
|
|
Dim IdCtaContable As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", DdlAlmacenTransitorio.SelectedValue.ToEntero)).ToEntero
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoVirtualSalida, ImporteMX:=importe, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
|
|
If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, TxtObservaciones.Text, 68, TxtObservaciones.Text, Fecha, IdCtaContable, -1, CveMovimientoAlmacen:=CveMovimientoVirtualEntrada, ImporteMX:=importe, Contabilizable:=False) Then
|
|
ErrorMovInv = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
Else
|
|
TextoError = "No se pudo registrar el movimiento virtual"
|
|
ErrorMovInv = True
|
|
End If
|
|
'Else
|
|
' TextoError = "La Sucursal no tiene creado un almacen virtual"
|
|
' ErrorMovInv = True
|
|
End If
|
|
End If
|
|
|
|
Dim CancelacionTraspaso As MCancelacionTraspaso = Nothing
|
|
If UsuarioActual.Empresa.Funcionalidad(162) = "1" AndAlso ChkRealizarDevolucion.Checked AndAlso Not ErrorMovInv Then
|
|
CancelacionTraspaso = CancelarTraspaso(ObjInventario, ObjConta, GvDatosRecepcion.Rows(0).DataKey("CveAlmacenSalida").ToEntero, TxtFechaRecepcion.Text.ToDateTime())
|
|
If CancelacionTraspaso IsNot Nothing Then
|
|
ErrorMovInv = CancelacionTraspaso.TieneError
|
|
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 correctamente la recepción. <br/> Folio de Entrada: <b><a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{0}</a></b>", Folio, CveMovimientoEntrada)
|
|
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()'
|
|
If CveMovimientoVirtualEntrada > 0 Then Mensaje.AppendFormat("<br/><br/><br/>Folio Virtual <b> <a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{2}</a> </b> <br/><a target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtualEntrada)), CveMovimientoVirtualEntrada, FolioVirtualEntrada) 'onclick='ImprimirTraslado()'
|
|
|
|
If CancelacionTraspaso IsNot Nothing Then
|
|
If CancelacionTraspaso.CveMovimientoEntrada > 0 Then Mensaje.AppendFormat("<br/><br/><br/>Folio Devolución <b> <a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={1}"" target=""_blank"">{2}</a> </b> <br/><a target='_blank' href='/Compras/PopUpVerFactura.aspx?P={0}'>Imprimir Reporte</a>", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CancelacionTraspaso.CveMovimientoEntrada)), CancelacionTraspaso.CveMovimientoEntrada, CancelacionTraspaso.FolioEntrada) 'onclick='ImprimirTraslado()'
|
|
End If
|
|
|
|
Alert(Mensaje.ToString, TipoMensaje.MsgInformacion)
|
|
|
|
DivCodigoSeriePSRecepcion.Visible = False
|
|
|
|
GvDatosRecepcion.DataBind()
|
|
UpDatosRecepcion.Update()
|
|
UPDatosAlmacen.Update()
|
|
CargaRecepcion()
|
|
Else
|
|
ObjInventario.RollBack()
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
End If
|
|
ObjInventario.Dispose()
|
|
ObjConta.Dispose()
|
|
|
|
Else
|
|
Alert("No hay movimientos para el traspaso", TipoMensaje.MsgAdvertencia)
|
|
If ChkTransitorio.Checked Then DivResponsable.Visible = True : DivTransitorio2.Visible = True
|
|
End If
|
|
End Sub
|
|
|
|
'Private Sub DdlProducto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProducto.SelectedIndexChanged
|
|
' 'CargarUM(DdlProducto.SelectedValue.ToEntero)
|
|
' ElProductoChange()
|
|
'End Sub
|
|
|
|
'Private Sub HFProducto_ValueChanged(sender As Object, e As EventArgs) Handles HFProducto.ValueChanged
|
|
' ElProductoChange()
|
|
'End Sub
|
|
Private Sub CargarUM(CvePS As Integer)
|
|
Dim ObjUM As New ClsProductosServicios()
|
|
If ObjUM.GetPSEquivalencias(CvePS, UsuarioActual.CveEmpresa) Then
|
|
DdlUnidad.Items.Clear()
|
|
DdlUnidad.DataSource = ObjUM.DtResultados
|
|
End If
|
|
ObjUM.Dispose()
|
|
DdlUnidad.DataBind()
|
|
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 " AGREGA CON TXT | CODIGO - SERIE "
|
|
Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs)
|
|
|
|
If TxtCodigoPS.Text = "" Then Exit Sub
|
|
|
|
TdSeriePS.Visible = False
|
|
|
|
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"CodigoBarras = '{TxtCodigoPS.Text.Trim}'")
|
|
If DrPS Is Nothing Then
|
|
Alert($"No se ha encontrado un producto del Código: ""<b>{TxtCodigoPS.Text}</b>"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);")
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
TxtCodigoPS.Text = ""
|
|
Exit Sub
|
|
End If
|
|
|
|
If DrPS("AplicaSerie").ToString = "True" Then
|
|
TdSeriePS.Visible = True
|
|
TxtSeriePS.Focus()
|
|
CvePSSerie = DrPS("CvePS").ToString.ToEntero
|
|
CveUMSerie = DrPS("CveUnidadMedida").ToString.ToEntero
|
|
Exit Sub
|
|
Else
|
|
AgregarPS(1, DrPS("CvePS").ToString.ToEntero, DrPS("CveUnidadMedida").ToString.ToEntero)
|
|
|
|
TxtCodigoPS.Text = ""
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs)
|
|
If TxtSeriePS.Text.Trim = "" Then Exit Sub
|
|
|
|
txtCantidad.Text = "1"
|
|
Dim Valido = ValidaExistencia(1, CvePSSerie, CveUMSerie, -1, TxtSeriePS.Text.Trim, "-1", MinFecha)
|
|
|
|
If Valido Then
|
|
AgregarPS(1, CvePSSerie, CveUMSerie, Serie:=TxtSeriePS.Text.Trim.ToUpper)
|
|
Else
|
|
TxtSeriePS.Text = ""
|
|
TxtSeriePS.Focus()
|
|
Exit Sub
|
|
End If
|
|
|
|
TdSeriePS.Visible = False
|
|
TxtSeriePS.Text = ""
|
|
TxtCodigoPS.Text = ""
|
|
TxtCodigoPS.Focus()
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " AGREGA CON TXT | CODIGO - SERIE --- RECEPCION "
|
|
Protected Sub BtnCodigoPSRecepcion_Click(sender As Object, e As EventArgs)
|
|
If TxtCodigoPSRecepcion.Text = "" Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim Existe = False
|
|
Dim PSTemp = ""
|
|
TdSeriePSRecepcion.Visible = False
|
|
|
|
For Each Gvr As GridViewRow In GvDatosRecepcion.Rows
|
|
If Gvr.DataKey("CodigoBarras") = TxtCodigoPSRecepcion.Text.Trim Then
|
|
Dim TxtCantidad = GvDatosRecepcion.Rows(Gvr.RowIndex).FCTextBox("TxtCantidad")
|
|
If Gvr.DataKey("Cantidad").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then
|
|
|
|
If Gvr.DataKey("AplicaSerie") = "True" Then
|
|
TdSeriePSRecepcion.Visible = True
|
|
TxtSeriePSRecepcion.Focus()
|
|
Exit Sub
|
|
End If
|
|
|
|
TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero
|
|
TxtCodigoPSRecepcion.Text = ""
|
|
RegistraScript("playsonidito('beep-07.wav')")
|
|
UpDatosRecepcion.Update()
|
|
Exit Sub
|
|
End If
|
|
|
|
Existe = True
|
|
PSTemp = Gvr.DataKey("PS").ToString
|
|
'Alert($"Ya se ha cargado la totalidad del Producto ""<b>{Gvr.DataKey("PS").ToString}</b>"" con el Codigo ""<b>{TxtCodigoPSRecepcion.Text}</b>"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);")
|
|
End If
|
|
Next
|
|
|
|
If Existe Then
|
|
Alert($"Ya se ha cargado la totalidad del Producto ""<b>{PSTemp}</b>"" con el Codigo ""<b>{TxtCodigoPSRecepcion.Text}</b>"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);")
|
|
Else
|
|
Alert($"No se ha encontrado un producto para surtir con el Código: ""<b>{TxtCodigoPSRecepcion.Text}</b>"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);")
|
|
End If
|
|
|
|
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
|
|
TxtCodigoPSRecepcion.Text = ""
|
|
|
|
End Sub
|
|
Protected Sub BtnSeriePSRecepcion_Click(sender As Object, e As EventArgs)
|
|
|
|
If TxtSeriePSRecepcion.Text = "" Then
|
|
Exit Sub
|
|
End If
|
|
|
|
For Each Gvr As GridViewRow In GvDatosRecepcion.Rows
|
|
If Gvr.DataKey("CodigoBarras") = TxtCodigoPSRecepcion.Text.Trim And Gvr.DataKey("Serie") = TxtSeriePSRecepcion.Text.Trim.ToUpper Then
|
|
Dim TxtCantidad = GvDatosRecepcion.Rows(Gvr.RowIndex).FCTextBox("TxtCantidad")
|
|
If Gvr.DataKey("Cantidad").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then
|
|
|
|
TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero
|
|
TxtCodigoPSRecepcion.Text = ""
|
|
TdSeriePSRecepcion.Visible = False
|
|
TxtSeriePSRecepcion.Text = ""
|
|
TxtCodigoPSRecepcion.Focus()
|
|
UpDatosRecepcion.Update()
|
|
Exit Sub
|
|
End If
|
|
|
|
Alert($"Ya se ha cargado la totalidad del Producto ""<b>{Gvr.DataKey("PS").ToString}</b>"" con el Código ""<b>{TxtCodigoPSRecepcion.Text}</b>"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);")
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
|
|
End If
|
|
Next
|
|
|
|
Alert($"No se ha encontrado un producto para surtir con el Codigo ""<b>{TxtCodigoPSRecepcion.Text}</b>"". Serie:{TxtSeriePSRecepcion.Text.Trim} ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus1,200);")
|
|
RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')")
|
|
|
|
TxtSeriePSRecepcion.Text = ""
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "CORREO"
|
|
|
|
Private Sub MandaCorreo(CveMovimiento As Integer, Para As String, Optional CCP As String = "")
|
|
Dim Mail As New ClsSisMail()
|
|
Dim Asunto As String = "NOTIFICACION DE TRASPASO ENTRE ALMACENES"
|
|
Dim Body As String = GeneraCorreo(CveMovimiento)
|
|
|
|
If Not Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, CCP) Then
|
|
'Dim objIE As New ClsBancos
|
|
'objIE.UpdateBancos_IENotificaciones(1, "-1", "-1", CveIE)
|
|
'objIE.Dispose()
|
|
Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
'Private Sub BtnSendMail_Click(sender As Object, e As EventArgs) Handles BtnSendMail.Click
|
|
' MandaCorreo(CveMov, TxtParaMail.Text.Trim, TxtCC.Text.Trim)
|
|
' RegistraScript("$('#ModalDivMail').modal('hide');")
|
|
'End Sub
|
|
Private Function GeneraCorreo(CveMovimientoSalida As Integer) As String
|
|
Dim strBody As New StringBuilder
|
|
Dim ObjInventario As New ClsInventarios
|
|
|
|
If ObjInventario.GetMovimientos(CveMovimientoSalida, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
|
|
strBody.Append("<head> ")
|
|
strBody.Append(" <style type=""text/css""> ")
|
|
strBody.Append(" body ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" margin:0px; ")
|
|
strBody.Append(" padding:0px 0px 0px 0px; ")
|
|
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
|
|
strBody.Append(" font-size: 10px; ")
|
|
strBody.Append(" background-color:#F0F0F0; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" a.Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" font-size:11px; ")
|
|
strBody.Append(" background-color:#F7F6F3; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .TextoAlterno ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .BarraIdentidad ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" color:#FFFFFF; ")
|
|
strBody.Append(" background:#F0F0F0; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" font-size:19px; ")
|
|
strBody.Append(" font-style:oblique; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Titulos ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: Gray;")
|
|
strBody.Append(" color:White; ")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Verde {color: #00CC00;} ")
|
|
strBody.Append(" .Negro {color: #000000;} ")
|
|
strBody.Append(" .Rojo {color: #FF0000;} ")
|
|
strBody.Append(" </style> ")
|
|
strBody.Append("</head> ")
|
|
strBody.Append("<body> ")
|
|
strBody.AppendFormat("<div id='C_div' style='width: 600px'>")
|
|
strBody.AppendFormat(" <fieldset>")
|
|
strBody.AppendFormat(" <legend><b>{0}</b></legend>", UsuarioActual.Empresa.Empresa)
|
|
strBody.AppendFormat(" <table class='TextoG' border='0' cellpadding='0' cellspacing='0' width='100%'>")
|
|
strBody.AppendFormat(" <tr>")
|
|
strBody.AppendFormat(" <td style='width:100px'>{0}</td>", UsuarioActual.Empresa.Direccion)
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" <tr>")
|
|
strBody.AppendFormat(" <td>Col. {0}</td>", UsuarioActual.Empresa.Colonia)
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" <tr>")
|
|
strBody.AppendFormat(" <td>{0}, {1}, C.P.{2}</td>", UsuarioActual.Empresa.Ciudad, UsuarioActual.Empresa.Estado, UsuarioActual.Empresa.CP)
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" <tr>")
|
|
strBody.AppendFormat(" <td>RFC {0}</td>", UsuarioActual.Empresa.RFC)
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" </table>")
|
|
strBody.AppendFormat(" </fieldset>")
|
|
strBody.AppendFormat("</div><br/><br/>")
|
|
|
|
|
|
strBody.AppendFormat("<div style='width: 600px'>")
|
|
strBody.AppendFormat(" <table style='width:100%'>")
|
|
strBody.AppendFormat(" <tr>")
|
|
strBody.AppendFormat(" <td style='vertical-align: top'>")
|
|
strBody.AppendFormat(" <fieldset>")
|
|
strBody.AppendFormat(" <legend>TRASPASO ENTRE ALMACENES<b>{0}</b> </legend>", " ")
|
|
strBody.AppendFormat(" <table width='100%'>")
|
|
strBody.AppendFormat(" <tr style='background-color: gray; color: White; font-family: Verdana; font-size: 10px; text-align: center; vertical-align: middle; font-weight: bold; height: 20px; text-decoration: none;'>")
|
|
strBody.AppendFormat(" <th scope='col' style='width:150px;'></th>")
|
|
strBody.AppendFormat(" <th scope='col' style='width:450px;'></th>")
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" <tr class='Texto'>")
|
|
strBody.AppendFormat(" <td>Fecha:</td>")
|
|
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", ObjInventario.Fecha.ToString("dd/MM/yyyy"))
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" <tr class='Texto'>")
|
|
strBody.AppendFormat(" <td>Almacén Origen:</td>")
|
|
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", ObjInventario.Almacen)
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" <tr class='Texto'>")
|
|
strBody.AppendFormat(" <td>Almacén Destino:</td>")
|
|
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", ObjInventario.AlmacenDestino)
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" <tr class='Texto'>")
|
|
strBody.AppendFormat(" <td>Observaciones:</td>")
|
|
strBody.AppendFormat(" <td style='text-align: left'>{0}</td>", ObjInventario.Observaciones)
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" <tr class='Texto'>")
|
|
strBody.AppendFormat(" <td colspan='2'>")
|
|
strBody.AppendFormat(" <hr />")
|
|
strBody.AppendFormat(" </td>")
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" </table>")
|
|
strBody.AppendFormat(" </fieldset>")
|
|
strBody.AppendFormat(" </td>")
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" </table>")
|
|
strBody.AppendFormat("</div>")
|
|
|
|
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
strBody.AppendFormat("<div style='width: 1000px'>")
|
|
strBody.AppendFormat(" <table style='width:1000px'>")
|
|
strBody.AppendFormat(" <tr>")
|
|
strBody.AppendFormat(" <td style='vertical-align: top'>")
|
|
strBody.AppendFormat(" <fieldset>")
|
|
strBody.AppendFormat(" <legend><b>Productos / Servicios <br/>{0}</b> </legend>", "")
|
|
strBody.AppendFormat(" <table width='1000px'>")
|
|
strBody.AppendFormat(" <tr style='background-color: gray; color: White; font-family: Verdana; font-size: 10px; text-align: center; vertical-align: middle; font-weight: bold; height: 20px; text-decoration: none;'>")
|
|
strBody.AppendFormat(" <th scope='col' style='width: 10%'>Cantidad</th>")
|
|
strBody.AppendFormat(" <th scope='col' style='width: 20%'>Unidad</th>")
|
|
strBody.AppendFormat(" <th scope='col' style='width: 70%'>Producto / Servicio</th>")
|
|
strBody.AppendFormat(" </tr>")
|
|
|
|
|
|
For Each dr As DataRow In ObjInventario.DtResultados.Rows
|
|
strBody.AppendFormat(" <tr class='Texto'>")
|
|
strBody.AppendFormat(" <td>{0}</td>", dr("Cantidad").ToString.FormatoNumero)
|
|
strBody.AppendFormat(" <td>{0}</td>", dr("UnidadMedida").ToString)
|
|
strBody.AppendFormat(" <td>{0}</td>", dr("CodigoPS").ToString)
|
|
strBody.AppendFormat(" </tr>")
|
|
Next
|
|
|
|
|
|
strBody.AppendFormat(" <tr class='Texto'>")
|
|
strBody.AppendFormat(" <td colspan='3'>")
|
|
strBody.AppendFormat(" <hr />")
|
|
strBody.AppendFormat(" </td>")
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" </table>")
|
|
strBody.AppendFormat(" </fieldset>")
|
|
strBody.AppendFormat(" </td>")
|
|
strBody.AppendFormat(" </tr>")
|
|
strBody.AppendFormat(" </table>")
|
|
strBody.AppendFormat("</div>")
|
|
End If
|
|
|
|
strBody.Append(" <div> Favor de no responder a este correo. </div> ")
|
|
|
|
strBody.Append("</body></html>")
|
|
|
|
|
|
End If
|
|
|
|
ObjInventario.Dispose()
|
|
Return strBody.ToString
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
#Region "TIMBRADO"
|
|
|
|
|
|
Private Sub EmitirTimbrado(CveTimbre As Integer, CveMovimientoTimbrado As Integer)
|
|
|
|
Dim ObjTimbres As New Timbres("Tra", CveTimbre, UsuarioActual)
|
|
|
|
MensajeAlert.Append("<br/><br/>")
|
|
|
|
If ObjTimbres.Timbrar() Then
|
|
|
|
Try
|
|
PdfFactura(ObjTimbres.ObjFactura)
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
MensajeAlert.Append("Emitido con éxito.")
|
|
'XML
|
|
Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjTimbres.ObjFactura.TipoDocto, ObjTimbres.ObjFactura.SerieFolio)
|
|
If File.Exists(ArchivoXML) Then
|
|
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar XML</a></li></ul>", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "XML", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto)))
|
|
End If
|
|
'PDF
|
|
'Dim ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjTimbres.ObjFactura.TipoDocto, ObjTimbres.ObjFactura.SerieFolio)
|
|
'If File.Exists(ArchivoPDF) Then
|
|
' MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul>", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "PDF", ObjTimbres.ObjFactura.SerieFolio, ObjTimbres.ObjFactura.TipoDocto)))
|
|
'End If
|
|
|
|
If ChkEmitirCartaPorte.Checked Then
|
|
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar Carta Porte</a></li></ul>", Encripta(String.Format("OP=CARPOTIMBRE&CVETIMBRE={0}", CveTimbre)))
|
|
Else
|
|
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar Traslado</a></li></ul>", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimientoTimbrado)))
|
|
End If
|
|
|
|
Else
|
|
MensajeAlert.AppendFormat("<ul><li>{0}</li></ul>", ObjTimbres.MsgError.ToString)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
'Private Sub Timbrar()
|
|
|
|
' CreaObjetosVenta()
|
|
' Dim ObjTimbrado As New Timbrado
|
|
' Dim FM As New Modelos.FemsaFactura
|
|
' Dim TmpDT7Eleven As New DataTable
|
|
' Dim TmpDTComplementosTimbrado As New DataTable
|
|
' PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado)
|
|
' MensajeAlert.Append("<br/><br/>")
|
|
|
|
|
|
' If ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) Then
|
|
' MensajeAlert.Append("Emitido con exito.")
|
|
' 'XML
|
|
' Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
|
|
' If File.Exists(ArchivoXML) Then
|
|
' MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar XML</a></li></ul>", Encripta(String.Format("OP=DesXmlTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "XML", ObjFactura.SerieFolio, ObjFactura.TipoDocto)))
|
|
' End If
|
|
' 'PDF
|
|
' 'GeneraPDFFactura()
|
|
' Dim ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
|
|
' If File.Exists(ArchivoPDF) Then
|
|
' MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul>", Encripta(String.Format("OP=DesPdfTra&CVEMOVIMIENTO={0}&EXT={1}&FOLIO={2}&TIPODOCTO={3}", CveMovimientoTimbrado, "PDF", ObjFactura.SerieFolio, ObjFactura.TipoDocto)))
|
|
' End If
|
|
|
|
' If UsuarioActual.Empresa.Funcionalidad(161) = "1" Then
|
|
' MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar Carta Porte</a></li></ul>", Encripta(String.Format("OP=CARPOTIMBRE&CVEMOV={0}", CveMovimientoTimbrado)))
|
|
' Else
|
|
' MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar Carta Porte</a></li></ul>", Encripta(String.Format("OP=CARPO&CVEMOV={0}", CveMovimientoTimbrado)))
|
|
' End If
|
|
|
|
' Else
|
|
' MensajeAlert.AppendFormat("<ul><li>{0}</li></ul>", ObjTimbrado.MensajeErrorCFDI)
|
|
' End If
|
|
|
|
'End Sub
|
|
|
|
Private Sub GeneraPDFFactura()
|
|
Try
|
|
PdfFactura(ObjFactura)
|
|
Catch ex As Exception
|
|
Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError)
|
|
End Try
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Protected Sub DldChofer_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
' Dim ObjAcar As New ClsAcarreos()
|
|
|
|
' If ObjAcar.GetChofer(DdlChofer.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 1, -1) Then
|
|
' Dim dr As DataRow = ObjAcar.DtResultados.Rows(0)
|
|
' If dr IsNot Nothing Then
|
|
' TxtResponsableRecibio.Text = dr("Chofer").ToString
|
|
' TxtIdentificacion.Text = dr("Identificacion").ToString
|
|
' TxtDomicilio.Text = dr("Domicilio").ToString
|
|
' TxtTelefono.Text = dr("Telefono").ToString
|
|
' TxtCiudad.Text = dr("Ciudad").ToString
|
|
' TxtLicencia.Text = dr("Licencia").ToString
|
|
' End If
|
|
' End If
|
|
' ObjAcar.Dispose()
|
|
End Sub
|
|
Protected Sub BtnCargaExcelConceptos_Click(sender As Object, e As EventArgs)
|
|
If TxtExcelConceptos.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtExcelConceptos.getfiles().Archivos(0)
|
|
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.path
|
|
CargarArchivoConceptos(Directorio, file.filename)
|
|
RegistraScript("$('#DivCargaExcelConceptos').modal('hide');")
|
|
Else
|
|
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnDescargarFormatoExcelConceptos_Click(sender As Object, e As EventArgs)
|
|
Dim DtExcel As New DataTable
|
|
DtExcel.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
|
|
DtExcel.Columns.Add(New DataColumn("Codigo", GetType(String)))
|
|
DtExcel.Columns.Add(New DataColumn("Producto", GetType(String)))
|
|
DtExcel.Columns.Add(New DataColumn("Serie", GetType(String)))
|
|
DtExcel.Columns.Add(New DataColumn("Lote", GetType(String)))
|
|
DtExcel.Columns.Add(New DataColumn("FechaCaducidad", GetType(Date)))
|
|
DtExcel.Columns.Add(New DataColumn("Observaciones", GetType(String)))
|
|
|
|
DtExcel.TableName = "Traspaso"
|
|
|
|
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
|
|
|
Dim FileExcel As New ExcelFile()
|
|
|
|
Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
|
|
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
|
{
|
|
.ColumnHeaders = True,
|
|
.StartRow = 0,
|
|
.StartColumn = 0
|
|
})
|
|
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255))
|
|
worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255)
|
|
|
|
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
|
For i = 0 To columnCount
|
|
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
|
Next
|
|
|
|
FileExcel.Save(Response, "Traspaso.xlsx", SaveOptions.XlsxDefault)
|
|
|
|
End Sub
|
|
|
|
Protected Sub CargarArchivoConceptos(Ruta As String, FileName As String)
|
|
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
|
|
|
Dim dt As DataTable = Nothing
|
|
Dim ErrorArchivo = False
|
|
|
|
Try
|
|
dt = ReadExcelFile(Ruta + FileName, True)
|
|
Catch ex As Exception
|
|
ErrorArchivo = True
|
|
OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
|
End Try
|
|
|
|
If Not ErrorArchivo AndAlso dt IsNot Nothing Then
|
|
|
|
If Not dt.Columns(0).ColumnName = "Cantidad" Then
|
|
Alert("El nombre de la primera columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(1).ColumnName = "Codigo" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(2).ColumnName = "Producto" Then
|
|
Alert("El nombre de la tercera columna debe ser 'Producto'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(3).ColumnName = "Serie" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Serie'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(4).ColumnName = "Lote" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Lote'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(5).ColumnName = "FechaCaducidad" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Fecha Caducidad'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(6).ColumnName = "Observaciones" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Observaciones'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
dt.TableName = "Datos"
|
|
Dim ProductosNoCargados As New StringBuilder()
|
|
Dim RowsCargados As Integer = 0
|
|
Dim RowsNoCargados As Integer = 0
|
|
Dim NoPSConSerie As Integer = 0
|
|
Try
|
|
Dim DtPS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa)
|
|
For Each RowExcel As DataRow In dt.Rows
|
|
If RowExcel("Codigo").ToString() <> "" Then
|
|
|
|
|
|
Dim RowPS = DtPS.FiltroPrimero(String.Format("Codigo='{0}'", RowExcel("Codigo").ToString()))
|
|
|
|
Dim CveProducto As Integer = RowPS("CvePS").ToString().ToEntero()
|
|
Dim CveUnidadMedida As Integer = RowPS("CveUnidadMedida").ToString().ToEntero()
|
|
|
|
Dim Cantidad As Double = RowExcel("Cantidad").ToString().ToDecimal()
|
|
Dim Serie As String = RowExcel("Serie").ToString()
|
|
Dim Lote As String = RowExcel("Lote").ToString()
|
|
Dim FechaCaducidad As Date = If(RowExcel("FechaCaducidad").ToString = "", MinFecha, RowExcel("FechaCaducidad").ToString.ToDate)
|
|
Dim Observaciones As String = RowExcel("Observaciones").ToString()
|
|
|
|
If CveProducto > 0 Then
|
|
|
|
Dim Valido As Boolean = True
|
|
|
|
If RowPS("AplicaSerie").ToString() = "True" And (String.IsNullOrEmpty(Serie.Trim()) OrElse Serie = "-1") Then
|
|
Valido = False
|
|
Alert($"El producto '{RowPS("PS")}' requiere 'Serie'", TipoMensaje.MsgAdvertencia)
|
|
ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
|
|
End If
|
|
|
|
If RowPS("AplicaSerie").ToString() = "True" AndAlso Not String.IsNullOrEmpty(Serie.Trim()) Then
|
|
NoPSConSerie = NoPSConSerie + 1
|
|
End If
|
|
|
|
If Valido AndAlso (Cantidad > 0 AndAlso RowPS("VentaMinima").ToString.ToDecimal > 0) Then
|
|
If Cantidad Mod RowPS("VentaMinima").ToString.ToDecimal <> 0 Then
|
|
Valido = False
|
|
ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
|
|
End If
|
|
End If
|
|
|
|
If Valido Then
|
|
Valido = ValidaExistencia(Cantidad, CveProducto, CveUnidadMedida, -1, If(Not String.IsNullOrEmpty(Serie), Serie, "-1"), If(Not String.IsNullOrEmpty(Lote), Lote, "-1"), FechaCaducidad)
|
|
End If
|
|
|
|
If Valido Then
|
|
AgregarPS(Cantidad, CveProducto, CveUnidadMedida, Observaciones, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(Not String.IsNullOrEmpty(Serie), Serie, ""), Lote:=Lote, FechaCaducidad:=FechaCaducidad, Limpia:=False)
|
|
RowsCargados = RowsCargados + 1
|
|
Else
|
|
RowsNoCargados = RowsNoCargados + 1
|
|
ProductosNoCargados.AppendFormat("{0},", RowPS("PS").ToString())
|
|
End If
|
|
|
|
Else
|
|
RowsNoCargados = RowsNoCargados + 1
|
|
ProductosNoCargados.AppendFormat("{0},", RowExcel("Producto").ToString())
|
|
End If
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al cargar los productos." & ProductosNoCargados.ToString(), ex)
|
|
Finally
|
|
|
|
If NoPSConSerie > 0 Then
|
|
ThSerie.Visible = True
|
|
TdSerie.Visible = True
|
|
TxtnSerie.Visible = True
|
|
GvDatos.Columns(5).Visible = True
|
|
End If
|
|
|
|
Dim MensajeFinal As New StringBuilder()
|
|
If RowsNoCargados = 0 AndAlso RowsCargados > 0 Then
|
|
MensajeFinal.Append("Los productos se cargaron correctamente. <br/><br/>")
|
|
End If
|
|
If RowsCargados > 0 Then
|
|
MensajeFinal.Append("Se cargaron <b>" & RowsCargados & "</b> productos correctamente.")
|
|
End If
|
|
If RowsNoCargados > 0 Then
|
|
MensajeFinal.Append("No se pudieron cargar <b>" & RowsNoCargados & "</b> productos. <br/>Los siguientes productos no se pudieron cargar: " & ProductosNoCargados.ToString())
|
|
End If
|
|
|
|
Alert(MensajeFinal.ToString())
|
|
|
|
End Try
|
|
UpDatos.Update()
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargarCamiones()
|
|
|
|
DdlConfigAuto.Items.Clear()
|
|
DdlUnidadCamion.Items.Clear()
|
|
|
|
'DdlUnidadCamion.DataSource = GlobalDTInvCamiones(UsuarioActual.CveEmpresa)
|
|
'DdlUnidadCamion.DataBind()
|
|
|
|
|
|
|
|
Using ObjInv As New ClsInventarios
|
|
|
|
If ObjInv.GetCamiones(-1, UsuarioActual.CveEmpresa, 1, Estatus:=1) Then
|
|
DdlUnidadCamion.DataSource = ObjInv.DtResultados
|
|
End If
|
|
|
|
|
|
If ObjInv.GetCamiones(-1, UsuarioActual.CveEmpresa, 2, Estatus:=1) Then
|
|
DdlRemolque1.DataSource = ObjInv.DtResultados
|
|
End If
|
|
|
|
End Using
|
|
|
|
DdlUnidadCamion.DataBind()
|
|
DdlUnidadCamion.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
|
|
|
|
|
DdlRemolque1.DataBind()
|
|
DdlRemolque1.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
|
|
|
|
|
|
|
Using ObjGrales As New ClsGenerales
|
|
|
|
If ObjGrales.GetCartaPorteConfigAutoTransportes() Then
|
|
DdlConfigAuto.DataSource = ObjGrales.DtResultados
|
|
End If
|
|
|
|
End Using
|
|
|
|
DdlConfigAuto.DataBind()
|
|
DdlConfigAuto.Items.Insert(0, New ListItem("Seleccione una", "-1"))
|
|
|
|
'Using ObjGral As New ClsGenerales
|
|
' If ObjGral.GetCartaPorteConfigAutoTransportes() Then
|
|
' DdlConfigAuto.DataSource = ObjGral.DtResultados
|
|
' End If
|
|
'End Using
|
|
|
|
'DdlConfigAuto.DataBind()
|
|
|
|
End Sub
|
|
'Public Sub BtnAgregarCamion_Click(sender As Object, e As EventArgs) Handles BtnAgregarCamion.Click
|
|
' 'Dim ObjInventarios As New ClsInventarios
|
|
' 'If ObjInventarios.AddCamiones(TxtPlacaNuevo.Text, TxtEspecificacionNuevo.Text, ConfigCartaPorte:=DdlConfigAuto.SelectedValue, Anio:=TxtAnio.Text.ToEntero(), TipoPermisoSCT:=TxtTipoPermisoSCT.Text, NumPermisoSCT:=TxtNumermisoSCT.Text, NombreAseguradora:=TxtNombreAseguradora.Text, NumPolizaSeguro:=TxtNumPolizaSeguro.Text, CveEmpresa:=UsuarioActual.CveEmpresa, CveUsuario:=UsuarioActual.CveUsuario) Then
|
|
' ' RegistraScript("$('#DivAgregarNuevoCamion').modal('hide');")
|
|
' ' CargarCamiones()
|
|
' ' LimpiarAgregarCamion()
|
|
' 'End If
|
|
' 'ObjInventarios.Dispose()
|
|
'End Sub
|
|
|
|
'Private Sub LimpiarAgregarCamion()
|
|
' TxtPlacaNuevo.Text = ""
|
|
' TxtEspecificacionNuevo.Text = ""
|
|
' TxtAnio.Text = ""
|
|
' TxtTipoPermisoSCT.Text = ""
|
|
' TxtNumermisoSCT.Text = ""
|
|
' TxtNombreAseguradora.Text = ""
|
|
' TxtNumPolizaSeguro.Text = ""
|
|
'End Sub
|
|
|
|
Private Sub DdlUnidadCamion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlUnidadCamion.SelectedIndexChanged
|
|
'If DdlUnidadCamion.SelectedValue = "-1" Then
|
|
' 'divPlacaEspecificacion.Visible = True
|
|
' TxtPlaca.Text = ""
|
|
' TxtEspecifUnidad.Text = ""
|
|
'Else
|
|
' 'divPlacaEspecificacion.Visible = False
|
|
' TxtPlaca.Text = DtCamiones.FiltroPrimeroValor("Placa", String.Format("CveCamion = {0}", DdlUnidadCamion.SelectedValue))
|
|
' TxtEspecifUnidad.Text = DtCamiones.FiltroPrimeroValor("Especificacion", String.Format("CveCamion = {0}", DdlUnidadCamion.SelectedValue))
|
|
'End If
|
|
End Sub
|
|
|
|
Protected Sub DdlAlmacenOrigen_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAlmacenOrigen.SelectedIndexChanged
|
|
If UsuarioActual.Empresa.Funcionalidad(141) = "1" Then
|
|
CargaExistenciasSucursal()
|
|
End If
|
|
If DdlAlmacenOrigen.SelectedValue.ToEntero > 0 Then
|
|
DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacenOrigen.SelectedValue.ToEntero)
|
|
DdlSeccionAlmacen.DataBind()
|
|
DdlSeccionAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
UpDatos.Update()
|
|
|
|
CargaAlmacenDestino()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaAlmacenDestino()
|
|
|
|
Dim DrAlmO As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenOrigen.SelectedValue.ToEntero).FiltroPrimero("")
|
|
If DrAlmO("CveTipoAlmacen").ToString = "26" Then 'costeados
|
|
Dim tTipoAlmacen As String = "26"
|
|
'If UsuarioActual.CveUsuario = 1703 Then ''1703, Jesus lópez,codigo tempora. RMF.2022.10.17
|
|
' tTipoAlmacen = "1,16,26"
|
|
'End If
|
|
If ChkTransitorio.Checked Then
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($" CveTipoAlmacen IN ({tTipoAlmacen}) AND Estatus = 'Activo' ")
|
|
Else
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros($"CveTipoAlmacen IN ({tTipoAlmacen}) ")
|
|
End If
|
|
|
|
DdlAlmacenDestino.DataBind()
|
|
DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
ElseIf DrAlmO("CveTipoAlmacen").ToString.Contiene("22") Then 'Recepcion de Usados
|
|
|
|
If ChkTransitorio.Checked Then
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros(" CveTipoAlmacen IN (21,22) AND Estatus = 'Activo' ")
|
|
Else
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros("CveTipoAlmacen IN (21,22) ")
|
|
End If
|
|
|
|
DdlAlmacenDestino.DataBind()
|
|
DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
ElseIf DrAlmO("CveTipoAlmacen").ToString.Contiene("21") Then 'dev proveedor
|
|
|
|
If ChkTransitorio.Checked Then
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros(" CveTipoAlmacen IN (21,22) AND Estatus = 'Activo' ")
|
|
Else
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros("CveTipoAlmacen IN (1,21,22) ")
|
|
End If
|
|
|
|
DdlAlmacenDestino.DataBind()
|
|
DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
Else
|
|
|
|
Dim Str As String
|
|
If ChkTransitorio.Checked Then
|
|
Str = "" ' String.Format(" AND CveSubProyecto <> {0} ", DrAlmO("CveSubProyecto")) 'RMF. pueden haber almacen que esten dentro de lamisma sucursal, pero que requeiren transitorio
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros(String.Format(" CveTipoAlmacen NOT IN (3,4,9,10,11,24,25,28) {0} AND Estatus = 'Activo' ", Str))
|
|
Else
|
|
Str = String.Format(" AND CveSubProyecto = {0} ", DrAlmO("CveSubProyecto"))
|
|
DdlAlmacenDestino.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=-1).FiltraParametros(String.Format(" CveTipoAlmacen NOT IN (3,4,9,10,11,24,25,28) {0} ", Str))
|
|
End If
|
|
|
|
DdlAlmacenDestino.DataBind()
|
|
DdlAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub DdlAlmacenDestino_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAlmacenDestino.SelectedIndexChanged
|
|
|
|
'If GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveTipoAlmacen", $"CveAlmacen = {DdlAlmacenDestino.SelectedValue.ToEntero}").ToString.ToEntero = 21 Then
|
|
' ChkTransitorio.Checked = False
|
|
' ChkTransitorio.Enabled = False
|
|
'Else
|
|
' ChkTransitorio.Enabled = True
|
|
'End If
|
|
If DdlAlmacenDestino.SelectedValue.ToEntero > 0 Then
|
|
DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, DdlAlmacenDestino.SelectedValue.ToEntero)
|
|
DdlSeccionAlmacenDestino.DataBind()
|
|
DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
UpDatos.Update()
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub ChkEmitirTimbrado_CheckedChanged(sender As Object, e As EventArgs)
|
|
|
|
If ChkEmitirTimbrado.Checked Then
|
|
ChkEmitirCartaPorte.Checked = True
|
|
ChkEmitirCartaPorte.Visible = True
|
|
Else
|
|
ChkEmitirCartaPorte.Visible = False
|
|
ChkEmitirCartaPorte.Checked = False
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub HplCargaBitacora_Click(sender As Object, e As EventArgs)
|
|
|
|
If IO.File.Exists(ArchivoBitacora) Then
|
|
DtMovimientos.ReadXml(ArchivoBitacora)
|
|
CargaGvDatos()
|
|
Alert("Registro(s) Recuperados", TipoMensaje.ToastInformacion)
|
|
Else
|
|
Alert("No hay bitácora para recuperar.", TipoMensaje.ToastInformacion)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
#Region "remolques"
|
|
|
|
|
|
|
|
|
|
Protected Sub DdlUnidadCamionActivoFijo_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
|
|
DvRemolque1.Visible = False
|
|
DvRemolque2.Visible = False
|
|
|
|
DdlRemolque1.SelectedValueExist(-1)
|
|
DdlRemolque2.SelectedValueExist(-1)
|
|
|
|
If DdlUnidadCamion.SelectedValue.ToEntero > 0 Then
|
|
|
|
|
|
Using ObjInv As New ClsInventarios
|
|
|
|
If ObjInv.GetCamiones(DdlUnidadCamion.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, 1) Then
|
|
DdlConfigAuto.SelectedValueExist(ObjInv.DtResultados.FiltroPrimeroValor("CveConfigAutoTransporte"))
|
|
DdlConfigAuto_SelectedIndexChanged(Nothing, Nothing)
|
|
End If
|
|
|
|
End Using
|
|
|
|
|
|
End If
|
|
|
|
UpEmitirTransitorio.Update()
|
|
|
|
End Sub
|
|
|
|
Property RequiereRemolque As Boolean
|
|
Get
|
|
If ViewState("RequiereRemolque") Is Nothing Then
|
|
ViewState("RequiereRemolque") = False
|
|
End If
|
|
|
|
Return Boolean.Parse(ViewState("RequiereRemolque").ToString)
|
|
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("RequiereRemolque") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Property MostrarRemolques As Boolean
|
|
Get
|
|
If ViewState("MostrarRemolques") Is Nothing Then
|
|
ViewState("MostrarRemolques") = False
|
|
End If
|
|
|
|
Return Boolean.Parse(ViewState("MostrarRemolques").ToString)
|
|
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("MostrarRemolques") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Protected Sub DdlConfigAuto_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
ValidaConfiguracionVehiculo()
|
|
End Sub
|
|
|
|
|
|
Private Sub ValidaConfiguracionVehiculo()
|
|
DvRemolque1.Visible = False
|
|
DvRemolque2.Visible = False
|
|
|
|
DdlRemolque1.SelectedValueExist(-1)
|
|
DdlRemolque2.SelectedValueExist(-1)
|
|
|
|
If DdlConfigAuto.SelectedValue.ToEntero > 0 Then
|
|
|
|
Using ObjGrales As New ClsGenerales
|
|
If ObjGrales.GetCartaPorteConfigAutoTransportes() Then
|
|
Dim Remolque As String = ObjGrales.DtResultados.FiltroPrimeroValor("Remolque", $" CveConfigAutoTransporte ='{DdlConfigAuto.SelectedValue.ToEntero}'")
|
|
|
|
|
|
If Remolque = "1" Then
|
|
RequiereRemolque = True
|
|
MostrarRemolques = True
|
|
End If
|
|
|
|
If Remolque = "0, 1" Then
|
|
RequiereRemolque = False
|
|
MostrarRemolques = True
|
|
End If
|
|
|
|
If Remolque = "0" Then
|
|
RequiereRemolque = False
|
|
MostrarRemolques = False
|
|
End If
|
|
End If
|
|
End Using
|
|
|
|
Else
|
|
RequiereRemolque = False
|
|
MostrarRemolques = False
|
|
End If
|
|
|
|
|
|
|
|
|
|
If RequiereRemolque Or MostrarRemolques Then
|
|
DvRemolque1.Visible = True
|
|
End If
|
|
|
|
If Not RequiereRemolque Then
|
|
DvConfiguracionVeiculo.Visible = False
|
|
Else
|
|
DvConfiguracionVeiculo.Visible = True
|
|
End If
|
|
|
|
|
|
UpEmitirTransitorio.Update()
|
|
End Sub
|
|
|
|
Protected Sub DdlRemolque1_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
DdlRemolque2.Items.Clear()
|
|
|
|
If DdlRemolque1.SelectedValue.ToEntero > 0 Then
|
|
DvRemolque2.Visible = True
|
|
|
|
Using ObjInv As New ClsInventarios
|
|
If ObjInv.GetCamiones(-1, UsuarioActual.CveEmpresa, 2, Estatus:=1) Then
|
|
DdlRemolque2.DataSource = ObjInv.DtResultados.FiltraParametros($"CveCamion <> {DdlRemolque1.SelectedValue.ToEntero}")
|
|
End If
|
|
End Using
|
|
|
|
DdlRemolque2.DataBind()
|
|
|
|
|
|
Else
|
|
DvRemolque2.Visible = False
|
|
End If
|
|
|
|
DdlRemolque2.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
|
|
UpEmitirTransitorio.Update()
|
|
|
|
End Sub
|
|
|
|
Private Function validarRemolques() As Boolean
|
|
Dim Respuesta As Boolean = False
|
|
|
|
|
|
If RequiereRemolque And DdlRemolque1.SelectedValue.ToEntero <= 0 Then
|
|
Alert("La configuración de la carta porte requiere que seleccione un remolque", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
If RequiereRemolque And DdlRemolque1.SelectedValue.ToEntero > 0 Then
|
|
Respuesta = True
|
|
End If
|
|
|
|
If Not RequiereRemolque Then
|
|
Respuesta = True
|
|
End If
|
|
|
|
Return Respuesta
|
|
|
|
End Function
|
|
|
|
Function ValidaPSSAT(DrPS As DataRow) As Boolean
|
|
Dim Respuesta As Boolean = False
|
|
|
|
Dim CveSATPS As Integer = DrPS("CveSATPS").ToString.ToEntero
|
|
Dim PesoKg As Decimal = DrPS("PesoKg").ToString.ToDecimal
|
|
Dim SATClaveUnidadMedida As String = DrPS("SATClaveUnidadMedida").ToString.Trim
|
|
|
|
If CveSATPS > 0 AndAlso PesoKg > 0 AndAlso SATClaveUnidadMedida.Length > 0 Then
|
|
Respuesta = True
|
|
Else
|
|
Respuesta = False
|
|
Dim SBMensaje As New StringBuilder
|
|
|
|
SBMensaje.AppendLine("El producto seleccionado presenta la siguiente situación: <br>")
|
|
|
|
If CveSATPS <= 0 Then SBMensaje.AppendLine("-Producto SAT no asignado. <br>")
|
|
|
|
If PesoKg = 0 Then SBMensaje.AppendLine("-Producto sin peso definido. <br>")
|
|
|
|
If SATClaveUnidadMedida.Length = 0 Then SBMensaje.AppendLine("-Producto sin unidad de medida SAT asignada. ")
|
|
|
|
SBMensaje.AppendLine($"<br><strong><a class='texto' target='_blank' href='/Ventas/ProductosServicios.aspx?CvePS={DrPS("CvePS").ToString}' > Editar Producto </a></strong>")
|
|
|
|
Alert(SBMensaje.ToString, TipoMensaje.MsgAdvertencia)
|
|
|
|
End If
|
|
|
|
Return Respuesta
|
|
End Function
|
|
|
|
'Private Sub CargaDireccionesEnvio()
|
|
' Dim ObjClientes As New ClsClientes
|
|
' Dim TieneError = False
|
|
|
|
' DdlDireccionEnvio.Items.Clear()
|
|
' If ObjClientes.DireccionEnvioGet(-1, CveCliente, -1) Then
|
|
' DdlDireccionEnvio.DataSource = ObjClientes.DtResultados.FiltraParametros(String.Format("Estatus = 1"))
|
|
' DdlDireccionEnvio.DataBind()
|
|
' 'DdlDireccionEnvio.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
' TmpDTEnvioDireccion = ObjClientes.DtResultados
|
|
' Else
|
|
' TieneError = True
|
|
' End If
|
|
|
|
' If TieneError Then
|
|
' Alert("Ocurrió un error al obtener las direcciones de envío", TipoMensaje.MsgError)
|
|
' End If
|
|
|
|
' ObjClientes.Dispose()
|
|
' UpCliente.Update()
|
|
|
|
'End Sub
|
|
|
|
#End Region
|
|
End Class
|
|
|
|
|
|
|
|
|