コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: luke-95/css_proj
        private void Button_ImportCSV_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            //openFileDialog.Filter = "ImageCSV (*.csv;)";

            if (openFileDialog.ShowDialog() == true)
            {
                CsvImporter csvIMporter = new CsvImporter();
                Dictionary <string, List <string> > import = csvIMporter.ReadCsv(openFileDialog.FileName);
                string tableName = Path.GetFileNameWithoutExtension(openFileDialog.FileName);

                var columns = new List <string>();
                foreach (string column in import.Keys)
                {
                    columns.Add(column);
                }

                databaseController.CreateEmptyTable(tableName, columns);
                ReloadTableNames();
                TableNamesComboBox.SelectedIndex = TableNamesComboBox.Items.IndexOf(tableName);
                databaseController.AddEntries(SelectedTableName, import);
                DisplayTable(uiDataGrid, databaseController.ImportedDatabaseModel.GetTable(SelectedTableName));
            }
        }