private void FindItem(List <string> searchFor, List <string> searchValues)
        {
            string            errorText = null;
            string            errorCode = null;
            List <RetailItem> searchItems;
            string            searchFlag = "NORMAL";

            RetailProcedures.SearchForItem(searchFor, searchValues, DesktopSession, searchFlag, false, out searchItems, out errorCode, out errorText);

            RetailItem        item          = null;
            ItemSearchResults searchResults = new ItemSearchResults(DesktopSession, ItemSearchResultsMode.CHANGE_RETAIL_PRICE);

            if (searchItems.Count == 0)
            {
                searchResults.ShowDialog();
                return;
            }

            if (searchItems.Count == 1)
            {
                item = searchItems[0];
                if (Item.ItemLocked(item))
                {
                    MessageBox.Show(Item.ItemLockedMessage);
                    return;
                }
                if (Commons.CheckICNSubItem(item.Icn))
                {
                    MessageBox.Show("Invalid ICN");
                    return;
                }
            }

            if (searchItems.Count == 1 && searchItems[0].ItemStatus != ProductStatus.PFI)
            {
                searchResults.ShowDialog();
                return;
            }

            if (searchItems.Count == 1)
            {
                item = searchItems[0];
            }
            else if (searchItems.Count > 1)
            {
                var distinctItems = (from sItem in searchItems
                                     where ((sItem.IsJewelry && sItem.Jewelry.Any(j => j.SubItemNumber == 0)) ||
                                            !sItem.IsJewelry)
                                     select sItem).ToList();

                if (distinctItems.Count == 0)
                {
                    //item = selectItems.SelectedItem;
                    item = searchItems.First();
                    if (Item.ItemLocked(item))
                    {
                        MessageBox.Show(Item.ItemLockedMessage);
                        return;
                    }
                    //item = selectItems.SelectedItem;
                    if (Commons.CheckICNSubItem(item.Icn))
                    {
                        MessageBox.Show("Invalid ICN");
                        return;
                    }
                }
                else
                {
                    SelectItems selectItems = new SelectItems(searchItems, ItemSearchResultsMode.CHANGE_RETAIL_PRICE);
                    selectItems.ErrorMessage = "The Short code entered is a duplicate. Please make your selection from the list";
                    if (selectItems.ShowDialog() == DialogResult.OK)
                    {
                        item = selectItems.SelectedItem;
                        if (Item.ItemLocked(item))
                        {
                            MessageBox.Show(Item.ItemLockedMessage);
                            return;
                        }
                        if (Commons.CheckICNSubItem(item.Icn))
                        {
                            MessageBox.Show("Invalid ICN");
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }

            LockUnlockRetailItem(item, true);

            DesktopSession.ActiveRetail = new SaleVO();
            DesktopSession.ActiveRetail.RetailItems.Add(item);

            //BZ: 899 - Allow the submit, form changes are handled in the flow executor
            NavControlBox.Action = NavBox.NavAction.SUBMIT;
        }
        private bool FindItem(List <string> searchFor, List <string> searchValues)
        {
            bool              retval    = false;
            string            errorText = null;
            string            errorCode = null;
            List <RetailItem> searchItems;
            string            searchFlag = "NORMAL";

            this.customLabelError.Visible = false;
            this.customLabelError.Text    = string.Empty;


            bool loadQty = this.txtQty.Visible;

            RetailProcedures.SearchForItem(searchFor, searchValues, CDS, searchFlag, loadQty, out searchItems, out errorCode, out errorText);

            RetailItem        item          = null;
            ItemSearchResults searchResults = new ItemSearchResults(GlobalDataAccessor.Instance.DesktopSession, ItemSearchResultsMode.CHARGEOFF);

            if (searchItems.Count == 0)
            {
                this.customLabelError.Visible = true;
                this.customLabelError.Text    = " This ICN number was not found in the current shop. Please check the number and try again.";
                return(retval);
            }

            if (searchItems.Count == 1 && searchItems[0].ItemStatus != ProductStatus.PFI)
            {
                searchResults.ShowDialog();
                return(retval);
            }

            if (searchItems.Count == 1)
            {
                item = searchItems[0];
                if (Item.ItemLocked(item))
                {
                    MessageBox.Show(Item.ItemLockedMessage);
                    return(retval);
                }
            }
            else if (searchItems.Count > 1)
            {
                var distinctItems = from sItem in searchItems
                                    where ((sItem.IsJewelry && sItem.Jewelry.Any(j => j.SubItemNumber == 0)) ||
                                           !sItem.IsJewelry)
                                    select sItem;
                if (distinctItems.Any())
                {
                    SelectItems selectItems = new SelectItems(searchItems, ItemSearchResultsMode.CHARGEOFF);
                    selectItems.ErrorMessage = "The Short code entered is a duplicate. Please make your selection from the list";
                    if (selectItems.ShowDialog() == DialogResult.OK)
                    {
                        item = selectItems.SelectedItem;
                        if (Item.ItemLocked(item))
                        {
                            this.customLabelError.Text    = Item.ItemLockedMessage;
                            this.customLabelError.Visible = true;
                            return(retval);
                        }
                        if (item.mDocType == "9")
                        {
                            this.customLabelError.Text    = "Item is not eligible for Charge off.";
                            this.customLabelError.Visible = true;
                            return(retval);
                        }
                        else if (item.Icn.Substring(Icn.ICN_LENGTH - 1) != "0")
                        {
                            this.customLabelError.Text    = "Item is not eligible for Charge off.";
                            this.customLabelError.Visible = true;
                            return(retval);
                        }

                        if (item.HoldType == HoldTypes.POLICEHOLD.ToString())
                        {
                            this.customLabelError.Visible = true;
                            this.customLabelError.Text    = "This merchandise is on Police Hold. The Police Hold must be released before the item can be charged off.";
                            return(retval);
                        }
                    }
                    else
                    {
                        return(retval);
                    }
                }
                else
                {
                    item = searchItems[0];
                    if (Item.ItemLocked(item))
                    {
                        MessageBox.Show(Item.ItemLockedMessage);
                        return(retval);
                    }
                }
            }

            if (item != null)
            {
                if (item.HoldType == HoldTypes.POLICEHOLD.ToString())
                {
                    this.customLabelError.Text    = "This merchandise is on Police Hold. The Police Hold must be released before the item can be charged off.";
                    this.customLabelError.Visible = true;
                    return(retval);
                }
                else if (item.mDocType == "9")
                {
                    this.customLabelError.Text    = "Cannot charge off NXT items.";
                    this.customLabelError.Visible = true;
                    return(retval);
                }
                else if (item.Icn.Substring(Icn.ICN_LENGTH - 1) != "0")
                {
                    this.customLabelError.Text    = "Cannot charge off sub items.";
                    this.customLabelError.Visible = true;
                    return(retval);
                }
                else if (int.Parse(this.txtQty.Text) > item.Quantity)
                {
                    this.customLabelError.Text    = item.Quantity + " items were found for this CACC category.  Please revise the charge off quantity.";
                    this.customLabelError.Visible = true;

                    this.continueButton.Enabled = false;

                    return(retval);
                }
                else
                {
                    //if (txtQty.Visible)
                    if (isCACC(this.txtICN.Text))
                    {
                        decimal qtyText = 0;

                        if (decimal.TryParse(txtQty.Text, out qtyText) && (item.Quantity > 0))
                        {
                            //do we need to check to make sure DB didn't give us 0 or null
                            decimal qtyRatio = (qtyText / Convert.ToDecimal(item.Quantity));
                            item.ItemAmount = item.PfiAmount * qtyRatio;
                        }
                        item.Quantity = int.Parse(this.txtQty.Text);
                    }

                    ChargeOffDetails detailsForm = new ChargeOffDetails
                    {
                        ChargeOffItem = item
                    };
                    detailsForm.ShowDialog();

                    retval      = (detailsForm.DialogResult == DialogResult.OK);
                    txtICN.Text = string.Empty;
                }
            }

            return(retval);
        }