예제 #1
0
        private void btnLAWPASaveChanges_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult dr = MessageBox.Show(ResourcesUtils.GetMessage("lott_lwpa_msg3"),
                                                  ResourcesUtils.GetMessage("lott_lwpa_msg2"), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (dr == DialogResult.No)
                {
                    return;
                }

                Lottery lottery = (Lottery)cmbLWPAGameMode.SelectedItem;
                LotteryWinningCombination      originalCombination = this.lotteryDataServices.GetLotteryWinningCombinations(lottery.GetGameMode());
                LotteryWinningCombinationSetup lotteryUpdated      = (LotteryWinningCombinationSetup)originalCombination.Clone();
                lotteryUpdated.Match1 = int.Parse(txtbLWPABet1.Value.ToString());
                lotteryUpdated.Match2 = int.Parse(txtbLWPABet2.Value.ToString());
                lotteryUpdated.Match3 = int.Parse(txtbLWPABet3.Value.ToString());
                lotteryUpdated.Match4 = int.Parse(txtbLWPABet4.Value.ToString());
                lotteryUpdated.Match5 = int.Parse(txtbLWPABet5.Value.ToString());
                lotteryUpdated.Match6 = int.Parse(txtbLWPABet6.Value.ToString());
                this.lotteryDataServices.SaveWinningCombination(lotteryUpdated);
                MessageBox.Show(ResourcesUtils.GetMessage("lott_lwpa_msg1"));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void cmbLWPAGameMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            Lottery lottery = (Lottery)cmbLWPAGameMode.SelectedItem;

            lblLWPASelectedGame.Text = lottery.GetDescription();
            LotteryWinningCombination prize = this.lotteryDataServices.GetLotteryWinningCombinations(lottery.GetGameMode());

            txtbLWPABet1.Text = prize.GetMatch1().ToString();
            txtbLWPABet2.Text = prize.GetMatch2().ToString();
            txtbLWPABet3.Text = prize.GetMatch3().ToString();
            txtbLWPABet4.Text = prize.GetMatch4().ToString();
            txtbLWPABet5.Text = prize.GetMatch5().ToString();
            txtbLWPABet6.Text = prize.GetMatch6().ToString();
        }
        public void ProcessWinningBet(LotteryBet lotteryBet)
        {
            GameMode gameMode = ClassReflectionUtil.FindGameMode(lotteryBet.GetGameCode());
            LotteryWinningCombinationDao lotteryWinningCombinationDao = LotteryWinningCombinationDaoImpl.GetInstance();
            LotteryWinningCombination    lotteryWinningCombination    = lotteryWinningCombinationDao.GetLotteryWinningCombination(gameMode);

            RaiseEvent(LotteryDataWorkerEventStages.EXTRACTING, ResourcesUtils.GetMessage("lot_data_worker_cls_msg_3"));
            LotteryWinningBetDao lotteryWinningBetDao = LotteryWinningBetDaoImpl.GetInstance();

            RaiseEvent(LotteryDataWorkerEventStages.EXTRACTING, ResourcesUtils.GetMessage("lot_data_worker_cls_msg_4"));
            LotteryDrawResultDao lotteryDrawResultDao = LotteryDrawResultDaoImpl.GetInstance();

            LotteryDrawResult betDrawResult = lotteryDrawResultDao.GetLotteryDrawResultByDrawDate(
                gameMode, lotteryBet.GetTargetDrawDate());
            LotteryWinningBetSetup lotteryWinningBet = new LotteryWinningBetSetup();

            lotteryWinningBet.LotteryBetId = lotteryBet.GetId();

            if (betDrawResult == null)
            {
                return;
            }
            if (betDrawResult.IsDrawResulDetailsEmpty())
            {
                return;
            }

            int matchingNumberCtr = 0;

            foreach (int bet in lotteryBet.GetBetNumbersAsArray())
            {
                if (betDrawResult.IsWithinDrawResult(bet))
                {
                    matchingNumberCtr++;
                    lotteryWinningBet.FillNumberBySeq(matchingNumberCtr, bet);
                }
            }

            if (lotteryWinningBet.IsNumberSequenceMatchesAll(betDrawResult.GetAllNumberSequence()))
            {
                lotteryWinningBet.WinningAmount = betDrawResult.GetJackpotAmt();
            }
            else
            {
                lotteryWinningBet.WinningAmount = lotteryWinningCombination.GetWinningAmount(matchingNumberCtr);
            }

            RaiseEvent(LotteryDataWorkerEventStages.INSERT, ResourcesUtils.GetMessage("lot_data_worker_cls_msg_5"));
            lotteryWinningBetDao.InsertWinningBet(lotteryWinningBet);
        }
        public int InsertWinningCombination(LotteryWinningCombination lwc)
        {
            int modified = 0;

            using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
                using (OleDbCommand command = new OleDbCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = " INSERT INTO `lottery_winning_combination` " +
                                          "          (`game_cd`, `active`, `match_0`, `match_1`, `match_2`, `match_3`, `match_4`, `match_5`, `match_6`) " +
                                          "  VALUES (@game_cd, true, @m0, @m1, @m2, @m3, @m4, @m5, @m6) ";
                    command.Parameters.AddWithValue("@game_cd", (int)lwc.GetGameMode());
                    command.Parameters.AddWithValue("@m0", lwc.GetMatch0());
                    command.Parameters.AddWithValue("@m1", lwc.GetMatch1());
                    command.Parameters.AddWithValue("@m2", lwc.GetMatch2());
                    command.Parameters.AddWithValue("@m3", lwc.GetMatch3());
                    command.Parameters.AddWithValue("@m4", lwc.GetMatch4());
                    command.Parameters.AddWithValue("@m5", lwc.GetMatch5());
                    command.Parameters.AddWithValue("@m6", lwc.GetMatch6());
                    command.Connection = conn;
                    conn.Open();
                    OleDbTransaction transaction = conn.BeginTransaction();
                    command.Transaction = transaction;
                    int result = command.ExecuteNonQuery();

                    if (result < 0)
                    {
                        transaction.Rollback();
                        throw new Exception(String.Format(ResourcesUtils.GetMessage("lot_win_com_impl_msg1"), lwc.GetID()));
                    }
                    else
                    {
                        transaction.Commit();
                        modified = base.GetLastInsertedID(command);
                    }
                }
            return(modified);
        }
        public void RemoveWinningCombination(LotteryWinningCombination lwc)
        {
            using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
                using (OleDbCommand command = new OleDbCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = " UPDATE lottery_winning_combination SET active = false " +
                                          " WHERE ID = @id AND game_cd = @game_cd AND active = true";
                    command.Parameters.AddWithValue("@id", lwc.GetID());
                    command.Parameters.AddWithValue("@game_cd", lwc.GetGameMode());
                    command.Connection = conn;
                    conn.Open();
                    OleDbTransaction transaction = conn.BeginTransaction();
                    command.Transaction = transaction;
                    int result = command.ExecuteNonQuery();

                    if (result < 0)
                    {
                        transaction.Rollback();
                        throw new Exception(String.Format(ResourcesUtils.GetMessage("lot_win_com_impl_msg1"), lwc.GetID()));
                    }
                    transaction.Commit();
                }
        }