private void DeleteTournament() { int si = 0; try { si = lvwTournaments.SelectedItems[0].Index; } catch { MessageBox.Show("Please select the tournament you want to Delete"); return; } Tournament selectedTournament = list[si]; /* if(selectedTournament.tournamentStatus == 3 || selectedTournament.tournamentStatus == 2) * { * MessageBox.Show("Sorry you cannot delete this tournament that already active or close"); * return; * }*/ string message = "Do you really want delete?[" + selectedTournament.tournamentTitle + "] " + "All data that have been related in this tournament will be delete"; if (DialogResult.Yes == MessageBox.Show(message, "System", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)) { TournamentHelper.DeleteTournament(selectedTournament.tournamentID); displayTournament(); } }
private void button1_Click(object sender, EventArgs e) { int id = (tournament == null) ? 0 : tournament.tournamentID; Tournament tournaments = new Tournament() { tournamentID = id, tournamentStart = dtpStart.Value, tournamentEnd = dtpEnd.Value, tournamentMotto = txtMotto.Text, tournamentTitle = txtTitle.Text }; if (!tournaments.isValid()) { MessageBox.Show("Please check the data you input"); return; } if (TournamentHelper.SaveTournament(tournaments) == 0) { //report an error MessageBox.Show("Sorry you cant create tournament,One Tournament Per Year Policy"); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } this.DialogResult = System.Windows.Forms.DialogResult.OK; }
private void ActivateStatus() { tournamentDetails.tournamentStatus = 2; List <Team> team = TeamHelper.GetTeam(tournamentDetails); List <GameOfficial> gameofficial = GameOfficialHelper.GetAllGameOfficial(tournamentDetails); List <Player> player = PlayerHelper.GetPlayer(tournamentDetails); List <Venue> venue = VenueHelper.GetVenue(); /* if(tournamentDetails.ValidationOfActivation(team,gameofficial,player) != true) * { * MessageBox.Show("Error Activating"); * return; * } */ List <Match> match = Match.GenerateMatch(team, venue, tournamentDetails); foreach (Match m in match) { MatchHelper.SaveMatch(m); } if (TournamentHelper.UpdateTournamentStatus(tournamentDetails) == 0) { //report an error MessageBox.Show("Error activating tournament"); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } this.DialogResult = System.Windows.Forms.DialogResult.OK; }
public JsonResult ValidatePool(IEnumerable <ParticipationCombatModel> participations) { var result = new JsonResult(); result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; var tree = TournamentHelper.BuildTree(participations); result.Data = new { competiteurs = tree, count = participations.Count(), usePool = false }; return(result); }
private void CloseStatus() { tournamentDetails.tournamentStatus = 3; if (TournamentHelper.UpdateTournamentStatus(tournamentDetails) == 0) { //report an error MessageBox.Show("Error activating tournament"); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } this.DialogResult = System.Windows.Forms.DialogResult.OK; }
private void displayTournament() { int ctr = 0; list = TournamentHelper.GetTournament(); lvwTournaments.Items.Clear(); ListViewItem item; foreach (Tournament tournament in list) { item = lvwTournaments.Items.Add((++ctr).ToString()); item.SubItems.Add(tournament.tournamentID.ToString()); item.SubItems.Add(tournament.tournamentTitle.Trim()); item.SubItems.Add(tournament.tournamentStart.Year.ToString()); item.SubItems.Add(getStatus(tournament.tournamentStatus)); } }
private void ActivateStatus() { int si = 0; try { si = lvwTournaments.SelectedItems[0].Index; } catch { return; } Tournament selectedTournament = list[si]; selectedTournament.tournamentStatus = 2; List <Team> team = TeamHelper.GetTeam(selectedTournament); List <GameOfficial> gameofficial = GameOfficialHelper.GetAllGameOfficial(selectedTournament); List <Player> player = PlayerHelper.GetPlayer(selectedTournament); List <Venue> venue = VenueHelper.GetVenue(); if (selectedTournament.ValidationOfActivation(team, gameofficial, player) != true) { MessageBox.Show("Cannot Activate because you need follow the rules activating the tourmament[2 Teams] And [2 Game Official] require"); return; } List <Match> match = Match.GenerateMatch(team, venue, selectedTournament); foreach (Match m in match) { MatchHelper.SaveMatch(m); } if (TournamentHelper.UpdateTournamentStatus(selectedTournament) == 0) { //report an error MessageBox.Show("Error activating tournament"); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } lblStatus.Text = "Activate"; btnActivate.Visible = false; btnPrint.Visible = false; btnExportTeamRooster.Visible = true; btnClose.Visible = true; displayTournament(); }
private void frmViewTournament_Load(object sender, EventArgs e) { InitializeTournamentList(); //HIDE BUTTONS btnPrint.Visible = false; btnActivate.Visible = false; btnClose.Visible = false; //Add Tag in Button btnCreate.Tag = 1; btnUpdate.Tag = 2; btnDelete.Tag = 3; //Add Click Event in button btnCreate.Click += Button_Click; btnUpdate.Click += Button_Click; btnDelete.Click += Button_Click; list = TournamentHelper.GetTournament(); displayTournament(); }
private void CloseStatus() { int si = 0; try { si = lvwTournaments.SelectedItems[0].Index; } catch { return; } Tournament selectedTournament = list[si]; selectedTournament.tournamentStatus = 3; if (TournamentHelper.UpdateTournamentStatus(selectedTournament) == 0) { //report an error MessageBox.Show("Error activating tournament"); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } lblStatus.Text = "Closed"; btnClose.Visible = false; displayTournament(); }
public JsonResult UpdatePresentielCombat(IEnumerable <ParticipationModel> participations, IEnumerable <EncadrantModel> encadrants, string getTree) { this.resultats.Read(); var types = this.types.Read(); bool inError = false; try { var epreuveId = participations.First().EpreuveId; foreach (var participation in participations) { var participationCompetiteur = this.participations.Read(p => p.EpreuveId == participation.EpreuveId && p.ParticipantId == participation.ParticipantId).FirstOrDefault(); if (participationCompetiteur != null) { participationCompetiteur.Resultat.Absence = !participation.Present; this.participations.Update(participationCompetiteur); } else { inError = true; } } var encadrements = this.unitOfWork.Repository <Encadrement>(); if (encadrants != null) { foreach (var encadrant in encadrants) { var dbItem = this.encadrements.Read(e => e.EncadrantId == encadrant.Id).FirstOrDefault(); if (dbItem == null) { encadrements.Create(new Encadrement { EpreuveId = epreuveId, EncadrantId = encadrant.Id, Role = encadrant.Role == "Arbitre" ? Role.Arbitre : Role.Administrateur }); } else { dbItem.EncadrantId = encadrant.Id; dbItem.EpreuveId = epreuveId; dbItem.Role = encadrant.Role == "Arbitre" ? Role.Arbitre : Role.Administrateur; encadrements.Update(dbItem); } } } if (!inError) { var epreuve = this.epreuvesCombat.Read().FirstOrDefault(e => e.Id == epreuveId); if (epreuve != null) { bool needTree; if (!bool.TryParse(getTree, out needTree)) { needTree = false; } var result = new JsonResult(); result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; epreuve.Statut = StatutEpreuve.EnCours; this.epreuvesCombat.Update(epreuve); var competiteurs = participations.Where(p => p.Present).Select(p => p.ConvertToCombat()).OrderBy(c => Guid.NewGuid()); if (!epreuve.TypeEpreuve.UseSwissSystem || needTree) { var tree = TournamentHelper.BuildTree(competiteurs); result.Data = new { competiteurs = tree, count = competiteurs.Count(), usePool = false }; } else { var rounds = TournamentHelper.BuildRounds(competiteurs); result.Data = new { rounds = rounds, count = competiteurs.Count(), usePool = true }; } return(result); } throw new ArgumentException("unable to find contest !!"); } else { throw new ArgumentException("oups !!"); } } catch (Exception) { throw; } }
static void Main(string[] args) { //using (var context = new CoupeQuachVanKeContext()) //{ // var coupe = new Coupe() // { // Nom = "CoupeQVK2015", // Description = "Coupe Quach Van Kê 2015", // NombreTapis = 4, // Ville = "JACOU", // CodePostal = "34830", // Voie = "Rue Henri MOYNIER", // Complement = "Gymnase Puigsegur", // DateDebut = new DateTime(2015, 5, 16, 12, 0, 0), // DateFin = new DateTime(2015, 5, 17, 18, 0, 0), // Responsable = new ResponsableCoupe // { // Nom = "Tran Van Ba", // Prenom = "Christophe", // MailContact = "*****@*****.**", // Telephone = "00-00-00-00-00", // Adresse = "chez cricri" // } // }; // var md = new Medecin // { // Nom = "GALLAUX", // Prenom = "Jean-Pierre" // }; // coupe.Medecins = new List<Medecin>(); // coupe.Medecins.Add(md); // context.Entry(coupe).State = EntityState.Added; // context.SaveChanges(); //} int count; string input = Console.ReadLine(); if (!int.TryParse(input, out count)) { count = 1; } var list = new List <ParticipationCombatModel>(); for (int i = 1; i < count + 1; i++) { list.Add(new ParticipationCombatModel { Club = "Club " + (i), ClubId = i, Couleur = (i % 2 == 0)? "#0000FF" : "#FF0000", EpreuveId = 1004, Id = i, Nom = "Nom " + i, ParticipantId = i, Prenom = "Prenom " + i, }); } var source = list.OrderBy(a => Guid.NewGuid()); var tree = TournamentHelper.BuildTree(source); Console.ReadLine(); }
private void GetAllTournament() { listTournament = TournamentHelper.GetTournament(); }