Limpieza al surtir remision desde liga
This commit is contained in:
@@ -240,6 +240,15 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
ViewState("CveRemisionRecibida") = value
|
ViewState("CveRemisionRecibida") = value
|
||||||
End Set
|
End Set
|
||||||
End Property
|
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
|
Private Property EsDistribuidor As Boolean
|
||||||
Get
|
Get
|
||||||
Return CBool(IfNull(ViewState("EsDistribuidor"), False, CBool(ViewState("EsDistribuidor"))))
|
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
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||||
If Not IsPostBack Then
|
If Not IsPostBack Then
|
||||||
|
CargoRemisionDesdeURL = False
|
||||||
CargaInicial()
|
CargaInicial()
|
||||||
CargaRemisionFromURL()
|
CargaRemisionFromURL()
|
||||||
GeneraRNCFromURL()
|
GeneraRNCFromURL()
|
||||||
@@ -431,6 +441,7 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
|
|
||||||
Dim CveRemision As Integer = IfNull(Request("CveRemision"), "-1").ToString().ToEntero()
|
Dim CveRemision As Integer = IfNull(Request("CveRemision"), "-1").ToString().ToEntero()
|
||||||
If CveRemision > 0 Then
|
If CveRemision > 0 Then
|
||||||
|
Me.CargoRemisionDesdeURL = True
|
||||||
Me.CveRemisionRecibida = CveRemision
|
Me.CveRemisionRecibida = CveRemision
|
||||||
RecibirRemision()
|
RecibirRemision()
|
||||||
End If
|
End If
|
||||||
@@ -591,14 +602,7 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
DdlMoneda.DataSource = GlobalDTMonedas
|
DdlMoneda.DataSource = GlobalDTMonedas
|
||||||
DdlMoneda.DataBind()
|
DdlMoneda.DataBind()
|
||||||
|
|
||||||
Dim dtt As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros("CveTipoAlmacen IN (22)") 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
CargaAlmacen()
|
||||||
|
|
||||||
'Llenar el dropdownlist de almacén
|
|
||||||
DdlAlmacen.DataSource = dtt
|
|
||||||
|
|
||||||
'DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
||||||
'DdlAlmacen.SelectedValue = "-1"
|
|
||||||
DdlAlmacen.DataBind()
|
|
||||||
|
|
||||||
If IsNothing(Request("CveMovimiento")) Then
|
If IsNothing(Request("CveMovimiento")) Then
|
||||||
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen)
|
||||||
@@ -607,6 +611,33 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
|
|
||||||
CargaPS()
|
CargaPS()
|
||||||
End Sub
|
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()
|
Private Sub CargaPS()
|
||||||
Dim ObjAcum As New ClsAcumuladores
|
Dim ObjAcum As New ClsAcumuladores
|
||||||
Dim lista As New List(Of String)
|
Dim lista As New List(Of String)
|
||||||
@@ -723,6 +754,8 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
ObjFactura = Nothing
|
ObjFactura = Nothing
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
DivRemisionRecibida.Visible = False
|
||||||
|
|
||||||
If ObjRemisionNC IsNot Nothing Then
|
If ObjRemisionNC IsNot Nothing Then
|
||||||
ObjRemisionNC.Dispose()
|
ObjRemisionNC.Dispose()
|
||||||
ObjRemisionNC = Nothing
|
ObjRemisionNC = Nothing
|
||||||
@@ -753,9 +786,7 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
DivRegistro.Visible = False
|
DivRegistro.Visible = False
|
||||||
DivTipoCambio.Visible = False
|
DivTipoCambio.Visible = False
|
||||||
|
|
||||||
If Not DdlAlmacen.Items.Contains(New ListItem("Seleccione", "-1")) Then
|
CargaAlmacen()
|
||||||
DdlAlmacen.Items.Add(New ListItem("Seleccione", "-1"))
|
|
||||||
End If
|
|
||||||
|
|
||||||
DdlAlmacen.SelectedValue = "-1"
|
DdlAlmacen.SelectedValue = "-1"
|
||||||
If Not EsConsumoInterno Then
|
If Not EsConsumoInterno Then
|
||||||
@@ -785,6 +816,7 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
|
|
||||||
'CargaInicial()
|
'CargaInicial()
|
||||||
|
|
||||||
|
UpGenerales.Update()
|
||||||
UpRegistroTipoCambio.Update()
|
UpRegistroTipoCambio.Update()
|
||||||
UPDatos.Update()
|
UPDatos.Update()
|
||||||
End Sub
|
End Sub
|
||||||
@@ -1162,7 +1194,7 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
Guardar(True)
|
Guardar(True)
|
||||||
End Sub
|
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
|
If GvM.Rows.Count > 0 Then
|
||||||
Dim Msg As New StringBuilder()
|
Dim Msg As New StringBuilder()
|
||||||
Dim Resp As Modelos.Factura.MMensajeFactura = Nothing
|
Dim Resp As Modelos.Factura.MMensajeFactura = Nothing
|
||||||
@@ -1350,7 +1382,13 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
ObjVentas.Dispose()
|
ObjVentas.Dispose()
|
||||||
|
|
||||||
If Not ErrorMovInv Then
|
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
|
End If
|
||||||
|
|
||||||
Else
|
Else
|
||||||
@@ -2206,19 +2244,6 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
Private Sub RecibirRemision()
|
Private Sub RecibirRemision()
|
||||||
DtMovimientos.Rows.Clear()
|
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
|
If Me.ObjFactura IsNot Nothing Then
|
||||||
Me.ObjFactura.Dispose()
|
Me.ObjFactura.Dispose()
|
||||||
Me.ObjFactura = Nothing
|
Me.ObjFactura = Nothing
|
||||||
@@ -2226,54 +2251,95 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
|
|
||||||
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas)
|
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas)
|
||||||
|
|
||||||
TxtRemisionRecibida.Text = Me.ObjFactura.SerieFolio
|
If Me.ObjFactura IsNot Nothing Then
|
||||||
DivRemisionRecibida.Visible = True
|
|
||||||
|
|
||||||
'SI ES DISTRIBUIDOR VAMOS A GENERAR LA REMISION DE NOTA DE CREDITO
|
TxtRemisionRecibida.Text = Me.ObjFactura.SerieFolio
|
||||||
If EsDistribuidor Then
|
DivRemisionRecibida.Visible = True
|
||||||
DivCliente.Visible = True
|
|
||||||
DdlClientes.SelectedValueExist(CveCliente)
|
|
||||||
DdlClientes_SelectedIndexChanged(DdlClientes, EventArgs.Empty)
|
|
||||||
|
|
||||||
If Me.ObjRemisionNC IsNot Nothing Then
|
Dim DtUsados As DataTable = Nothing
|
||||||
Me.ObjRemisionNC.Dispose()
|
Dim CveCliente As Integer = -1
|
||||||
Me.ObjRemisionNC = Nothing
|
|
||||||
|
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
|
End If
|
||||||
|
|
||||||
If Me.ObjFactura IsNot Nothing Then
|
If ObjVentas.GetVentasUsadosDetalle(CveRemisionRecibida) Then
|
||||||
'CreaRemisionNC(ObjFactura.CveCliente, ObjFactura.CveSubProyecto, ObjFactura.CveMoneda)
|
DtUsados = ObjVentas.DtResultados.Copy()
|
||||||
DivTotal.Visible = True
|
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
|
End If
|
||||||
Else
|
Else
|
||||||
'DivCliente.Visible = False
|
Alert("No se pudo recibir la remisión", TipoMensaje.MsgAdvertencia)
|
||||||
'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
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
UpGenerales.Update()
|
UpGenerales.Update()
|
||||||
@@ -2801,8 +2867,9 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
If DdlClientes.SelectedValue <> "-1" Then
|
If DdlClientes.SelectedValue <> "-1" Then
|
||||||
CargaAjuste()
|
CargaAjuste()
|
||||||
DivAjuste.Visible = True
|
DivAjuste.Visible = True
|
||||||
|
DivRecepcionUsados.Visible = False
|
||||||
'Llenar el dropdownlist de almacén
|
'Llenar el dropdownlist de almacén
|
||||||
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6)
|
CargaAlmacen(TipoAlmacen:=6)
|
||||||
CargarDescuento()
|
CargarDescuento()
|
||||||
LnkAgregarUsado.Visible = False
|
LnkAgregarUsado.Visible = False
|
||||||
UppAcciones.Update()
|
UppAcciones.Update()
|
||||||
@@ -2812,8 +2879,9 @@ Partial Class Inventarios_RecepcionUsados
|
|||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
DivAjuste.Visible = False
|
DivAjuste.Visible = False
|
||||||
|
DivRecepcionUsados.Visible = True
|
||||||
'Llenar el dropdownlist de almacén
|
'Llenar el dropdownlist de almacén
|
||||||
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 22)
|
CargaAlmacen(TipoAlmacen:=22)
|
||||||
LnkAgregarUsado.Visible = True
|
LnkAgregarUsado.Visible = True
|
||||||
UppAcciones.Update()
|
UppAcciones.Update()
|
||||||
End If
|
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 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 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)
|
Dim params As New List(Of ReportParameter)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user