/// <summary>
        /// Loads this instance.
        /// </summary>
        public void Load()
        {
            BaseController.CalcCharges();

            BetteryVend betteryVend = BaseController.SelectedBettery;

            //if (BaseController.GetBatteriesMode == GetBatteriesModes.BuyNew)
            //{
            AATextbox.Text  = betteryVend.AaVend.ToString();
            AAATextbox.Text = betteryVend.AaaVend.ToString();

            AAPrice.Text  = string.Format(Constants.Messages.PriceMessage, betteryVend.CalculatedAaAmount);
            AAAPrice.Text = string.Format(Constants.Messages.PriceMessage, betteryVend.CalculatedAaaAmount);

            TotalCartridge.Text         = betteryVend.TotalVendCartridges.ToString();
            PurchaseSubtotalAmount.Text = string.Format(Constants.Messages.PriceMessage, betteryVend.SubSubTotalAmount);

            //}
            //else
            //{
            //    AATextbox.Text = betteryVend.AaForgotDrainedVend.ToString();
            //    AAATextbox.Text = betteryVend.AaaForgotDrainedVend.ToString();

            //    AAPrice.Text = string.Format(Constants.Messages.PriceMessage, betteryVend.AaNewForgotDrainedAmount);
            //    AAAPrice.Text = string.Format(Constants.Messages.PriceMessage, betteryVend.AaaNewForgotDrainedAmount);

            //    TotalCartridge.Text = betteryVend.TotalForgotDrainedVendCartridges.ToString();
            //}

            PopulateCreditAndTotal();
        }
예제 #2
0
        /// <summary>
        /// Authenticates the user.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <returns></returns>
        public static bool?AuthenticateUser(string userName, string password)
        {
            BetteryMember betteryMember;

            using (KioskServiceClient bKioskService = new KioskServiceClient())
            {
                try
                {
                    betteryMember = bKioskService.AuthenticateUser(userName, password);
                }
                catch (Exception ex)
                {
                    Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                    BaseController.RaiseOnThrowExceptionEvent();

                    return(null);
                }
                finally
                {
                    bKioskService.Close();
                }
            }

            if (betteryMember != null)
            {
                BaseController.LoggedOnUser = new BetteryUser(userName, password)
                {
                    BatteriesCheckedOut = betteryMember.BatteryPacksCheckedOut,
                    BatteriesInPlan     = betteryMember.BatteryPacksInPlan,
                    CustomerProfileId   = betteryMember.CustomerProfileID,
                    PaymentProfileId    = betteryMember.PaymentProfileID,
                    FreeCasesRemaining  = betteryMember.FreeCases,
                    Email                  = userName,
                    MemberFirstName        = betteryMember.MemberFirstName,
                    MemberId               = betteryMember.MemberID,
                    MemberLastName         = betteryMember.MemberLastName,
                    MemberTotalBatteries   = betteryMember.MemberTotalBatteries,
                    OutstandingCredit      = betteryMember.AccountBalance,
                    CCOnFileExPireDate     = betteryMember.CCExPireDate,
                    CCOnFileLastFourDigits = betteryMember.CCLastFourDigits,
                    GroupID                = betteryMember.GroupID
                };

                BaseController.LoggedOnUser.NewBatteriesInPlan = BaseController.LoggedOnUser.BatteriesInPlan;

                if (OnLogin != null)
                {
                    //Reset selection amount
                    if (BaseController.LoggedOnUser.BatteriesInPlan > 0)
                    {
                        if (BaseController.SelectedBettery != null)
                        {
                            BaseController.CalcCharges(0, 0, BaseController.GetBatteriesMode);

                            if (BaseController.RecentViewOfCurrentFlow == Constants.ViewName.Checkout || BaseController.RecentViewOfCurrentFlow == Constants.ViewName.TransactionSummary || BaseController.RecentViewOfCurrentFlow == Constants.ViewName.CreditSwap)
                            {
                                if (BaseController.SelectedBettery.ReturnedCartridges > 0)
                                {
                                    BaseController.RecentViewOfCurrentFlow = Constants.ViewName.GetBatteries;
                                }
                                else
                                {
                                    BaseController.RecentViewOfCurrentFlow = Constants.ViewName.Selection;
                                }
                            }
                        }
                    }

                    OnLogin.Invoke(null, EventArgs.Empty);
                }

                return(true);
            }

            return(false);
        }
예제 #3
0
        /// <summary>
        /// Called when [batteries amount changed].
        /// </summary>
        private void OnBatteriesAmountChanged()
        {
            BaseController.CalcCharges(_aa, _aaa, BaseController.GetBatteriesMode);

            bool isReachedAALimit  = _aa >= _maxAaProduct;
            bool isReachedAAALimit = _aaa >= _maxAaaProduct;


            AAPlus.IsEnabled  = (!isReachedAALimit && !isReachedLimitPlan);
            AAAPlus.IsEnabled = (!isReachedAAALimit && !isReachedLimitPlan);

            // User has requested the max batteries in inventory?
            if (isReachedAALimit)
            {
                LimitAaMessageTextBlock.Visibility = Visibility.Visible;
                LimitAaMessageTextBlock.Text       = Constants.Messages.LimitedBatteries;
            }
            // Subscription plan limit, un-used code branch?
            else if (isReachedLimitPlan)
            {
                LimitAaMessageTextBlock.Visibility = Visibility.Visible;
                if (BaseController.GetBatteriesMode == GetBatteriesModes.BuyNew)
                {
                    LimitAaMessageTextBlock.Text = Constants.Messages.LimitedBatteriesInPlan;
                }
                else
                {
                    LimitAaMessageTextBlock.Text = Constants.Messages.LimitedBatteriesCheckedOut;
                }
            }
            else
            {
                LimitAaMessageTextBlock.Visibility = Visibility.Hidden;
            }

            // User has requested the max batteries in inventory?
            if (isReachedAAALimit)
            {
                LimitAaaMessageTextBlock.Visibility = Visibility.Visible;
                LimitAaaMessageTextBlock.Text       = Constants.Messages.LimitedBatteries;
            }
            // Subscription plan limit, un-used code branch?
            else if (isReachedLimitPlan)
            {
                LimitAaaMessageTextBlock.Visibility = Visibility.Visible;
                if (BaseController.GetBatteriesMode == GetBatteriesModes.BuyNew)
                {
                    LimitAaaMessageTextBlock.Text = Constants.Messages.LimitedBatteriesInPlan;
                }
                else
                {
                    LimitAaaMessageTextBlock.Text = Constants.Messages.LimitedBatteriesCheckedOut;
                }
            }
            else
            {
                LimitAaaMessageTextBlock.Visibility = Visibility.Hidden;
            }

            AAMinus.IsEnabled  = _aa > 0;
            AAAMinus.IsEnabled = _aaa > 0;

            // Update view
            if (BaseController.GetBatteriesMode == GetBatteriesModes.BuyNew)
            {
                ReturnMessage.Text      = Constants.Messages.YouHaveReturnMessage;                                                                                         //Unused ??  This is blank in the constants file
                ValueReturnMessage.Text = string.Format(Constants.Messages.ValueReturnMessage, BaseController.SelectedBettery.ReturnedCartridges);                         //ValueReturnMessage = "You have returned {0} pack(s) of BETTERY batteries.";
                NewSelectMessage.Text   = string.Format(Constants.Messages.NewSelectMessage, BaseController.SelectedBettery.ReturnedCartridges, BaseController.SwapPrice); //NewSelectMessage = "SWAP up to {0} 4-pack(s) of freshly charged batteries at the SWAP price of ${1:N2} per pack.";

                CommitMessage.Visibility = Visibility.Collapsed;                                                                                                           // This means this branch is run when you have not forgotten batteries.  (which is no longer a function we support)
                NewMessage.Visibility    = Visibility.Visible;                                                                                                             // Blank
                ReturnMessage.Visibility = Visibility.Visible;                                                                                                             //Blank
                //NewSelectMessage.Visibility = Visibility.Visible;  //CK, not sure what this was, it would always be visible, even though the branches above turn it on/off

                //
                // CK 1/26/13 - New code branch, hiding too much text if no swaps are available, and simplifying text
                //
                if (BaseController.SelectedBettery.ReturnedCartridges > 0)
                {
                    Message.Text = string.Format(Constants.Messages.BuyNewAdditionalMessage, BaseController.SwapPrice); //BuyNewAdditionalMessage = "Get additional 4-packs for ${1:N2} per pack, with a one-time $5 deposit per pack.";
                    //Message.Text = Constants.Messages.BuyNewAdditionalMessage;
                    ValueReturnMessage.Visibility = Visibility.Visible;
                    NewSelectMessage.Visibility   = Visibility.Visible;
                    Message.Visibility            = Visibility.Visible;
                }
                else
                {
                    Message.Text = string.Format(Constants.Messages.BuyNewMessage, BaseController.SwapPrice); //BuyNewMessage = "Get 4-packs for ${1:N2} per pack, with a one-time $5 deposit per pack.";
                    //Message.Text = Constants.Messages.BuyNewMessage;
                    ValueReturnMessage.Visibility = Visibility.Collapsed;
                    NewSelectMessage.Visibility   = Visibility.Collapsed;
                    Message.Visibility            = Visibility.Visible;
                }
            }
            else
            {
                //
                //  CK 1/6/13 - this whole branch should never run, since we have disabled the forgot batteries button.
                //
                Message.Visibility            = Visibility.Collapsed;
                CommitMessage.Text            = string.Format(Constants.Messages.SwapForgotBatteryNotice, _aa, _aaa);
                CommitMessage.Visibility      = Visibility.Visible;
                NewMessage.Visibility         = Visibility.Collapsed;
                NewSelectMessage.Visibility   = Visibility.Collapsed;
                ReturnMessage.Visibility      = Visibility.Collapsed;
                ValueReturnMessage.Visibility = Visibility.Collapsed;
            }

            if (BaseController.SelectedBettery != null && BaseController.SelectedBettery.TotalVendCartridges > 0)
            {
                DoneButton.IsEnabled = true;
            }
            else
            {
                DoneButton.IsEnabled = false;
            }
        }