Esempio n. 1
0
        public string this[string propertyName]
        {
            get
            {
                try
                {
                    string validationResult = String.Empty;
                    if (ValidationEnabled)
                    {
                        switch (propertyName)
                        {
                        case "TUID":
                            if (TUID == 0 || _dbservicewms.FindPlaceByTUID(TUID) != null)
                            {
                                validationResult = ResourceReader.GetString("ERR_MATERIALEXISTS");
                            }
                            break;

                        case "PlaceID":
                            var pid = _dbservicewms.FindPlaceID(PlaceID);
                            if (!PlaceID.StartsWith("W"))
                            {
                                validationResult = ResourceReader.GetString("ERR_NOTWH");
                            }
                            else if (pid == null || pid.DimensionClass < 0)
                            {
                                validationResult = ResourceReader.GetString("ERR_PLACE");
                            }
                            else if (pid.DimensionClass < 999 && _dbservicewms.FindPlaceByPlace(PlaceID) != null)
                            {
                                validationResult = ResourceReader.GetString("ERR_OCCUPIED");
                            }
                            break;

                        case "DimensionClass":
                            var p = _dbservicewms.FindPlaceID(PlaceID);
                            if (p != null && DimensionClass > p.DimensionClass)
                            {
                                validationResult = ResourceReader.GetString("ERR_CLASS");
                            }
                            break;
                        }
                    }
                    Validator.AddOrUpdate(propertyName, validationResult == String.Empty);
                    AllPropertiesValid = Validator.IsValid() && SubTableValidation;
                    return(validationResult);
                }
                catch (Exception e)
                {
                    _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception,
                                        string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
                    Validator.AddOrUpdate(propertyName, false);
                    AllPropertiesValid = Validator.IsValid();
                    return(ResourceReader.GetString("ERR_EXCEPTION"));
                }
            }
        }