39 lines
991 B
Plaintext
39 lines
991 B
Plaintext
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Globalization;
|
|
using System.Windows.Controls;
|
|
|
|
namespace Haftmittel
|
|
{
|
|
public class ClassProcentyValidationRule : ValidationRule
|
|
{
|
|
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
|
{
|
|
decimal procent = 0;
|
|
|
|
try
|
|
{
|
|
if (((string)value).Length > 0)
|
|
{
|
|
procent = decimal.Parse((String)value);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return new ValidationResult(false, "Nieprawidłowe znaki");
|
|
}
|
|
|
|
if ((procent < 0) || (procent > 100))
|
|
{
|
|
return new ValidationResult(false, "Wartość powinna być z zakresu: 0 - 100");
|
|
}
|
|
else
|
|
{
|
|
return new ValidationResult(true, null);
|
|
}
|
|
}
|
|
}
|
|
}
|