コード例 #1
0
    protected void rptr_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "EditGroup")
        {
            DataSet ds = new DataSet();
            ds = cls.ReturnDataSet("sp_RetriveDataWithField",
                                   new SqlParameter("@Fields", "*"),
                                   new SqlParameter("@TblNm", "ProductSubCategory"),
                                   new SqlParameter("@WhereClause", "ProductSubCategory where Id ='" + e.CommandArgument + "' and ProductSubCategory.IsActive = 1"));
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblId.Text = e.CommandArgument.ToString();
                cls.SetSelctedDropDownListValues(ds.Tables[0].Rows[0]["ProductCategoryid"].ToString(), ddlCategory);
                txtSubCategoryName.Text = ds.Tables[0].Rows[0]["SubCategoryName"].ToString();
                imgPhoto.ImageUrl       = "../" + ds.Tables[0].Rows[0]["Image"].ToString();
                ViewState["img"]        = ds.Tables[0].Rows[0]["Image"].ToString();
                imgBannerPhoto.ImageUrl = "../" + ds.Tables[0].Rows[0]["ImageBanner"].ToString();
                ViewState["imgBanner"]  = ds.Tables[0].Rows[0]["ImageBanner"].ToString();

                imgPhoto.Visible       = true;
                imgBannerPhoto.Visible = true;
            }
        }
        if (e.CommandName == "DeleteGroup")
        {
            if (cls.CheckExistField("CheckExistField", "Product", "ProductSubCategoryId", e.CommandArgument.ToString(), "and IsActive = 1"))
            {
                lblMsg.Text = "This SubCategory exists in Product. First delete products related to this SubCategory.";
                return;
            }
            else
            {
                cls.ExecuteDA("DeleteRecord", new SqlParameter("@TblNm", "ProductSubCategory"),
                              new SqlParameter("@strField", "Id"),
                              new SqlParameter("@strValue", e.CommandArgument.ToString()));
                clearall();
                lblMsg.Text = "Product Sub Category Deleted";
                BindProductSubCategory();

                cls.ExecuteNonQueryBySQLQuery("delete from SubCategoryImageMap where SubCategoryId='" + e.CommandArgument.ToString() + "'");
            }
        }
    }