Ejemplo n.º 1
0
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            kindBox.ItemsSource = null;
            kindBox.IsReadOnly  = true;
            DeleteSpaces(kindBox);

            foreach (TextBox tb in _tblist)
            {
                DeleteSpaces(tb);
                tb.IsReadOnly = true;
            }

            int _mistakes = 0;

            if (timeBox.Text != null)
            {
                try
                {
                    int.Parse(timeBox.Text);
                }
                catch
                {
                    _mistakes += 1;
                }
            }
            if (kindBox.Text == "")
            {
                _mistakes += 1;
            }
            if (nameBox.Text == "")
            {
                _mistakes += 1;
            }
            if (_mistakes == 0)
            {
                RecipePage.ChosenCommon().Kind = kindBox.Text;
                RecipePage.ChosenCommon().Name = nameBox.Text;
                RecipePage.ChosenCommon().Time = timeBox.Text;
                RecipePage.ChosenCommon().Link = linkBox.Text;
                RecipePage.ChosenCommon().Text = recipeBox.Text;
                MainMenu.CommonList()[RecipePage.IndexOfItem()] = RecipePage.ChosenCommon();
                if (LoginPage.IsLogged())
                {
                    MainMenu.UsersList()[RecipePage.IndexOfItemU()] = RecipePage.ChosenCommon();
                }
            }
            else
            {
                MessageBox.Show("Incorrect data was entered");
                kindBox.Text   = RecipePage.ChosenCommon().Kind;
                nameBox.Text   = RecipePage.ChosenCommon().Name;
                timeBox.Text   = RecipePage.ChosenCommon().Time;
                recipeBox.Text = RecipePage.ChosenCommon().Text;
                linkBox.Text   = RecipePage.ChosenCommon().Link;
            }
        }
Ejemplo n.º 2
0
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            int _mistakes = 0;

            DeleteSpaces(gameBox);
            gameBox.ItemsSource = null;
            foreach (var box in _tblist)
            {
                DeleteSpaces(box);
            }
            if (gameBox.Text == "")
            {
                _mistakes += 1;
            }
            if (nameBox.Text == "")
            {
                _mistakes += 1;
            }
            if (ingBox.Text == "")
            {
                _mistakes += 1;
            }
            if (_mistakes == 0)
            {
                RecipePage.ChosenGame().Game        = gameBox.Text;
                RecipePage.ChosenGame().Name        = nameBox.Text;
                RecipePage.ChosenGame().Link        = linkBox.Text;
                RecipePage.ChosenGame().Ingredients = ingBox.Text;
                MainMenu.GameList()[RecipePage.IndexOfItem()] = RecipePage.ChosenGame();
            }
            else
            {
                MessageBox.Show("Incorrect data was entered");
                gameBox.Text = RecipePage.ChosenGame().Game;
                nameBox.Text = RecipePage.ChosenGame().Name;
                linkBox.Text = RecipePage.ChosenGame().Link;
                ingBox.Text  = RecipePage.ChosenGame().Ingredients;
            }
        }