Пример #1
0
        void saveButtonClicked(object sender, System.EventArgs e)
        {
            if (firstNameField.Text != null && lastNameField.Text != null && countryPicker.SelectedIndex != -1 && App.imagePath != null)
            {
                connection = new SQLiteConnection(App.Path);
                connection.CreateTable <FootballPlayer> ();

                string Name        = firstNameField.Text + " " + lastNameField.Text;
                string DateOfBirth = dateOfBirth.Date.ToShortDateString();
                string Country     = countryList [countryPicker.SelectedIndex];

                FootballPlayer footballPlayer = new FootballPlayer(Name, DateOfBirth, Country, App.imagePath, false);

                try
                {
                    if (connection.Insert(footballPlayer) == 1)
                    {
                        DisplayAlert("Success", "Saved Details", "OK");
                        MessagingCenter.Send <CreateFootballPlayerPage> (this, "Reload");
                        Navigation.PopAsync();
                    }
                    else
                    {
                        DisplayAlert("Error", "Please try again", "OK");
                    }
                }
                catch (SQLiteException exception)
                {
                    DisplayAlert("Duplicate Entry", "Please try again", "OK");
                    Debug.WriteLine(exception);
                }
            }
            else
            {
                DisplayAlert("Warning", "Fields cannot be empty", "OK");
            }
        }
        void saveButtonClicked(object sender, System.EventArgs e)
        {
            if (firstNameField.Text != null && lastNameField.Text != null && countryPicker.SelectedIndex != -1 && App.imagePath != null) {

                connection = new SQLiteConnection (App.Path);
                connection.CreateTable<FootballPlayer> ();

                string Name = firstNameField.Text + " " + lastNameField.Text;
                string DateOfBirth = dateOfBirth.Date.ToShortDateString();
                string Country = countryList [countryPicker.SelectedIndex];

                FootballPlayer footballPlayer = new FootballPlayer (Name, DateOfBirth, Country, App.imagePath, false);

                try
                {
                    if (connection.Insert (footballPlayer) == 1)
                    {
                        DisplayAlert ("Success", "Saved Details", "OK");
                        MessagingCenter.Send<CreateFootballPlayerPage> (this, "Reload");
                        Navigation.PopAsync ();
                    }
                    else
                    {
                        DisplayAlert ("Error", "Please try again", "OK");
                    }
                }
                catch(SQLiteException exception)
                {
                    DisplayAlert ("Duplicate Entry", "Please try again", "OK");
                    Debug.WriteLine (exception);
                }
            }
            else
            {
                DisplayAlert ("Warning", "Fields cannot be empty", "OK");
            }
        }