private void button5_Click(object sender, EventArgs e) { string pageid = ""; string pagename = ""; page page = new page(); if (string.IsNullOrWhiteSpace(textBox3.Text) || string.IsNullOrWhiteSpace(textBox5.Text)) { MessageBox.Show("Please Empty values not allowed"); return; } if (fbEntities.pages.Any(c => c.pagefbid.Trim().ToLower() == textBox3.Text.ToLower().Trim())) { MessageBox.Show("This Page already exist !"); return; } pageid = textBox3.Text; pagename = textBox5.Text; page.pagefbid = pageid; page.pagename = pagename; fbEntities.pages.Add(page); if (fbEntities.SaveChanges() == 1) { MessageBox.Show("Added Sucessfully "); } }
//Add page private void button5_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { MessageBox.Show("Please choose criteria"); return; } if ( string.IsNullOrWhiteSpace(textBox3.Text) || string.IsNullOrWhiteSpace(textBox5.Text) || string.IsNullOrWhiteSpace(textBox7.Text) || string.IsNullOrWhiteSpace(textBox8.Text) || string.IsNullOrWhiteSpace(textBox9.Text) ) { MessageBox.Show("Please make sure that you inserted all values"); return; } string pageid = ""; string pagename = ""; int criteriaId = int.Parse(listView1.SelectedItems[0].SubItems[0].Text); page page = new page(); if (string.IsNullOrWhiteSpace(textBox3.Text) || string.IsNullOrWhiteSpace(textBox5.Text)) { MessageBox.Show("Please Empty values not allowed"); return; } if (fbEntities.pages.Any(c => c.pagefbid.Trim().ToLower() == textBox3.Text.ToLower().Trim())) { MessageBox.Show("This Page already exist !"); return; } pageid = textBox3.Text; pagename = textBox5.Text; page.pagefbid = pageid; page.pagename = pagename; page.category = textBox7.Text; page.location = textBox8.Text; page.pageurl = textBox9.Text; page.criteriaId = criteriaId; fbEntities.pages.Add(page); if (fbEntities.SaveChanges() == 1) { MessageBox.Show("Added Sucessfully "); } }
public void Addpage(string pageid, string pagename, string pagecategory, string pagelocation, string pageurl, int criteriaId) { page page = new page(); page.pagefbid = pageid; page.pagename = pagename; page.category = pagecategory; page.location = pagelocation; page.pageurl = pageurl; page.criteriaId = criteriaId; fbEntities.pages.Add(page); fbEntities.SaveChanges(); // if (fbEntities.SaveChanges() == 1) // MessageBox.Show("Added Sucessfully "); }