コード例 #1
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 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);
        }