예제 #1
0
 private void Exit_Clicked(object sender, EventArgs e)
 {
     for (int i = 0; i < ExercisesTest.exercisesTest.Count; i++)
     {
         DBSaverLoader.SAVE_EXERCISE(ExercisesTest.exercisesTest[i], App.Database);
     }
     App.UpdateMainTableList();
     Navigation.PushAsync(new ProfilePage());
 }
예제 #2
0
 private void UpdateApproachButton_Clicked(object sender, EventArgs e)
 {
     if (type == App.TypeExercises.Count)
     {
         Frame       frame       = UpdateStackLayout.Children[0] as Frame;
         StackLayout stackLayout = frame.Content as StackLayout;
         Entry       entry       = stackLayout.Children[1] as Entry;
         if (NameEntry != null && entry != null)
         {
             DBSaverLoader.UPDATE_EXERCISE(Exercises.CurrentExercisesId, new ExercisesCount()
             {
                 Name        = NameEntry.Text,
                 Information = InformationEditor.Text,
                 LinkName    = NameLinkEntry.Text,
                 LinkURL     = UrlLinkEntry.Text,
                 Purpose     = Int32.Parse(entry.Text)
             }, App.Database);
             App.UpdateMainTableList();
         }
     }
     else if (type == App.TypeExercises.Approach)
     {
         int        Count  = UpdateStackLayout.Children.Count;
         List <int> result = new List <int>();
         for (int i = 0; i < Count - 1; i++)
         {
             if (UpdateStackLayout.Children[i] == null)
             {
                 return;
             }
             Frame       frame       = UpdateStackLayout.Children[i] as Frame;
             StackLayout stackLayout = frame.Content as StackLayout;
             Entry       entry       = stackLayout.Children[1] as Entry;
             result.Add(Int32.Parse(entry.Text));
         }
         Frame       frame1       = UpdateStackLayout.Children[Count - 1] as Frame;
         StackLayout stackLayout1 = frame1.Content as StackLayout;
         Entry       entry1       = stackLayout1.Children[1] as Entry;
         result.Add(Int32.Parse(entry1.Text));
         if (NameEntry != null)
         {
             DBSaverLoader.UPDATE_EXERCISE(Exercises.CurrentExercisesId, new ExercisesApproach()
             {
                 Name         = NameEntry.Text,
                 Information  = InformationEditor.Text,
                 LinkName     = NameLinkEntry.Text,
                 LinkURL      = UrlLinkEntry.Text,
                 ApproachList = result
             }, App.Database);
             App.UpdateMainTableList();
         }
     }
     else if (type == App.TypeExercises.Time)
     {
         Frame       frame       = UpdateStackLayout.Children[0] as Frame;
         StackLayout stackLayout = frame.Content as StackLayout;
         Entry       entry       = stackLayout.Children[1] as Entry;
         if (NameEntry != null && entry != null)
         {
             DBSaverLoader.UPDATE_EXERCISE(Exercises.CurrentExercisesId, new ExercisesTime()
             {
                 Name        = NameEntry.Text,
                 Information = InformationEditor.Text,
                 LinkName    = NameLinkEntry.Text,
                 LinkURL     = UrlLinkEntry.Text,
                 Time        = new TimeSpan(0, 0, Int32.Parse(entry.Text))
             }, App.Database);
             App.UpdateMainTableList();
         }
     }
     Navigation.PushAsync(new ProfilePage());
 }
예제 #3
0
        private void CreateApproachButton_Clicked(object sender, EventArgs e)
        {
            if (TypePicker.SelectedIndex == -1 || NameEntry == null || NameEntry.Text == "" || NameEntry.Text == null)
            {
                DisplayAlert("Помилка", "Ви не вибрали тип або не ввели ім'я!", "Добре");
                if (TypePicker.SelectedIndex == -1)
                {
                    PickerStackLayout.BorderColor  = Color.Red;
                    PickerStackLayout.CornerRadius = 10;
                }
                else
                {
                    PickerStackLayout.BorderColor  = Color.Black;
                    PickerStackLayout.CornerRadius = 10;
                }
                if (NameEntry == null || NameEntry.Text == "" || NameEntry.Text == null)
                {
                    NameStackLayout.BorderColor  = Color.Red;
                    NameStackLayout.CornerRadius = 10;
                }
                else
                {
                    NameStackLayout.BorderColor  = Color.Black;
                    NameStackLayout.CornerRadius = 10;
                }
            }
            else
            {
                try
                {
                    if (NameEntry != null && PurposeEntry != null && NameEntry.Text != "" && TypePicker.SelectedIndex != -1)
                    {
                        switch (TypePicker.SelectedIndex)
                        {
                        case 0:
                            DBSaverLoader.SAVE_EXERCISE(new ExercisesCount()
                            {
                                Name        = NameEntry.Text,
                                Information = InformationEditor.Text,
                                LinkName    = NameLinkEntry.Text,
                                LinkURL     = UrlLinkEntry.Text,
                                Purpose     = Int32.Parse(PurposeEntry.Text)
                            }, App.Database);
                            App.UpdateMainTableList(); break;

                        case 1:
                            List <int> ApproachListInt = new List <int>();
                            for (int i = 0; i < ApproachStackLayout.Children.Count; ++i)
                            {
                                Frame       frame       = ApproachStackLayout.Children[i] as Frame;
                                StackLayout stackLayout = frame.Content as StackLayout;
                                Entry       entry       = stackLayout.Children[1] as Entry;
                                ApproachListInt.Add(Int32.Parse(entry.Text));
                            }
                            DBSaverLoader.SAVE_EXERCISE(new ExercisesApproach()
                            {
                                Name         = NameEntry.Text,
                                Information  = InformationEditor.Text,
                                LinkName     = NameLinkEntry.Text,
                                LinkURL      = UrlLinkEntry.Text,
                                ApproachList = ApproachListInt
                            }, App.Database);
                            App.UpdateMainTableList(); break;

                        case 2:
                            DBSaverLoader.SAVE_EXERCISE(new ExercisesTime()
                            {
                                Name        = NameEntry.Text,
                                Information = InformationEditor.Text,
                                LinkName    = NameLinkEntry.Text,
                                LinkURL     = UrlLinkEntry.Text,
                                Time        = new TimeSpan(0, 0, Int32.Parse(PurposeEntry.Text))
                            }, App.Database);
                            App.UpdateMainTableList(); break;
                        }
                    }
                    Navigation.PushAsync(new ProfilePage());
                }
                catch (Exception)
                {
                    bool tryParse = Int32.TryParse(PurposeEntry.Text, out int result);
                    if (tryParse == false)
                    {
                        DisplayAlert("Помилка. Формат цілі.", "Невірно введена кількість!", "Добре");
                        PickerStackLayout.BorderColor   = Color.Black;
                        PickerStackLayout.CornerRadius  = 10;
                        NameStackLayout.BorderColor     = Color.Black;
                        NameStackLayout.CornerRadius    = 10;
                        MissionStackLayout.BorderColor  = Color.Red;
                        MissionStackLayout.CornerRadius = 10;
                    }
                }
            }
        }