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;
            }
        }
示例#2
0
 public gamePage()
 {
     InitializeComponent();
     if (!LoginPage.IsLogged())
     {
         editButton.IsEnabled = false;
         saveButton.IsEnabled = false;
     }
     gameBox.Text       = RecipePage.ChosenGame().Game;
     gameBox.IsReadOnly = true;
     nameBox.Text       = RecipePage.ChosenGame().Name;
     _tblist.Add(nameBox);
     linkBox.Text = RecipePage.ChosenGame().Link;
     _tblist.Add(linkBox);
     ingBox.Text = RecipePage.ChosenGame().Ingredients;
     _tblist.Add(ingBox);
     foreach (var box in _tblist)
     {
         box.IsReadOnly = true;
     }
 }
示例#3
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;
            }
        }
 public commonPage()
 {
     InitializeComponent();
     if (!LoginPage.IsLogged())
     {
         editButton.IsEnabled = false;
         saveButton.IsEnabled = false;
     }
     kindBox.Text       = RecipePage.ChosenCommon().Kind;
     kindBox.IsReadOnly = true;
     nameBox.Text       = RecipePage.ChosenCommon().Name;
     _tblist.Add(nameBox);
     timeBox.Text = RecipePage.ChosenCommon().Time;
     _tblist.Add(timeBox);
     recipeBox.Text = RecipePage.ChosenCommon().Text;
     _tblist.Add(recipeBox);
     linkBox.Text = RecipePage.ChosenCommon().Link;
     _tblist.Add(linkBox);
     foreach (var box in _tblist)
     {
         box.IsReadOnly = true;
     }
 }