public static void Proceed(filetype filetype, string filenameOrConnectionString, Item source, string[] categories = null) { switch (filetype) { case filetype.CSV: { CSV csvFile = new CSV(filenameOrConnectionString); csvFile.New(); csvFile.Save(source); } break; case filetype.XML: { XML xmlFile = new XML(filenameOrConnectionString); xmlFile.New(); xmlFile.Save(source); } break; case filetype.MySQL: { Database db = new Database(filenameOrConnectionString); db.FillTables(); foreach (Seznam item in source.GetItemsList()) { db.AddRecord(item.Nazev, item.Kategorie, item.Obsah); } db.Save(); } break; } }
private void uložitToolStripMenuItem1_Click(object sender, EventArgs e) { try { if (sett.přípona == ".csv") { csvFile.Save(items); } else if (sett.přípona == ".xml") { xmlFile.Save(items); } MessageBox.Show("Data byla uložena", "Informace", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(Program.message + ex.Message + Environment.NewLine + "Zdroj" + ex.Source, "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error); } }