protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label lblSubCategoryId = (Label)e.Row.FindControl("lblSubCategoryId");
                if (lblSubCategoryId.Text != "")
                {
                    dtSubCategory = taSubCategory.GetDataBySubCategoryId(Convert.ToInt16(lblSubCategoryId.Text.ToString()));

                    if (dtSubCategory.Rows.Count > 0)
                        lblSubCategoryId.Text =  dtSubCategory[0].SubCategoryName.ToString();
                    else
                    {

                        lblSubCategoryId.Visible = false;
                    }

                    LinkButton lbtnDelete = (LinkButton)e.Row.FindControl("lbtnDelete");
                    lbtnDelete.Attributes.Add("OnClick", "return confirm('Are you sure to delete this record?');");
                }
            }
    }
    private void BindData()
    {
        DataTable DT;
        ylib = new ylibWebClass(constr.connect());

        FillWebControlClass FCC = new FillWebControlClass();

        int CompanyId; int SubCategoryId; int CategoryId; int ProductGroupCode;

        #region SetListVariables

        CompanyId = StringOperation.QueryStringInt16Value(Request.QueryString["CompanyId"]);
        CategoryId = StringOperation.QueryStringInt16Value(Request.QueryString["CategoryId"]);
        SubCategoryId = StringOperation.QueryStringInt16Value(Request.QueryString["SubCategoryId"]);
        ProductGroupCode = StringOperation.QueryStringInt16Value(Request.QueryString["ProductGroupCode"]);

        #endregion

        #region FillDropDownLists

        dtCompany = taCompany.GetData();
        FCC.FillDropDownList(ref ddlCompany, dtCompany, "CompanyName", "CompanyId", true, true, CompanyId.ToString());

        dtCategory = taCategory.SelectCategorybyCompanyId(CompanyId);
        FCC.FillDropDownList(ref ddlCategory, dtCategory, "CategoryName", "CategoryId", true, true, CategoryId.ToString());

        dtSubCategory = taSubCategory.GetDataByCategoryId(CategoryId);
        FCC.FillDropDownList(ref ddlSubCategory, dtSubCategory, "SubCategoryName", "SubCategoryId", true, true, SubCategoryId.ToString());

        dtProductGroup = taProductGroup.GetDataBySubCategoryId(SubCategoryId);
        FCC.FillDropDownList(ref ddlProductGroupCode, dtProductGroup, "ProductGroupDescription", "ProductGroupCode", true, true, ProductGroupCode.ToString());

        #endregion

        #region SetSelectionLabel

        if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0 && ProductGroupCode != 0)
            lblGroupLevel.Text = "Product Group";
        else if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0)
            lblGroupLevel.Text = "Sub Category";
        else if (CompanyId != 0 && CategoryId != 0)
            lblGroupLevel.Text = "Category";
        else if (CompanyId != 0)
            lblGroupLevel.Text = "Company";

        #endregion

        #region Set Main Repeater Page Parts

        DT = ylib.GiveDataTable_BySQLStatement("select PagePartName from PageParts ");

        if (DT.Rows.Count > 0)
        {
            if (CompanyId != 0)
            {
                Repeater1.DataSource = DT;
                Repeater1.DataBind();
            }

        }
        else
        {
            lblMsg.Text = "No record found";
            return;
        }

        #endregion
    }
    private void BindData()
    {
        if (Request.QueryString["CompanyId"] != null && Request.QueryString["CategoryId"] !=null)
        {
            int CompanyId = Convert.ToInt32(Request.QueryString["CompanyId"]);
            int CategoryId = Convert.ToInt32(Request.QueryString["CategoryId"]);

            dtSubCategory = taSubCategory.GetDataByCategoryId(CategoryId);
            ddlCompany.Items.FindByValue(CompanyId.ToString()).Selected = true;

            if (dtSubCategory.Rows.Count > 0)
            {
                GridView1.DataSourceID = null;
                GridView1.DataSource = dtSubCategory;
                GridView1.DataBind();
            }
            else
            {
                lblMsg.Text = "No record found";
                return;
            }
        }
    }
    private void BindData()
    {
        int SectionCode = 0;
        FillWebControlClass FCC = new FillWebControlClass();

        ylib = new ClassP.ylibWebClass(constr.connect());

        lblGroupLevel.Text = Request.QueryString["lblGroupLevel"];

        int CompanyId ;        int SubCategoryId ;        int CategoryId;        int ProductGroupCode ;

        #region SetListVariables

        SectionCode = StringOperation.QueryStringInt16Value(Request.QueryString["SectionCode"]);
        CompanyId = StringOperation.QueryStringInt16Value(Request.QueryString["CompanyId"]);
        CategoryId = StringOperation.QueryStringInt16Value(Request.QueryString["CategoryId"]);
        SubCategoryId = StringOperation.QueryStringInt16Value(Request.QueryString["SubCategoryId"]);
        ProductGroupCode = StringOperation.QueryStringInt16Value(Request.QueryString["ProductGroupCode"]);

        #region Write Cookies

        if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0 && ProductGroupCode != 0)
        {
            Response.Cookies["ProductGroupCode"].Value=ProductGroupCode.ToString();
            Response.Cookies["ProductGroupCode"].Expires=DateTime.Now.AddDays(1);
        }
        else if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0)
        {
            Response.Cookies["SubCategoryId"].Value=SubCategoryId.ToString();
            Response.Cookies["SubCategoryId"].Expires=DateTime.Now.AddDays(1);
        }
        else if (CompanyId != 0 && CategoryId != 0)
        {
            Response.Cookies["CategoryId"].Value = CategoryId.ToString();
            Response.Cookies["CategoryId"].Expires = DateTime.Now.AddDays(1);
        }
        else if (CompanyId != 0)
        {
            Response.Cookies["CompanyId"].Value = CompanyId.ToString();
            Response.Cookies["CompanyId"].Expires = DateTime.Now.AddDays(1);
        }

        #endregion

        #endregion

        lblSectionName.Text = ylib.giveValue("select SectionName from   MainPageSection where SectionCode=" + SectionCode);

        #region FillDropDownLists

        dtCompany = taCompany.GetData();
        FCC.FillDropDownList(ref ddlCompany, dtCompany, "CompanyName", "CompanyId",true,true,CompanyId.ToString());

        dtCategory = taCategory.SelectCategorybyCompanyId(CompanyId);
        FCC.FillDropDownList(ref ddlCategory, dtCategory, "CategoryName", "CategoryId", true, true, CategoryId.ToString());

        dtSubCategory = taSubCategory.GetDataByCategoryId(CategoryId);
        FCC.FillDropDownList(ref ddlSubCategory, dtSubCategory, "SubCategoryName", "SubCategoryId", true, true, SubCategoryId.ToString());

        dtProductGroup = taProductGroup.GetDataBySubCategoryId(SubCategoryId);
        FCC.FillDropDownList(ref ddlProductGroupCode, dtProductGroup, "ProductGroupDescription", "ProductGroupCode", true, true, ProductGroupCode.ToString());

        #endregion

        if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0 && ProductGroupCode!=0)
            dtProduct = taProduct.GetDataByProductGroupCode(ProductGroupCode);
        else
            dtProduct = taProduct.GetDataByProductGroupCode(0);

        if (dtProduct.Rows.Count > 0)
        {
            GridView1.DataSourceID = null;
            GridView1.DataSource = dtProduct;
            GridView1.DataBind();
        }
        else
        {
            GridView1.DataSourceID = null;
            GridView1.DataSource = dtProduct;
            GridView1.DataBind();
            lblMsg.Text = "No record found";
            return;
        }
    }
Esempio n. 5
0
    private void BindData()
    {
        FillWebControlClass FCC = new FillWebControlClass();

        int CompanyId ;        int SubCategoryId ;        int CategoryId;        int ProductGroupCode ;

        #region SetListVariables

        CompanyId = StringOperation.QueryStringInt16Value(Request.QueryString["CompanyId"]);
        CategoryId = StringOperation.QueryStringInt16Value(Request.QueryString["CategoryId"]);
        SubCategoryId = StringOperation.QueryStringInt16Value(Request.QueryString["SubCategoryId"]);
        ProductGroupCode = StringOperation.QueryStringInt16Value(Request.QueryString["ProductGroupCode"]);

        #region Write Cookies

        if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0 && ProductGroupCode != 0)
        {
            Response.Cookies["ProductGroupCode"].Value = ProductGroupCode.ToString();
            Response.Cookies["ProductGroupCode"].Expires = DateTime.Now.AddDays(1);
        }
        else if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0)
        {
            Response.Cookies["SubCategoryId"].Value = SubCategoryId.ToString();
            Response.Cookies["SubCategoryId"].Expires = DateTime.Now.AddDays(1);
        }
        else if (CompanyId != 0 && CategoryId != 0)
        {
            Response.Cookies["CategoryId"].Value = CategoryId.ToString();
            Response.Cookies["CategoryId"].Expires = DateTime.Now.AddDays(1);
        }
        else if (CompanyId != 0)
        {
            Response.Cookies["CompanyId"].Value = CompanyId.ToString();
            Response.Cookies["CompanyId"].Expires = DateTime.Now.AddDays(1);
        }

        #region GetCookies

        if (Request.Cookies["CompanyId"] != null && CompanyId==0)
            CompanyId = StringOperation.QueryStringInt16Value(Convert.ToString(Request.Cookies["CompanyId"].Value));
        if (Request.Cookies["CompanyId"] != null && Request.Cookies["CategoryId"] != null && CategoryId == 0)
            CategoryId = StringOperation.QueryStringInt16Value(Convert.ToString(Request.Cookies["CategoryId"].Value));
        if (Request.Cookies["CompanyId"] != null && Request.Cookies["CategoryId"] != null && Request.Cookies["SubCategoryId"] != null && SubCategoryId == 0)
            SubCategoryId = StringOperation.QueryStringInt16Value(Convert.ToString(Request.Cookies["SubCategoryId"].Value));
        //if (Request.Cookies["ProductGroupCode"] != null && ProductGroupCode == 0)
        //    ProductGroupCode = StringOperation.QueryStringInt16Value(Convert.ToString(Request.Cookies["ProductGroupCode"].Value));

        #endregion

        #endregion

        #endregion

        #region FillDropDownLists

        dtCompany = taCompany.GetData();
        FCC.FillDropDownList(ref ddlCompany, dtCompany, "CompanyName", "CompanyId",true,true,CompanyId.ToString());

        dtCategory = taCategory.SelectCategorybyCompanyId(CompanyId);
        FCC.FillDropDownList(ref ddlCategory, dtCategory, "CategoryName", "CategoryId", true, true, CategoryId.ToString());

        dtSubCategory = taSubCategory.GetDataByCategoryId(CategoryId);
        FCC.FillDropDownList(ref ddlSubCategory, dtSubCategory, "SubCategoryName", "SubCategoryId", true, true, SubCategoryId.ToString());

        dtProductGroup = taProductGroup.GetDataBySubCategoryId(SubCategoryId);
        FCC.FillDropDownList(ref ddlProductGroupCode, dtProductGroup, "ProductGroupDescription", "ProductGroupCode", true, true, ProductGroupCode.ToString());

        #endregion

        if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0 && ProductGroupCode!=0)
            dtProduct = taProduct.GetDataByProductGroupCode(ProductGroupCode);
        else
            dtProduct = taProduct.GetDataByProductGroupCode(0);

        if (dtProduct.Rows.Count > 0)
        {
            GridView1.DataSourceID = null;
            GridView1.DataSource = dtProduct;
            GridView1.DataBind();
        }
        else
        {
            GridView1.DataSourceID = null;
            GridView1.DataSource = dtProduct;
            GridView1.DataBind();
            lblMsg.Text = "No record found";
            return;
        }
    }
    protected void SelectSubCategories()
    {
        int SubCategoryId = Convert.ToInt32(Request.QueryString["SubCategoryId"]);

        if ((Request.QueryString["CategoryId"] != null) && (Convert.ToInt16(Request.QueryString["CategoryId"]) != 0))
        {
            int CategoryId = Convert.ToInt32(Request.QueryString["CategoryId"]);

            dtSubCategory = taSubCategory.GetDataByCategoryId(CategoryId);
            ddlCategory.Items.FindByValue(CategoryId.ToString()).Selected = true;

            ddlSubCategory.DataSourceID = null;
            ddlSubCategory.DataSource = dtSubCategory;
            ddlSubCategory.DataTextField = dtSubCategory.Columns[2].ToString();
            ddlSubCategory.DataValueField = dtSubCategory.Columns[1].ToString();
            ddlSubCategory.DataBind();

            if ((Request.QueryString["SubCategoryId"] != null) && (Convert.ToInt16(Request.QueryString["SubCategoryId"]) != 0))
            {
                ddlSubCategory.Items.FindByValue(Request.QueryString["SubCategoryId"]).Selected = true;

            }
            else
                ddlSubCategory.Items.Insert(0, new ListItem("Please Select", ""));
        }
        else
            ddlSubCategory.Items.Insert(0, new ListItem("Please Select", ""));
    }