Esempio n. 1
0
    //Inserting a new category
    public void InsertCategory()
    {
        try
        {
            categoryBLLObj.categoryId   = Convert.ToInt32(Convert.ToString(Request.QueryString["id"]));
            categoryBLLObj.categoryName = txtCategoryName.Text;

            if (ddlSelectParent.Text == "---Set Parent---")
            {
                categoryBLLObj.parentCategoryId = -1;
                categoryBLLObj.catLevel         = 1;
            }
            else
            {
                categoryBLLObj.parentCategoryId = Convert.ToInt32(ddlSelectParent.SelectedValue);
                int level = categoryBLLObj.BLLGetSelectedCategoryLevel(categoryBLLObj);
                categoryBLLObj.catLevel = level + 1;
            }
            if (Convert.ToString(ViewState["categoryId"]) == "")
            {
                status = categoryBLLObj.BLLInsertCategory(categoryBLLObj);
                if (status == 1)
                {
                    Response.Write("<script>alert('Category Inserted')</script>");

                    clearAll();
                }
                else
                {
                    Response.Write("<script>alert('Category already present')</script>");
                }
            }
            else
            {
                categoryBLLObj.categoryId = Convert.ToInt32(Convert.ToString(ViewState["categoryId"]));

                status = categoryBLLObj.BLLUpdateCategory(categoryBLLObj);

                if (status == 1)
                {
                    Response.Write("<script>alert('Category Updated')</script>");
                }
                else
                {
                    Response.Write("<script>alert('Category Not Updated Successfully')</script>");
                }
            }
        }
        catch (Exception ex)
        {
            string m = ex.Message;
        }
    }