private void showDB() { double result = 0; tableDG.Items.Clear(); SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=" + db_path + ";Version=3;"); m_dbConnection.Open(); string sqlRequest = "SELECT * FROM expenses"; SQLiteCommand command = new SQLiteCommand(sqlRequest, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { dbNote note = new dbNote { name = reader["name"].ToString(), cost = double.Parse(reader["cost"].ToString()) }; tableDG.Items.Add(note); result += note.cost; resultLb.Content = result.ToString(); if (tableDG.Items.Count == 0) { resultLb.Content = ""; } } m_dbConnection.Close(); }
private void editNoteBt_Click(object sender, RoutedEventArgs e) { selectedNote = (dbNote)tableDG.SelectedItem; if (db_path == "") { MessageBox.Show("Создайте новую базу данных или\nоткройте уже существующую."); } else { EditNoteWindow editWin = new EditNoteWindow(); editWin.edited += refresh_dbnote; if (editWin.ShowDialog() == true) { } editWin.edited -= refresh_dbnote; } }