Пример #1
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;
            }
        }
Пример #2
0
        /*
         * On row select to popup subcategory window.
         */
        protected void GridView_OnRowCommand_Subcategory(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "ToggleSubcat")
                {
                    lblErrMessageSubEdit.Text = string.Empty;
                    hfCurrentSubcatID.Value   = e.CommandArgument.ToString();
                    CatalogCategoriesDAL subcatDAL = new CatalogCategoriesDAL();

                    if (((LinkButton)e.CommandSource).Text == "Inactive")
                    {
                        subcatDAL.DeleteSubcategory_DAL(int.Parse(e.CommandArgument.ToString()), true);
                        BindSubCategories(hfCategoryID.Value);
                        modPopupSubCat.Show();
                    }
                    else
                    {
                        subcatDAL.DeleteSubcategory_DAL(int.Parse(e.CommandArgument.ToString()), false);
                        string deleteSubCat = (new CatalogCategoriesDAL()).DeleteSubcategory_DAL(int.Parse(e.CommandArgument.ToString()), false);

                        if (deleteSubCat != string.Empty)
                        {
                            lblErrMessageSubEdit.Visible = true;
                            lblErrMessageSubEdit.Text    = "Unable to Inactive as it is currently in use by the product.";

                            BindSubCategories(hfCategoryID.Value);
                            modPopupSubCat.Show();
                        }
                    }
                    BindSubCategories(hfCategoryID.Value);
                    modPopupSubCat.Show();
                }
                else if (e.CommandName == "PopupSubCatUpdate")
                {
                    lblErrMessageSubEdit.Text = string.Empty;
                    clearAddSubCatTextBox();
                    int     id = Convert.ToInt32(e.CommandArgument);
                    DataSet getSubCatBySubCatID = null;
                    lnkBtnInsertNewSubCategories.Visible = false;
                    lnkSubCatUpdate.Visible = true;

                    getSubCatBySubCatID = new DataSet();

                    getSubCatBySubCatID = (new CatalogCategoriesDAL().GetSubcategoryBySubcategoryID_DAL(id));

                    hfSubCatID.Value       = getSubCatBySubCatID.Tables[0].Rows[0]["Subcategory_Id"].ToString();
                    txtSubCatName.Text     = getSubCatBySubCatID.Tables[0].Rows[0]["Subcategory_Name"].ToString();
                    txtSubDescription.Text = getSubCatBySubCatID.Tables[0].Rows[0]["Subcategory_Desc"].ToString();
                    //txtSubCatShipClass.Text = getSubCatBySubCatID.Tables[0].Rows[0]["Shipping_Class"].ToString();
                    string ddlShipClstext = getSubCatBySubCatID.Tables[0].Rows[0]["Shipping_Class"].ToString();

                    if (ddlShipClstext != string.Empty)
                    {
                        //string ddlvalue = ddlShipClass.Items.FindByText(ddlShipClstext).Value;

                        foreach (ListItem li in ddlShipClass.Items)
                        {
                            if (ddlShipClstext == li.Text)
                            {
                                ddlShipClass.SelectedValue = ddlShipClass.Items.FindByText(ddlShipClstext).Value;
                            }
                        }
                    }
                    string tempChkTax = getSubCatBySubCatID.Tables[0].Rows[0]["Is_Taxable"].ToString();

                    string ddlSubCartFtext = string.Empty;
                    ddlSubCartFtext = getSubCatBySubCatID.Tables[0].Rows[0]["Feature_Rank"].ToString();
                    if (ddlSubCartFtext != string.Empty)
                    {
                        ddlSubCatFRank.SelectedValue = ddlSubCatFRank.Items.FindByText(ddlSubCartFtext).Value;
                    }
                    // txtSubCatFeatureRank.Text = getSubCatBySubCatID.Tables[0].Rows[0]["Feature_Rank"].ToString();

                    if (tempChkTax.Equals("True"))
                    {
                        chkTax.Checked = true;
                    }
                    else
                    {
                        chkTax.Checked = false;
                    }

                    modPopupSubCat.Show();
                }
            }
            catch (Exception ex)
            {
                string strErrCode = ERROR_DISPLAY_MESSAGE + "," + (new Error_Log()).LogErrorIntoDB(ex, "GridView_OnRowCommand_Subcategory");
                lblErr.Text = strErrCode;
            }
        }