private void button6_Click(object sender, EventArgs e) { string key = ""; keyword keyword = new keyword(); if (textBox4.Text == null) { MessageBox.Show("Please Empty values not allowed"); return; } key = textBox4.Text; keyword.keywords = key; if (fbEntities.keywords.Any(c => c.keywords.Trim().ToLower() == key.ToLower().Trim())) { MessageBox.Show("This Keyword already exist !"); return; } fbEntities.keywords.Add(keyword); if (fbEntities.SaveChanges() == 1) { MessageBox.Show("Added Sucessfully "); } }
public void AddKeyword(string keyword, int criteriaId) { keyword akeyword = new keyword(); akeyword.keywords = keyword; akeyword.cirteriaId = criteriaId; fbEntities.keywords.Add(akeyword); fbEntities.SaveChanges(); // if (fbEntities.SaveChanges() == 1) // MessageBox.Show("Added Sucessfully "); }
//Add Keyword private void button6_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { MessageBox.Show("Please choose criteria"); return; } string key = ""; int criteriaId = int.Parse(listView1.SelectedItems[0].SubItems[0].Text); keyword keyword = new keyword(); if (textBox4.Text == null) { MessageBox.Show("Please Empty values not allowed"); return; } key = textBox4.Text; keyword.keywords = key; keyword.cirteriaId = criteriaId; if (fbEntities.keywords.Any(c => c.keywords.Trim().ToLower() == key.ToLower().Trim())) { MessageBox.Show("This Keyword already exist !"); return; } fbEntities.keywords.Add(keyword); if (fbEntities.SaveChanges() == 1) { MessageBox.Show("Added Sucessfully "); } }