Validacion Contrato prodctos
This commit is contained in:
@@ -10,6 +10,7 @@ Imports System.Text.RegularExpressions
|
||||
Imports System.Threading.Tasks
|
||||
Imports System.Xml
|
||||
Imports Extensiones
|
||||
Imports Newtonsoft.Json
|
||||
|
||||
Partial Class Compras_Compras
|
||||
Inherits ClsPaginas
|
||||
@@ -4280,7 +4281,11 @@ Partial Class Compras_Compras
|
||||
Next
|
||||
If ErrorValidacion Then Exit Sub
|
||||
|
||||
|
||||
Dim dtPSInvalidos As String = ValidarPSContrato(TmpDT.FiltraParametros("", "", {"CveSubProyecto", "CvePS", "Cantidad", "PU"}))
|
||||
If dtPSInvalidos <> "" Then
|
||||
Alert(dtPSInvalidos, TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
'RECORRO LOS PRODUCTOS O SERVICIOS PARA REGISTRARLOS LOS QUE NO EXISTEN EN EL CATÁLOGO
|
||||
Dim tCve As Integer
|
||||
@@ -4586,7 +4591,7 @@ Partial Class Compras_Compras
|
||||
Else
|
||||
CveConceptoContableAlmacen = 205
|
||||
End If
|
||||
If OCVinculada AndAlso DdlOCVinculaInv.visible AndAlso Not (CveImportacion > 0 Or CveFlete > 0) Then
|
||||
If OCVinculada AndAlso DdlOCVinculaInv.Visible AndAlso Not (CveImportacion > 0 Or CveFlete > 0) Then
|
||||
CveConceptoContableAlmacen = DdlOCVinculaInv.SelectedValue.ToEntero
|
||||
End If
|
||||
If UsuarioActual.CveEmpresa.Contiene(72, 80, 140, 141) And Not (CveImportacion > 0 Or CveFlete > 0) Then 'se comento, RMF. 2020.08.19, no le hallo sentido
|
||||
@@ -9056,7 +9061,7 @@ Partial Class Compras_Compras
|
||||
PorcentajeImpuesto = TmpDT.MAX("IVAPorcentaje").ToDecimal
|
||||
IdCtaContable = If(IdCtaIVAXAcreditar > 0, IdCtaIVAXAcreditar, 0)
|
||||
|
||||
If chkImportacion.checked Then
|
||||
If chkImportacion.Checked Then
|
||||
ConceptoContable = 287
|
||||
End If
|
||||
|
||||
@@ -9109,7 +9114,7 @@ Partial Class Compras_Compras
|
||||
PorcentajeImpuesto = TmpDT.MAX("IVAPorcentaje").ToDecimal
|
||||
IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0)
|
||||
|
||||
If chkImportacion.checked Then
|
||||
If chkImportacion.Checked Then
|
||||
ConceptoContable = 288
|
||||
End If
|
||||
If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
|
||||
@@ -11200,7 +11205,7 @@ Partial Class Compras_Compras
|
||||
Dim subproyectos As New List(Of Integer)
|
||||
|
||||
For Each Row As DataRow In TmpDT.FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}).Rows
|
||||
Dim RowCon As DataRow = GlobalDTContratos.FiltroPrimero(String.Format("CveSubProyecto={0}", Row("CveSubProyecto")))
|
||||
Dim RowCon As DataRow = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveSubProyecto={0}", Row("CveSubProyecto")))
|
||||
If Not IsNothing(RowCon) Then
|
||||
filtro.AppendFormat(",{0}", Row("CveSubProyecto"))
|
||||
subproyectos.Add(Row("CveSubProyecto").ToString.ToEntero)
|
||||
@@ -15043,7 +15048,7 @@ Partial Class Compras_Compras
|
||||
dt = ObjContabilidad.DtResultados
|
||||
|
||||
For Each dr As DataRow In dt.Rows
|
||||
If Not ObjContabilidad.UpdatePrepolizasDetalle(dr("CvePrePolizaDetalle").ToString.ToEntero, dr("Concepto").ToString, dr("CveSubProyecto").ToString.ToEntero, dr("IdCtaContable").ToString.ToEntero, CBool(dr("TipoMovto").ToString), 0, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||
If Not ObjContabilidad.UpdatePrePolizasDetalle(dr("CvePrePolizaDetalle").ToString.ToEntero, dr("Concepto").ToString, dr("CveSubProyecto").ToString.ToEntero, dr("IdCtaContable").ToString.ToEntero, CBool(dr("TipoMovto").ToString), 0, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||
ErrorCancelar = True : Exit For
|
||||
End If
|
||||
Next
|
||||
@@ -18103,40 +18108,55 @@ Partial Class Compras_Compras
|
||||
ActualizaTotales = True
|
||||
Dim ObjContratos As New ClsContratos
|
||||
Dim TieneError As Boolean = False
|
||||
Dim Mensaje As String = ""
|
||||
Dim dttemp As DataTable = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveSubProyecto = {0}", DdlSubProyecto.SelectedValue.ToString))
|
||||
If dttemp IsNot Nothing AndAlso dttemp.Rows.Count > 0 Then
|
||||
Dim drContrato As DataRow = dttemp.Rows(0)
|
||||
If ObjContratos.GetContratosDetalle(drContrato("CveContrato").ToString.ToEntero) Then
|
||||
Dim dtContratodetalle As DataTable = ObjContratos.DtResultados.FiltraParametros(String.Format("CvePS = {0}", DdlPS.SelectedValue.ToString))
|
||||
If dtContratodetalle IsNot Nothing AndAlso dtContratodetalle.Rows.Count > 0 Then
|
||||
Dim drContratoDetalle As DataRow = dtContratodetalle(0)
|
||||
If Convert.ToBoolean(drContratoDetalle("LimitarCantidad")) Then
|
||||
If ObjContratos.GetReporteContratosAvancesDetalleControl(drContrato("CveContrato").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
Dim dtContratodetalleControl As DataTable = ObjContratos.DtResultados.FiltraParametros(String.Format("CvePS = {0}", DdlPS.SelectedValue.ToString))
|
||||
If dtContratodetalleControl IsNot Nothing AndAlso dtContratodetalleControl.Rows.Count > 0 Then
|
||||
Dim drContratoDetalleControl As DataRow = dtContratodetalleControl(0)
|
||||
If TxtCantidad.Text.Trim.ToDouble > drContratoDetalleControl("FaltanteCantidad").ToString.ToDouble Then
|
||||
Mensaje = String.Format("La cantidad del Producto/Servicio debe ser menor o igual a {0}", drContratoDetalleControl("FaltanteCantidad").ToString)
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
Mensaje = "Este producto no pertenece al contrato seleccionado."
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
Mensaje = "Error al consultar el contrato."
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
Mensaje = "Este producto no pertenece al contrato seleccionado."
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
Mensaje = "Error al consultar el contrato."
|
||||
Dim dttemp As New DataTable ' GlobalDTContratos().FiltraParametros(String.Format("CveSubProyecto = {0}", DdlSubProyecto.SelectedValue.ToString))
|
||||
dttemp.Columns.Add("CveSubProyecto", GetType(Integer))
|
||||
dttemp.Columns.Add("CvePS", GetType(Integer))
|
||||
dttemp.Columns.Add("Cantidad", GetType(Decimal))
|
||||
dttemp.Columns.Add("PU", GetType(Decimal))
|
||||
|
||||
End If
|
||||
Dim DrPS = dttemp.NewRow
|
||||
DrPS("CveSubProyecto") = DdlSubProyecto.SelectedValue.ToString.ToEntero
|
||||
DrPS("CvePS") = DdlPS.SelectedValue.ToString.ToEntero
|
||||
DrPS("Cantidad") = TxtCantidad.Text.Trim.ToDecimal
|
||||
DrPS("PU") = TxtPrecio.Text.Trim.ToDecimal
|
||||
dttemp.Rows.Add(DrPS)
|
||||
|
||||
Dim dtPSInvalidos As String = ValidarPSContrato(dttemp)
|
||||
If dtPSInvalidos <> "" Then
|
||||
TieneError = True
|
||||
End If
|
||||
'If dttemp IsNot Nothing AndAlso dttemp.Rows.Count > 0 Then
|
||||
' Dim drContrato As DataRow = dttemp.Rows(0)
|
||||
' If ObjContratos.GetContratosDetalle(drContrato("CveContrato").ToString.ToEntero) Then
|
||||
' Dim dtContratodetalle As DataTable = ObjContratos.DtResultados.FiltraParametros(String.Format("CvePS = {0}", DdlPS.SelectedValue.ToString))
|
||||
' If dtContratodetalle IsNot Nothing AndAlso dtContratodetalle.Rows.Count > 0 Then
|
||||
' Dim drContratoDetalle As DataRow = dtContratodetalle(0)
|
||||
' If Convert.ToBoolean(drContratoDetalle("LimitarCantidad")) Then
|
||||
' If ObjContratos.GetReporteContratosAvancesDetalleControl(drContrato("CveContrato").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
' Dim dtContratodetalleControl As DataTable = ObjContratos.DtResultados.FiltraParametros(String.Format("CvePS = {0}", DdlPS.SelectedValue.ToString))
|
||||
' If dtContratodetalleControl IsNot Nothing AndAlso dtContratodetalleControl.Rows.Count > 0 Then
|
||||
' Dim drContratoDetalleControl As DataRow = dtContratodetalleControl(0)
|
||||
' If TxtCantidad.Text.Trim.ToDouble > drContratoDetalleControl("FaltanteCantidad").ToString.ToDouble Then
|
||||
' Mensaje = String.Format("La cantidad del Producto/Servicio debe ser menor o igual a {0}", drContratoDetalleControl("FaltanteCantidad").ToString)
|
||||
' TieneError = True
|
||||
' End If
|
||||
' Else
|
||||
' Mensaje = "Este producto no pertenece al contrato seleccionado."
|
||||
' TieneError = True
|
||||
' End If
|
||||
' Else
|
||||
' Mensaje = "Error al consultar el contrato."
|
||||
' End If
|
||||
' End If
|
||||
' Else
|
||||
' Mensaje = "Este producto no pertenece al contrato seleccionado."
|
||||
' TieneError = True
|
||||
' End If
|
||||
' Else
|
||||
' Mensaje = "Error al consultar el contrato."
|
||||
|
||||
' End If
|
||||
'End If
|
||||
ObjContratos.Dispose()
|
||||
If Not TieneError Then
|
||||
Select Case Modalidad
|
||||
@@ -18181,9 +18201,10 @@ Partial Class Compras_Compras
|
||||
GuardaAC()
|
||||
End If
|
||||
Else
|
||||
Alert(Mensaje, TipoMensaje.MsgAdvertencia)
|
||||
Alert(dtPSInvalidos, TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
|
||||
'If UsuarioActual.Empresa.Funcionalidad(577).ToString = "1" Then
|
||||
|
||||
' 'If UsuarioActual.CveRol = 1 Then
|
||||
@@ -20777,7 +20798,7 @@ Partial Class Compras_Compras
|
||||
|
||||
|
||||
DdlContratosObra.Items.Clear()
|
||||
DdlContratosObra.DataSource = GlobalDTContratos.FiltraParametros(String.Format($"CveContratoTipo in (30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}"))
|
||||
DdlContratosObra.DataSource = GlobalDTContratos(UsuarioActual.CveEmpresa).FiltraParametros(String.Format($"CveContratoTipo in (30,31) AND CveEmpresa = {UsuarioActual.CveEmpresa}"))
|
||||
DdlContratosObra.DataBind()
|
||||
DdlContratosObra.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
|
||||
@@ -20894,6 +20915,41 @@ Partial Class Compras_Compras
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Private Function ValidarPSContrato(DtPS As DataTable) As String
|
||||
Dim Retorno As String = ""
|
||||
Dim objContratos As New ClsContratos
|
||||
Dim TempPS As String = JsonConvert.SerializeObject(DtPS).ToString
|
||||
Dim MensajeProducto As String = ""
|
||||
Dim MensajeCantidad As String = ""
|
||||
Dim MensajeImporte As String = ""
|
||||
If objContratos.ValidaPSContrato(TempPS) Then
|
||||
If objContratos.DtResultados.Rows.Count > 0 Then
|
||||
MensajeProducto = "Los siguientes productos no pertenece al contrato seleccionado: "
|
||||
MensajeCantidad = "Los siguientes productos sobrepasan la cantidad faltante del contrato seleccionado: "
|
||||
MensajeImporte = "Los siguientes productos sobrepasan los importes faltantes del contrato seleccionado: "
|
||||
For Each dr As DataRow In objContratos.DtResultados.Rows
|
||||
If dr("ProductoNoContratado").ToString.ToEntero = 1 Then
|
||||
MensajeProducto += String.Format("<br/> {0}", dr("PS"))
|
||||
ElseIf dr("CantidadSobrePasada").ToString.ToEntero = 1 Then
|
||||
MensajeCantidad += String.Format("<br/> {0} - Cantidad maxima: {1}", dr("PS"), dr("FaltanteCantidad"))
|
||||
ElseIf dr("ImporteSobrePasado").ToString.ToEntero = 1 Then
|
||||
MensajeImporte += String.Format("<br/> {0} - Importe maximo: {1}", dr("PS"), dr("FaltanteImporte"))
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
If MensajeProducto.Length <> 64 Then
|
||||
Retorno = MensajeProducto
|
||||
ElseIf MensajeCantidad.Length <> 84 Then
|
||||
Retorno = MensajeCantidad
|
||||
ElseIf MensajeImporte.Length <> 86 Then
|
||||
Retorno = MensajeImporte
|
||||
End If
|
||||
|
||||
Return Retorno
|
||||
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
Reference in New Issue
Block a user