private void UpdateLinkButton_Click(object sender, EventArgs e) { Link link = new Link() { LinkTitle = UpdateTItleBox.Text, LinkURL = UpdateLinkBox.Text }; try { if (existinglink != null) { link.LinkId = existinglink.LinkId; LinkDB.Update(link); MessageBox.Show("Link Updated!"); } Close(); } catch (SqlException) { MessageBox.Show("It didn't work."); } }
private void AddLinkButton_Click(object sender, EventArgs e) { Link link = new Link() { LinkTitle = AddTitleBox.Text, LinkURL = AddLinkiBox.Text }; LinkDB.Add(link); MessageBox.Show("Link added!"); Close(); }
private void PopulateLinkComboBox() { List <Link> links = LinkDB.GetAllLinks(); links = links.OrderBy(link => link.LinkTitle).ToList(); LinkCboBox.Items.Clear(); foreach (Link l in links) { LinkCboBox.Items.Add(l); } }
private void MainDeleteLinkButton_Click(object sender, EventArgs e) { if (LinkCboBox.SelectedIndex < 0) { MessageBox.Show("Please choose a Link!"); return; } Link link = LinkCboBox.SelectedItem as Link; string msg = $"Are you sure you want to delete {link.LinkTitle} \n" + $"{link.LinkURL}"; DialogResult answer = MessageBox.Show(msg, "Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (answer == DialogResult.Yes) { LinkDB.Delete(link.LinkTitle); PopulateLinkComboBox(); MessageBox.Show("Link deleted successfully"); } }