예제 #1
0
 public override string this[string propertyName]
 {
     get
     {
         try
         {
             string validationResult = String.Empty;
             if (ValidationEnabled)
             {
                 switch (propertyName)
                 {
                 case "Boxes":
                     string[] boxArray = Regex.Split(Boxes, @"[,|;\s\n]+");
                     _boxList.Clear();
                     foreach (var b in boxArray)
                     {
                         if (b != "")
                         {
                             if (DBServiceWMS.FindBoxByBoxID(b) == null)
                             {
                                 validationResult = ResourceReader.GetString("ERR_NOBOXID");
                             }
                             else if (DBServiceWMS.FindTUByBoxID(b) == null)
                             {
                                 validationResult = ResourceReader.GetString("ERR_TUBOXNOEXISTS");
                             }
                             else if (_boxList.Contains(b))
                             {
                                 validationResult = ResourceReader.GetString("ERR_TUBOXEXISTS");
                             }
                             else
                             {
                                 _boxList.Add(b);
                             }
                         }
                     }
                     if (validationResult != String.Empty)
                     {
                         _boxList.Clear();
                     }
                     else
                     {
                         var x = DBServiceWMS.GetTUIDsForBoxes(_boxList);
                         if (x.Count == 0)
                         {
                             validationResult = ResourceReader.GetString("ERR_NOTUID");
                         }
                         else if (x.Count > 1)
                         {
                             validationResult = ResourceReader.GetString("ERR_MANYTUIDFORBOXES");
                         }
                         else if (PickBox &&
                                  DBServiceWMS.GetPlaceWithTUID(x[0]).PlaceID != DBServiceWMS.GetParameter("Place.IOStation"))
                         {
                             validationResult = ResourceReader.GetString("ERR_BOXNOTONSTATION");
                         }
                     }
                     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"));
         }
     }
 }
예제 #2
0
        public string this[string propertyName]
        {
            get
            {
                try
                {
                    string validationResult = String.Empty;
                    if (ValidationEnabled)
                    {
                        switch (propertyName)
                        {
                        case "BoxID":
                            var b = _dbservicewms.FindBoxByBoxID(BoxID);
                            if (b != null)
                            {
                                SKUID       = b.SKU_ID;
                                Batch       = b.Batch;
                                Description = _dbservicewms.FindSKUID(SKUID)?.Description ?? "-";
                                var tu = _dbservicewms.FindTUByBoxID(BoxID);
                                if (tu != null && tu.TU_ID != _tuid)
                                {
                                    validationResult = ResourceReader.GetString("ERR_BOXID_EXISTS");
                                }
                            }
                            else
                            {
                                SKUID       = null;
                                Batch       = null;
                                Description = null;
                                if (BoxID != null)
                                {
                                    validationResult = ResourceReader.GetString("ERR_BOXID_EXISTS");
                                }
                            }
                            break;

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

                        case "DimensionClass":
                            if (Qty <= 0)
                            {
                                validationResult = ResourceReader.GetString("ERR_CLASS");
                            }
                            break;

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

                        case "ExpDate":
                            if (ExpDate < SqlDateTime.MinValue.Value || ExpDate > SqlDateTime.MaxValue.Value)
                            {
                                validationResult = ResourceReader.GetString("ERR_DATE");
                            }
                            break;
                        }
                    }
                    Validator.AddOrUpdate(propertyName, validationResult == String.Empty);
                    AllPropertiesValid = Validator.IsValid();
                    Messenger.Default.Send <MessageValidationInfo>(new MessageValidationInfo()
                    {
                        AllPropertiesValid = AllPropertiesValid
                    });
                    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"));
                }
            }
        }
예제 #3
0
        public override string this[string propertyName]
        {
            get
            {
                try
                {
                    string validationResult = String.Empty;
                    if (ValidationEnabled)
                    {
                        switch (propertyName)
                        {
                        case "TUID":
                        case "TUIDstr":
                            if (TUID == 0)
                            {
                                validationResult = ResourceReader.GetString("ERR_TUID");
                            }
                            else
                            {
                                var p = DBServiceWMS.FindPlaceByTUID(TUID);
                                if (p == null)
                                {
                                    validationResult = ResourceReader.GetString("ERR_TUID");
                                }
                                else if (p.PlaceID.StartsWith("W:out"))
                                {
                                    validationResult = ResourceReader.GetString("ERR_TUID");
                                }
                                var place = DBServiceWMS.GetPlaceWithTUID(TUID);
                                PlaceID = place != null ? place.PlaceID : "-";
                            }
                            break;

                        case "Boxes":
                            if (Boxes != null)
                            {
                                string[] boxArray = Regex.Split(Boxes, @"[,|;\s\n]+");
                                _boxList.Clear();
                                foreach (var b in boxArray)
                                {
                                    if (b != "")
                                    {
                                        if (DBServiceWMS.FindBoxByBoxID(b) == null)
                                        {
                                            if (b.Length == 14 && b[4] == '-' && b[9] == '-' &&
                                                !_boxesAnnounced.Exists(p => p == b))      // announce box to WMS and ERP
                                            {
                                                using (WMSToUIClient client = new WMSToUIClient())
                                                {
                                                    client.BoxEntry(b);
                                                    _boxesAnnounced.Add(b);
                                                }
                                            }
                                            validationResult = ResourceReader.GetString("ERR_NOBOXID");
                                        }
                                        else if (DBServiceWMS.FindTUByBoxID(b) != null)
                                        {
                                            validationResult = ResourceReader.GetString("ERR_TUBOXEXISTS");
                                        }
                                        else if (_boxList.Contains(b))
                                        {
                                            validationResult = ResourceReader.GetString("ERR_TUBOXEXISTS");
                                        }
                                        else
                                        {
                                            _boxList.Add(b);
                                        }
                                    }
                                }
                                if (validationResult == String.Empty && _boxList.Count > 1)
                                {
                                    var skuid = DBServiceWMS.FindBoxByBoxID(_boxList[0]).SKU_ID;
                                    foreach (var b in _boxList)
                                    {
                                        if (DBServiceWMS.FindBoxByBoxID(b).SKU_ID != skuid)
                                        {
                                            validationResult = ResourceReader.GetString("ERR_NOTSAMESKUID");
                                        }
                                    }
                                }
                            }
                            if (validationResult != String.Empty)
                            {
                                _boxList.Clear();
                            }
                            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"));
                }
            }
        }