protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            DataProfile = e.Parameter as Profile;


        }
Ejemplo n.º 2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var readData = await ReadWrite.readStringFromLocalFile("data");
            Profile CurrentProfile = JsonSerilizer.ToProfile(readData);
            MyProfile = CurrentProfile;

        }
Ejemplo n.º 3
0
 protected async override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     var profile = e.Parameter as Models.Account;
     myID = profile.Idacc;
     var readDataa = await ReadWrite.readStringFromLocalFile("data");
     Profile CurrentProfilea = JsonSerilizer.ToProfile(readDataa);
     MyProfile = CurrentProfilea;
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            acc = e.Parameter as DataToProvide;
            myID = acc.id;
            CurrentProfile = acc.MyProfile;



            //var vm = DataContext as AddNewHistoryViewModel;

            //vm.TestItems = new ObservableCollection<Category>(GetFakeRuntimeItems());


        }
Ejemplo n.º 5
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (CheckLastPageForward(typeof(AddNewHistory))) //Переход с AddNewAccount via Forward
            {
                
            }
            else if (CheckLastPage(typeof (AddNewHistory)))
            {
                var backStack = Frame.BackStack;
                var backStackCount = backStack.Count;
                var profile = e.Parameter as DataToProvide;
                myID = profile.id; 
                if (backStackCount > 1)
                {
                    backStack.RemoveAt(backStackCount - 1);
                    backStack.RemoveAt(backStackCount - 2);
                }
             
                CurrentProfile = profile.MyProfile;
                var vm = DataContext as HistoryPageViewModel;

                await ReadWrite.saveStringToLocalFile("data", JsonSerilizer.ToJson(profile.MyProfile));

                profile.MyProfile.Accounts[profile.id].Histories.OrderBy(o => o.DateOfOperation);
                vm.SelectedItem = profile.MyProfile.Accounts[profile.id];

               
            }
            else
            {
            
                   var vm = DataContext as HistoryPageViewModel;
                var readData = await ReadWrite.readStringFromLocalFile("data");
                myID = (int) e.Parameter;
                var profile = JsonSerilizer.ToProfile(readData);
               
                Models.Account list = profile.Accounts[myID];
                list.Histories.OrderBy(o => o.DateOfOperation);
                CurrentProfile = profile;
               
                vm.SelectedItem = list;


            }
        }
Ejemplo n.º 6
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (CheckLastPageForward(typeof(AddNewAccount))) //Переход с AddNewAccount via Forward
            {
                //NothingTODO
            }
            else if (CheckLastPage(typeof (AddNewAccount)))
            {
                var backStack = Frame.BackStack;
                var backStackCount = backStack.Count;

                if (backStackCount > 1)
                {
                    backStack.RemoveAt(backStackCount - 1);
                    backStack.RemoveAt(backStackCount - 2);
                }
            
             
                var vm = DataContext as AccountPageViewModel;
                vm.TestItems.Clear();

                var readDataa = await ReadWrite.readStringFromLocalFile("data");
                Profile profile = JsonSerilizer.ToProfile(readDataa);
                DataProfile = profile;
                if (profile == null)
                {
                    
                }
                else
                {
                    vm.TestItems.Clear();
                    foreach (var item in profile.Accounts)
                    {
                        vm.TestItems.Add(item);
                    }
                   
                }
              
            }
            else if (CheckLastPage(typeof(AddNewHistory)))
            {
                var backStack = Frame.BackStack;
                var backStackCount = backStack.Count;

                if (backStackCount > 1)
                {
                    backStack.RemoveAt(backStackCount - 1);
                    backStack.RemoveAt(backStackCount - 2);
                }


                var vm = DataContext as AccountPageViewModel;
                vm.TestItems.Clear();

                var readDataa = await ReadWrite.readStringFromLocalFile("data");
                Profile CurrentProfilea = JsonSerilizer.ToProfile(readDataa);
                DataProfile = CurrentProfilea;
                string limits = "";
                var category = DataProfile.Accounts[_lastSelectedItem.Idacc].Categories;

                if (category.Telephone.isShow)
                {
                    if (category.Telephone.Amount >= category.Telephone.Limit * 0.95)
                    {
                        limits += category.Telephone.name + " ";
                        category.Telephone.isShow = false;
                    
                    }

                }
                if (category.Transport.isShow)
                {
                    if (category.Transport.Amount >= category.Transport.Limit * 0.95)
                    {
                        limits +=  category.Transport.name + " " ;
                        category.Transport.isShow = false;
                 
                    }

                }
               if (category.Food.isShow)
                {
                    if (category.Food.Amount >= category.Food.Limit * 0.95)
                    {
                        limits += category.Food.name + " ";
                        category.Food.isShow = false;
                    }

                }
                if (category.Entertaiment.isShow)
                {
                    if (category.Entertaiment.Amount >= category.Entertaiment.Limit * 0.95)
                    {
                        limits += category.Entertaiment.name + " ";
                        category.Entertaiment.isShow = false;
                    }

                }
              if (category.Internet.isShow)
                {
                    if (category.Internet.Amount >= category.Internet.Limit * 0.95)
                    {
                        limits += category.Internet.name + " ";
                        category.Internet.isShow = false;
                    }

                }
               if (category.Everything.isShow)
                {
                    if (category.Everything.Amount >= category.Everything.Limit * 0.95)
                    {
                        limits += category.Everything.name + " ";
                        category.Everything.isShow = false;
                    }

                }
                if (limits != "")
                {
                    ContentDialog dialogo = new ContentDialog();
                    dialogo.Title = "Вы превысили лимит на следующие категории:"+" " + limits;
                    dialogo.PrimaryButtonText = "Ок";

                    await dialogo.ShowAsync();

                }


                foreach (var item in CurrentProfilea.Accounts)
                {
                    vm.TestItems.Add(item);
                }


                if (e.Parameter != null)
                {
                    //  Parameter is item ID
                    var id = (int)e.Parameter;
                    var readData = await ReadWrite.readStringFromLocalFile("data");
                    Profile CurrentProfile = JsonSerilizer.ToProfile(readData);
                    foreach (var sub in CurrentProfile.Accounts)
                    {
                        if (sub.Idacc == id)
                        {
                            _lastSelectedItem = sub;

                        }
                    }
                }

            }
            else if (CheckLastPageForward(typeof(AddNewHistory)))
            {
                var backStack = Frame.BackStack;
                var backStackCount = backStack.Count;

                if (backStackCount > 1)
                {
                    backStack.RemoveAt(backStackCount - 1);
                    backStack.RemoveAt(backStackCount - 2);
                }

               
                var vm = DataContext as AccountPageViewModel;
                vm.TestItems.Clear();

                var readDataa = await ReadWrite.readStringFromLocalFile("data");
                Profile CurrentProfilea = JsonSerilizer.ToProfile(readDataa);
                DataProfile = CurrentProfilea;
              

                foreach (var item in CurrentProfilea.Accounts)
                {
                    vm.TestItems.Add(item);
                }


                if (e.Parameter != null)
                {
                    //  Parameter is item ID
                    var id = (int)e.Parameter;
                    var readData = await ReadWrite.readStringFromLocalFile("data");
                    Profile CurrentProfile = JsonSerilizer.ToProfile(readData);
                    foreach (var sub in CurrentProfile.Accounts)
                    {
                        if (sub.Idacc == id)
                        {
                            _lastSelectedItem = sub;

                        }
                    }
                }

            }
            else
            {
                var readDataa = await ReadWrite.readStringFromLocalFile("data");
                Profile CurrentProfilea = JsonSerilizer.ToProfile(readDataa);
              
                var vm = DataContext as AccountPageViewModel;
                vm.TestItems.Clear();
                
                  
                  
                    DataProfile = CurrentProfilea;
                    foreach (var item in CurrentProfilea.Accounts)
                    {
                        vm.TestItems.Add(item);
                    }
                

                if (e.Parameter != null)
                {
                    //  Parameter is item ID
                    var id = (int)e.Parameter;
                    var readData = await ReadWrite.readStringFromLocalFile("data");
                    Profile CurrentProfile = JsonSerilizer.ToProfile(readData); 
                    foreach (var sub in CurrentProfile.Accounts)
                    {
                        if (sub.Idacc == id)
                        {
                            _lastSelectedItem = sub;
                            
                        }
                    }
                }

                UpdateForVisualState(AdaptiveStates.CurrentState);

                // Don't play a content transition for first item load.
                // Sometimes, this content will be animated as part of the page transition.
                DisableContentTransitions();
            }
          
        }
        private async void NewAccount(object sender, RoutedEventArgs e)
        {
            Profile profile = new Profile();
            if (DataProfile != null)
            {
                profile = DataProfile;
            }
            double accStart;
   
            Models.Account acc = new Models.Account();
            acc.Name = accname.Text;


            if (String.IsNullOrEmpty(accname.Text))
            {
                Error("Введите название аккаунта");
               
                accname.Focus(FocusState.Keyboard);

            }
            else if (accname.Text.Length > 19)
            {
                Error("Введите название не длинее 20-ти символов");
            }
            else
            {
                if (!Double.TryParse(accbalance.Text, out accStart))
                {
                      Error("Введите текущий баланс");
                
                      accbalance.Text = "";
                  

                }
                else if (Convert.ToDouble(accbalance.Text) > 1000000000000)
                {
                    Error("Слишком большое число");

                    accbalance.Text = "";
                }
                else if (Convert.ToDouble(accbalance.Text) < 0)
                {
                    Error("Введите положительный текущий баланс");

                    accbalance.Text = "";
                }
                else
                {
                    double balance = Convert.ToDouble(accbalance.Text);
                  
                    acc.start = balance;
                    if (profile.Accounts.Count == 0)
                    {
                        acc.Idacc = 0;
                    }
                    else
                    {
                        acc.Idacc = profile.Accounts.Count;
                    }

                    acc.Histories = new ObservableCollection<History>();
                    profile.Accounts.Add(acc);

                    await ReadWrite.saveStringToLocalFile("data", JsonSerilizer.ToJson(profile));
                    if (profile.Password == null)
                    {
                        this.Frame.Navigate(
                      typeof(NewPassword),
                      new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo());
                    }
                    else
                    {
                        this.Frame.Navigate(
                      typeof(AccountPage),
                      new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo());
                    }
                }

            }





        }