public void ReadVehicles()
        {
            try
            {
                string         path       = "";
                OpenFileDialog filedialog = new OpenFileDialog();
                filedialog.Filter      = "CSV Files (*.csv)|*.csv";
                filedialog.FilterIndex = 1;
                filedialog.Multiselect = false;

                if (filedialog.ShowDialog() == DialogResult.OK)
                {
                    path = filedialog.FileName;
                }
                else
                {
                    return;
                }


                List <vehicles> values = File.ReadAllLines(path)
                                         .Skip(1)
                                         .Select(v => vehicles.FromCsv(v))
                                         .ToList();
                DataAccess  dtc = new DataAccess();
                SQLCreation cre = new SQLCreation();
                dtc.SQLCommand(Properties.Settings.Default.DBName, cre.vehicles());
                dtc.CreateBulckVehicles(Properties.Settings.Default.DBName, path);
            }
            catch (Exception e)
            {
                MessageBox.Show(@"There was an error. Probably you tried to read a wrong csv file." + Environment.NewLine + Environment.NewLine + "Error: " + e.ToString());
            }
        }
Exemple #2
0
        private void Button_Click_RecreateDB(object sender, RoutedEventArgs e)
        {
            SQLCreation sql = new SQLCreation();
            DataAccess  dts = new DataAccess();

            //string command = sql.CreateDB() + sql.User() + sql.CarProduct() + sql.categories() + sql.vehicles();
            dts.SQLCommand(Properties.Settings.Default.DBName, sql.CreateDB());
            dts.SQLCommand(Properties.Settings.Default.DBName, sql.User());
            dts.SQLCommand(Properties.Settings.Default.DBName, sql.CreateFirstUser());
            dts.SQLCommand(Properties.Settings.Default.DBName, sql.categories());
            dts.SQLCommand(Properties.Settings.Default.DBName, sql.vehicles());
            dts.SQLCommand(Properties.Settings.Default.DBName, sql.CarProduct());
        }