//public void Save() //{ // //SqlTransaction trans = null; // try // { // //trans = SqlHelper.BeginTransaction(Config.ConnectionString); // this.Save(trans); // //Challenge Challenge = Challenge.CreateChallenge(this); // //Challenge.Save(trans); // //SqlHelper.CommitTransaction(trans); // } // catch (Exception ex) // { // //SqlHelper.RollbackTransaction(trans); // Log.Write(base.Cxt, ex); // } //} public void UpdateUserPoints(SqlTransaction t) { double wPoints = 0; double bPoints = 0; switch (this.GameResultIDE) { case GameResultE.WhiteWin: wPoints = 1; bPoints = 0; break; case GameResultE.WhiteLose: wPoints = 0; bPoints = 1; break; case GameResultE.Draw: wPoints = 0.5; bPoints = 0.5; break; } BaseCollection.ExecuteSql2(t, "Update TournamentUser set TournamentPoints = ISNULL(TournamentPoints,0) + " + wPoints + " where IsNull(UserID2, UserID) = " + this.WhiteUserID + " and TournamentID = " + this.TournamentID); BaseCollection.ExecuteSql2(t, "Update TournamentUser set TournamentPoints = ISNULL(TournamentPoints,0) + " + bPoints + " where IsNull(UserID2, UserID) = " + this.BlackUserID + " and TournamentID = " + this.TournamentID); }
public static void DeleteTournamentTeams(Cxt cxt, TournamentTeams TournamentTeams) { SqlTransaction trans = null; try { trans = SqlHelper.BeginTransaction(Config.ConnectionString); for (int i = 0; i < TournamentTeams.Count; i++) { //TournamentTeams.Delete(InfiChess.TournamentTeam, Convert.ToInt32(TournamentTeams.DataTable.Rows[i]["TournamentTeamID"])); BaseCollection.ExecuteSql2(trans, "update TournamentTeam statusid = @p1 where TournamentTeamID = @p2", (int)StatusE.Deleted, Convert.ToInt32(TournamentTeams.DataTable.Rows[i]["TournamentTeamID"])); } for (int i = 0; i < TournamentTeams.Count; i++) { BaseCollection.Execute(trans, "UpdateTournamentUserStatusByTeamID", Convert.ToInt32(TournamentTeams.DataTable.Rows[i]["TeamID"]), TournamentTeams.TournamentID, cxt.CurrentUserID, DateTime.Now, (int)StatusE.Deleted); } SqlHelper.CommitTransaction(trans); } catch (Exception ex) { SqlHelper.RollbackTransaction(trans); Log.Write(cxt, ex); } }
public static void RevokeAdmin(string userIDs, RankE humanRankID, RoleE roleID) { System.Data.SqlClient.SqlTransaction t = null; try { t = SqlHelper.BeginTransaction(Config.ConnectionString); //BaseCollection.ExecuteSql2(t, "update [User] set HumanRankID = " + humanRankID.ToString("d") + " WHERE userID in (" + userIDs + ")"); BaseCollection.ExecuteSql2(t, "update [UserRole] set RoleID = " + roleID.ToString("d") + " WHERE userID in (" + userIDs + ")"); SqlHelper.CommitTransaction(t); } catch (Exception ex) { SqlHelper.RollbackTransaction(t); Log.Write(Ap.Cxt, ex); } }
public static void DeleteTournamentTeams(Cxt cxt, string tournamentTeamIDs, int tournamentID) { string[] tournamentTeamIDsArr = tournamentTeamIDs.Split(','); SqlTransaction trans = null; try { trans = SqlHelper.BeginTransaction(Config.ConnectionString); foreach (string itemID in tournamentTeamIDsArr) { if (string.IsNullOrEmpty(itemID)) { continue; } BaseCollection.ExecuteSql2(trans, "update TournamentTeam set StatusID = @p1 where TeamID = @p2 and TournamentID = @p3", (int)StatusE.Deleted, Convert.ToInt32(itemID), tournamentID); //TournamentTeams.DeleteInfiChess.TournamentTeam, Convert.ToInt32(itemID)); } BaseCollection.Execute(trans, "UpdateTournamentUserStatusByTeamID", tournamentTeamIDs, tournamentID, cxt.CurrentUserID, DateTime.Now, (int)StatusE.Deleted); BaseCollection.Execute(trans, "UpdateTournamentWantinUserStatus", tournamentTeamIDs, tournamentID, (int)TournamentUserStatusE.Declined, (int)StatusE.Deleted, cxt.CurrentUserID, DateTime.Now); SqlHelper.CommitTransaction(trans); } catch (Exception ex) { SqlHelper.RollbackTransaction(trans); Log.Write(cxt, ex); } }
public static DataTable UpdateFini(SqlTransaction t, int fini, int userID) { string str = "update [User] set Fini = " + fini.ToString() + " WHERE userID = " + userID.ToString(); return(BaseCollection.ExecuteSql2(t, str)); }