Optimizacion de carga de factura en modelos, validacion de recepcion de usados
This commit is contained in:
@@ -613,7 +613,7 @@ Partial Class Inventarios_RecepcionUsados
|
||||
CargaPS()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaAlmacen(Optional CveSubProyecto As Integer = -1, Optional TipoAlmacen As Integer = 22)
|
||||
Private Sub CargaAlmacen(Optional CveSubProyecto As Integer = -1, Optional TipoAlmacen As Integer = 22, Optional BloquearAlmacen As Boolean = False)
|
||||
DdlAlmacen.Items.Clear()
|
||||
'Llenar el dropdownlist de almacén
|
||||
Dim dt As DataTable = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoAlmacen:=TipoAlmacen)
|
||||
@@ -633,6 +633,9 @@ Partial Class Inventarios_RecepcionUsados
|
||||
Dim CveAlmacen As Integer = dt.FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto = {CveSubProyecto}").ToEntero()
|
||||
If CveAlmacen > 0 Then
|
||||
DdlAlmacen.SelectedValueExist(CveAlmacen)
|
||||
If BloquearAlmacen Then
|
||||
DdlAlmacen.Enabled = False
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -766,10 +769,13 @@ Partial Class Inventarios_RecepcionUsados
|
||||
TmpDTAjustes.Rows.Clear()
|
||||
End If
|
||||
|
||||
RblUsadosAjuste.Enabled = True
|
||||
|
||||
CveRemisionRecibida = -1
|
||||
EsDistribuidor = False
|
||||
DdlClientes.SelectedValueExist("-1")
|
||||
DdlClientes_SelectedIndexChanged(DdlClientes, EventArgs.Empty)
|
||||
InicializaClientes(True)
|
||||
DdlClientes.Enabled = True
|
||||
ChkClientesTodos.Enabled = True
|
||||
|
||||
SiguienteFolio()
|
||||
|
||||
@@ -2024,15 +2030,17 @@ Partial Class Inventarios_RecepcionUsados
|
||||
Protected Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
CambiaCliente()
|
||||
End Sub
|
||||
Private Sub CambiaCliente()
|
||||
DivClienteSucursal.Visible = False
|
||||
DdlClientesSucursales.Items.Clear()
|
||||
|
||||
Private Sub CambiaCliente(Optional CargaSucursales As Boolean = True, Optional CargaFacturas As Boolean = True)
|
||||
If DdlClientes.SelectedValue.ToEntero > 0 Then
|
||||
Me.EsDistribuidor = CBool(GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=DdlClientes.SelectedValue.ToEntero()).FiltroPrimeroValor("EsDistribuidor", ""))
|
||||
|
||||
CargaSucursalesCliente()
|
||||
CargaFacturasCliente()
|
||||
If CargaSucursales Then
|
||||
DivClienteSucursal.Visible = False
|
||||
DdlClientesSucursales.Items.Clear()
|
||||
CargaSucursalesCliente()
|
||||
End If
|
||||
If CargaFacturas Then
|
||||
CargaFacturasCliente()
|
||||
End If
|
||||
End If
|
||||
UpGenerales.Update()
|
||||
End Sub
|
||||
@@ -2250,7 +2258,12 @@ Partial Class Inventarios_RecepcionUsados
|
||||
Me.CveRemisionRecibida = -1
|
||||
Me.CveRemisionRecibida = CType(CType(sender, LinkButton).NamingContainer, GridViewRow).DataKey("CveVenta").ToEntero()
|
||||
|
||||
RecibirRemision()
|
||||
If Me.CveRemisionRecibida > 0 Then
|
||||
RecibirRemision()
|
||||
Else
|
||||
Alert("No se pudo recibir la remisión", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub RecibirRemision()
|
||||
@@ -2261,7 +2274,7 @@ Partial Class Inventarios_RecepcionUsados
|
||||
Me.ObjFactura = Nothing
|
||||
End If
|
||||
|
||||
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas)
|
||||
Me.ObjFactura = New Modelos.Factura(UsuarioActual, CveRemisionRecibida, UsuarioActual.CveEmpresa, DirectorioServidor:=ModExtensiones.DirectorioBaseEmpresas, CargaDatosCliente:=False, CargaDatosRelacionados:=False)
|
||||
|
||||
If Me.ObjFactura IsNot Nothing Then
|
||||
|
||||
@@ -2271,28 +2284,15 @@ Partial Class Inventarios_RecepcionUsados
|
||||
Dim DtUsados As DataTable = Nothing
|
||||
Dim CveCliente As Integer = -1
|
||||
|
||||
EsDistribuidor = ObjFactura.EsDistribuidor
|
||||
CveCliente = Me.ObjFactura.CveCliente
|
||||
|
||||
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 ObjVentas.GetVentasUsadosDetalle(CveRemisionRecibida) Then
|
||||
DtUsados = ObjVentas.DtResultados.Copy()
|
||||
End If
|
||||
|
||||
'RELACIONA LA VENTA DETALLA DE LA REMISION
|
||||
If DtUsados IsNot Nothing Then
|
||||
DtUsados.Columns.Add(New DataColumn("CveVentaDetalle", GetType(Integer)))
|
||||
For Each RowUsado As DataRow In DtUsados.Rows
|
||||
Dim CveVentaDetalle As Integer = Me.ObjFactura.DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"EsCargo = 1 AND Cantidad = {RowUsado("Cantidad")} AND CvePS = {RowUsado("CvePS")}").ToEntero()
|
||||
If CveVentaDetalle > 0 Then
|
||||
RowUsado("CveVentaDetalle") = CveVentaDetalle
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
Dim RecepcionValida As Boolean = True
|
||||
|
||||
If ObjVentas.GetVentasUsados(ObjFactura.CveVenta, ObjFactura.CveSubProyecto, ObjFactura.Fecha, UsuarioActual.CveEmpresa, ServicioDomicilio:=ObjFactura.ServicioDomicilio) Then
|
||||
@@ -2312,22 +2312,38 @@ Partial Class Inventarios_RecepcionUsados
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
'RELACIONA LA VENTA DETALLA DE LA REMISION
|
||||
If DtUsados IsNot Nothing Then
|
||||
DtUsados.Columns.Add(New DataColumn("CveVentaDetalle", GetType(Integer)))
|
||||
For Each RowUsado As DataRow In DtUsados.Rows
|
||||
Dim CveVentaDetalle As Integer = Me.ObjFactura.DtDetalle.FiltroPrimeroValor("CveVentaDetalle", $"EsCargo = 1 AND Cantidad = {RowUsado("Cantidad")} AND CvePS = {RowUsado("CvePS")}").ToEntero()
|
||||
If CveVentaDetalle > 0 Then
|
||||
RowUsado("CveVentaDetalle") = CveVentaDetalle
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
If ObjFactura.CveSubProyecto > 0 Then
|
||||
CargaAlmacen(CveSubProyecto:=ObjFactura.CveSubProyecto)
|
||||
CargaAlmacen(CveSubProyecto:=ObjFactura.CveSubProyecto, BloquearAlmacen:=True)
|
||||
End If
|
||||
|
||||
If CveCliente > 0 Then
|
||||
DivCliente.Visible = True
|
||||
|
||||
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveCliente = {0}", CveCliente))
|
||||
DdlClientes.DataBind()
|
||||
|
||||
DdlClientes.SelectedValueExist(CveCliente)
|
||||
CambiaCliente(False, False)
|
||||
|
||||
DdlClientes.Enabled = False
|
||||
ChkClientesTodos.Enabled = False
|
||||
End If
|
||||
|
||||
RblUsadosAjuste.Enabled = False
|
||||
|
||||
'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
|
||||
@@ -2337,9 +2353,6 @@ Partial Class Inventarios_RecepcionUsados
|
||||
'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
|
||||
|
||||
Reference in New Issue
Block a user