Ejemplo n.º 1
0
        private void HandleRfid
        (
            [NotNull] string rfid
        )
        {
            _goodRecord = null;
            SetStatus(new bool?());
            _descriptionBox.Clear();
            PodsobRecord podsob = Kladovka.FindPodsobByBarcode(rfid);

            if (!ReferenceEquals(podsob, null) &&
                !ReferenceEquals(podsob.Record, null))
            {
                _descriptionBox.Text = podsob.Record.Description;

                bool status = CheckPodsob(rfid, podsob);
                SetStatus(status);
                if (status)
                {
                }
            }
            else
            {
                SetStatus(false);
            }
        }
Ejemplo n.º 2
0
        private bool CheckPodsob
        (
            [NotNull] string rfid,
            [NotNull] PodsobRecord podsob
        )
        {
            Code.NotNull(podsob, "podsob");

            bool usePodsob = podsob.Inventory != 0;

            string place = _placeBox.Text.Trim();

            if (string.IsNullOrEmpty(place))
            {
                WriteLine("Не задано место хранения!");

                return(false);
            }

            if (usePodsob && !string.IsNullOrEmpty(podsob.Ticket) &&
                !podsob.Ticket.SameString(place))
            {
                WriteLine
                (
                    "Место хранения не совпадает: {0}",
                    podsob.Ticket.ToVisibleString()
                );

                return(false);
            }

            if (usePodsob && !string.IsNullOrEmpty(podsob.OnHand))
            {
                WriteLine
                (
                    "Книга числится за {0}",
                    podsob.OnHand.ToVisibleString()
                );

                return(false);
            }

            if (usePodsob && !string.IsNullOrEmpty(podsob.Sigla) &&
                !place.SameString(podsob.Sigla))
            {
                WriteLine
                (
                    "Не совпадает сигла: {0}",
                    podsob.Sigla.ToVisibleString()
                );

                return(false);
            }

            MarcRecord  record = podsob.Record.ThrowIfNull("podsob.Record");
            RecordField field  = record.Fields
                                 .GetField(910)
                                 .FirstOrDefault
                                 (
                f => rfid.SameString(f.GetFirstSubFieldValue('b')) ||
                rfid.SameString(f.GetFirstSubFieldValue('h')) ||
                rfid.SameString(f.GetFirstSubFieldValue('t'))
                                 );

            if (ReferenceEquals(field, null))
            {
                WriteLine("Не найден экземпляр: {0}", rfid);

                return(false);
            }

            string status = field.GetFirstSubFieldValue('a');

            if (!status.SameString("0"))
            {
                WriteLine
                (
                    "Неожиданный статус: {0}",
                    status.ToVisibleString()
                );

                return(false);
            }

            string inventory = field.GetFirstSubFieldValue('b');

            if (string.IsNullOrEmpty(inventory))
            {
                WriteLine
                (
                    "Инвентарный номер: {0}",
                    inventory.ToVisibleString()
                );

                return(false);
            }
            if (usePodsob &&
                !inventory.SameString(podsob.Inventory.ToInvariantString()))
            {
                WriteLine
                (
                    "Инвентарный номер не совпадает: {0} и {1}",
                    podsob.Inventory,
                    inventory
                );

                return(false);
            }

            string fieldPlace = field.GetFirstSubFieldValue('d');

            if (!string.IsNullOrEmpty(fieldPlace) &&
                !place.SameString(fieldPlace))
            {
                WriteLine
                (
                    "Не совпадает место хранения: {0}",
                    fieldPlace.ToVisibleString()
                );

                return(false);
            }

            _goodRecord = new StatusRecord
            {
                Inventory   = podsob.Inventory,
                Record      = record,
                Description = record.Description,
                Field       = field,
                Place       = place
            };

            return(true);
        }