示例#1
0
 public Rent(Receipt receipt, MovieItem item) : this(receipt, item, 0)
 {
 }
示例#2
0
        void WriteHistoryToDB()
        {
            bool realTime = VideoRentDateTime.RealTime;

            VideoRentDateTime.RealTime = false;
            backgroundWorker.ReportProgress(10);
            WriteItemsToDB();
            double percentProgress = backgroundWorker.ReportedProgress;
            double percentPerDay   = (70.0 - percentProgress) / daysCount;

            VideoRentDateTime.AddDays(-daysCount - 1);
            for (int day = 0; day < daysCount; ++day)
            {
                VideoRentDateTime.AddDays(1);
                foreach (CustomerData customer in customers)
                {
                    Point point = customer.GetPoint(day);
                    if (point == null)
                    {
                        continue;
                    }
                    VideoRentDateTime.SetTimeOfDay(point.Time);
                    List <RentInfo> rentsInfo = new List <RentInfo>();
                    foreach (RentData rent in point.Rents)
                    {
                        rentsInfo.Add(new RentInfo(rent.Item.DBItem, rent.Days));
                    }
                    Receipt receipt = customer.DBCustomer.DoRent(rentsInfo);
                    foreach (RentData rent in point.Rents)
                    {
                        foreach (Rent dbRent in receipt.Rents)
                        {
                            if (dbRent.Item != rent.Item.DBItem)
                            {
                                continue;
                            }
                            rent.DBRent = dbRent;
                            break;
                        }
                    }
                    List <Rent> returns = new List <Rent>();
                    foreach (RentData rent in point.Returns)
                    {
                        returns.Add(rent.DBRent);
                    }
                    customer.DBCustomer.ReturnRents(returns);
                    List <RentInfo> sellsInfo = new List <RentInfo>();
                    foreach (RentData sell in point.Sells)
                    {
                        sellsInfo.Add(new RentInfo(sell.Item.DBItem));
                    }
                    customer.DBCustomer.Buy(sellsInfo);
                }
                foreach (LostDamageItemAction action in lostDamageItemActions)
                {
                    if (action.Day != day)
                    {
                        continue;
                    }
                    VideoRentDateTime.SetTimeOfDay(action.Time);
                    if (action.Damage)
                    {
                        action.Item.DBItem.Status = MovieItemStatus.Damaged;
                    }
                    else
                    {
                        action.Item.DBItem.Status = MovieItemStatus.Lost;
                    }
                }
                percentProgress += percentPerDay;
                backgroundWorker.ReportProgress((int)percentProgress);
            }
            backgroundWorker.ReportProgress(70);
            WriteAddedItems();
            SessionHelper.CommitInBackground(session, exceptionProcesser, backgroundWorker, 100);
            VideoRentDateTime.RealTime = realTime;
        }