Example #1
0
        public CardDataReport(DateTime fromDate, DateTime toDate, int cardId)
        {
            CardReport cardReport = new CardReport();

            cardReport.GetOneCardReport(fromDate, toDate, cardId);
            SqlConn       conn      = new  SqlConn();
            List <Client> clients   = conn.selectClient("client_info", "card_id='" + cardId + "'");
            CardPrice     cardPrice = conn.selectCardPrice("cards_price", "card_id='" + cardId + "'");

            conn.close();
            this.cardReport = cardReport;
            this.clients    = clients;
            this.cardPrice  = cardPrice;
        }
Example #2
0
        public void GetCardReport(DateTime fromDate, DateTime toDate)
        {
            SqlConn     conn  = new SqlConn();
            List <Card> cards = conn.selectCards("cards", "");

            List <TransactionAttractions> transactionsAttraction = conn.selectTransactionAttractions("transactions_attractions",
                                                                                                     " date >= '" + fromDate.ToString("dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture) + " 0:00:00' AND date <= '" + toDate.ToString("dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture) + " 23:59:59'");
            List <TransactionCashRegister> transactionsCashRegister = conn.selectTransactionCashRegister("transactions_cashiermashine",
                                                                                                         " date BETWEEN '" + fromDate.ToString("dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture) + " 0:00:00' AND '" + toDate.ToString("dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture) + " 23:59:59'");

            this.reportedCards = new List <ReportedCard>();
            foreach (Card card in cards)
            {
                int     gamesForMoney = 0, gamesForBonuses = 0, gamesTotal = 0;
                decimal spendMoney = 0, spendBonuses = 0, recievedTicketsFromAttraction = 0, receivedMoney = 0, receivedBonus = 0, recievedTicketsFromCashierRegister = 0, spendTickets = 0, writenOffBonuses = 0, writenOffMoney = 0, writenOffCardPrice = 0;
                bool    cardUsed = false;
                foreach (TransactionAttractions transactionAttraction in transactionsAttraction)
                {
                    if (((int)transactionAttraction.operation) != 23)
                    {
                        if ((int)transactionAttraction.cardId == (int)card.cardId)
                        {
                            if ((decimal)transactionAttraction.summ != 0)
                            {
                                gamesForMoney++;
                                spendMoney += (decimal)transactionAttraction.summ;
                                cardUsed    = true;
                            }
                            else if ((decimal)transactionAttraction.bonus != 0)
                            {
                                gamesForBonuses++;
                                spendBonuses += (decimal)transactionAttraction.bonus;
                                cardUsed      = true;
                            }
                            recievedTicketsFromAttraction += (int)transactionAttraction.tickets;
                        }
                    }
                }
                gamesTotal = gamesForMoney + gamesForBonuses;
                foreach (TransactionCashRegister transactionCashRegister in transactionsCashRegister)
                {
                    if ((int)transactionCashRegister.cardId == (int)card.cardId)
                    {
                        if (((int)transactionCashRegister.operation >= 5 &&
                             (int)transactionCashRegister.operation <= 7) ||
                            (int)transactionCashRegister.operation == 12 ||
                            (int)transactionCashRegister.operation == 14 ||
                            (int)transactionCashRegister.operation == 18 ||
                            (int)transactionCashRegister.operation == 19)
                        {
                            receivedMoney += (decimal)transactionCashRegister.summ;
                            receivedBonus += (decimal)transactionCashRegister.bonus;
                            recievedTicketsFromCashierRegister += (int)transactionCashRegister.tickets;
                            cardUsed = true;
                        }
                        else if (((int)transactionCashRegister.operation >= 8 &&
                                  (int)transactionCashRegister.operation <= 11) ||
                                 (int)transactionCashRegister.operation == 13 ||
                                 (int)transactionCashRegister.operation == 21)
                        {
                            writenOffMoney   += (decimal)transactionCashRegister.summ;
                            writenOffBonuses += (decimal)transactionCashRegister.bonus;
                            spendTickets     += (int)transactionCashRegister.tickets;
                            cardUsed          = true;
                        }
                        else if ((int)transactionCashRegister.operation == 20)
                        {
                            writenOffCardPrice += (decimal)transactionCashRegister.summ;
                        }
                    }
                }

                Sale cardSale = conn.selectSale("sales", "sale_id='" + card.cardSale + "'");

                CardPrice cardPrice = new CardPrice();
                cardPrice = conn.selectCardPrice("cards_price", "card_id='" + card.cardId + "'");
                if (cardUsed == true)
                {
                    CardStatus cardStatus = conn.selectCardStatus("card_state", "state_id='" + card.cardStatus + "'");
                    reportedCards.Add(
                        new ReportedCard(
                            (int)card.cardId,
                            (string)card.cardParentName,
                            cardStatus.status_message,
                            card.cardCount,
                            (decimal)card.cardBonus,
                            (int)card.cardTicket,
                            cardPrice.cardPrice,
                            cardSale.saleValue + "%",
                            (DateTime)card.cardRegDate,
                            gamesForMoney,
                            gamesForBonuses,
                            gamesTotal,
                            spendMoney,
                            spendBonuses,
                            spendTickets,
                            recievedTicketsFromAttraction,
                            recievedTicketsFromCashierRegister,
                            receivedMoney,
                            receivedBonus,
                            writenOffMoney,
                            writenOffCardPrice,
                            writenOffBonuses
                            ));
                }
            }
        }