public override void SetOpened(bool opened)
 {
     if (drawer == null)
     {
         drawer = (CashDrawer)PosCommon;
     }
 }
Beispiel #2
1
        public ActionResult Create(CashDrawer item)
        {
            if (!ModelState.IsValid)
                return PartialView ("_Create", item);

            item.Store = Store.Find (item.StoreId);

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return PartialView ("_CreateSuccesful", item);
        }
Beispiel #3
1
        public ActionResult Edit(CashDrawer item)
        {
            if (!ModelState.IsValid)
                return PartialView ("_Edit", item);

            var entity = CashDrawer.Find (item.Id);

            entity.Code = item.Code;
            entity.Name = item.Name;
            entity.Comment = item.Comment;

            using (var scope = new TransactionScope ()) {
                entity.UpdateAndFlush ();
            }

            return PartialView ("_Refresh");
        }
        public void Put(int id, [FromBody] CashDrawer cashDrawer)
        {
            var cashDrawerToUpdate = _uow.CashDrawerRepository.GetById(id);

            _uow.CashDrawerRepository.Update(cashDrawerToUpdate);
            _uow.Save();
        }
 public CashPayment(double g, MainWindow win)
 {
     goal = g;
     InitializeComponent();
     TextTotal.Text = total.ToString("C");
     cs             = win.Dr;
 }
        public void MakeChangeShouldReturnCorrectChange(double change, double total, int pen, int nick, int dimes, int quart, int hd, int dol, int ones, int twos, int fives, int tens, int twen, int fift, int hund)
        {
            CashDrawer.ResetDrawer();

            var rvm = new RegisterViewModel();

            rvm.PenniesFromCustomer     = pen;
            rvm.NickelsFromCustomer     = nick;
            rvm.DimesFromCustomer       = dimes;
            rvm.QuartersFromCustomer    = quart;
            rvm.HalfDollarsFromCustomer = hd;
            rvm.DollarsFromCustomer     = dol;
            rvm.OnesFromCustomer        = ones;
            rvm.TwosFromCustomer        = twos;
            rvm.FivesFromCustomer       = fives;
            rvm.TensFromCustomer        = tens;
            rvm.TwentiesFromCustomer    = twen;
            rvm.FiftiesFromCustomer     = fift;
            rvm.HundredsFromCustomer    = hund;

            rvm.MakeChange(total);

            double actualChange = (rvm.PenniesAsChange * 0.01) + (rvm.NickelsAsChange * 0.05) + (rvm.DimesAsChange * 0.1) +
                                  (rvm.QuartersAsChange * 0.25) + (rvm.HalfDollarsAsChange * 0.5) + (rvm.DollarsAsChange * 1) +
                                  (rvm.OnesAsChange * 1) + (rvm.TwosAsChange * 2) + (rvm.FivesAsChange * 5) + (rvm.TensAsChange * 10) +
                                  (rvm.TwentiesAsChange * 20) + (rvm.FiftiesAsChange * 50) + (rvm.HundredsAsChange * 100);

            Assert.Equal(change, actualChange);
        }
        public void TotalAmountFromCustomerShouldEqualTotalAmount(int pen, int nick, int dimes, int quart, int hd, int dol, int ones, int twos, int fives, int tens, int twen, int fift, int hund)
        {
            CashDrawer.ResetDrawer();

            double total = (pen * 0.01) + (nick * 0.05) + (dimes * 0.1) + (quart * 0.25) + (hd * 0.5) + (dol * 1) + (ones * 1) + (twos * 2) + (fives * 5) + (tens * 10) + (twen * 20) + (fift * 50) + (hund * 100);

            total = Math.Round(total, 2);
            var rvm = new RegisterViewModel();

            rvm.PenniesFromCustomer     = pen;
            rvm.NickelsFromCustomer     = nick;
            rvm.DimesFromCustomer       = dimes;
            rvm.QuartersFromCustomer    = quart;
            rvm.HalfDollarsFromCustomer = hd;
            rvm.DollarsFromCustomer     = dol;
            rvm.OnesFromCustomer        = ones;
            rvm.TwosFromCustomer        = twos;
            rvm.FivesFromCustomer       = fives;
            rvm.TensFromCustomer        = tens;
            rvm.TwentiesFromCustomer    = twen;
            rvm.FiftiesFromCustomer     = fift;
            rvm.HundredsFromCustomer    = hund;

            Assert.Equal(Math.Round(rvm.TotalAmountFromCustomer(), 2), total);
        }
        public OPOSCashDrawerServer(string deviceName)
        {
            PosExplorer      myPosExplorer = new PosExplorer();
            DeviceCollection myDevices     = myPosExplorer.GetDevices(DeviceType.CashDrawer);

            try
            {
                foreach (DeviceInfo devInfo in myDevices)
                {
                    if (devInfo.ServiceObjectName == deviceName)
                    {
                        _cashDrawer = myPosExplorer.CreateInstance(devInfo) as CashDrawer;

                        //open
                        _cashDrawer.Open();

                        //claim the printer for use
                        _cashDrawer.Claim(CLAIM_TIMEOUT_MS);

                        //make sure it is enabled
                        _cashDrawer.DeviceEnabled = true;
                    }
                }

                if (_cashDrawer == null)
                {
                    throw new Exception("No Cash Drawer Available!");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("No Cash Drawer Available!");
            }
        }
 public MainWindow()
 {
     InitializeComponent();
     cashdrawer              = new CashDrawer();
     orderControl            = new OrderControl();
     screenHousingmain.Child = orderControl;
 }
Beispiel #10
0
        /// <summary>
        /// Finalizes the sale and takes user money and gives user change
        /// </summary>
        public void FinalizeSale()
        {
            CashDrawer.OpenDrawer();
            Pennies     += uPennies;
            Nickels     += uNickels;
            Dimes       += uDimes;
            Quarters    += uQuarters;
            HalfDollars += uHalfDollars;
            Dollars     += uDollars;

            Ones     += uOnes;
            Twos     += uTwos;
            Fives    += uFives;
            Tens     += uTens;
            Twenties += uTwenties;
            Fifties  += uFifties;
            Hundreds += uHundreds;

            Pennies     -= changePennies;
            Nickels     -= changeNickels;
            Dimes       -= changeDimes;
            Quarters    -= changeQuarters;
            HalfDollars -= changeHalfDollars;
            Dollars     -= changeDollars;

            Ones     -= changeOnes;
            Twos     -= changeTwos;
            Fives    -= changeFives;
            Tens     -= changeTens;
            Twenties -= changeTwenties;
            Fifties  -= changeFifties;
            Hundreds -= changeHundreds;
        }
Beispiel #11
0
        /// <summary>
        /// Creates the default cash drawer.
        /// </summary>
        /// <param name="instance">Specifies the cash drawer instance that should be used.</param>
        /// <returns>True if the cash drawer was created, false otherwise.</returns>
        private async Task <bool> CreateDefaultCashDrawerObject(CashDrawerInstance instance)
        {
            rootPage.NotifyUser("Creating cash drawer object.", NotifyType.StatusMessage);

            CashDrawer tempDrawer = null;

            tempDrawer = await DeviceHelpers.GetFirstCashDrawerAsync();

            if (tempDrawer == null)
            {
                rootPage.NotifyUser("Cash drawer not found. Please connect a cash drawer.", NotifyType.ErrorMessage);
                return(false);
            }

            switch (instance)
            {
            case CashDrawerInstance.Instance1:
                cashDrawerInstance1 = tempDrawer;
                break;

            case CashDrawerInstance.Instance2:
                cashDrawerInstance2 = tempDrawer;
                break;

            default:
                return(false);
            }

            return(true);
        }
 /// <summary>
 /// Sets up the transaction control
 /// </summary>
 /// <param name="dc"></param>
 /// <param name="co"></param>
 public TransactionControl(CashDrawer dc, OrderControl co)
 {
     DataContext = this;
     InitializeComponent();
     cd                = dc;
     oc                = co;
     ord               = oc.DataContext as Order;
     Subtotal          = ord.Subtotal;
     Tax               = ord.Tax;
     Total             = ord.Total;
     CashPay.IsEnabled = false;
     LeftToPay         = Total;
     Items             = ord.Items;
     OrderNumber       = ord.OrderNumber;
     foreach (IOrderItem i in Items)
     {
         OrderList.Items.Add(i.ToString());
         PriceBox.Items.Add(i.Price.ToString("C2"));
         foreach (string s in i.SpecialInstructions)
         {
             OrderList.Items.Add(s);
             PriceBox.Items.Add("");
         }
     }
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Tax"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Total"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("OrderNumber"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LeftToPay"));
 }
 async Task <bool> CreateDeviceList_OneTime(Type[] deviceClasses)
 {
     foreach (Type ty in deviceClasses)
     {
         DeviceInformationCollection deviceList = null;
         if (ty == typeof(BarcodeScanner))
         {
             deviceList = await DeviceInformation.FindAllAsync(BarcodeScanner.GetDeviceSelector());
         }
         else if (ty == typeof(PosPrinter))
         {
             deviceList = await DeviceInformation.FindAllAsync(PosPrinter.GetDeviceSelector());
         }
         else if (ty == typeof(CashDrawer))
         {
             deviceList = await DeviceInformation.FindAllAsync(CashDrawer.GetDeviceSelector());
         }
         else if (ty == typeof(MagneticStripeReader))
         {
             deviceList = await DeviceInformation.FindAllAsync(MagneticStripeReader.GetDeviceSelector());
         }
         else if (ty == typeof(LineDisplay))
         {
             deviceList = await DeviceInformation.FindAllAsync(LineDisplay.GetDeviceSelector());
         }
         AddToSelectionList(ty, deviceList);
     }
     return(true);
 }
Beispiel #14
0
        public void OpenCashDrawer(bool IsWaited = false)
        {
            try
            {
                string strLogicalName = "CashDrawer";

                //PosExplorerを生成します。
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;

                deviceInfo = posExplorer.GetDevice(DeviceType.CashDrawer, strLogicalName);
                m_Drawer   = (CashDrawer)posExplorer.CreateInstance(deviceInfo);
                try
                {
                    // m_Drawer.DeviceEnabled = true;
                }
                catch { }
                m_Drawer.Open();

                m_Drawer.Claim(1000);

                //デバイスを使用可能(動作できる状態)にします。

                m_Drawer.DeviceEnabled = true;
            }
            catch (PosControlException)
            {
            }
            m_Drawer.OpenDrawer();

            // ドロワーが開いている間、待ちます。

            while (m_Drawer.DrawerOpened == false)
            {
                System.Threading.Thread.Sleep(100);
            }

            //開いてから10秒間経っても閉じられない場合はビープ音を断続的に鳴らします。

            //このメソッドを実行すると、ドロワーが閉じられるまで処理が戻ってこないので注意してください。

            if (IsWaited)
            {
                m_Drawer.WaitForDrawerClose(10000, 2000, 100, 1000);
            }

            try
            {
                CloseCashDrawer();
            }
            catch
            {
                try
                {
                    m_Drawer = null;
                }
                catch { }
            }
        }
Beispiel #15
0
 public OrderControl()
 {
     InitializeComponent();
     cancelOrder.Click   += OnCancelOrder_Click;
     completeOrder.Click += OnCompleteOrder_Click;
     cd = new CashDrawer();
 }
        public void SettingBillsShouldNotifyProperties()
        {
            CashDrawer.ResetDrawer();
            var ord = new Order();

            ord.Add(new PhillyPoacher());
            var cvm = new CashViewModel(ord);

            Assert.PropertyChanged(cvm, "Pennies", () =>
            {
                cvm.Pennies += 1;
            });
            Assert.PropertyChanged(cvm, "AmountTendered", () =>
            {
                cvm.Ones += 1;
            });
            Assert.PropertyChanged(cvm, "AmountDue", () =>
            {
                cvm.Nickels += 1;
            });
            Assert.PropertyChanged(cvm, "AmountOwed", () =>
            {
                cvm.Twenties += 1;
            });
            Assert.PropertyChanged(cvm, "FiftiesOwed", () =>
            {
                cvm.Fifties += 1;
            });
        }
        public void Change(CashDrawer d, double change)
        {
            int penniesCount     = 0;
            int nickelsCount     = 0;
            int dimesCount       = 0;
            int quartersCount    = 0;
            int halfDollarsCount = 0;
            int dollarsCount     = 0;
            int onesCount        = 0;
            int twosCount        = 0;
            int fivesCount       = 0;
            int tensCount        = 0;
            int twentiesCount    = 0;
            int fiftiesCount     = 0;
            int hundredsCount    = 0;

            while (change != 0)
            {
                //find highest denomination
                //change -= (denomination);
                //switch denomination needed, cases increment related count
            }
            //check if drawer has the change
            //display change needed
        }
Beispiel #18
0
        /// <summary>
        /// Resets the display elements to original state
        /// </summary>
        private void ResetScenarioState()
        {
            if (claimedCashDrawerInstance1 != null)
            {
                claimedCashDrawerInstance1.Dispose();
                claimedCashDrawerInstance1 = null;
            }

            if (claimedCashDrawerInstance2 != null)
            {
                claimedCashDrawerInstance2.Dispose();
                claimedCashDrawerInstance2 = null;
            }

            if (cashDrawerInstance1 != null)
            {
                cashDrawerInstance1.Dispose();
                cashDrawerInstance1 = null;
            }

            if (cashDrawerInstance2 != null)
            {
                cashDrawerInstance2.Dispose();
                cashDrawerInstance2 = null;
            }

            ClaimButton1.IsEnabled    = true;
            ClaimButton2.IsEnabled    = true;
            ReleaseButton1.IsEnabled  = false;
            ReleaseButton2.IsEnabled  = false;
            RetainCheckBox1.IsChecked = true;
            RetainCheckBox2.IsChecked = true;

            rootPage.NotifyUser("Click a claim button to begin.", NotifyType.StatusMessage);
        }
Beispiel #19
0
 /// <summary>
 /// Constuctor initilizes component and creates the datacontext for the ordercontrol
 /// </summary>
 public OrderControl()
 {
     InitializeComponent();
     order            = new Order(0);
     this.DataContext = order;
     cashDrawer       = new CashDrawer();
 }
Beispiel #20
0
        /// <summary>
        /// Event callback for a release device request for instance 2.
        /// </summary>
        /// <param name="sender">The drawer receiving the release device request.</param>
        /// <param name="e">Unused for ReleaseDeviceRequested events.</param>
        private async void claimedCashDrawerInstance2_ReleaseDeviceRequested(ClaimedCashDrawer drawer, object e)
        {
            await MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
            {
                rootPage.NotifyUser("Release instance 2 requested.", NotifyType.StatusMessage);

                if (RetainCheckBox2.IsChecked == true)
                {
                    if (await claimedCashDrawerInstance2.RetainDeviceAsync() == false)
                    {
                        rootPage.NotifyUser("Cash drawer instance 2 retain failed.", NotifyType.ErrorMessage);
                    }
                }
                else
                {
                    claimedCashDrawerInstance2.Dispose();
                    claimedCashDrawerInstance2 = null;

                    if (cashDrawerInstance2 != null)
                    {
                        cashDrawerInstance2.Dispose();
                        cashDrawerInstance2 = null;
                    }

                    SetReleasedUI(CashDrawerInstance.Instance2);
                }
            });
        }
        public TestTransControl(CashDrawer cd, OrderControl o)
        {
            DataContext = this;
            InitializeComponent();

            oc = o;
            Order or = (Order)o.DataContext;

            /* Cash should not be able to complete until enough has been received */
            CompleteCashButton.IsEnabled = false;

            /* Assign the cash drawer instance */
            this.cd = cd;

            /* Get the important stuff out of the order */
            PrevOrderNumber = or.OrderNumber;
            Items           = or.Items;

            /* Do some quick maffs */
            Subtotal     = or.Subtotal;
            Tax          = Subtotal * .16;
            TotalWithTax = Subtotal + Tax;

            /* How much do we need to charge the customer? */
            AmountLeftToTender = TotalWithTax;

            /* Let the xaml know that we updated properties */
            PopulateItemsStackPanel();
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Tax"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TotalWithTax"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AmountLeftToTender"));
        }
        /// <summary>
        /// Creates a receipt
        /// </summary>
        /// <param name="data">The order being billed.</param>
        /// <param name="register">The amount being handled</param>
        /// <returns>A receipt.</returns>
        private string CreateCashReceipt(Order data, CashDrawer register)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("***********************************************************\n");
            sb.Append("Order NO: " + data.OrderNumber + "\n");
            sb.Append("Time: " + DateTime.Now.ToString() + "\n");
            sb.Append("****************************\n");

            foreach (var i in data.Items)
            {
                sb.Append(i.ToString() + "\t\t");
                sb.Append(i.Price + "\n");
                if (i.SpecialInstructions != null)
                {
                    for (int x = 0; x < i.SpecialInstructions.Count; x++)
                    {
                        sb.Append("\t" + i.SpecialInstructions[x].ToString() + "\n");
                    }
                }
            }
            sb.Append("****************************\n");
            sb.Append("Subtotal:\t\t" + data.Subtotal + "\n");
            sb.Append("Tax:\t\t\t" + (data.Subtotal * 0.16) + "\n");
            sb.Append("Total:\t\t\t" + data.Total + "\n");
            sb.Append("Paid:\t\t\t" + register.Paid);
            sb.Append("Change:\t\t\t" + register.Change);
            sb.Append("****************************\n");
            return(sb.ToString());
        }
Beispiel #23
0
        private void Panel_Empleados_Load(object sender, EventArgs e)
        {
            //<<< step1 >>> --Start
            //Use a Logical Device Name which has been set on the SetupPOS.
            string strLogicalName = "CashDrawer";

            try
            {
                //Create PosExplorer
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;

                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.CashDrawer, strLogicalName);
                    m_Drawer   = (CashDrawer)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception)
                {
                    //Nothing can be used.
                    return;
                }
            }
            catch (PosControlException)
            {
                //Nothing can be used.
                //Nothing can be used.
            }
            //<<<step1>>>--End
        }
Beispiel #24
0
 public override void SetOpened(bool opened)
 {
     if (drawer == null)
     {
         drawer = (CashDrawer)PosCommon;
     }
 }
Beispiel #25
0
        public CashDrawerClass()
        {
            explorer = new PosExplorer(this);
            DeviceInfo ObjDevicesInfo = explorer.GetDevice("CashDrawer");

            myCashDrawer = explorer.CreateInstance(ObjDevicesInfo);
        }
Beispiel #26
0
        private static void InitializeCashDrawer2()
        {
            DeviceCollection cashDrawerList = CashDrawerDeviceCollection;

            if (cashDrawerList.Count > 0)
            {
                try
                {
                    DeviceInfo cashDrawer = GetActiveDeviceInfo(cashDrawerList,
                                                                "CashDrawerName2", true);
                    if (cashDrawer != null)
                    {
                        activeCashDrawer2 = (CashDrawer)explorer.CreateInstance(cashDrawer);
                        activeCashDrawer2.Open();
                        activeCashDrawer2.Claim(1000);
                        activeCashDrawer2.DeviceEnabled = true;
                    }
                }
                catch (PosControlException)
                {
                    // Log error and set the active to nil
                    activeCashDrawer2 = null;
                    Logger.Error("InitializePosDevices", Strings.InitializationException);
                }
            }
        }
Beispiel #27
0
 /// <summary>
 /// Event handler for finalizing the sale
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void FinalizeSaleClick(object sender, RoutedEventArgs e)
 {
     cmv.FinalizeCashTransaction(); //opens drawer
     cmv.PrintReceipt();
     CashDrawer.ResetDrawer();
     DataContext = new Order();
 }
        public void ShouldCalculateCorrectChange(double changeDue, int payment)
        {
            CashDrawer.ResetDrawer();
            Order                 order = new Order();
            BriarheartBurger      bb    = new BriarheartBurger();
            MarkarthMilk          mm    = new MarkarthMilk();
            DragonbornWaffleFries dwf   = new DragonbornWaffleFries();

            order.Add(bb);
            order.Add(mm);
            order.Add(dwf);
            CashRegisterViewModel crv = new CashRegisterViewModel(order, null);

            crv.ChangeOwedToCustomer();
            crv.PaymentHundreds = payment;

            Assert.Equal(changeDue, Math.Round(crv.ChangeDue, 2));
            Assert.Equal(0, crv.ChangeHundreds);
            Assert.Equal(0, crv.ChangeFifties);
            Assert.Equal(4, crv.ChangeTwenties);
            Assert.Equal(1, crv.ChangeTens);
            Assert.Equal(0, crv.ChangeFives);
            Assert.Equal(0, crv.ChangeTwos);
            Assert.Equal(1, crv.ChangeOnes);
            Assert.Equal(0, crv.ChangeDollarCoins);
            Assert.Equal(0, crv.ChangeHalfDollars);
            Assert.Equal(1, crv.ChangeQuarters);
            Assert.Equal(0, crv.ChangeDimes);
            Assert.Equal(0, crv.ChangeNickles);
            Assert.Equal(2, crv.ChangePennies);
        }
Beispiel #29
0
        public ActionResult LocalSettings(LocalSettings item)
        {
            item.Store       = Store.TryFind(item.StoreId);
            item.PointOfSale = PointOfSale.TryFind(item.PointOfSaleId);
            item.CashDrawer  = CashDrawer.TryFind(item.CashDrawerId.GetValueOrDefault());

            if (!ModelState.IsValid)
            {
                return(View(item));
            }

            Response.Cookies.Add(new HttpCookie(WebConfig.StoreCookieKey)
            {
                Value   = item.Store.Id.ToString(),
                Expires = DateTime.Now.AddYears(100)
            });

            if (item.PointOfSale != null)
            {
                Response.Cookies.Add(new HttpCookie(WebConfig.PointOfSaleCookieKey)
                {
                    Value   = item.PointOfSale.Id.ToString(),
                    Expires = DateTime.Now.AddYears(100)
                });
            }
            else
            {
                if (Request.Cookies [WebConfig.PointOfSaleCookieKey] != null)
                {
                    Response.Cookies.Add(new HttpCookie(WebConfig.PointOfSaleCookieKey)
                    {
                        Value   = string.Empty,
                        Expires = DateTime.Now.AddDays(-1d)
                    });
                }
            }

            if (item.CashDrawer != null)
            {
                Response.Cookies.Add(new HttpCookie(WebConfig.CashDrawerCookieKey)
                {
                    Value   = item.CashDrawer.Id.ToString(),
                    Expires = DateTime.Now.AddYears(100)
                });
            }
            else
            {
                if (Request.Cookies [WebConfig.CashDrawerCookieKey] != null)
                {
                    Response.Cookies.Add(new HttpCookie(WebConfig.CashDrawerCookieKey)
                    {
                        Value   = string.Empty,
                        Expires = DateTime.Now.AddDays(-1d)
                    });
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #30
0
 /// <summary>
 /// Event callback for device status updates.
 /// </summary>
 /// <param name="drawer">CashDrawer object sending the status update event.</param>
 /// <param name="e">Event data associated with the status update.</param>
 private async void drawer_StatusUpdated(CashDrawer drawer, CashDrawerStatusUpdatedEventArgs e)
 {
     await MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         UpdateStatusOutput(e.Status.StatusKind);
         rootPage.NotifyUser("Status updated event: " + e.Status.StatusKind.ToString(), NotifyType.StatusMessage);
     });
 }
        public void DollarCoinShouldBeDollarCoin()
        {
            CashDrawer.OpenDrawer();
            RegisterFunction register = new RegisterFunction(new Order());

            Assert.Equal(register.DollarCoin, CashDrawer.Dollars);
            CashDrawer.ResetDrawer();
        }
        public void OnesShouldBeOnes()
        {
            CashDrawer.OpenDrawer();
            RegisterFunction register = new RegisterFunction(new Order());

            Assert.Equal(register.Ones, CashDrawer.Ones);
            CashDrawer.ResetDrawer();
        }
        public void HundredsShouldBeHundreds()
        {
            CashDrawer.OpenDrawer();
            RegisterFunction register = new RegisterFunction(new Order());

            Assert.Equal(register.Hundreds, CashDrawer.Hundreds);
            CashDrawer.ResetDrawer();
        }
        /// <summary>
        /// Creates the default cash drawer.
        /// </summary>
        /// <param name="instance">Specifies the cash drawer instance that should be used.</param>
        /// <returns>True if the cash drawer was created, false otherwise.</returns>
        private async Task<bool> CreateDefaultCashDrawerObject(CashDrawerInstance instance)
        {
            rootPage.NotifyUser("Creating cash drawer object.", NotifyType.StatusMessage);

            CashDrawer tempDrawer = null;
            tempDrawer = await CashDrawer.GetDefaultAsync();

            if (tempDrawer == null)
            {
                rootPage.NotifyUser("Cash drawer not found. Please connect a cash drawer.", NotifyType.ErrorMessage);
                return false;
            }

            switch (instance)
            {
                case CashDrawerInstance.Instance1:
                    cashDrawerInstance1 = tempDrawer;
                    break;
                case CashDrawerInstance.Instance2:
                    cashDrawerInstance2 = tempDrawer;
                    break;
                default:
                    return false;
            }

            return true;
        }
 public CashDrawerEvents(CashDrawer This)
 {
     this.This = This;
 }
        /// <summary>
        /// Reset the scenario to its initial state.
        /// </summary>
        private void ResetScenarioState()
        {
            drawer = null;

            if (claimedDrawer != null)
            {
                claimedDrawer.Dispose();
                claimedDrawer = null;
            }

            UpdateStatusOutput(CashDrawerStatusKind.Offline);

            InitDrawerButton.IsEnabled = true;
            DrawerWaitButton.IsEnabled = false;

            rootPage.NotifyUser("Click the init drawer button to begin.", NotifyType.StatusMessage);
        }
        /// <summary>
        /// Creates the default cash drawer.
        /// </summary>
        /// <returns>True if the cash drawer was created, false otherwise.</returns>
        private async Task<bool> CreateDefaultCashDrawerObject()
        {
            rootPage.NotifyUser("Creating cash drawer object.", NotifyType.StatusMessage);

            if (drawer == null)
            {
                drawer = await CashDrawer.GetDefaultAsync();
                if (drawer == null)
                    return false;
            }

            return true;
        }
        /// <summary>
        /// Reset the scenario to its initial state.
        /// </summary>
        private void ResetScenarioState()
        {
            drawer = null;

            if (claimedDrawer != null)
            {
                claimedDrawer.Dispose();
                claimedDrawer = null;
            }

            InitDrawerButton.IsEnabled = true;
            OpenDrawerButton.IsEnabled = false;

            rootPage.NotifyUser("Click the init drawer button to begin.", NotifyType.StatusMessage);
        }
 /// <summary>
 /// Event callback for claim instance 2 button.
 /// </summary>
 /// <param name="sender">Button that was clicked.</param>
 /// <param name="e">Event data associated with click event.</param>
 private async void ClaimButton2_Click(object sender, RoutedEventArgs e)
 {
     if (await CreateDefaultCashDrawerObject(CashDrawerInstance.Instance2))
     {
         if (await ClaimCashDrawer(CashDrawerInstance.Instance2))
         {
             claimedCashDrawerInstance2.ReleaseDeviceRequested += claimedCashDrawerInstance2_ReleaseDeviceRequested;
             SetClaimedUI(CashDrawerInstance.Instance2);
         }
         else
         {
             cashDrawerInstance2 = null;
         }
     }
 }
        /// <summary>
        /// Resets the display elements to original state
        /// </summary>
        private void ResetScenarioState()
        {
            cashDrawerInstance1 = null;
            cashDrawerInstance2 = null;

            if (claimedCashDrawerInstance1 != null)
            {
                claimedCashDrawerInstance1.Dispose();
                claimedCashDrawerInstance1 = null;
            }

            if (claimedCashDrawerInstance2 != null)
            {
                claimedCashDrawerInstance2.Dispose();
                claimedCashDrawerInstance2 = null;
            }

            ClaimButton1.IsEnabled = true;
            ClaimButton2.IsEnabled = true;
            ReleaseButton1.IsEnabled = false;
            ReleaseButton2.IsEnabled = false;
            RetainCheckBox1.IsChecked = true;
            RetainCheckBox2.IsChecked = true;

            rootPage.NotifyUser("Click a claim button to begin.", NotifyType.StatusMessage);
        }
 /// <summary>
 /// Event callback for device status updates.
 /// </summary>
 /// <param name="drawer">CashDrawer object sending the status update event.</param>
 /// <param name="e">Event data associated with the status update.</param>
 private async void drawer_StatusUpdated(CashDrawer drawer, CashDrawerStatusUpdatedEventArgs e)
 {
     await MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         UpdateStatusOutput(e.Status.StatusKind);
         rootPage.NotifyUser("Status updated event: " + e.Status.StatusKind.ToString(), NotifyType.StatusMessage);
     });
 }