private void SmartMacCheck(SerialNumberItem item, out string errorMessage)
        {
            item.MacId = item.SerialCode.Length >= 29 ? item.SerialCode.Remove(item.SerialCode.Length - 17, 17) : item.SerialCode;

            //Check if its unique
            var isUnique = !item.SmartCodeOnly && !item.NoSerialization;
            //Check if its repeatable
            var isRepeatable = item.SmartCodeOnly && !item.NoSerialization;

            //If its repeatable, allow it.
            if (!isRepeatable)
            {
                if (item.MacId.Length == 12 || item.MacId.Length == 16 || !isUnique)
                {
                    SerialNumberItem serialItem = null;

                    if (isUnique)
                    {
                        serialItem = _repo.SelectSmartMac(new SerialNumberItemQuery
                        {
                            MacId        = item.MacId,
                            ProductGroup = item.ProductGroup
                        });

                        if (serialItem != null)
                        {
                            errorMessage = "This item has been scanned on another delivery order - #" +
                                           serialItem.DocNum;
                            return;
                        }
                    }
                }
                else
                {
                    errorMessage = "Mac is the wrong size. Please enter one the correct length.";
                    return;
                }
            }
            errorMessage = null;
        }
示例#2
0
 public bool ReturnDeliveryLineItem(SerialNumberItem lineItem, bool isInternal)
 {
     return(_sqlMapperFactory.InventoryMasterMapper.ReturnDeliveryLineItem(lineItem, isInternal));
 }
        public SaveScanModel MatchAndSave(MatchModel scanModel)
        {
            var model = new SaveScanModel();

            if (!string.IsNullOrEmpty(scanModel.SerialCode) && scanModel.SerialCode.Length >= 7)
            {
                var productId = scanModel.SerialCode.Substring(scanModel.SerialCode.Length - 7, 5);
                var color     = scanModel.SerialCode.Substring(scanModel.SerialCode.Length - 2, 2);
                var matches   =
                    _repo.FindUnScannedMatch(new SerialNumberItemQuery
                {
                    ProductId = productId,
                    Color     = color,
                    DocNum    = scanModel.DocNumber
                });
                //Verify there are matches
                if (matches.Any())
                {
                    //check if match requires smart code
                    //All Singles

                    var updated            = false;
                    var matchIndex         = 0;
                    SerialNumberItem match = null;
                    if (scanModel.KitId > 0)
                    {
                        match =
                            matches.FirstOrDefault(
                                m => m.KitCounter.Equals(scanModel.KitCounter) && m.KitId.Equals(scanModel.KitId));
                        if (match != null)
                        {
                            match.ScannedBy  = _identity.Name;
                            match.SerialCode = scanModel.SerialCode;
                            var error = string.Empty;
                            SmartMacCheck(match, out error);
                            if (string.IsNullOrEmpty(error))
                            {
                                _repo.UpdateSerialNumberItem(match, scanModel.IsInternal);
                            }
                            else
                            {
                                model.ErrorMessage = error;
                            }
                        }
                        else
                        {
                            model.ErrorMessage =
                                "No matches found in kit. You may have scanned the bar code incorrectly";
                        }
                    }
                    else
                    {
                        var list = matches.All(m => m.KitId == 0) || matches.All(m => m.KitId > 0)
                            ? matches
                            : matches.Where(m => m.KitId.Equals(0)).ToList();
                        while (!updated && matchIndex <= list.Count - 1)
                        {
                            var item = list[matchIndex];
                            item.ScannedBy  = _identity.Name;
                            item.SerialCode = scanModel.SerialCode;
                            var error = string.Empty;
                            SmartMacCheck(item, out error);
                            if (string.IsNullOrEmpty(error))
                            {
                                updated = _repo.UpdateSerialNumberItem(item, scanModel.IsInternal);
                                if (!updated)
                                {
                                    matchIndex++;
                                }
                                else
                                {
                                    match = list[matchIndex];
                                    break;
                                }
                            }
                            else
                            {
                                model.ErrorMessage = error;
                                break;
                            }
                        }
                    }


                    if (match == null && string.IsNullOrEmpty(model.ErrorMessage))
                    {
                        model.ErrorMessage = "All matches already scanned";
                    }
                    else
                    {
                        model.UpdatedItem = match.Map <SerialNumberItem, DeliveryOrderItemModel>();
                    }
                }
                else
                {
                    model.ErrorMessage = "No items found that match that MacId";
                }
            }
            else
            {
                model.ErrorMessage = "Scanned serial code invalid, length is too short";
            }
            //return unique row number, js will need to find this and remove to proper table on view
            return(model);
        }
示例#4
0
 public bool UpdateSerialNumberItem(SerialNumberItem serialNumberItem, bool isInternal)
 {
     return(_sqlMapperFactory.InventoryMasterMapper.UpdateSerialNumberItem(serialNumberItem, isInternal));
 }
示例#5
0
 public bool IsScanned(SerialNumberItem item)
 {
     return(_sqlMapperFactory.InventoryMasterMapper.IsScanned(item));
 }
 public bool IsScanned(SerialNumberItem item)
 {
     return(_sqlMapper.QueryForObject <SerialNumberItem>("IsScanned", item) != null);
 }
 public bool ReturnDeliveryLineItem(SerialNumberItem lineItem, bool isInternal)
 {
     return(_sqlMapper.Update(isInternal ? "ReturnDeliveryByLineItemIR" : "ReturnDeliveryByLineItem", lineItem) > 0);
 }
 public bool UpdateSerialNumberItem(SerialNumberItem serialNumberItem, bool isInternal)
 {
     return(_sqlMapper.Update(isInternal ?"UpdateSerialNumberIR": "UpdateSerialNumber", serialNumberItem) > 0);
 }