예제 #1
0
        private void TransactionAdd(object sender, EventArgs e)
        {
            Transaction transaction;
            String      transactionTitle = String.Empty;

            try {
                String pickerValue = PickerPerson.SelectedItem as String;
                if (pickerValue != String.Empty || pickerValue != null)
                {
                    transactionTitle = "Wpłata od: " + pickerValue;
                    transaction      = new Transaction(DateTime.Now, transactionTitle, float.Parse(EntryTransactionValueDeposit.Text), true);
                    dataBase.Insert(transaction);
                    ViewTransactionManager.ClearInput(EditorTransactionTitle, EntryTransactionValueDeposit);
                    ViewTransactionManager.CalculateBudget(dataBase, LabelShoppingBudgetValue);
                    LabelLastDepositValue.Text = pickerValue;
                    DisplayAlert("Information", "Transaction Added", "Ok");
                }
                else
                {
                    throw new Exception("Empty value of picker, please pick person");
                }
            } catch (Exception ex) {
                DisplayAlert("Exception!", ex.Message, "Ok");
            }
        }
예제 #2
0
        public void ReadDatabase()
        {
            String dataBasePath         = String.Empty;
            String dataBaseBusinessPath = String.Empty;

            try {
                String pathSufix   = DateTime.Today.Month.ToString() + "R" + DateTime.Today.Year.ToString() + ".db3";
                String pathSufixBS = DateTime.Today.Month.ToString() + "BS" + ".db3";
                dataBasePath = DependencyService.Get <IPathGenerator>().GetPath(pathSufix);
                //dataBaseBusinessPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), pathSufixBS);

                if (!File.Exists(dataBasePath))
                {
                    calculateBudgetFromPrevMonth = true;
                }

                dataBase = new SQLiteConnection(dataBasePath);
                dataBase.CreateTable <Transaction>();
                //dataBaseBusiness = new SQLiteConnection(dataBaseBusinessPath);
                //dataBaseBusiness.CreateTable<Business>();

                ViewTransactionManager.CalculateBudget(dataBase, LabelShoppingBudgetValue);
                ViewTransactionManager.SetLastDepositor(dataBase, LabelLastDepositValue, PickerPerson);

                if (calculateBudgetFromPrevMonth == true)
                {
                    TransactionAdd();
                }
            } catch (Exception ex) {
                DisplayAlert("Exception!", ex.Message, "Ok");
            }
        }
예제 #3
0
 public void ReadAndViewDatabase()
 {
     try {
         ViewTransactionManager.ReadAndViewDatabase(dataBase, LabelTransactionList, false);
         ViewTransactionManager.ReadAndViewDatabase(dataBase, LabelDepositList, true);
         ViewTransactionManager.CalculateBudget(dataBase, LabelSummaryBudgetValue);
         ViewTransactionManager.CalculateMoneySpent(dataBase, LabelMoneySpentValue);
         ViewTransactionManager.HowMuchAddedMoneyByPerson(dataBase, LabelPawełAddedValue, LabelKasiaAddedValue);
     } catch (Exception ex) {
         DisplayAlert("Exception!", ex.Message, "Ok");
     }
 }
예제 #4
0
        private void TransactionSubstract(object sender, EventArgs e)
        {
            Transaction transaction;

            try {
                transaction = new Transaction(DateTime.Now, EditorTransactionTitle.Text, -float.Parse(EntryTransactionValueTransaction.Text), false);
                dataBase.Insert(transaction);
                ViewTransactionManager.ClearInput(EditorTransactionTitle, EntryTransactionValueTransaction);
                ViewTransactionManager.CalculateBudget(dataBase, LabelShoppingBudgetValue);
                DisplayAlert("Information", "Transaction Added", "Ok");
            }catch (Exception ex) {
                DisplayAlert("Exception!", ex.Message, "Ok");
            }
        }
예제 #5
0
        private void TransactionAdd()
        {
            Transaction      transaction;
            int              prevMonthDB = DateTime.Today.Month - 1;
            String           pathSufix   = prevMonthDB.ToString() + "R" + DateTime.Today.Year.ToString() + ".db3";
            String           oldDBPath   = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), pathSufix);
            SQLiteConnection oldDB;

            if (File.Exists(oldDBPath) == true)
            {
                try {
                    oldDB = new SQLiteConnection(oldDBPath);
                    oldDB.CreateTable <Transaction>();

                    transaction = new Transaction(DateTime.Now, "Budget from prev month", ViewTransactionManager.CalculateBudget(oldDB), true);
                    dataBase.Insert(transaction);
                    ViewTransactionManager.CalculateBudget(dataBase, LabelShoppingBudgetValue);
                    DisplayAlert("Information", "Added Busget from prev month", "Ok");
                } catch (Exception ex) {
                    DisplayAlert("Exception!", ex.Message, "Ok");
                }
            }
        }