コード例 #1
0
        /*
         * Update Category by Category ID when click on update button.
         */
        protected void UpdateCategory_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUpdateCat.Text.Trim() == string.Empty)
                {
                    ModlPopupUpdatecat.Show();
                    lblErrMessageUpdate.Text = "Please enter the category name.";
                }

                int    id             = Convert.ToInt32(hfCategoryID.Value);
                int    updateCategory = 0;
                string tempName       = txtUpdateCat.Text.Trim();

                if (txtUpdateCat.Text.Trim() != string.Empty)
                {
                    updateCategory = (new CatalogCategoriesDAL()).UpdateCategory_DAL(id, tempName);
                    BindCategories();
                }
            }
            catch (Exception ex)
            {
                string strErrCode = ERROR_DISPLAY_MESSAGE + "," + (new Error_Log()).LogErrorIntoDB(ex, "UpdateCategory_Click");
                lblErr.Text = strErrCode;
            }
        }//End of UpdateCategory_Click...
コード例 #2
0
        protected void GridView_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                lblErrMessageUpdate.Text = string.Empty;
                if (e.CommandName == "PopupCategory")
                {
                    int     id = Convert.ToInt32(e.CommandArgument);
                    DataSet getCategoryByCatID = (new CatalogCategoriesDAL().GetCategoryByCategory_DAL(id));

                    hfCategoryID.Value = getCategoryByCatID.Tables[0].Rows[0]["Category_ID"].ToString();
                    txtUpdateCat.Text  = getCategoryByCatID.Tables[0].Rows[0]["Category_Name"].ToString();

                    ModlPopupUpdatecat.Show(); // pop up Category for update or delete
                }
                else if (e.CommandName == "PopupSubcategories")
                {
                    int     id = Convert.ToInt32(e.CommandArgument);
                    DataSet getCategoryByCatID = (new CatalogCategoriesDAL().GetCategoryByCategory_DAL(id));
                    lblErrCategories.Text     = string.Empty;
                    lblErrMessageSubEdit.Text = string.Empty;
                    lblnoSubcatFound.Text     = string.Empty;
                    lblCategory.Text          = getCategoryByCatID.Tables[0].Rows[0]["Category_Name"].ToString();
                    hfCategoryID.Value        = getCategoryByCatID.Tables[0].Rows[0]["Category_Id"].ToString();
                    string tempName = e.CommandArgument.ToString();
                    BindSubCategories(tempName);
                    lnkBtnInsertNewSubCategories.Visible = true;
                    lnkSubCatUpdate.Visible = false;
                    modPopupSubCat.Show();
                }
                else if (e.CommandName == "ToggleCategory")
                {
                    lblErrCategories.Text = string.Empty;
                    hfCurrentID.Value     = e.CommandArgument.ToString();

                    CatalogCategoriesDAL catalogDAL = new CatalogCategoriesDAL();
                    if (((LinkButton)e.CommandSource).Text == "Inactive")
                    {
                        catalogDAL.DeleteCategory_DAL(int.Parse(e.CommandArgument.ToString()), true);
                    }
                    else
                    {
                        catalogDAL.DeleteCategory_DAL(int.Parse(e.CommandArgument.ToString()), false);
                        string deleteCategory = (new CatalogCategoriesDAL()).DeleteCategory_DAL(int.Parse(e.CommandArgument.ToString()), false);
                        if (deleteCategory != string.Empty)
                        {
                            lblErrCategories.Visible = true;
                            lblErrCategories.Text    = "Unable to Inactive the category as it is currently in use by the product.";
                            BindCategories();
                        }
                    }
                    BindCategories();
                }
            }
            catch (Exception ex)
            {
                string strErrCode = ERROR_DISPLAY_MESSAGE + "," + (new Error_Log()).LogErrorIntoDB(ex, "GridView_OnRowCommand");
                lblErr.Text = strErrCode;
            }
        }