Beispiel #1
0
 private void miCreateTournament_Click(object sender, EventArgs e)
 {
     DlgTournamentCreation creation = new DlgTournamentCreation();
     creation.MainForm = this;
     creation.Show();
 }
 private void btnRegister_Click(object sender, EventArgs e)
 {
     WaitCallback callBack = null;
     WaitCallback callback2 = null;
     if (((int) this.btnRegister.Tag) == 0)
     {
         if (this.mSelectedRecord != null)
         {
             this.btnRegister.Enabled = false;
             if (!this.CheckMap(this.mSelectedRecord["map"]))
             {
                 DlgMessage.ShowDialog(base.MainForm, Loc.Get("<LOC>You are missing this map.  Please download it from the vault first."));
             }
             else
             {
                 if (callBack == null)
                 {
                     callBack = delegate (object o) {
                         VGen0 method = null;
                         VGen0 gen3 = null;
                         DataList queryData = DataAccess.GetQueryData("Tournament Status Check", new object[] { this.mSelectedRecord["tournament_id"] });
                         if ((queryData.Count == 0) || (queryData[0][0].ToUpper() != "REGISTRATION"))
                         {
                             if (method == null)
                             {
                                 method = delegate {
                                     DlgMessage.ShowDialog(base.MainForm, Loc.Get("<LOC>This tournament has already started.  You can no longer join."));
                                 };
                             }
                             base.Invoke(method);
                         }
                         else
                         {
                             if (ConfigSettings.GetBool("CheckCustomTournyFilters", true))
                             {
                                 VGen0 gen = null;
                                 bool flag = false;
                                 string gamedesc = "";
                                 foreach (GameInformation information in GameInformation.Games)
                                 {
                                     if (information.GameID.ToString() == this.mSelectedRecord["gpgnet_game_id"])
                                     {
                                         gamedesc = information.GameDescription;
                                         if ((information.CDKey != "") || User.Current.IsAdmin)
                                         {
                                             flag = true;
                                         }
                                     }
                                 }
                                 if (!flag)
                                 {
                                     if (gen == null)
                                     {
                                         gen = delegate {
                                             DlgMessage.ShowDialog(this.MainForm, Loc.Get("<LOC>You are not eligible for this tournament.  This tournament is for " + gamedesc + " and you do not have a valid CD key for it."));
                                         };
                                     }
                                     base.Invoke(gen);
                                     return;
                                 }
                                 if (((this.mSelectedRecord["custom_filter_query_name"].Trim() != "") && (this.mSelectedRecord["custom_filter_query_name"].Trim().ToUpper() != "(NULL)")) && (DataAccess.GetQueryData(this.mSelectedRecord["custom_filter_query_name"], new object[0]).Count == 0))
                                 {
                                     if (gen3 == null)
                                     {
                                         gen3 = delegate {
                                             DlgMessage.ShowDialog(base.MainForm, Loc.Get("<LOC>You are not eligible for this tournament.  Please check the tournament details for eligibility."));
                                         };
                                     }
                                     base.Invoke(gen3);
                                     return;
                                 }
                             }
                             DataAccess.ExecuteQuery("Tournament Register", new object[] { this.mSelectedRecord["tournament_id"] });
                             DataAccess.ExecuteQuery("Tournament Player Count", new object[] { this.mSelectedRecord["tournament_id"] });
                             base.Invoke((VGen0)delegate {
                                 this.mSelectedRecord.SetValue("registered", "1");
                                 int result = 0;
                                 if (int.TryParse(this.mSelectedRecord["player_count"], out result))
                                 {
                                     this.mSelectedRecord.SetValue("player_count", (result + 1).ToString());
                                 }
                                 else
                                 {
                                     this.mSelectedRecord.SetValue("player_count", "1");
                                 }
                                 this.btnRegister.Enabled = true;
                                 this.CheckSelection();
                                 this.CheckUnderlines();
                             });
                         }
                     };
                 }
                 ThreadQueue.QueueUserWorkItem(callBack, new object[0]);
             }
         }
     }
     else if (((int) this.btnRegister.Tag) == 1)
     {
         if (this.mSelectedRecord != null)
         {
             this.btnRegister.Enabled = false;
             if (callback2 == null)
             {
                 callback2 = delegate (object o) {
                     VGen0 method = null;
                     DataList queryData = DataAccess.GetQueryData("Tournament Status Check", new object[] { this.mSelectedRecord["tournament_id"] });
                     if ((queryData.Count == 0) || (queryData[0][0].ToUpper() != "REGISTRATION"))
                     {
                         if (method == null)
                         {
                             method = delegate {
                                 DlgMessage.ShowDialog(base.MainForm, Loc.Get("<LOC>This tournament has already started.  You can no longer join."));
                             };
                         }
                         base.Invoke(method);
                     }
                     else
                     {
                         DataAccess.ExecuteQuery("Tournament Unregister", new object[] { this.mSelectedRecord["tournament_id"] });
                         DataAccess.ExecuteQuery("Tournament Player Count", new object[] { this.mSelectedRecord["tournament_id"] });
                         base.Invoke((VGen0)delegate {
                             this.mSelectedRecord.SetValue("registered", "0");
                             int result = 0;
                             if (int.TryParse(this.mSelectedRecord["player_count"], out result))
                             {
                                 this.mSelectedRecord.SetValue("player_count", (result - 1).ToString());
                             }
                             else
                             {
                                 this.mSelectedRecord.SetValue("player_count", "0");
                             }
                             this.btnRegister.Enabled = true;
                             this.CheckSelection();
                             this.CheckUnderlines();
                         });
                     }
                 };
             }
             ThreadQueue.QueueUserWorkItem(callback2, new object[0]);
         }
     }
     else if (((int) this.btnRegister.Tag) == 3)
     {
         new DlgTournamentResults(Convert.ToInt32(this.mSelectedRecord["tournament_id"])).Show();
     }
     else if (this.mSelectedRecord != null)
     {
         DlgTournamentCreation creation = new DlgTournamentCreation();
         creation.MainForm = base.MainForm;
         creation.LoadTournament(Convert.ToInt32(this.mSelectedRecord["tournament_id"]));
         creation.FormClosed += new FormClosedEventHandler(this.dlg_FormClosed);
         creation.Show();
     }
 }