Beispiel #1
0
        /// <summary>
        /// Prompt to select card type.
        /// </summary>
        /// <param name="cardInfo">If not null, it contains all data, i.e. card number, card name, checkings data etc.</param>
        /// <param name="cardList">The list of card types.</param>
        /// <param name="allowCancel">if set to <c>true</c> [allow cancel].</param>
        public void SelectCardType(ref ICardInfo cardInfo, bool allowCancel, IEnumerable <ICardInfo> cardList)
        {
            using (frmSelectCardType dialog = new frmSelectCardType(cardList, allowCancel))
            {
                this.Application.ApplicationFramework.POSShowForm(dialog);

                if (dialog.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    cardInfo = dialog.SelectedCard;
                }
                else
                {
                    cardInfo = null;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Finds the type of the correct card.
        /// </summary>
        /// <param name="swipedCard">The swiped card.</param>
        /// <param name="allowCancel">if set to <c>true</c> [allow cancel].</param>
        /// <param name="exclusionList">The list of card types to exlcude from search.</param>
        /// <returns>The card info object.</returns>
        private ICardInfo FindCorrectCardType(ICardInfo swipedCard, bool allowCancel, IEnumerable <CardTypes> exclusionList)
        {
            ICardInfo result = null;

            Int64 binTo         = 0;
            Int64 binFrom       = 0;
            int   binLength     = 0;
            Int64 cardSubString = 0;

            List <ICardInfo> matchingCards = new List <ICardInfo>();

            foreach (ICardInfo cardInfo in cardTypes)
            {
                binTo     = Convert.ToInt64(cardInfo.BinTo);
                binFrom   = Convert.ToInt64(cardInfo.BinFrom);
                binLength = Convert.ToInt32(cardInfo.BinLength);

                string track2Data = LSRetailPosis.Settings.HardwareProfiles.MSR.Track2Data(swipedCard.Track2);
                if (!string.IsNullOrEmpty(track2Data))
                {
                    if (track2Data.Length >= binLength)
                    {
                        cardSubString = Convert.ToInt64(track2Data.Substring(0, binLength));
                    }
                }
                else
                {
                    swipedCard.CardNumber = swipedCard.CardNumber.Replace("-", string.Empty);
                    if (swipedCard.CardNumber.Length >= binLength)
                    {
                        cardSubString = Convert.ToInt64(swipedCard.CardNumber.Substring(0, binLength));
                    }
                    else if (swipedCard.CardNumber.Trim().Length != 0)
                    {
                        cardSubString = Convert.ToInt64(swipedCard.CardNumber);
                    }
                    else
                    {
                        cardSubString = 0;
                    }
                }

                if ((binFrom <= cardSubString) &&
                    (cardSubString <= binTo) &&
                    (exclusionList == null || !exclusionList.Contains(cardInfo.CardType)))
                {
                    // The card number is within this bin series and not in exlustion list
                    matchingCards.Add(cardInfo);
                }
            }

            // Select from matching card types
            if (matchingCards.Count == 1)
            {
                // if there is only one, then just auto-select it
                result = matchingCards[0];
            }
            else if (matchingCards.Count > 1)
            {
                // otherwise, pop UI and prompt the user to select a card type.
                using (frmSelectCardType dialog = new frmSelectCardType(matchingCards, allowCancel))
                {
                    this.Application.ApplicationFramework.POSShowForm(dialog);

                    if (dialog.DialogResult == System.Windows.Forms.DialogResult.OK)
                    {
                        result = dialog.SelectedCard;
                    }
                    else
                    {
                        // User hit cancel
                        result          = swipedCard;
                        result.CardType = CardTypes.None;
                    }
                }
            }

            return(result);
        }