I need to add ranges and if a range is missed while adding i should display a message
Posted
by sabita
on Stack Overflow
See other posts from Stack Overflow
or by sabita
Published on 2010-04-23T11:35:21Z
Indexed on
2010/04/23
12:03 UTC
Read the original article
Hit count: 162
EXAMPLE :if i add a range {1,10} and another range{15,20} i should get a message saying the ranges from 11 to 14 are missing.
for (int i = 0; i < weightdata.Count; i++)
{
if ((i == 0 && i<weightdata.Count-1) && ((MaximumValue < weightdata[i].MinRange && BaseAmount < weightdata[i].BaseAmount)||
(MaximumValue>weightdata[i].MinRange && MaximumValue<weightdata[i+1].MinRange && BaseAmount>weightdata[i].BaseAmount &&BaseAmount>weightdata[i].BaseAmount)))
{
hdnflag.Value = "";
flag = false;
if (weightdata[i].MinRange - MaximumValue > 1)
{
AlertMsg = string.Format(MinSpeedReqMsg.ErrorMessage, MaximumValue,weightdata[i].MinRange);
flag = true;
}
break;
}
else if ((i == weightdata.Count - 1 && weightdata[i].MaxRange != null) && ((MinimumValue > weightdata[i].MaxRange && BaseAmount > weightdata[i].BaseAmount)))
{
hdnflag.Value = "";
flag = false;
if (MinimumValue - weightdata[i].MaxRange > 1)
{
AlertMsg = string.Format(MinSpeedReqMsg.ErrorMessage, MaximumValue, weightdata[i].MinRange);
flag = true;
}
break;
}
else if ((i > 0 && i < weightdata.Count - 1) && (MinimumValue > weightdata[i].MaxRange && MaximumValue < weightdata[i + 1].MinRange && MaximumValue > weightdata[i].MaxRange
&& BaseAmount > weightdata[i].BaseAmount && BaseAmount < weightdata[i + 1].BaseAmount))
{
hdnflag.Value = "";
flag = false;
if (MinimumValue - weightdata[i].MaxRange > 1)
{
AlertMsg =string.Format(MinSpeedReqMsg.ErrorMessage ,weightdata[i].MaxRange, MinimumValue);
flag = true;
}
break;
}
© Stack Overflow or respective owner