Dodaj pliki projektów.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user