Esempio n. 1
0
        private void Salary_Btn_Click(object sender, RoutedEventArgs e)
        {
            float input;

            float.TryParse(Salary_TextBox.Text, out input);

            if (input == 0)
            {
                MessageBox.Show("Entrer un entier");
            }
            else
            {
                //adjusting balance
                var finances = SQLiteDataAccess.GetBalance().FirstOrDefault();

                float x;
                if (finances.Balance != 0)
                {
                    x = float.Parse(Salary_TextBox.Text) + finances.Balance;

                    Balance_Label.Content = $"Balance:{x} TND";
                }
                else
                {
                    x = float.Parse(Salary_TextBox.Text);
                    Balance_Label.Content = $"Balance:0 TND";
                }

                finances.Balance = x;
                SQLiteDataAccess.LoadSalary(finances);

                //setting values for new item
                var item = new Item();
                item.Date      = DateTime.Now;
                item.ItemName  = "Salaire";
                item.ItemPrice = input;
                item.Category  = Categories.Misc;

                //saving to db
                SQLiteDataAccess.SaveItem(item);
            }
            Salary_TextBox.Text = "";
            RefreshHistoryDataGrid();
        }
Esempio n. 2
0
 private void RefreshHistoryDataGrid()
 {
     history.Items_DataGrid.ItemsSource = items = SQLiteDataAccess.GetItems();
 }