Exemplo n.º 1
0
        private void buttonImportuj_Click(object sender, RoutedEventArgs e)
        {
            char separator = '\0';

            if (rbTabulator.IsChecked == true)
            {
                separator = '\t';
            }
            if (rbComma.IsChecked == true)
            {
                separator = ',';
            }
            if (rbSemicolon.IsChecked == true)
            {
                separator = ';';
            }
            if (rbCustom.IsChecked == true)
            {
                separator = textBoxCustomSeparator.Text.First();
            }

            if (separator == '\0')
            {
                MessageBox.Show("Niepoprawny separator");
            }
            else
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.ShowDialog() == true)
                {
                    MainWindow mainWindow       = new MainWindow();
                    bool       firstRowIsHeader = checkBoxFirstRowIsHeader.IsChecked == true ? true : false;
                    mainTable = DataTableService.GetTableFromFile(openFileDialog.FileName, firstRowIsHeader, separator);
                    if (mainTable != null)
                    {
                        dataWasImported = true;
                    }
                }
            }
            this.Close();
        }