public List<Button> loadMediaButtons()
        {
            MaintenanceDAO maintenanceDAO = new MaintenanceDAO();
            mediaList = maintenanceDAO.getMedia();
            int topMargin = 60;
            int itemLimit = 5;
            int count = 1;
            int left = 520;
            int[] leftButtons = { 0, 3, 6,9,12,15,18 };
            int[] middleButton = { 1, 4, 7, 10, 13, 16 };
            List<Button> mediaButtons = new List<Button>();
            foreach (Media media in mediaList)
            {
                if(!string.IsNullOrEmpty(media.MediaName.Trim()))
                {
                    int x = left;
                    int bHeight = 70;
                    if (leftButtons.Contains(count - 1))
                    {//Left button
                        x = left;
                    }
                    else if (middleButton.Contains(count -1))
                    {//middle button
                        x = left + 80;
                        topMargin -= bHeight;
                    }
                    else
                    {//right button
                        x = left + 160;
                        topMargin -= bHeight;
                    }

                    Point p = new Point(x, topMargin);
                    mediaButtons.Add(_addMediaButton(media.MediaIndex.ToString(), media.MediaName, p));
                    topMargin += bHeight;
                    count += 1;
                }
            }
            return mediaButtons;
        }
Пример #2
0
        private CSSale _buildCSSale(Sale sale)
        {
            CSSale csSale = null;
            maintenanceDAO = new MaintenanceDAO();
            int totalItems = 0;
            SaleInfo saleInfo = new SaleInfo();
            saleInfo.seats = new List<Seat>();
            SaleItemDAO saleItemDAO = new SaleItemDAO();
            Seat currentSeat = new Seat();
            foreach (SaleItem saleItem in saleItemDAO.find(sale.SaleID.ToString()))
            {
                Console.WriteLine(saleItem.ToString());
                if (saleItem.Flags == 4 || saleItem.Flags == 20)//it's a seat!
                {
                    Seat seat = new Seat();
                    currentSeat = seat;
                    seat.saleItems = new List<SaleItem>();
                    seat.number = saleItem.BasePrice;
                    saleInfo.seats.Add(seat);
                    Logger.log.Debug("seat #" + seat.number + " added");
                    if (saleItem.Flags == 20)
                        currentSeat.ignorePrint = true;
                }
                else//it's an item
                {
                    if (!currentSeat.ignorePrint)
                    {
                        currentSeat.saleItems.Add(saleItem);
                        totalItems++;
                        Logger.log.Debug("item " + saleItem.ItemName + " added to seat #" + currentSeat.number);
                    }
                }
            }

            if (totalItems > 0)
            {
                csSale = new CSSale();
                csSale.CSSaleID = sale.SaleID;
                csSale.CheckNo = sale.CheckNumber;
                csSale.EndDate = DateTime.Now;
                //replace csSale data
                _clearCSSale(csSale);
                _buildCSSaleItem(saleInfo.seats);
                CSSaleDAO csSaleDAO = new CSSaleDAO();
                csSaleDAO.add(csSale);
                //build CSSale data
                //1. TOTALS
                int totalDisc = 0;
                foreach (Seat seat in saleInfo.seats)
                {
                    foreach (CSSaleItem csSaleItem in seat.csSaleItems)
                    {
                        //1.1. discounts
                    }
                }
            }
            else
            {
                Logger.log.Info("No Items found.");
            }
            return csSale;
        }