private void button1_Click(object sender, EventArgs e) { using (AddFilesForm dlg = new AddFilesForm()) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string[] fp = dlg.FilePaths; string cmnt = dlg.Comment; foreach (string f in fp) { if ((from s in _activeAttachements where s.FilePath.ToLower() == f.ToLower() select s).FirstOrDefault() == null) { AttachementItem ai = new AttachementItem(); ai.FilePath = f; ai.Comment = cmnt; ai.GeocacheCode = Core.ActiveGeocache.Code; _activeAttachements.Add(ai); addAttachementItemToList(ai); lock (Core.SettingsProvider) { try { Core.SettingsProvider.Database.Execute(string.Format("insert into {3} (code, filepath, comment) values ('{2}', '{0}', '{1}')", ai.FilePath.Replace("'", "''"), ai.Comment.Replace("'", "''"), ai.GeocacheCode.Replace("'", "''"), Core.SettingsProvider.GetFullTableName("attachements"))); } catch { } } } } } } }
private void button1_Click(object sender, EventArgs e) { using (AddFilesForm dlg = new AddFilesForm()) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string[] fp = dlg.FilePaths; string cmnt = dlg.Comment; foreach (string f in fp) { if ((from s in _activeAttachements where s.FilePath.ToLower() == f.ToLower() select s).FirstOrDefault() == null) { AttachementItem ai = new AttachementItem(); ai.FilePath = f; ai.Comment = cmnt; ai.GeocacheCode = Core.ActiveGeocache.Code; _activeAttachements.Add(ai); addAttachementItemToList(ai); if (initDatabase() != null) { try { _dbcon.ExecuteNonQuery(string.Format("insert into attachements (code, filepath, comment) values ('{2}', '{0}', '{1}')", ai.FilePath.Replace("'", "''"), ai.Comment.Replace("'", "''"), ai.GeocacheCode.Replace("'", "''"))); } catch { } } } } } } }