/// <summary>
        /// Callback-метод кнопки начала игры
        /// </summary>
        void StartGameButton_Click(object sender, RoutedEventArgs e)
        {
            if (findGame.WinCombination == "")
            {
                Random        rand    = new Random();
                StringBuilder str     = new StringBuilder();
                int[]         randmas = new int[findGame.GetMaxNum()];
                for (int i = 0; i < findGame.GetMaxNum(); i++)
                {
                    randmas[i] = i + 1;
                }
                int currand = 0;
                for (int i = 0; i < findGame.GetNumCount(); i++)
                {
                    currand = rand.Next() % (findGame.GetMaxNum());
                    if (currand != i)
                    {
                        randmas[i]      += randmas[currand];
                        randmas[currand] = randmas[i] - randmas[currand];
                        randmas[i]      -= randmas[currand];
                    }
                }
                Array.Sort(randmas, 0, findGame.GetNumCount());

                for (int i = 0; i < findGame.GetNumCount(); i++)
                {
                    str.AppendFormat("_{0}", randmas[i]);
                }
                str.Remove(0, 1);
                findGame.WinCombination = str.ToString();
                dbase.SaveGame(findGame);
                FindDataPermBox.Text = str.ToString();
                List <Ticket> tickets   = dbase.GetTicketsByGameId(findGame.GameId);
                int[][]       ticketMas = new int[tickets.Count][];
                for (int i = 0; i < tickets.Count; i++)
                {
                    ticketMas[i] = new int[findGame.GetNumCount() + 1];
                }

                for (int i = 0; i < tickets.Count; i++)
                {
                    ticketMas[i] = dbase.SplitCombination(tickets[i].Combination, findGame.GetNumCount());
                }

                for (int i = 0; i < findGame.GetNumCount(); i++)
                {
                    for (int j = 0; j < tickets.Count; j++)
                    {
                        for (int k = 0; k < findGame.GetNumCount(); k++)
                        {
                            if (randmas[i] > ticketMas[j][k])
                            {
                                break;
                            }
                            if (randmas[i] == ticketMas[j][k])
                            {
                                ticketMas[j][findGame.GetNumCount()]++;
                                break;
                            }
                        }
                    }
                }

                for (int i = 0; i < tickets.Count; i++)
                {
                    for (int j = findGame.GetNumCount(); j > 0; j--)
                    {
                        if (ticketMas[i][findGame.GetNumCount()] == j)
                        {
                            dbase.SetPrize(tickets[i].OwnerId, dbase.GetPrizeByNumberOfMatches(findGame.Pool, j, findGame.GetNumCount()));
                        }
                    }
                }
                var mes = new Sign("Игра успешно проведена!");
                mes.Show();
            }
        }
        /// <summary>
        /// Callback-метод кнопки поиска содержимого строки поиска
        /// в зависимости от выбора в выпадающем меню
        /// </summary>
        void FindButton_Click(object sender, RoutedEventArgs e)
        {
            int a = 0;

            if (flag == 0)
            {
                FindMyGamesGrid.Items.Clear();
                if (int.TryParse(FindTextBox.Text, out a))
                {
                    findUser = dbase.LoadClient(a);
                }
                else
                {
                    findUser = dbase.LoadClient(FindTextBox.Text);
                }
                if (findUser.IsUserValid())
                {
                    FindProfileData.IsEnabled = true;
                    FindMyGames.IsEnabled     = true;

                    FindDataLogBox.Text   = findUser.Login;
                    FindDataPassBox.Text  = findUser.Pass;
                    FindDataPermBox.Text  = findUser.Type.ToString();
                    FindDataIdBox.Text    = findUser.Id.ToString();
                    FindDataPointBox.Text = findUser.Money.ToString();
                    if (dbase.Type < 3)
                    {
                        FindDataPermBox.IsEnabled = false;
                    }
                    List <Game> games = findUser.GetGames();
                    for (int i = 0; i < games.Count; i++)
                    {
                        Sample sam = new Sample();
                        sam    = games[i].ToSample();
                        sam.P7 = findUser.GetTicketByGameId(games[i].GameId).GetStringFromCombination();
                        FindMyGamesGrid.Items.Add(sam);
                    }
                }
                else
                {
                    var mes = new Sign("Пользователя не существует");
                    mes.Show();
                }
            }
            else
            {
                if (Int32.TryParse(FindTextBox.Text, out a))
                {
                    if (flag == 1)
                    {
                        findGame = dbase.GetGame(a);
                        if (findGame.IsGameValid())
                        {
                            FindProfileData.IsEnabled = true;
                            FindDataLogBox.Text       = findGame.Pool.ToString();
                            FindDataPassBox.Text      = findGame.Type.ToString();
                            FindDataPermBox.Text      = findGame.WinCombination;
                            FindDataIdBox.Text        = findGame.GameId.ToString();
                            FindDataPointBox.Text     = findGame.TicketCost.ToString();
                            if (dbase.Type < 3)
                            {
                                FindDataPermBox.IsEnabled = false;
                            }
                        }
                        else
                        {
                            var mes = new Sign("Игры не существует");
                            mes.Show();
                        }
                    }
                    else if (flag == 2)
                    {
                        findTicket = dbase.GetTicket(a);
                        if (findTicket.IsTicketValid())
                        {
                            FindProfileData.IsEnabled = true;
                            FindDataLogBox.Text       = findTicket.GameId.ToString();
                            FindDataPassBox.Text      = findTicket.OwnerId.ToString();
                            FindDataPermBox.Text      = findTicket.Combination;
                            FindDataPermBox.IsEnabled = true;
                            FindDataIdBox.Text        = findTicket.TicketId.ToString();
                        }
                        else
                        {
                            var mes = new Sign("Билета не существует");
                            mes.Show();
                        }
                    }
                }
            }
        }