Exemplo n.º 1
0
        private void PurchaseALotteryTicket(double moneyPayed, int userID)
        {
            StoreDL       handler = StoreDL.Instance;
            LotteryTicket lottery = new LotteryTicket(SystemID, (int)TotalMoneyPayed,
                                                      (int)(TotalMoneyPayed + moneyPayed), moneyPayed, userID);

            handler.AddLotteryTicket(lottery);
            TotalMoneyPayed += moneyPayed;
            handler.EditLotteryInDatabase(this);
        }
Exemplo n.º 2
0
        private bool Equals(LotteryTicket obj)
        {
            StockSyncher handler = StockSyncher.Instance;

            return(obj.IntervalStart == IntervalStart &&
                   obj.IntervalEnd == IntervalEnd &&
                   obj.LotteryNumber == LotteryNumber &&
                   obj.myID == myID &&
                   EnumStringConverter.PrintEnum(obj.myStatus).Equals(EnumStringConverter.PrintEnum(myStatus)) &&
                   obj.UserID == UserID
                   );
        }
Exemplo n.º 3
0
        public void AddLotteryTicket(LotteryTicket ticket)
        {
            object[] ticketVals = ticket.GetTicketValuesArray();
            foreach (object val in ticketVals)
            {
                dbConnection.CheckInput(val.ToString());
            }

            dbConnection.InsertTable("LotteryTicket", "myID, LotteryID, IntervalStart, IntervalEnd,Cost, Status, UserID",
                                     new[] { "@idParam", "@lotteryParam", "@interStart", "@interEnd", "@cost", "@stat", "@user" },
                                     ticketVals);
        }
Exemplo n.º 4
0
        public LotteryTicket GetLotteryTicket(string ticketid)
        {
            dbConnection.CheckInput(ticketid);
            using (var dbReader = dbConnection.SelectFromTableWithCondition("LotteryTicket", "*", "myID = '" + ticketid + "'"))
            {
                while (dbReader.Read())
                {
                    LotteryTicket lotty = new LotteryTicket(dbReader.GetString(0), dbReader.GetString(1),
                                                            dbReader.GetDouble(2), dbReader.GetDouble(3), dbReader.GetDouble(4), dbReader.GetInt32(6));
                    lotty.myStatus = EnumStringConverter.GetLotteryStatusString(dbReader.GetString(5));
                    return(lotty);
                }
            }

            return(null);
        }
Exemplo n.º 5
0
        public LinkedList <LotteryTicket> GetAllTickets(string systemid)
        {
            dbConnection.CheckInput(systemid);
            LinkedList <LotteryTicket> result = new LinkedList <LotteryTicket>();

            using (var dbReader = dbConnection.SelectFromTableWithCondition("LotteryTicket", "*", "LotteryID = '" + systemid + "'"))
            {
                while (dbReader.Read())
                {
                    LotteryTicket lottery = new LotteryTicket(dbReader.GetString(0), dbReader.GetString(1),
                                                              dbReader.GetDouble(2), dbReader.GetDouble(3), dbReader.GetDouble(4), dbReader.GetInt32(6));
                    lottery.myStatus = EnumStringConverter.GetLotteryStatusString(dbReader.GetString(5));
                    result.AddLast(lottery);
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        private LotteryTicket InformAllWinner(int winningNumber)
        {
            LotteryTicket winner  = null;
            StoreDL       handler = StoreDL.Instance;
            LinkedList <LotteryTicket> tickets = handler.GetAllTickets(SystemID);

            foreach (LotteryTicket lotter in tickets)
            {
                if (lotter.IsWinning(winningNumber))
                {
                    winner = lotter;
                    lotter.RunWinning();
                }
                else
                {
                    lotter.RunLosing();
                }
                handler.EditLotteryTicketInDatabase(lotter);
            }
            return(winner);
        }
Exemplo n.º 7
0
 public void EditLotteryTicketInDatabase(LotteryTicket ticket)
 {
     string[] columnNames =
     {
         "myID",
         "LotteryID",
         "IntervalStart",
         "IntervalEnd",
         "Cost",
         "Status",
         "UserID"
     };
     dbConnection.CheckInput(ticket.myID);
     object[] ticketVals = ticket.GetTicketValuesArray();
     foreach (object val in ticketVals)
     {
         dbConnection.CheckInput(val.ToString());
     }
     dbConnection.UpdateTable("LotteryTicket", "myID = '" + ticket.myID + "'", columnNames,
                              new [] { "@idParam", "@lotteryParam", "@interStart", "@interEnd", "@cost", "@stat", "@user" }, ticketVals);
 }
Exemplo n.º 8
0
 public void RemoveLotteryTicket(LotteryTicket lottery)
 {
     dbConnection.CheckInput(lottery.myID);
     dbConnection.DeleteFromTable("LotteryTicket", "myID = '" + lottery.myID + "'");
 }