diff --git a/Inventarios/RecepcionUsados.aspx.vb b/Inventarios/RecepcionUsados.aspx.vb
index a78ec0fb7..ef2bf7701 100644
--- a/Inventarios/RecepcionUsados.aspx.vb
+++ b/Inventarios/RecepcionUsados.aspx.vb
@@ -751,6 +751,8 @@ Partial Class Inventarios_RecepcionUsados
End Sub
Private Sub LimpiarMovimiento()
CveMovimiento = -1
+ CveRemisionRecibida = -1
+ CargoRemisionDesdeURL = False
If ObjFactura IsNot Nothing Then
ObjFactura.Dispose()
@@ -771,7 +773,7 @@ Partial Class Inventarios_RecepcionUsados
RblUsadosAjuste.Enabled = True
RblUsadosAjuste.SelectedValue = "0"
- CveRemisionRecibida = -1
+
EsDistribuidor = False
InicializaClientes(True)
DdlClientes.Enabled = True
@@ -831,6 +833,14 @@ Partial Class Inventarios_RecepcionUsados
'CargaInicial()
+
+ If Me.ObjRemisionNC IsNot Nothing Then
+ Me.ObjRemisionNC.Dispose()
+ Me.ObjRemisionNC = Nothing
+ End If
+
+ DtMovimientos.Rows.Clear()
+
UpGenerales.Update()
UpRegistroTipoCambio.Update()
UPDatos.Update()
@@ -1234,12 +1244,14 @@ Partial Class Inventarios_RecepcionUsados
End If
End Sub
Private Sub BtnGenerarRNC_Click(sender As Object, e As EventArgs) Handles BtnGenerarRNC.Click
- Guardar(True)
+ Guardar(True, RecargarPagina:=True)
End Sub
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 MsgError As New StringBuilder()
+ Dim Msg As New StringBuilder
+
Dim Resp As Modelos.Factura.MMensajeFactura = Nothing
Dim ObjInventario As New ClsInventarios
Dim ObjAcum As New ClsAcumuladores(ObjInventario.IniciaTransacSQL())
@@ -1255,9 +1267,7 @@ Partial Class Inventarios_RecepcionUsados
Dim CveSubProyecto As Integer = -1
Dim ActivoFijo As Integer = -1
- If CveMovimiento > 0 Then
- Else
-
+ If Not CveMovimiento > 0 Then
Dim Fecha As Date = String.Format("{0}", TxtFecha.Text.ToDate.ToString("yyyy/MM/dd")).ToDate
Dim CveCliente As Integer = CInt(IIf((DdlClientes.SelectedValue.ToEntero <= 0), -1, DdlClientes.SelectedValue.ToEntero))
Dim CveClienteSucursal As Integer = CInt(IIf((DdlClientesSucursales.SelectedValue.ToEntero <= 0), -1, DdlClientesSucursales.SelectedValue.ToEntero))
@@ -1281,22 +1291,23 @@ Partial Class Inventarios_RecepcionUsados
CargaDTDetalleRNC()
Resp = ObjRemisionNC.EmitirFactura(False, ObjInventario.IniciaTransacSQL)
- 'For Each mensaje2 As String In Resp.Mensajes
- ' Msg.AppendFormat("
{0}", mensaje2)
- 'Next
- If Resp.TieneError Then ErrorMovInv = True
- 'Alert(Msg.ToString, If(Resp.CveVenta > 0, TipoMensaje.MsgInformacion, TipoMensaje.MsgAdvertencia))
- CveVenta = Resp.CveVenta
- If Resp.CveMovimientoUsado <= 0 Then
- Msg.Append("Error al guardar los movimientos de usados")
+ If Resp.TieneError Then ErrorMovInv = True
+
+ If Resp.CveVenta > 0 Then
+ CveVenta = Resp.CveVenta
+ Else
+ MsgError.Append("Error al generar la remisión de nota de crédito")
ErrorMovInv = True
End If
+ If Resp.CveMovimientoUsado <= 0 Then
+ MsgError.Append("Error al guardar los movimientos de usados")
+ ErrorMovInv = True
+ End If
End If
- Dim Mensaje As String = ""
Dim FolioInv As String = ""
If GenerarRNC Then
@@ -1314,7 +1325,7 @@ Partial Class Inventarios_RecepcionUsados
Recibio:=TxtResponsable.Text.Trim, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, DepartamentoEntrega:=TxtDepartamentoEntrega.Text,
PedidoContrato:=TxtPedidoContrato.Text, CveProveedor:=tCveProveedor, Modulo:="RU/G")
If CveMovimiento <= 0 Then
- Mensaje = "Error al guardar los movimientos"
+ MsgError.Append("Error al guardar los movimientos")
ErrorMovInv = True
Else
FolioInv = ObjInventario.Folio.ToString()
@@ -1322,14 +1333,14 @@ Partial Class Inventarios_RecepcionUsados
For Each Dr As DataRow In DtMovimientos.Rows
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, ImporteConcepto, CveAF:=Dr("CveAF").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, Observaciones:=Dr("Observaciones").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
- Mensaje = "Error al guardar los movimientos"
+ MsgError.Append("Error al guardar los movimientos")
ErrorMovInv = True
Exit For
End If
If CveVenta > 0 AndAlso Not ObjVentas.UpdateVentaUsadoRecibido(CveVenta, Dr("CvePS").ToString.ToEntero, True, CveMovimiento) Then
- Mensaje = "Error al actualizar el recibo de los usados"
ErrorMovInv = True
+ MsgError.Append("Error al actualizar el recibo de los usados")
Exit For
End If
@@ -1346,7 +1357,7 @@ Partial Class Inventarios_RecepcionUsados
If Not ObjAcum.DistribuidorMovtosAdd(DdlClientes.SelectedValue.ToEntero, Dr("Cantidad").ToString.ToEntero(), Dr("CveTamaño").ToString.ToEntero, Puntos, Cargo, Bonificacion, CveConceptoUsados, CveVenta, UsuarioActual.CveUsuario,
UsuarioActual.CveEmpresa, 0, Dr("Observaciones").ToString, NowADS(), CveMovimiento:=CveMovimiento) Then
- Mensaje = "Error al guardar Movimientos de distribuidor"
+ MsgError.Append("Error al guardar Movimientos de distribuidor")
ErrorMovInv = True
Exit For
End If
@@ -1354,24 +1365,10 @@ Partial Class Inventarios_RecepcionUsados
End If
Next
- 'ACTUALIZA LA POLIZA VIRTUAL DEL LA REMISION
- 'If Not ErrorMovInv AndAlso ObjFactura.TipoDocto = "Rem" Then
- ' If ObjAcum.GetPolizasVirtuales(ObjFactura.CveVenta) Then
- ' Dim DtPoliza As DataTable = ObjAcum.DtResultados.Copy()
- ' For Each RowPoliza As DataRow In DtPoliza.Rows
- ' If Not ObjAcum.UpdatePolizaVirtual(RowPoliza("CvePolizaVirtual").ToString().ToEntero, DdlMarcaRem.SelectedValue.ToEntero(), TxtFechaVigencia.Text.ToDateTime()) Then
- ' Mensaje = "Error al guardar la póliza virtual"
- ' ErrorMovInv = True
- ' Exit For
- ' End If
- ' Next
-
- ' DtPoliza.Dispose()
- ' Else
- ' Mensaje = "Error al obtener la póliza virtual"
- ' ErrorMovInv = True
- ' End If
- 'End If
+ If Not ErrorMovInv AndAlso ObjFactura.CveCliente <> CveCliente Then
+ ErrorMovInv = True
+ MsgError.Append("Error al asignar el cliente")
+ End If
''GENERA LA PREPOLIZA DE ALMACEN VS EL CONCEPTO DE RNC
If Not ErrorMovInv Then
@@ -1384,14 +1381,12 @@ Partial Class Inventarios_RecepcionUsados
If Not ErrorMovInv Then
+
If Resp IsNot Nothing Then
For Each mensaje2 As String In Resp.Mensajes
Msg.AppendFormat("
{0}", mensaje2)
Next
End If
- End If
-
- If Not ErrorMovInv Then
Msg.AppendFormat("
El Movimiento se registro con el Folio: {0}", FolioInv, CveMovimiento)
Msg.AppendFormat("
Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento)))
@@ -1399,27 +1394,17 @@ Partial Class Inventarios_RecepcionUsados
If IDPoliza > 0 Then Msg = Msg.AppendFormat("
Ver Póliza", IDPoliza)
ObjInventario.Commit() ' aplica los movimientos insertados
-
- 'Limpia Valores cuando inserta de campos especiales
- If UsuarioActual.CveEmpresa = 66 Then
- DdlSubProyecto.SelectedValueExist("-1")
- End If
-
- ' EnvioCorreo()
-
- CargaPendientesRecibir()
- UPDatos.Update()
-
Else
ObjInventario.RollBack() 'deshace lo insertado
CveMovimiento = 0
- Alert("ocurrió un Error al registrar los movimientos", TipoMensaje.MsgError)
+ MsgError.Append("Ocurrió un error al registrar.")
+ Alert(MsgError.ToString(), TipoMensaje.MsgError)
End If
End If
Catch ex As Exception
ObjInventario.RollBack() 'deshace lo insertado
CveMovimiento = 0
- Alert("Ocurrió un Error inesperado en el registro" & ex.Message, TipoMensaje.MsgError)
+ Alert("Ocurrió un error inesperado en el registro" & ex.Message, TipoMensaje.MsgError)
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
End Try
@@ -1435,15 +1420,19 @@ Partial Class Inventarios_RecepcionUsados
End If
Alert(Msg.ToString, TipoMensaje.MsgInformacion, JSBtnAceptar:=Liga, ShowCloseButton:=False)
- End If
+ If CveRemisionRecibida > 0 Then
+ CargaRemisionesPendientes()
+ UPDatos.Update()
+ End If
+ End If
Else
Alert("No hay ningun registro para generar el movimiento. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgError)
RegistraScript("playsonidito('142608__autistic-lucario__error.wav')")
End If
LimpiarMovimiento()
- CargaGVM(DtMovimientos.FiltraParametros("Estatus <> 'E' "))
+ CargaGVM(DtMovimientos)
End Sub
@@ -1655,7 +1644,7 @@ Partial Class Inventarios_RecepcionUsados
#End Region
#Region " GVM "
- Private Sub CargaGVM(DtTemp As DataTable)
+ Private Sub CargaGVM(ByRef DtTemp As DataTable)
GvM.DataSource = DtTemp
GvM.DataBind()
@@ -2243,10 +2232,10 @@ Partial Class Inventarios_RecepcionUsados
End Sub
Protected Sub BtnConsultarPendientes_Click(sender As Object, e As EventArgs)
- CargaPendientesRecibir()
+ CargaRemisionesPendientes()
End Sub
- Private Sub CargaPendientesRecibir()
+ Private Sub CargaRemisionesPendientes()
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVentasUsados(-1, DdlSubProyectos.SelectedValue.ToEntero(), TxtFechaPendientes.Text.ToDateTime(), UsuarioActual.CveEmpresa, ServicioDomicilio:=ChkServicioDomicilio.Checked) Then
GVPendientes.DataSource = ObjVentas.DtResultados
@@ -2365,8 +2354,7 @@ Partial Class Inventarios_RecepcionUsados
End If
If DtUsados IsNot Nothing Then
-
- 'DivRecepcionApartado.Visible = True
+ AgregarUsado = True
For Each RowUsado As DataRow In DtUsados.Rows
Dim CvePS As Integer = RowUsado("CvePS").ToString().ToEntero()
@@ -2382,8 +2370,9 @@ Partial Class Inventarios_RecepcionUsados
Dim CveVentaDetalle As Integer = RowUsado("CveVentaDetalle").ToString().ToEntero()
AddNew(CvePS, PS, CveUM, UM, Cantidad, PU, "", "-1", "-1", "-1", "", "", DdlAlmacen.SelectedValue.ToEntero, DdlAlmacen.SelectedItem.Text, "", CveTamaño, CveVentaDetalle:=CveVentaDetalle)
-
Next
+
+ AgregarUsado = False
End If
Else
Alert("No se pudo recibir la remisión", TipoMensaje.MsgAdvertencia)