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; } }
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; } }