Exemplo n.º 1
0
        public static List <CurrencyRow> Get_currencies(string file_path)
        {
            SQLiteConnection connection = new SQLiteConnection(string.Format("DataSource={0}", file_path));

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

            while (results_reader.Read())
            {
                CurrencyRow row = new CurrencyRow
                {
                    Id            = Convert.ToInt32(results_reader["id"]),
                    Currency_name = Convert.ToString(results_reader["currency"]),
                    Vs_usd_rate   = Convert.ToDouble(results_reader["vs_usd_rate"])
                };
                rows.Add(row);
            }
            results_reader.Close();
            connection.Close();
            return(rows);
        }
        private void Currency_selected(object sender, RoutedEventArgs e)
        {
            int selected_row_index = SelectCurrencyDataGrid.SelectedIndex;

            if (selected_row_index != -1)
            {
                this.selected_row = this.datagrid_rows[selected_row_index];
                this.selected     = true;
                this.Close();
            }
        }