示例#1
0
 public ViewItemSoldInfoViewModel(IChangeViewModel viewModelChanger, DateTime startDate, DateTime endDate,
                                  ReportItemSold reportForItem, User userToFilterBy = null) : base(viewModelChanger)
 {
     _reportForItem   = reportForItem;
     _inventoryItemID = reportForItem.InventoryItemID;
     _item            = InventoryItem.LoadItemByID(_inventoryItemID);
     _startDate       = startDate;
     _endDate         = endDate;
     _userToFilterBy  = userToFilterBy;
     LoadData();
 }
        private void LoadViewPurchaseDetailsScreenForWeek(ReportItemSold reportForItem)
        {
            _isViewingDailyReportInfo       = false;
            _lastDailyReportInfoInventoryID = reportForItem.InventoryItemID;
            var userToFilterBy = WeeklyReportUserChoiceIndex == 0 ? null : _users[WeeklyReportUserChoiceIndex - 1];

            PushViewModel(new ViewItemSoldInfoViewModel(ViewModelChanger, SelectedWeeklyReportDate,
                                                        SelectedWeeklyReportDate.AddDays(6), reportForItem, userToFilterBy)
            {
                CurrentUser = CurrentUser, DeletedItemSoldInfoListener = this
            });
        }
        /// <summary>
        /// returns null if no updated report (e.g. you deleted the last item of that type that was sold)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ReportItemSold ItemSoldInfoWasDeleted(ItemSoldInfo model)
        {
            // need to rerun all reports!!
            RunDayReport();
            RunWeeklyReport();
            RunStockReport();
            ReportItemSold report     = null;
            var            reportList = _isViewingDailyReportInfo ? CurrentDaySalesReport.ItemsSold : CurrentWeeklySalesReport.AllItemsSold;

            foreach (ReportItemSold itemReport in reportList)
            {
                if (itemReport.InventoryItemID == _lastDailyReportInfoInventoryID)
                {
                    report = itemReport;
                    break;
                }
            }
            return(report);
        }