private void Show_row(object sender, RoutedEventArgs e)
        {
            int selected_row_index = RegistryViewDataGrid.SelectedIndex;

            if (selected_row_index != -1)
            {
                RegistryRow        selected_row            = this.available_rows[selected_row_index];
                ShowRegistryDialog regitry_show_row_dialog = new ShowRegistryDialog();
                regitry_show_row_dialog.Set_row(selected_row);
                if (regitry_show_row_dialog.custom_show_dialog())
                {
                    this.Set_rows();
                }
            }
        }
Beispiel #2
0
        public static List <RegistryRow> Get_registries(string file_path, RegistrySearchCondition condition)
        {
            SQLiteConnection connection = new SQLiteConnection(string.Format("DataSource={0}", file_path));

            connection.Open();
            SQLiteCommand command = new SQLiteCommand(connection)
            {
                CommandText = "SELECT * FROM registries"
            };
            SQLiteDataReader   results_reader = command.ExecuteReader();
            List <RegistryRow> rows           = new List <RegistryRow>();

            while (results_reader.Read())
            {
                RegistryRow row = new RegistryRow
                {
                    ID          = Convert.ToInt32(results_reader["id"]),
                    Amount      = Convert.ToDouble(results_reader["amount"]),
                    Date        = Convert.ToDateTime(results_reader["date"]),
                    Category    = Convert.ToString(results_reader["category"]),
                    Type_       = Convert.ToString(results_reader["type"]),
                    Description = Convert.ToString(results_reader["description"]),
                    Currency    = Convert.ToString(results_reader["currency"])
                };
                if (condition.Default_search)
                {
                    if (row.Type_ == "outcome")
                    {
                        row.Amount *= -1;
                    }
                    rows.Add(row);
                }
                else
                {
                    if (condition.Check_condition(row.Date, row.Category, row.Type_, row.Amount, row.Description, row.Currency))
                    {
                        if (row.Type_ == "outcome")
                        {
                            row.Amount *= -1;
                        }
                        rows.Add(row);
                    }
                }
            }
            results_reader.Close();
            connection.Close();
            return(rows);
        }
        private void Show_row(object sender, RoutedEventArgs e)
        {
            int selected_row_index = SearchResultsDialogDataGrid.SelectedIndex;

            if (selected_row_index != -1)
            {
                RegistryRow        selected_row            = this.available_rows[selected_row_index];
                ShowRegistryDialog regitry_show_row_dialog = new ShowRegistryDialog();
                regitry_show_row_dialog.Set_row(selected_row);
                if (regitry_show_row_dialog.custom_show_dialog())
                {
                    this.Set_rows(this.available_rows.Where(row => row.ID != selected_row.ID).ToList());
                    this.success = true;
                }
            }
        }
 public void Set_row(RegistryRow row)
 {
     this.EditRegistryDialogAmountBox.Text = Math.Abs(row.Amount).ToString();
     this.EditRegistryDialogCategoryButton.Content = row.Category;
     this.EditRegistryDialogCurrencyButton.Content = row.Currency;
     this.EditRegistryDialogDateBox.Text = row.Date.ToString();
     this.EditRegistryDialogDescriptionBox.Text = row.Description;
     if (row.Type_ == "income")
     {
         this.EditRegistryDialogIncomeRadioButton.IsChecked = true;
     }
     else
     {
         this.EditRegistryDialogOutcomeRadioButton.IsChecked = true;
     }
 }
 public void Set_row(RegistryRow row)
 {
     this.ShowRegistryDialogAmountField.Text      = Math.Abs(row.Amount).ToString();
     this.ShowRegistryDialogCategoryField.Text    = row.Category;
     this.ShowRegistryDialogCurrencyField.Text    = row.Currency;
     this.ShowRegistryDialogDateBox.Text          = row.Date.ToString();
     this.ShowRegistryDialogDescriptionField.Text = row.Description;
     if (row.Type_ == "income")
     {
         this.ShowRegistryDialogIncomeRadioButton.IsChecked = true;
     }
     else
     {
         this.ShowRegistryDialogOutcomeRadioButton.IsChecked = true;
     }
     this.row = row;
 }
        private void Insert_data_in_database(object sender, RoutedEventArgs e)
        {
            if (this.Verify_registry())
            {
                this.success = true;
                DatabaseHandler.Add_registry(GlobalVariables.temporary_file_path, this.Date, this.Category, this.Type_, this.Amount,  this.Description, this.Currency);
                this.row = new RegistryRow
                {
                    Date = this.Date,
                    Category = this.Category,
                    Type_ = this.Type_,
                    Amount = this.Amount,
                    Description = this.Description,
                    Currency = this.Currency
                };
                this.Close();
            }

        }