| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Controls;
- namespace Muchinfo.MTPClient.Infrastructure.ValidationRules
- {
- /// <summary>
- /// 数据范围验证
- /// </summary>
- public class DataRangeValidationRules:ValidationRule
- {
- private decimal _minValue =0;
- public decimal MinValue
- {
- get { return _minValue; }
- set { _minValue = value; }
- }
- private decimal _maxValue=decimal.MaxValue;
- public decimal MaxValue
- {
- get { return _maxValue; }
- set { _maxValue = value; }
- }
- public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
- {
- if (value == null)
- {
- return new ValidationResult(false,null);
- }
- if (string.IsNullOrEmpty(value.ToString()))
- {
- return new ValidationResult(false, null);
- }
- if (decimal.Parse(value.ToString()) < MinValue || decimal.Parse(value.ToString()) > MaxValue)
- {
- return new ValidationResult(false, "数字范围错误!");
- }
- return new ValidationResult(true, null);
- }
- }
- }
|