private void btnAdd_Click(object sender, RoutedEventArgs e) { try { Skill s = new Skill(); s.SkillName = txtSkillName.Text; s.SkillDescription = txtSkillName.Text; s.CategoryId = ((Category)cbCategory.SelectedItem).CategoryID; bll.Add(s); lsSearch.ItemsSource = bll.GetAll(); lsSearch.DisplayMemberPath = "SkillId"; cbCategory.ItemsSource = bll.GetAllCategory(); cbCategory.DisplayMemberPath = "CategoryName"; dgRecords.ItemsSource = bll.GetAll(); ClearWindow(); MessageBox.Show("Skill Added Sucessfully"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected void btnInsert_Click(object sender, EventArgs e) { try { Skill skill = new Skill(); skill.SkillName = txtSkillName.Text; skill.SkillDescription = txtSkillDes.Text; skill.CategoryId = int.Parse(ddCategory.SelectedValue); bll.Add(skill); Response.Write("<script type='text/javascript'>alert('Details Inserted Successfully');</script>"); Response.Redirect("SkillSearch.aspx"); } catch (SkillException ex) { Response.Write("<script type='text/javascript'>alert('" + ex.Message + "');</script>"); } catch (SystemException ex) { Response.Write("<script type='text/javascript'>alert('" + ex.Message + "');</script>"); } }