Limpieza al surtir remision desde liga
This commit is contained in:
@@ -240,6 +240,15 @@ Partial Class Inventarios_RecepcionUsados
|
||||
ViewState("CveRemisionRecibida") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CargoRemisionDesdeURL As Boolean
|
||||
Get
|
||||
Return CBool(IfNull(ViewState("CargoRemisionDesdeURL"), False, CBool(ViewState("CargoRemisionDesdeURL"))))
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("CargoRemisionDesdeURL") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property EsDistribuidor As Boolean
|
||||
Get
|
||||
Return CBool(IfNull(ViewState("EsDistribuidor"), False, CBool(ViewState("EsDistribuidor"))))
|
||||
@@ -348,6 +357,7 @@ Partial Class Inventarios_RecepcionUsados
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
CargoRemisionDesdeURL = False
|
||||
CargaInicial()
|
||||
CargaRemisionFromURL()
|
||||
GeneraRNCFromURL()
|
||||
@@ -431,6 +441,7 @@ Partial Class Inventarios_RecepcionUsados
|
||||
|
||||
Dim CveRemision As Integer = IfNull(Request("CveRemision"), "-1").ToString().ToEntero()
|
||||
If CveRemision > 0 Then
|
||||
Me.CargoRemisionDesdeURL = True
|
||||
Me.CveRemisionRecibida = CveRemision
|
||||
RecibirRemision()
|
||||
End If
|
||||
@@ -591,14 +602,7 @@ Partial Class Inventarios_RecepcionUsados
|
||||
DdlMoneda.DataSource = GlobalDTMonedas
|
||||
DdlMoneda.DataBind()
|
||||
|
||||
Dim dtt As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (22)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
||||
|
||||
'Llenar el dropdownlist de almacén
|
||||
DdlAlmacen.DataSource = dtt
|
||||
|
||||
'DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
'DdlAlmacen.SelectedValue = "-1"
|
||||
DdlAlmacen.DataBind()
|
||||
CargaAlmacen()
|
||||
|
||||
If IsNothing(Request("CveMovimiento")) Then
|
||||
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
||||
@@ -607,6 +611,33 @@ Partial Class Inventarios_RecepcionUsados
|
||||
|
||||
CargaPS()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaAlmacen(Optional CveSubProyecto As Integer = -1, Optional TipoAlmacen As Integer = 22)
|
||||
DdlAlmacen.Items.Clear()
|
||||
'Llenar el dropdownlist de almacén
|
||||
Dim dt As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=TipoAlmacen)
|
||||
|
||||
If CveSubProyecto > 0 Then
|
||||
dt = dt.FiltraParametros($"CveSubProyecto = {CveSubProyecto}")
|
||||
End If
|
||||
|
||||
DdlAlmacen.DataSource = dt
|
||||
DdlAlmacen.DataBind()
|
||||
|
||||
If Not DdlAlmacen.Items.Contains(New ListItem("Seleccione", "-1")) Then
|
||||
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
End If
|
||||
|
||||
If CveSubProyecto > 0 Then
|
||||
Dim CveAlmacen As Integer = dt.FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {CveSubProyecto}").ToEntero()
|
||||
If CveAlmacen > 0 Then
|
||||
DdlAlmacen.SelectedValueExist(CveAlmacen)
|
||||
End If
|
||||
End If
|
||||
|
||||
dt.Dispose()
|
||||
|
||||
End Sub
|
||||
Private Sub CargaPS()
|
||||
Dim ObjAcum As New ClsAcumuladores
|
||||
Dim lista As New List(Of String)
|
||||
@@ -723,6 +754,8 @@ Partial Class Inventarios_RecepcionUsados
|
||||
ObjFactura = Nothing
|
||||
End If
|
||||
|
||||
DivRemisionRecibida.Visible = False
|
||||
|
||||
If ObjRemisionNC IsNot Nothing Then
|
||||
ObjRemisionNC.Dispose()
|
||||
ObjRemisionNC = Nothing
|
||||
@@ -753,9 +786,7 @@ Partial Class Inventarios_RecepcionUsados
|
||||
DivRegistro.Visible = False
|
||||
DivTipoCambio.Visible = False
|
||||
|
||||
If Not DdlAlmacen.Items.Contains(New ListItem("Seleccione", "-1")) Then
|
||||
DdlAlmacen.Items.Add(New ListItem("Seleccione", "-1"))
|
||||
End If
|
||||
CargaAlmacen()
|
||||
|
||||
DdlAlmacen.SelectedValue = "-1"
|
||||
If Not EsConsumoInterno Then
|
||||
@@ -785,6 +816,7 @@ Partial Class Inventarios_RecepcionUsados
|
||||
|
||||
'CargaInicial()
|
||||
|
||||
UpGenerales.Update()
|
||||
UpRegistroTipoCambio.Update()
|
||||
UPDatos.Update()
|
||||
End Sub
|
||||
@@ -1162,7 +1194,7 @@ Partial Class Inventarios_RecepcionUsados
|
||||
Guardar(True)
|
||||
End Sub
|
||||
|
||||
Protected Sub Guardar(Optional GenerarRNC As Boolean = False)
|
||||
Protected Sub Guardar(Optional GenerarRNC As Boolean = False, Optional RecargarPagina As Boolean = False)
|
||||
If GvM.Rows.Count > 0 Then
|
||||
Dim Msg As New StringBuilder()
|
||||
Dim Resp As Modelos.Factura.MMensajeFactura = Nothing
|
||||
@@ -1350,7 +1382,13 @@ Partial Class Inventarios_RecepcionUsados
|
||||
ObjVentas.Dispose()
|
||||
|
||||
If Not ErrorMovInv Then
|
||||
Alert(Msg.ToString, TipoMensaje.MsgInformacion)
|
||||
Dim Liga As String = ""
|
||||
|
||||
If RecargarPagina Then
|
||||
Liga = "document.location.href=""/Inventarios/RecepcionUsados.aspx"";"
|
||||
End If
|
||||
|
||||
Alert(Msg.ToString, TipoMensaje.MsgInformacion, JSBtnAceptar:=Liga, ShowCloseButton:=False)
|
||||
End If
|
||||
|
||||
Else
|
||||
@@ -2206,19 +2244,6 @@ Partial Class Inventarios_RecepcionUsados
|
||||
Private Sub RecibirRemision()
|
||||
DtMovimientos.Rows.Clear()
|
||||
|
||||
Dim DtUsados As DataTable = Nothing
|
||||
Dim CveCliente As Integer = -1
|
||||
|
||||
Dim ObjVentas As New ClsVentas
|
||||
If ObjVentas.GetVenta(CveRemisionRecibida, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
||||
EsDistribuidor = CBool(ObjVentas.DtResultados.Rows(0)("EsDistribuidor").ToString())
|
||||
CveCliente = ObjVentas.DtResultados.Rows(0)("CveCliente").ToString().ToEntero()
|
||||
|
||||
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveCliente = {0}", CveCliente))
|
||||
DdlClientes.DataBind()
|
||||
DdlClientes.SelectedValueExist(CveCliente)
|
||||
End If
|
||||
|
||||
If Me.ObjFactura IsNot Nothing Then
|
||||
Me.ObjFactura.Dispose()
|
||||
Me.ObjFactura = Nothing
|
||||
@@ -2226,54 +2251,95 @@ Partial Class Inventarios_RecepcionUsados
|
||||
|
||||
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas)
|
||||
|
||||
TxtRemisionRecibida.Text = Me.ObjFactura.SerieFolio
|
||||
DivRemisionRecibida.Visible = True
|
||||
If Me.ObjFactura IsNot Nothing Then
|
||||
|
||||
'SI ES DISTRIBUIDOR VAMOS A GENERAR LA REMISION DE NOTA DE CREDITO
|
||||
If EsDistribuidor Then
|
||||
DivCliente.Visible = True
|
||||
DdlClientes.SelectedValueExist(CveCliente)
|
||||
DdlClientes_SelectedIndexChanged(DdlClientes, EventArgs.Empty)
|
||||
TxtRemisionRecibida.Text = Me.ObjFactura.SerieFolio
|
||||
DivRemisionRecibida.Visible = True
|
||||
|
||||
If Me.ObjRemisionNC IsNot Nothing Then
|
||||
Me.ObjRemisionNC.Dispose()
|
||||
Me.ObjRemisionNC = Nothing
|
||||
Dim DtUsados As DataTable = Nothing
|
||||
Dim CveCliente As Integer = -1
|
||||
|
||||
Dim ObjVentas As New ClsVentas
|
||||
If ObjVentas.GetVenta(CveRemisionRecibida, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
||||
EsDistribuidor = CBool(ObjVentas.DtResultados.Rows(0)("EsDistribuidor").ToString())
|
||||
CveCliente = ObjVentas.DtResultados.Rows(0)("CveCliente").ToString().ToEntero()
|
||||
End If
|
||||
|
||||
If Me.ObjFactura IsNot Nothing Then
|
||||
'CreaRemisionNC(ObjFactura.CveCliente, ObjFactura.CveSubProyecto, ObjFactura.CveMoneda)
|
||||
DivTotal.Visible = True
|
||||
If ObjVentas.GetVentasUsadosDetalle(CveRemisionRecibida) Then
|
||||
DtUsados = ObjVentas.DtResultados.Copy()
|
||||
End If
|
||||
|
||||
Dim RecepcionValida As Boolean = True
|
||||
|
||||
If ObjVentas.GetVentasUsados(ObjFactura.CveVenta, ObjFactura.CveSubProyecto, ObjFactura.Fecha, UsuarioActual.CveEmpresa, ServicioDomicilio:=ObjFactura.ServicioDomicilio) Then
|
||||
If ObjVentas.DtResultados.Rows.Count = 0 Then
|
||||
RecepcionValida = False
|
||||
End If
|
||||
End If
|
||||
ObjVentas.Dispose()
|
||||
|
||||
If Not RecepcionValida Then
|
||||
Dim Liga As String = ""
|
||||
If CargoRemisionDesdeURL Then
|
||||
Liga = "document.location.href=""/Inventarios/RecepcionUsados.aspx"";"
|
||||
End If
|
||||
|
||||
Alert("La recepción del usado ya se realizó", TipoMensaje.MsgAdvertencia, JSBtnAceptar:=Liga, ShowCloseButton:=False)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If ObjFactura.CveSubProyecto > 0 Then
|
||||
CargaAlmacen(CveSubProyecto:=ObjFactura.CveSubProyecto)
|
||||
End If
|
||||
|
||||
If CveCliente > 0 Then
|
||||
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveCliente = {0}", CveCliente))
|
||||
DdlClientes.DataBind()
|
||||
DdlClientes.SelectedValueExist(CveCliente)
|
||||
End If
|
||||
|
||||
'SI ES DISTRIBUIDOR VAMOS A GENERAR LA REMISION DE NOTA DE CREDITO
|
||||
If EsDistribuidor Then
|
||||
DivCliente.Visible = True
|
||||
DdlClientes.SelectedValueExist(CveCliente)
|
||||
DdlClientes_SelectedIndexChanged(DdlClientes, EventArgs.Empty)
|
||||
|
||||
If Me.ObjRemisionNC IsNot Nothing Then
|
||||
Me.ObjRemisionNC.Dispose()
|
||||
Me.ObjRemisionNC = Nothing
|
||||
End If
|
||||
|
||||
If Me.ObjFactura IsNot Nothing Then
|
||||
'CreaRemisionNC(ObjFactura.CveCliente, ObjFactura.CveSubProyecto, ObjFactura.CveMoneda)
|
||||
DivTotal.Visible = True
|
||||
End If
|
||||
Else
|
||||
'DivCliente.Visible = False
|
||||
'DivFactura.Visible = False
|
||||
End If
|
||||
|
||||
If DtUsados IsNot Nothing Then
|
||||
|
||||
'DivRecepcionApartado.Visible = True
|
||||
|
||||
For Each RowUsado As DataRow In DtUsados.Rows
|
||||
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
|
||||
|
||||
Dim RowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).Rows(0)
|
||||
Dim CveTamaño As Integer = RowPS("CveTamaño").ToString().ToEntero()
|
||||
|
||||
Dim PS As String = RowPS("PS").ToString()
|
||||
Dim CveUM As Integer = RowPS("CveUnidadMedida").ToString().ToEntero()
|
||||
Dim UM As String = RowPS("UnidadMedida").ToString()
|
||||
Dim Cantidad As Double = RowUsado("Cantidad").ToString().ToEntero()
|
||||
Dim PU As Double = RowUsado("PU").ToString().ToDouble()
|
||||
|
||||
AddNew(CvePS, PS, CveUM, UM, Cantidad, PU, "", "-1", "-1", "-1", "", "", DdlAlmacen.SelectedValue.ToEntero, DdlAlmacen.SelectedItem.Text, "", CveTamaño)
|
||||
|
||||
Next
|
||||
End If
|
||||
Else
|
||||
'DivCliente.Visible = False
|
||||
'DivFactura.Visible = False
|
||||
End If
|
||||
|
||||
If ObjVentas.GetVentasUsadosDetalle(CveRemisionRecibida) Then
|
||||
DtUsados = ObjVentas.DtResultados.Copy()
|
||||
End If
|
||||
|
||||
ObjVentas.Dispose()
|
||||
|
||||
If DtUsados IsNot Nothing Then
|
||||
|
||||
'DivRecepcionApartado.Visible = True
|
||||
|
||||
For Each RowUsado As DataRow In DtUsados.Rows
|
||||
Dim CvePS = RowUsado("CvePS").ToString().ToEntero()
|
||||
|
||||
Dim RowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).Rows(0)
|
||||
Dim CveTamaño As Integer = RowPS("CveTamaño").ToString().ToEntero()
|
||||
|
||||
Dim PS As String = RowPS("PS").ToString()
|
||||
Dim CveUM As Integer = RowPS("CveUnidadMedida").ToString().ToEntero()
|
||||
Dim UM As String = RowPS("UnidadMedida").ToString()
|
||||
Dim Cantidad As Double = RowUsado("Cantidad").ToString().ToEntero()
|
||||
Dim PU As Double = RowUsado("PU").ToString().ToDouble()
|
||||
|
||||
AddNew(CvePS, PS, CveUM, UM, Cantidad, PU, "", "-1", "-1", "-1", "", "", DdlAlmacen.SelectedValue.ToEntero, DdlAlmacen.SelectedItem.Text, "", CveTamaño)
|
||||
|
||||
Next
|
||||
Alert("No se pudo recibir la remisión", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
UpGenerales.Update()
|
||||
@@ -2801,8 +2867,9 @@ Partial Class Inventarios_RecepcionUsados
|
||||
If DdlClientes.SelectedValue <> "-1" Then
|
||||
CargaAjuste()
|
||||
DivAjuste.Visible = True
|
||||
DivRecepcionUsados.Visible = False
|
||||
'Llenar el dropdownlist de almacén
|
||||
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6)
|
||||
CargaAlmacen(TipoAlmacen:=6)
|
||||
CargarDescuento()
|
||||
LnkAgregarUsado.Visible = False
|
||||
UppAcciones.Update()
|
||||
@@ -2812,8 +2879,9 @@ Partial Class Inventarios_RecepcionUsados
|
||||
End If
|
||||
Else
|
||||
DivAjuste.Visible = False
|
||||
DivRecepcionUsados.Visible = True
|
||||
'Llenar el dropdownlist de almacén
|
||||
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 22)
|
||||
CargaAlmacen(TipoAlmacen:=22)
|
||||
LnkAgregarUsado.Visible = True
|
||||
UppAcciones.Update()
|
||||
End If
|
||||
@@ -3384,7 +3452,7 @@ Partial Class Inventarios_RecepcionUsados
|
||||
|
||||
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
||||
Dim logouri = String.Format("{0}//{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
||||
Dim DtDatos As New DataTable
|
||||
Dim DtDatos As New DataTable
|
||||
|
||||
Dim params As New List(Of ReportParameter)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user