Esempio n. 1
0
        /// <summary>
        /// Handles when a reques save cost event has completed.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The even data.</param>
        private void OnRequestSaveCostCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                IsDataModified = false;

                // Refresh the costs
                PopulateCosts(m_pendingCost);
                m_pendingCost = null;

                if (!m_closing)
                {
                    HasSuccess      = true;
                    ProgressMessage = Resources.SaveSuccess;
                }
                else
                {
                    Controller.CloseCurrentView();
                }
            }
            else
            {
                HasSuccess      = false;
                ProgressMessage = Error;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Populates the view model with costs
        /// </summary>
        /// <param name="select">the cost to try to select.</param>
        private void PopulateCosts(SessionCost select)
        {
            List <SessionCost> list = new List <SessionCost>(Controller.SessionCosts);

            Costs = new ListCollectionView(list);
            Costs.SortDescriptions.Add(new SortDescription(CostNameProperty, ListSortDirection.Ascending));
            // Reset the filter
            ShowInactive = ShowInactive;

            SessionCost newSelect = null;

            if (select != null)
            {
                // Find the cost item again and select id
                foreach (SessionCost cost in Costs)
                {
                    if (cost.MasterId == select.MasterId)
                    {
                        newSelect = cost;
                        break;
                    }
                }
            }

            if (newSelect == null && Costs.Count > 0)
            {
                newSelect = (SessionCost)Costs.GetItemAt(0);
            }

            SelectedCost = newSelect;
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new cost
        /// </summary>
        private void NewCost()
        {
            bool proceed = true;

            if (IsDataModified)
            {
                MessageBoxResult result = MessageBoxResult.Cancel;
                if (HasError)
                {
                    result = Controller.ShowObjectModifiedMessage(Resources.ChangedCantSave, false);
                }
                else
                {
                    result = Controller.ShowObjectModifiedMessage(Resources.CostChanged, true);
                }

                if (result == MessageBoxResult.Yes)
                {
                    SaveCost();
                }
                else if (result == MessageBoxResult.Cancel)
                {
                    proceed = false;
                }
            }

            if (proceed)
            {
                SelectedCost = null;
                EditingCost  = new SessionCost();
                RaiseEditingCostChanges();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Saves the cost
 /// </summary>
 private void SaveCost()
 {
     if (m_pendingCost == null)
     {
         m_pendingCost = EditingCost;
     }
     Controller.RequestSaveCost(EditingCost);
 }
Esempio n. 5
0
        /// <summary>
        /// Initializes a SessionCostSelectionViewModel
        /// </summary>
        /// <param name="cost">The session cost.</param>
        public SessionCostSelectionViewModel(SessionCost cost)
        {
            if (cost == null)
            {
                throw new ArgumentNullException("cost");
            }

            m_cost = cost;
        }
Esempio n. 6
0
        /// <summary>
        /// Intializez a SetSessionCostMessage with the associated cost
        /// </summary>
        /// <param name="cost">The cost.</param>
        public SetSessionCost(SessionCost cost)
        {
            if (cost == null)
            {
                throw new ArgumentNullException("cost");
            }

            m_cost = cost;
        }
Esempio n. 7
0
 /// <summary>
 /// Handles when a request cost event has completed
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The event data.</param>
 private void OnRequestCostsCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         // Refresh the costs completed
         PopulateCosts(m_pendingCost);
         m_pendingCost = null;
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Initializes a SessionCostSelectionViewModel
        /// </summary>
        /// <param name="cost">the cost.</param>
        /// <param name="selected">whether the item is selected or not.</param>
        public SessionCostSelectionViewModel(SessionCost cost, bool selected)
        {
            if (m_cost == null)
            {
                throw new ArgumentNullException("cost");
            }

            m_cost     = cost;
            IsSelected = selected;
        }
Esempio n. 9
0
        /// <summary>
        /// Save the cost and closes the window
        /// </summary>
        private void OnCostSave()
        {
            if (IsDataModified)
            {
                List <SessionCost> costList = new List <SessionCost>();
                foreach (SessionCostSelectionViewModel costVM in ChoosenCosts)
                {
                    SessionCost cost = (SessionCost)costVM.Cost.Clone();
                    costList.Add(cost);
                }

                Summary.SessionCosts = costList;
                IsDataModified       = false;
            }

            Controller.CloseCurrentView();
        }
Esempio n. 10
0
        /// <summary>
        /// Releases all resources used by SessionCostsViewModel.
        /// </summary>
        /// <param name="disposing">Whether this function is being called from
        /// user code.</param>
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (disposing)
                {
                    // Set data modified false
                    IsDataModified = false;
                    SelectedCost   = null;
                    Costs          = null;

                    m_pendingCost = null;

                    PropertyChangedEventManager.RemoveListener(Controller, this, string.Empty);
                    Controller.RequestCostsCompleted    -= OnRequestCostsCompleted;
                    Controller.RequestSaveCostCompleted -= OnRequestSaveCostCompleted;
                }

                base.Dispose(disposing);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Unpacks a GetSessionCostsMessage server response.
        /// </summary>
        /// <param name="responseReader">The server response.</param>
        protected override void UnpackResponse(BinaryReader responseReader)
        {
            base.UnpackResponse(responseReader);

            List <SessionCost> costs = new List <SessionCost>();

            uint itemCount = responseReader.ReadUInt32();

            for (int itemIndex = 0; itemIndex < itemCount; ++itemIndex)
            {
                SessionCost cost = new SessionCost();
                cost.Id         = responseReader.ReadInt32();
                cost.MasterId   = responseReader.ReadInt32();
                cost.Name       = ReadString(responseReader);
                cost.Code       = ReadString(responseReader);
                cost.Value      = ReadDecimal(responseReader) ?? 0;
                cost.IsRegister = responseReader.ReadBoolean();
                cost.IsInactive = responseReader.ReadBoolean();
                costs.Add(cost);
            }

            Costs = costs;
        }
Esempio n. 12
0
        /// <summary>
        /// Updates information when a selection has been changed
        /// </summary>
        private void RaiseEditingCostChanges()
        {
            SessionCost cost = EditingCost;

            RaisePropertyChanged("EditingCost");
            RaisePropertyChanged("CostName");
            RaisePropertyChanged("CostCode");

            if (cost == null)
            {
                CostValue = null;
            }
            else
            {
                CostValue = cost.Value.ToString("F2", CultureInfo.CurrentCulture);
            }

            RaisePropertyChanged("CostRegister");
            RaisePropertyChanged("DeactivateText");
            IsDataModified = false;

            HasSuccess      = false;
            ProgressMessage = Error;
        }
Esempio n. 13
0
        /// <summary>
        /// Unpacks the request reponse received from the server.
        /// </summary>
        /// <param name="responseReader">The response.</param>
        protected override void UnpackResponse(BinaryReader responseReader)
        {
            if (responseReader == null)
            {
                throw new ArgumentNullException("responseReader");
            }

            if (ReturnCode == ServerReturnCode.Success)
            {
                // Create a new summary with the passed in date and session
                Summary summary = new Summary(m_date, m_session);
                // Attendance
                summary.AttendanceSystem     = responseReader.ReadInt32();
                summary.AttendanceSystemTime = ReadDateTime(responseReader) ?? DateTime.Now;
                summary.AttendanceManual     = responseReader.ReadInt32();
                summary.AttendanceManualTime = ReadDateTime(responseReader) ?? DateTime.Now;

                // Staff (Manager and Callers)
                int managerId = responseReader.ReadInt32();

                summary.Manager = m_staff.FirstOrDefault(staffMember => staffMember.Id == managerId);
                IList <Staff> callers = new List <Staff>();

                short callerCount = responseReader.ReadInt16();
                for (int callerIndex = 0; callerIndex < callerCount; ++callerIndex)
                {
                    int   callerId = responseReader.ReadInt32();
                    Staff caller   = m_staff.FirstOrDefault(staffMember => staffMember.Id == callerId);

                    if (caller != null)
                    {
                        callers.Add(caller);
                    }
                }
                summary.Callers = callers;

                // Comments
                summary.Comments = ReadString(responseReader);

                // Sales
                summary.SalesPaper       = ReadDecimal(responseReader) ?? 0M;
                summary.SalesElectronic  = ReadDecimal(responseReader) ?? 0M;
                summary.SalesBingoOther  = ReadDecimal(responseReader) ?? 0M; //FIX: DE8961 Session summary does calculate bingo other sales
                summary.SalesPullTab     = ReadDecimal(responseReader) ?? 0M;
                summary.SalesConcession  = ReadDecimal(responseReader) ?? 0M;
                summary.SalesMerchandise = ReadDecimal(responseReader) ?? 0M;
                summary.SalesDeviceFee   = ReadDecimal(responseReader) ?? 0M;
                summary.SalesDiscount    = ReadDecimal(responseReader) ?? 0M;
                summary.SalesValidation  = ReadDecimal(responseReader) ?? 0M;

                // Prizes
                summary.PrizesCash        = ReadDecimal(responseReader) ?? 0M;
                summary.PrizesCheck       = ReadDecimal(responseReader) ?? 0M;
                summary.PrizesMerchandise = ReadDecimal(responseReader) ?? 0M;
                summary.PrizesAccrualInc  = ReadDecimal(responseReader) ?? 0M;
                summary.PrizesPullTab     = ReadDecimal(responseReader) ?? 0M;
                summary.PrizesOther       = ReadDecimal(responseReader) ?? 0M;

                // Session Costs
                IList <SessionCost> costs = new List <SessionCost>();
                short costCount           = responseReader.ReadInt16();
                for (int costIndex = 0; costIndex < costCount; ++costIndex)
                {
                    SessionCost cost = new SessionCost();
                    cost.Id         = responseReader.ReadInt32();
                    cost.MasterId   = responseReader.ReadInt32();
                    cost.Name       = ReadString(responseReader);
                    cost.Code       = ReadString(responseReader);
                    cost.Value      = ReadDecimal(responseReader) ?? 0;
                    cost.IsRegister = responseReader.ReadBoolean();
                    cost.IsInactive = responseReader.ReadBoolean();
                    costs.Add(cost);
                }
                summary.SessionCosts = costs;

                // Money values
                summary.BankBegin          = ReadDecimal(responseReader) ?? 0M;
                summary.BankFill           = ReadDecimal(responseReader) ?? 0M;
                summary.PrizesAccrualPay   = ReadDecimal(responseReader) ?? 0M;
                summary.PrizesFees         = ReadDecimal(responseReader) ?? 0M;
                summary.OverCoupons        = ReadDecimal(responseReader) ?? 0M;
                summary.SalesTax           = ReadDecimal(responseReader) ?? 0M;
                summary.OverCash           = ReadDecimal(responseReader) ?? 0M;
                summary.OverDebitCredit    = ReadDecimal(responseReader) ?? 0M;
                summary.OverChecks         = ReadDecimal(responseReader) ?? 0M;
                summary.BankEnd            = ReadDecimal(responseReader) ?? 0M;
                summary.OverMoneyOrders    = ReadDecimal(responseReader) ?? 0M;
                summary.OverGiftCards      = ReadDecimal(responseReader) ?? 0M;
                summary.OverChips          = ReadDecimal(responseReader) ?? 0M;
                summary.AccrualCashPayouts = ReadDecimal(responseReader) ?? 0M;
                summary.KioskSale          = ReadDecimal(responseReader) ?? 0M;
                summary.KioskVoids         = ReadDecimal(responseReader) ?? 0M; //US5352 - kiosk voids

                var   actualCashDenoms = new List <ActualCashCurrencyDenom>();
                short actualCashCount  = responseReader.ReadInt16();
                for (short i = 0; i < actualCashCount; ++i)
                {
                    var item = new ActualCashCurrencyDenom();
                    item.ID = responseReader.ReadInt32();
                    item.SessionSummaryID = responseReader.ReadInt32();
                    item.ISOCode          = ReadString(responseReader);
                    item.CurrencyDetailID = responseReader.ReadInt32();
                    item.Quantity         = responseReader.ReadInt32();
                    item.CurrencyValue    = ReadDecimal(responseReader) ?? 0M;
                    item.ExchangeRate     = ReadDecimal(responseReader) ?? 1M;
                    item.DefaultValue     = ReadDecimal(responseReader) ?? 0M;
                    actualCashDenoms.Add(item);
                }
                summary.LoadActualCashDenomQuantities(actualCashDenoms);

                // Do the assignment
                Summary = summary;
            }
        }