コード例 #1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Category c = new Category();
                c.CategoryName        = txtCategoryName.Text;
                c.CategoryDescription = txtCategoryDesc.Text;
                bll.Add(c);
                lsSearch.ItemsSource       = bll.GetAll();
                lsSearch.DisplayMemberPath = "CategoryID";
                txtCategoryId.Text         = bll.GetCategoryID().ToString();

                dgRecords.ItemsSource = bll.GetAll();
                ClearWindow();
                MessageBox.Show("Category Added Sucessfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                Category category = new Category();
                category.CategoryName        = txtCatName.Text;
                category.CategoryDescription = txtCatDesc.Text;

                bll.Add(category);
                Response.Write("<script type='text/javascript'>alert('Details Inserted Successfully');</script>");
                Response.Redirect("CategoriesSearch.aspx");
            }
            catch (CategoryException ex)
            {
                Response.Write("<script type='text/javascript'>alert('" + ex.Message + "');</script>");
            }
            catch (SystemException ex)
            {
                Response.Write("<script type='text/javascript'>alert('" + ex.Message + "');</script>");
            }
        }