validación de los rangos en cxp
This commit is contained in:
@@ -43,7 +43,7 @@ public partial class CRM_RepAcercamientos : ClsPaginas
|
||||
{
|
||||
CveVendedor = DdlVendedor.SelectedValue.ToEntero();
|
||||
|
||||
if (true)
|
||||
if (CveVendedor > 0)
|
||||
{
|
||||
string FechaInicio = TxtFechaInicio.Text == "" ? "-1" : TxtFechaInicio.Text;
|
||||
string FechaFin = TxtFechaFin.Text == "" ? "-1" : TxtFechaFin.Text;
|
||||
|
||||
@@ -763,6 +763,9 @@ Partial Class Compras_RepCxP
|
||||
TxtRF.Text = ""
|
||||
RFVRF.Enabled = True
|
||||
End If
|
||||
UpBodyEdit.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnGuardarPersonalizarRangoEditar_Click(sender As Object, e As EventArgs)
|
||||
|
||||
If Not ChkMayor.Checked And TxtRI.Text.ToDouble > TxtRF.Text.ToDouble Then
|
||||
@@ -771,6 +774,9 @@ Partial Class Compras_RepCxP
|
||||
End If
|
||||
|
||||
If Modalidad = "A" Then
|
||||
If Not ValidarRangosAgregar() Then
|
||||
Exit Sub
|
||||
End If
|
||||
Dim Dt As DataRow = Nothing
|
||||
Dt = DtPersonalizarRango.NewRow
|
||||
Dt("RangoInicial") = TxtRI.Text.ToDouble
|
||||
@@ -783,6 +789,61 @@ Partial Class Compras_RepCxP
|
||||
Exit Sub
|
||||
End If
|
||||
DtPersonalizarRango.Rows(Index)("RangoInicial") = TxtRI.Text.ToDouble
|
||||
DtPersonalizarRango.Rows(Index)("RangoFinal") = TxtRF.Text.ToDouble
|
||||
DtPersonalizarRango.Rows(Index)("Tipo") = DdlTipo.SelectedValue
|
||||
DtPersonalizarRango.Rows(Index)("TipoEscrito") = DdlTipo.SelectedItem.Text
|
||||
DtPersonalizarRango.AcceptChanges()
|
||||
End If
|
||||
DtPersonalizarRango = DtPersonalizarRango.FiltraParametros("", "Tipo,RangoInicial,RangoFinal")
|
||||
CargaGv()
|
||||
RegistraScript("$('#DivPersonalizarRangoEditar').modal('hide')")
|
||||
RegistraScript("$('#DivPersonalizarRango').modal()", "SDSD")
|
||||
End Sub
|
||||
|
||||
Private Function ValidarRangosAgregar() As Boolean
|
||||
Dim UltimoRango As DataTable = DtPersonalizarRango.FiltraParametros(String.Format("Tipo = {0}", DdlTipo.SelectedValue), "RangoInicial")
|
||||
Dim TieneNullRow As DataRow = UltimoRango.Rows(UltimoRango.Rows.Count - 1)
|
||||
Dim aux As String = TieneNullRow.Item("RangoFinal").ToString
|
||||
'Dim TieneNull As DataTable = UltimoRango.FiltraParametros(String.Format("RangoFinal < 0"))
|
||||
If aux = "" Then
|
||||
Alert("Falta indicar el valor maximo del rango anterior", TipoMensaje.MsgAdvertencia)
|
||||
Return False
|
||||
End If
|
||||
Dim ValorMinimoPosible As Double = UltimoRango.MAX("RangoFinal").ToDouble
|
||||
If Not TxtRI.Text.ToDouble > ValorMinimoPosible Then
|
||||
Alert("El rango inicial no puede ser inferior al rango final anterior", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
Return TxtRI.Text.ToDouble > ValorMinimoPosible
|
||||
End Function
|
||||
|
||||
Private Function ValidarRangosEditar() As Boolean
|
||||
Dim TablaDeDatosAux As DataTable = DtPersonalizarRango.FiltraParametros(String.Format("Tipo = {0}", DdlTipo.SelectedValue))
|
||||
|
||||
'Valida que hay datos en el row anterior
|
||||
Dim valorMinimo As Double = 0.0
|
||||
If Index > 0 Then
|
||||
'Validar que el RowAnterior sea del mismo tipo
|
||||
Dim RowAnterior As GridViewRow = GvPersonalizarRango.Rows(Index - 1)
|
||||
If RowAnterior.DataKey("Tipo") = DdlTipo.SelectedValue Then
|
||||
'Validar que el valor final del row anterior no sea null
|
||||
valorMinimo = If(RowAnterior.DataKey("RangoFinal") IsNot Nothing, RowAnterior.DataKey("RangoFinal").ToDouble, -1.0)
|
||||
End If
|
||||
End If
|
||||
|
||||
'Valida que datos en e row siguiente
|
||||
Dim valorMaximo As Double = 1000000.0
|
||||
If Index < (GvPersonalizarRango.Rows.Count - 1) Then
|
||||
'Validamos que el row siguiente sea del mismo tipo
|
||||
Dim RowSiguiente As GridViewRow = GvPersonalizarRango.Rows(Index + 1)
|
||||
If RowSiguiente.DataKey("Tipo") = DdlTipo.SelectedValue Then
|
||||
'Validamos que el valor inicial del row siguiente no sea NULL
|
||||
valorMaximo = If(RowSiguiente.DataKey("RangoInicial") IsNot Nothing, RowSiguiente.DataKey("RangoInicial").ToDouble, 1000000.0)
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not TxtRI.Text.ToDouble > valorMinimo Then
|
||||
Alert("El rango inicial no puede ser inferior al rango final anterior", TipoMensaje.MsgAdvertencia)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If Not TxtRF.Text.ToDouble < valorMaximo Then
|
||||
|
||||
Reference in New Issue
Block a user