private void btnAdd_Click(object sender, EventArgs e) { fbdRepo.ShowNewFolderButton = true; DialogResult result = fbdRepo.ShowDialog(); if (result == DialogResult.OK) { string path = fbdRepo.SelectedPath; DirectoryInfo d = new DirectoryInfo(path); if (Equals(_database, null)) { _database = new DAL(); } SubversionRepositoryInfo r = new SubversionRepositoryInfo(); r.Name = d.Name; r.RepositoryPath = path; int id = _database.AddRepository(r.Name, r.RepositoryPath); r.RepositoryId = id; if (Equals(_repos, null)) { _repos = new List <SubversionRepositoryInfo>(); } _repos.Add(r); lstMulti.Items.Add(r); } }
public List <SubversionRepositoryInfo> LoadRepositories() { SQLiteConnection conn = GetDatabaseConnection(); var cmd = new SQLiteCommand("SELECT * FROM Repositories"); conn.Open(); cmd.Connection = conn; SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { var r = new SubversionRepositoryInfo { RepositoryId = Convert.ToInt32(dr["RepoID"]), Name = dr["RepoName"].ToString(), RepositoryPath = dr["RepoPath"].ToString() }; _repositories.Add(r); } dr.Close(); conn.Close(); return(_repositories); }
private void btnDelete_Click(object sender, EventArgs e) { if (lstMulti.SelectedItem == null) { MessageBox.Show("Please Select a repository from the list", "A repository must be selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { SubversionRepositoryInfo delRepo = (SubversionRepositoryInfo)lstMulti.SelectedItem; int id = delRepo.RepositoryId; _database.DeleteRepository(id); lstMulti.Items.Remove(delRepo.Name); btnDelete.Enabled = false; btnAdd.Focus(); } }