Ejemplo n.º 1
0
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            //Добавить нового пользователя
            if (textBoxRegistrationLogin.Text == "" || passwordBoxRegistration.Password == "" || passwordBoxConfirming.Password == "")
            {
                MessageBox.Show("Fill login and password fields", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (LINQFactory.IsLogin(textBoxRegistrationLogin.Text) == true)
            {
                MessageBox.Show("This login exists!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (passwordBoxRegistration.Password != passwordBoxConfirming.Password)
            {
                MessageBox.Show("You entered different passwords", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            using (var context = new Context())
            {
                context.Users.Add(new User(textBoxRegistrationLogin.Text, Hashing.HashPaswword(passwordBoxRegistration.Password)));
                context.SaveChanges();
            }
            GridRegistration.Visibility = Visibility.Hidden;
            GridEnter.Visibility        = Visibility.Visible;
        }
Ejemplo n.º 2
0
 private void ButtomEnter_Click(object sender, RoutedEventArgs e)
 {
     if (textBoxLogin.Text == "" || passwordBox.Password == "")//no login
     {
         MessageBox.Show("Enter login and password please", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     else if (LINQFactory.IsLogin(textBoxLogin.Text) == false)
     {
         MessageBox.Show("You enter incorrect login", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     else if (LINQFactory.IsLoginAndPassword(textBoxLogin.Text, passwordBox.Password) == false)
     {
         MessageBox.Show("Your password is incorrect", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     else if (LINQFactory.HasACareer(textBoxLogin.Text)) //has choosen a team
     {
         //start a game
         this.UserId = LINQFactory.GetUserIdByLogin(textBoxLogin.Text);
         Champoins_League chp = new Champoins_League(userId, Setting, SP);
         chp.ShowDialog();
     }
     else
     {
         this.UserId                   = LINQFactory.GetUserIdByLogin(textBoxLogin.Text);
         GridEnter.Visibility          = Visibility.Hidden;
         GridChoosingMyTeam.Visibility = Visibility.Visible;
     }
 }
Ejemplo n.º 3
0
        private void ButtonStartGame_Click(object sender, RoutedEventArgs e)
        {
            string color1 = ComboBoxColorFirst.SelectedIndex == -1 ? "" : ComboBoxColorFirst.SelectedValue.ToString();
            string color2 = ComboBoxCOlorSecond.SelectedIndex == -1? "" : ComboBoxCOlorSecond.SelectedValue.ToString();

            if (color1 == "" || color2 == "")
            {
                System.Windows.MessageBox.Show("Choose forms for the game", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            int   round = LINQFactory.Round(UserId);
            Match match = Championship.playRound(userId, round);

            //Game
            sp.Stop();
            FootballGameForm f = new FootballGameForm(match.TeamName1, match.TeamName2, LINQFactory.GetNamesById(match.PlayersOne),
                                                      LINQFactory.GetNamesById(match.PlayersTwo), settings.Time, settings.Level, false,
                                                      match.ScorersOne, match.ScorersTwo, color1, color2);

            f.ShowDialog();
            sp = new SoundPlayer(RandomMusic.GetRandomMusic());
            sp.Play();
            match.ScorersOne = f.MyRep.ScoredFirstTeam;
            match.ScorersTwo = f.MyRep.ScoredSecondTeam;
            Championship.SaveMyMatch(match, round, userId);
            ListViewTable.ItemsSource   = Sorting.Sort(LINQFactory.GetTeamsByUser(UserId));
            ListViewResults.ItemsSource = LINQFactory.GetResults(UserId, LINQFactory.Round(UserId) - 1);
            if (round == Repository.Cnt - 1)
            {
                SendToEmail send = new SendToEmail(LINQFactory.GetPointsById(userId));
                send.Show();
                ButtonStartGame.Content   = "Tournament ended!";
                ButtonStartGame.IsEnabled = false;
                LabelTeam1.Content        = "";
                LabelTeam2.Content        = "";
            }
            else
            {
                List <string> Teams = LINQFactory.GetMyMatch(userId, round + 1);
                LabelTeam1.Content = Teams[0];
                LabelTeam2.Content = Teams[1];
            }
        }
Ejemplo n.º 4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            int round = LINQFactory.Round(userId);

            ComboBoxColorFirst.ItemsSource  = (new Repository()).Colors;
            ComboBoxCOlorSecond.ItemsSource = (new Repository()).Colors; ListViewTable.ItemsSource = Sorting.Sort(LINQFactory.GetTeamsByUser(UserId));
            ListViewResults.ItemsSource     = LINQFactory.GetResults(UserId, LINQFactory.Round(UserId) - 1);
            if (round == Repository.Cnt)
            {
                ButtonStartGame.Content   = "Tournament ended!";
                ButtonStartGame.IsEnabled = false;
                LabelTeam1.Content        = "";
                LabelTeam2.Content        = "";
            }
            else
            {
                List <string> Teams = LINQFactory.GetMyMatch(userId, round);
                LabelTeam1.Content = Teams[0];
                LabelTeam2.Content = Teams[1];
            }
        }