示例#1
0
        public string this[string propertyName]
        {
            get
            {
                try
                {
                    string validationResult = String.Empty;
                    if (ValidationEnabled)
                    {
                        switch (propertyName)
                        {
                        case "ERPID":
                            break;

                        case "OrderID":
                            if (OrderID <= 0 || (_dbservicewms.ExistsOrderID(ERPID, OrderID) && OrderID != ReferenceOrderID))
                            {
                                validationResult = ResourceReader.GetString("ERR_ORDERID");
                            }
                            break;

                        case "Destination":
                            if (_dbservicewms.FindPlaceID(Destination) == null)
                            {
                                validationResult = ResourceReader.GetString("ERR_DESTINATION");
                            }
                            break;

                        case "ReleaseTime":
                            if (ReleaseTime < SqlDateTime.MinValue.Value || ReleaseTime > SqlDateTime.MaxValue.Value)
                            {
                                validationResult = ResourceReader.GetString("ERR_RANGE");
                            }
                            break;

                        case "SubOrderID":
                            if (SubOrderID <= 0 || (_dbservicewms.ExistsSubOrderID(OrderID, SubOrderID) && SubOrderID != ReferenceSubOrderID))
                            {
                                validationResult = ResourceReader.GetString("ERR_SUBORDERID");
                            }
                            break;

                        case "SubOrderERPID":
                            if (SubOrderERPID < 0)
                            {
                                validationResult = ResourceReader.GetString("ERR_SUBORDERID");
                            }
                            break;

                        case "SubOrderName":
                            if (SubOrderName == null || SubOrderName.Length == 0)
                            {
                                validationResult = ResourceReader.GetString("ERR_SUBORDERNAME");
                            }
                            break;

                        case "SKUID":
                            if (_dbservicewms.FindSKUID(SKUID) == null)
                            {
                                validationResult = ResourceReader.GetString("ERR_SKU");
                            }
                            break;

                        case "SKUBatch":
                            break;

                        case "SKUQty":
                            if (SKUQty <= 0)
                            {
                                validationResult = ResourceReader.GetString("ERR_RANGE");
                            }
                            break;
                        }
                    }
                    Validator.AddOrUpdate(propertyName, validationResult == String.Empty);
                    AllPropertiesValid = Validator.IsValid();
                    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"));
                }
            }
        }