Bläddra i källkod

Сделана полная автоподстановка команд в следующие матчи и отображение счета в матче

максим карбышев 3 år sedan
förälder
incheckning
6967beeb58

+ 2 - 0
CybersportTournament/AddWindows/AddMatchWindow.xaml

@@ -12,8 +12,10 @@
         <DatePicker Name="Date" Margin="1010,134,0,0" VerticalAlignment="Top" Height="50" Width="250" FontSize="30" HorizontalAlignment="Left" Foreground="White"/>
         <Label Content="Команда 1:" HorizontalAlignment="Left" Margin="127,586,0,0" VerticalAlignment="Top" Height="50" Width="190" Foreground="White" FontSize="30"/>
         <ComboBox Name="TeamOneBox" HorizontalAlignment="Left" Margin="317,586,0,0" VerticalAlignment="Top" Height="50" Width="400" FontSize="30" SelectionChanged="TeamOneBoxSelectionChanged"/>
+        <Label Name="TeamOneLabel" HorizontalAlignment="Left" Margin="317,586,0,0" VerticalAlignment="Top" Height="50" Width="400" FontSize="30" Foreground="White" Visibility="Hidden"/>
         <Label Content="Команда 2:" HorizontalAlignment="Left" Margin="883,586,0,0" VerticalAlignment="Top" Height="50" Width="190" Foreground="White" FontSize="30"/>
         <ComboBox Name="TeamTwoBox" HorizontalAlignment="Left" Margin="1074,586,0,0" VerticalAlignment="Top" Height="50" Width="400" FontSize="30" SelectionChanged="TeamTwoBoxSelectionChanged"/>
+        <Label Name="TeamTwoLabel" HorizontalAlignment="Left" Margin="1074,586,0,0" VerticalAlignment="Top" Height="50" Width="400" FontSize="30" Foreground="White" Visibility="Hidden"/>
         <Image Name="TeamOneLogo" HorizontalAlignment="Left" Height="300" Margin="300,234,0,0" VerticalAlignment="Top" Width="300"/>
         <Image Name="TeamTwoLogo" HorizontalAlignment="Left" Height="300" Margin="1000,234,0,0" VerticalAlignment="Top" Width="300"/>
         <Button Name="BackButton"  Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>

+ 35 - 8
CybersportTournament/AddWindows/AddMatchWindow.xaml.cs

@@ -32,15 +32,21 @@ namespace CybersportTournament.AddWindows
             TournamentBox.ItemsSource = Connection.db.Tournaments.Where(item => item.ID == TournamentID).Select(item => item.Name).ToList();
             TournamentBox.SelectedIndex = 0;
         }
-        public AddMatchWindow(int TournamentID, List<int> teamsID, int NumberList)
+        public AddMatchWindow(int TournamentID, int FirstTeamNextMatchID, int SecondTeamNextMatchID, int NumberList)
         {
             InitializeComponent();
             this.NumberList = NumberList;
-            teamsOneID = Connection.db.Teams.Where(item => teamsID.Contains(item.ID)).Select(item => item.ID).ToList();
-            teamsTwoID = Connection.db.Teams.Where(item => teamsID.Contains(item.ID)).Select(item => item.ID).ToList();
+            TeamOneBox.Visibility = Visibility.Hidden;
+            TeamTwoBox.Visibility = Visibility.Hidden;
+            TeamOneLabel.Visibility = Visibility.Visible;
+            TeamTwoLabel.Visibility = Visibility.Visible;
+
+            TeamOneLogo.Source = (NewImage(FirstTeamNextMatchID));
+            TeamTwoLogo.Source = (NewImage(SecondTeamNextMatchID));
+
+            TeamOneLabel.Content = Connection.db.Teams.Where(item => item.ID == FirstTeamNextMatchID).Select(item => item.Name).FirstOrDefault();
+            TeamTwoLabel.Content = Connection.db.Teams.Where(item => item.ID == SecondTeamNextMatchID).Select(item => item.Name).FirstOrDefault();
 
-            TeamOneBox.ItemsSource = Connection.db.Teams.Where(item => teamsOneID.Contains(item.ID)).Select(item => item.Name).ToList();
-            TeamTwoBox.ItemsSource = Connection.db.Teams.Where(item => teamsTwoID.Contains(item.ID)).Select(item => item.Name).ToList();
             TournamentBox.ItemsSource = Connection.db.Tournaments.Where(item => item.ID == TournamentID).Select(item => item.Name).ToList();
             TournamentBox.SelectedIndex = 0;
         }
@@ -82,7 +88,16 @@ namespace CybersportTournament.AddWindows
         private void AddButtonClick(object sender, RoutedEventArgs e)
         {
             #region Добавление матча
-            if (TournamentBox.SelectedItem == null || TeamOneBox.SelectedItem == null || TeamTwoBox.SelectedItem == null || Date.SelectedDate == null)
+            if (TeamOneLabel.Content.ToString() == "" || TeamTwoLabel.Content.ToString() == "")
+            {
+                if (TeamOneBox.SelectedItem == null || TeamTwoBox.SelectedItem == null)
+                {
+                    ErrorWindow ew = new ErrorWindow("пустые поля");
+                    ew.Show();
+                    return;
+                }
+            }
+            if (TournamentBox.SelectedItem == null || Date.SelectedDate == null)
             {
                 ErrorWindow ew = new ErrorWindow("пустые поля");
                 ew.Show();
@@ -107,16 +122,28 @@ namespace CybersportTournament.AddWindows
             Connection.db.MatchList.Add(matchList);
             Connection.db.SaveChanges();
 
+            string teamOneName;
+            if (TeamOneBox.Visibility != Visibility.Hidden)
+                teamOneName = TeamOneBox.SelectedItem.ToString();
+            else
+                teamOneName = TeamOneLabel.Content.ToString();
+
+            string teamTwoName;
+            if (TeamTwoBox.Visibility != Visibility.Hidden)
+                teamTwoName = TeamTwoBox.SelectedItem.ToString();
+            else
+                teamTwoName = TeamTwoLabel.Content.ToString();
+
             TeamsList teamsListOne = new TeamsList()
             {
                 IDTournament = TournamentID,
-                IDTeam = Connection.db.Teams.Where(item => item.Name == TeamOneBox.SelectedItem.ToString()).Select(item => item.ID).FirstOrDefault(),
+                IDTeam = Connection.db.Teams.Where(item => item.Name == teamOneName).Select(item => item.ID).FirstOrDefault(),
                 NumberTeamList = NumberList
             };
             TeamsList teamsListTwo = new TeamsList()
             {
                 IDTournament = TournamentID,
-                IDTeam = Connection.db.Teams.Where(item => item.Name == TeamTwoBox.SelectedItem.ToString()).Select(item => item.ID).FirstOrDefault(),
+                IDTeam = Connection.db.Teams.Where(item => item.Name == teamTwoName).Select(item => item.ID).FirstOrDefault(),
                 NumberTeamList = NumberList
             };
 

+ 1 - 1
CybersportTournament/AddWindows/AddRoundWindow.xaml.cs

@@ -31,7 +31,7 @@ namespace CybersportTournament.AddWindows
 
         private void AddButtonClick(object sender, RoutedEventArgs e)
         {
-            #region Добавление раундreturn;
+            #region Добавление раунда;
 
             Rounds round = new Rounds()
             {

+ 14 - 0
CybersportTournament/ElementsWindows/TournamentWindow.xaml

@@ -17,45 +17,59 @@
         <Image Name="Logo" HorizontalAlignment="Left" Margin="984,34,0,0" Width="540" Height="93" VerticalAlignment="Top"/>
         <Label Name="FMatchFTeam" Content="" HorizontalAlignment="Left" Margin="78,270,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
                Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="FMatchMouseDoubleClick"/>
+        <Label Name="FMatchFTeamScore" Content="" HorizontalAlignment="Left" Margin="428,289,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,0 75,0 75,30 150,30" Height="30" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="329,292,0,0"/>
         <Label Name="FMatchSTeam" Content="" HorizontalAlignment="Left" Margin="78,330,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
                Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="FMatchMouseDoubleClick"/>
+        <Label Name="FMatchSTeamScore" Content="" HorizontalAlignment="Left" Margin="428,329,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,30 75,30 75,0 150,0" Height="30" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="329,322,0,0"/>
         <Label x:Name="SMatchFTeam" Content="" HorizontalAlignment="Left" Margin="78,390,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="SMatchMouseDoubleClick"/>
+        <Label Name="SMatchFTeamScore" Content="" HorizontalAlignment="Left" Margin="428,409,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,0, 75,0 75,30, 150,30" Height="30" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="329,412,0,0"/>
         <Label x:Name="SMatchSTeam" Content="" HorizontalAlignment="Left" Margin="78,450,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="SMatchMouseDoubleClick"/>
+        <Label Name="SMatchSTeamScore" Content="" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="428,449,0,0" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,30, 75,30 75,0, 150,0" Height="30" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="329,442,0,0"/>
         <Label x:Name="TMatchFTeam" Content="" HorizontalAlignment="Left" Margin="78,510,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="TMatchMouseDoubleClick"/>
+        <Label Name="TMatchFTeamScore" Content="" HorizontalAlignment="Left" Margin="428,529,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,0, 75,0 75,30, 150,30" Height="30" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="329,532,0,0"/>
         <Label x:Name="TMatchSTeam" Content="" HorizontalAlignment="Left" Margin="78,570,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="TMatchMouseDoubleClick"/>
+        <Label Name="TMatchSTeamScore" Content="" HorizontalAlignment="Left" Margin="428,569,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,30, 75,30 75,0 150,0" Height="30" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="329,562,0,0"/>
         <Label x:Name="FoMatchFTeam" Content="" HorizontalAlignment="Left" Margin="78,630,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="FoMatchMouseDoubleClick"/>
+        <Label Name="FoMatchFTeamScore" Content="" HorizontalAlignment="Left" Margin="428,649,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,0, 75,0 75,30 150,30" Height="30" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="329,652,0,0"/>
         <Label x:Name="FoMatchSTeam" Content="" HorizontalAlignment="Left" Margin="78,690,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="FoMatchMouseDoubleClick"/>
+        <Label Name="FoMatchSTeamScore" Content="" HorizontalAlignment="Left" Margin="428,689,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,30, 75,30 75,0 150,0" Height="30" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="329,682,0,0"/>
         <Label x:Name="FiMatchFTeam" Content="" HorizontalAlignment="Left" Margin="480,300,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="FiMatchMouseDoubleClick"/>
+        <Label Name="FiMatchFTeamScore" Content="" HorizontalAlignment="Left" Margin="831,349,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,0, 75,0 75,60 150,60" Height="60" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="732,322,0,0"/>
         <Label x:Name="FiMatchSTeam" Content="" HorizontalAlignment="Left" Margin="480,0,0,0" VerticalAlignment="Center" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="FiMatchMouseDoubleClick"/>
+        <Label Name="FiMatchSTeamScore" Content="" HorizontalAlignment="Left" Margin="831,389,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,60, 75,60 75,0 150,0" Height="60" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="732,382,0,0"/>
         <Label x:Name="SiMatchFTeam" Content="" HorizontalAlignment="Left" Margin="480,540,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="SiMatchMouseDoubleClick"/>
+        <Label Name="SiMatchFTeamScore" Content="" HorizontalAlignment="Left" Margin="831,589,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,0, 75,0 75,60 150,60" Height="60" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="732,562,0,0"/>
         <Label x:Name="SiMatchSTeam" Content="" HorizontalAlignment="Left" Margin="480,660,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="SiMatchMouseDoubleClick"/>
+        <Label Name="SiMatchSTeamScore" Content="" HorizontalAlignment="Left" Margin="831,629,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,60, 75,60 75,0 150,0" Height="60" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="732,622,0,0"/>
         <Label x:Name="SeMatchFTeam" Content="" HorizontalAlignment="Left" Margin="883,360,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="SeMatchMouseDoubleClick"/>
+        <Label Name="SeMatchFTeamScore" Content="" HorizontalAlignment="Left" Margin="1236,469,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,0, 75,0 75,120 150,120" Height="120" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="1135,382,0,0"/>
         <Label x:Name="SeMatchSTeam" Content="" HorizontalAlignment="Left" Margin="883,600,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center" MouseDoubleClick="SeMatchMouseDoubleClick"/>
+        <Label Name="SeMatchSTeamScore" Content="" HorizontalAlignment="Left" Margin="1236,509,0,0" VerticalAlignment="Top" Foreground="White" Width="30"/>
         <Polyline Stroke="White" Points="0,120,75,120 75,0 150,0" Height="120" Width="150" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="1135,502,0,0"/>
         <Label x:Name="Winner" Content="" HorizontalAlignment="Left" Margin="1286,480,0,0" VerticalAlignment="Top" Width="250" Height="45" FontSize="25" 
             Foreground="#FF54E4FF" HorizontalContentAlignment="Center"/>

+ 61 - 30
CybersportTournament/ElementsWindows/TournamentWindow.xaml.cs

@@ -6,7 +6,7 @@ using ConnectionClass;
 using CybersportTournament.ListWindows;
 using CybersportTournament.AddWindows;
 using System.Windows.Controls;
-using System.Collections.Generic;
+using System;
 
 namespace CybersportTournament.ElementsWindows
 {
@@ -24,8 +24,10 @@ namespace CybersportTournament.ElementsWindows
             Game.Content = tournament.Games.Name;
             PrizeFund.Content = tournament.PrizeFund;
             Logo.Source = NewImage(tournament);
-            Label[,] labels = new Label[7, 2] { { FMatchFTeam, FMatchSTeam }, {SMatchFTeam, SMatchSTeam }, { TMatchFTeam, TMatchSTeam },
-                { FoMatchFTeam, FoMatchSTeam }, { FiMatchFTeam, FiMatchSTeam }, { SiMatchFTeam, SiMatchSTeam }, { SeMatchFTeam, SeMatchSTeam } };
+            Label[,] labels = new Label[7, 4] { { FMatchFTeam, FMatchSTeam, FMatchFTeamScore, FMatchSTeamScore }, {SMatchFTeam, SMatchSTeam, SMatchFTeamScore, SMatchSTeamScore },
+                                                { TMatchFTeam, TMatchSTeam, TMatchFTeamScore, TMatchSTeamScore },{ FoMatchFTeam, FoMatchSTeam, FoMatchFTeamScore, FoMatchSTeamScore },
+                                                { FiMatchFTeam, FiMatchSTeam, FiMatchFTeamScore, FiMatchSTeamScore },{ SiMatchFTeam, SiMatchSTeam, SiMatchFTeamScore, SiMatchSTeamScore },
+                                                { SeMatchFTeam, SeMatchSTeam, SeMatchFTeamScore, SeMatchSTeamScore } };
             for (int i = 1; i < 8; i++)
             {
                 if (Connection.db.TeamsList.Where(item => item.IDTournament == tournament.ID).Select(item => item.NumberTeamList).Contains(i))
@@ -35,6 +37,13 @@ namespace CybersportTournament.ElementsWindows
                     labels[i - 1, 1].Content = Connection.db.TeamsList.Where(item => item.IDTournament == tournament.ID && item.NumberTeamList == i
                                                                          && item.IDTeam != firstTeamID).Select(item => item.Teams.Name).FirstOrDefault();
 
+                    string matchResult = Connection.db.MatchList.Where(item => item.Tournaments.ID == tournament.ID && item.Match.Number == i).Select(item => item.Match.Result).FirstOrDefault();
+                    int length = matchResult.IndexOf(':');
+                    int firstTeamScore = Convert.ToInt32(matchResult.Substring(0, length));
+                    int secondTeamScore = Convert.ToInt32(matchResult.Substring(length + 1, matchResult.Length - length - 1));
+
+                    labels[i - 1, 2].Content = firstTeamScore;
+                    labels[i - 1, 3].Content = secondTeamScore;
                 }
             }
         }
@@ -131,16 +140,24 @@ namespace CybersportTournament.ElementsWindows
         private void FiMatchMouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
         {
             #region Переход на матчи полуфинала и финала
-            if ((FMatchFTeam.Content.ToString() != "" && FMatchSTeam.Content.ToString() != ""
-                && SMatchFTeam.Content.ToString() != "" && SMatchSTeam.Content.ToString() != "")
-                && (FiMatchFTeam.Content.ToString() == "" && FiMatchSTeam.Content.ToString() == ""))
+            if ((FMatchFTeamScore.Content.ToString() != "0" && FMatchSTeamScore.Content.ToString() != "0"
+                && SMatchFTeamScore.Content.ToString() != "0" && SMatchSTeamScore.Content.ToString() != "0")
+                && (FiMatchFTeam.Content.ToString() == "" && FiMatchSTeam.Content.ToString() == "")
+                && (Convert.ToInt32(FMatchFTeamScore.Content) != Convert.ToInt32(FMatchSTeamScore.Content)
+                && Convert.ToInt32(SMatchFTeamScore.Content) != Convert.ToInt32(SMatchSTeamScore.Content)))
             {
-                List<int> teamsID = new List<int>();
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == FMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == FMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == SMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == SMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                AddMatchWindow mw = new AddMatchWindow(tournament.ID, teamsID, 5);
+                int FirstTeamNextMatchID = 0, SecondTeamNextMatchID = 0;
+                if (Convert.ToInt32(FMatchFTeamScore.Content) > Convert.ToInt32(FMatchSTeamScore.Content))
+                    FirstTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == FMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+                else if (Convert.ToInt32(FMatchFTeamScore.Content) < Convert.ToInt32(FMatchSTeamScore.Content))
+                    FirstTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == FMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+
+                if (Convert.ToInt32(SMatchFTeamScore.Content) > Convert.ToInt32(SMatchSTeamScore.Content))
+                    SecondTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == SMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+                else if (Convert.ToInt32(SMatchFTeamScore.Content) < Convert.ToInt32(SMatchSTeamScore.Content))
+                    SecondTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == SMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+
+                AddMatchWindow mw = new AddMatchWindow(tournament.ID, FirstTeamNextMatchID, SecondTeamNextMatchID, 5);
                 mw.Show();
                 this.Close();
             }
@@ -155,16 +172,23 @@ namespace CybersportTournament.ElementsWindows
 
         private void SiMatchMouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
         {
-            if ((TMatchFTeam.Content.ToString() != "" && TMatchSTeam.Content.ToString() != ""
-                && FoMatchFTeam.Content.ToString() != "" && FoMatchSTeam.Content.ToString() != "")
-                && (SiMatchFTeam.Content.ToString() == "" && SiMatchSTeam.Content.ToString() == ""))
+            if ((TMatchFTeamScore.Content.ToString() != "0" && TMatchSTeamScore.Content.ToString() != "0"
+                && FoMatchFTeamScore.Content.ToString() != "0" && FoMatchSTeamScore.Content.ToString() != "0")
+                && (SiMatchFTeam.Content.ToString() == "" && SiMatchSTeam.Content.ToString() == "")
+                && (Convert.ToInt32(TMatchFTeamScore.Content) != Convert.ToInt32(TMatchSTeamScore.Content)
+                && Convert.ToInt32(FoMatchFTeamScore.Content) != Convert.ToInt32(FoMatchSTeamScore.Content)))
             {
-                List<int> teamsID = new List<int>();
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == TMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == TMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == FoMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == FoMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                AddMatchWindow mw = new AddMatchWindow(tournament.ID, teamsID, 6);
+                int FirstTeamNextMatchID = 0, SecondTeamNextMatchID = 0;
+                if (Convert.ToInt32(TMatchFTeamScore.Content) > Convert.ToInt32(TMatchSTeamScore.Content))
+                    FirstTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == TMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+                else if (Convert.ToInt32(TMatchFTeamScore.Content) > Convert.ToInt32(TMatchSTeamScore.Content))
+                    FirstTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == TMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+                if (Convert.ToInt32(FoMatchFTeamScore.Content) > Convert.ToInt32(FoMatchSTeamScore.Content))
+                    SecondTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == FoMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+                else if (Convert.ToInt32(FoMatchFTeamScore.Content) < Convert.ToInt32(FoMatchSTeamScore.Content))
+                    SecondTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == FoMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+
+                AddMatchWindow mw = new AddMatchWindow(tournament.ID, FirstTeamNextMatchID, SecondTeamNextMatchID, 6);
                 mw.Show();
                 this.Close();
             }
@@ -179,16 +203,23 @@ namespace CybersportTournament.ElementsWindows
 
         private void SeMatchMouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
         {
-            if ((FiMatchFTeam.Content.ToString() != "" && FiMatchSTeam.Content.ToString() != ""
-                && SiMatchFTeam.Content.ToString() != "" && SiMatchSTeam.Content.ToString() != "")
-                && (SeMatchFTeam.Content.ToString() == "" && SeMatchSTeam.Content.ToString() == ""))
+            if ((FiMatchFTeamScore.Content.ToString() != "0" && FiMatchSTeamScore.Content.ToString() != "0"
+                && SiMatchFTeamScore.Content.ToString() != "0" && SiMatchSTeamScore.Content.ToString() != "0")
+                && (SeMatchFTeam.Content.ToString() == "" && SeMatchSTeam.Content.ToString() == "")
+                && (Convert.ToInt32(FiMatchFTeamScore.Content) != Convert.ToInt32(FiMatchSTeamScore.Content)
+                && Convert.ToInt32(SiMatchFTeamScore.Content) != Convert.ToInt32(SiMatchSTeamScore.Content)))
             {
-                List<int> teamsID = new List<int>();
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == FiMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == FiMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == SiMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                teamsID.Add(Connection.db.Teams.Where(item => item.Name == SiMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault());
-                AddMatchWindow mw = new AddMatchWindow(tournament.ID, teamsID, 7);
+                int FirstTeamNextMatchID = 0, SecondTeamNextMatchID = 0;
+                if (Convert.ToInt32(FiMatchFTeamScore.Content) > Convert.ToInt32(FiMatchSTeamScore.Content))
+                    FirstTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == FiMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+                else if (Convert.ToInt32(FiMatchFTeamScore.Content) > Convert.ToInt32(FiMatchSTeamScore.Content))
+                    FirstTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == FiMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+                if (Convert.ToInt32(SiMatchFTeamScore.Content) > Convert.ToInt32(SiMatchSTeamScore.Content))
+                    SecondTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == SiMatchFTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+                else if (Convert.ToInt32(SiMatchFTeamScore.Content) < Convert.ToInt32(SiMatchSTeamScore.Content))
+                    SecondTeamNextMatchID = Connection.db.Teams.Where(item => item.Name == SiMatchSTeam.Content.ToString()).Select(item => item.ID).FirstOrDefault();
+
+                AddMatchWindow mw = new AddMatchWindow(tournament.ID, FirstTeamNextMatchID, SecondTeamNextMatchID, 7);
                 mw.Show();
                 this.Close();
             }