Пример #1
0
        /// <summary>
        /// Testing still. Saves the subcategories to an XML file.
        /// </summary>
        public void SaveSubsAs()
        {
            Tuple <string, bool> selectedFile = _fileBrowser.SaveFileAccess(
                CategoryDirectory,
                "Save Sub Categories",
                false);

            if (selectedFile.Item2)
            {
                IXMLDataSub subData = new XMLData()
                {
                    IncomeSubCategories  = Income.AllIncomeCategories,
                    ExpenseSubCategories = Expense.AllExpenseCategories
                };

                XMLWrtier wrtier = new XMLWrtier(selectedFile.Item1, subData);
                wrtier.WriteSubFile();

                // Update the Shell
                CategoryFileName = selectedFile.Item1;
                IsSubFileSaved   = true;

                SetSubFileSaveState();
            }
        }
Пример #2
0
        /// <summary>
        /// Saves the project and sets the save state.
        /// </summary>
        public void SaveFile()
        {
            IXMLData data = new XMLData()
            {
                ProjectName = BudgetFileName,
                IncomeData  = DataViewModel.IncomeDataList.ToList(),
                ExpenseData = DataViewModel.ExpenseDataList.ToList()
            };

            // Shouldnt get to this point if its false.
            if (IsMainFileSaved)
            {
                XMLWrtier wrtier = new XMLWrtier(MainFileName, data);
                wrtier.WriteBudgetFile(
                    MessageManager.DisplayMessage,
                    MessageManager.DisplayMessage);
            }
            else
            {
                SaveFileAs();
            }

            IsMainFileSaved = true;
            SetMainFileSaveState();
        }
Пример #3
0
        /// <summary>
        /// For TESTING. Used for stress testing.
        /// ! bad path.
        /// </summary>
        public void SaveFileBad(bool path = true)
        {
            XMLWrtier writer   = new XMLWrtier();
            string    badPath  = @"C:\Users\Daxxn\Daxxn\TestFile.bpn";
            string    goodPath = @"C:\Users\Daxxn\Desktop\ErrorTest.bpn";

            IXMLData goodData = new XMLData()
            {
                ProjectName = BudgetFileName,
                IncomeData  = DataViewModel.IncomeDataList.ToList(),
                ExpenseData = DataViewModel.ExpenseDataList.ToList()
            };

            IXMLData badData = new XMLData()
            {
                ProjectName = BudgetFileName,
                IncomeData  = null,
                ExpenseData = DataViewModel.ExpenseDataList.ToList()
            };

            if (path)
            {
                writer = new XMLWrtier(badPath, goodData);
            }
            else
            {
                writer = new XMLWrtier(goodPath, badData);
            }

            try
            {
                writer.WriteBudgetFile();

                MainFileName    = badPath;
                IsFileOpen      = true;
                IsMainFileSaved = true;

                SetMainFileSaveState();
            }
            catch (Exception e)
            {
                MessageManager.DisplayMessage($"{e.HResult} : {e.Message}", "ERROR!!");
            }
        }
Пример #4
0
        public void SaveSubs()
        {
            if (FileCheck.CheckDirectory(CategoryFileName))
            {
                IXMLDataSub data = new XMLData()
                {
                    IncomeSubCategories  = Income.AllIncomeCategories,
                    ExpenseSubCategories = Expense.AllExpenseCategories
                };

                XMLWrtier wrtier = new XMLWrtier(CategoryFileName, data);
                wrtier.WriteSubFile(MessageManager.DisplayMessage);

                IsSubFileSaved = true;

                SetSubFileSaveState();
            }
            else
            {
                SaveSubsAs();
            }
        }
Пример #5
0
        /// <summary>
        /// Opens the SaveFileDialog, saves the current file, then stores the save state.
        /// </summary>
        public void SaveFileAs()
        {
            Tuple <string, bool> selectedFile = _fileBrowser.SaveFileAccess(
                MainFileDirectory,
                "Save Budget Plan",
                BudgetFileName,
                true);

            if (selectedFile.Item2)
            {
                IXMLData data = new XMLData()
                {
                    ProjectName = BudgetFileName,
                    IncomeData  = DataViewModel.IncomeDataList.ToList(),
                    ExpenseData = DataViewModel.ExpenseDataList.ToList()
                };

                XMLWrtier writer = new XMLWrtier(selectedFile.Item1, data);

                //writer.WriteBudgetFile(
                //    MessageManager.DisplayMessage,
                //    MessageManager.DisplayMessage);

                try
                {
                    writer.WriteBudgetFile();

                    MainFileName    = selectedFile.Item1;
                    IsFileOpen      = true;
                    IsMainFileSaved = true;

                    SetMainFileSaveState();
                }
                catch (Exception)
                {
                    MessageManager.DisplayMessage("An error occured while saving..");
                }
            }
        }