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(); } }