using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class product_details : System.Web.UI.Page
{
    SubCategory local_subcategory = new SubCategory();
    Products local_product = new Products();
    protected void Page_Load(object sender, EventArgs e)
    {
        string productid = Request.QueryString["proid"];
        string categoryid = Request.QueryString["category"];

        if (productid != null && categoryid != "6")
        {
            BindProductDetails(productid);
            BindProductName(productid);
        }
        else
        {
           Response.Redirect("product_details1.aspx?category=" + categoryid + "&proid=" + productid);
        }
        
    }

    private void BindProductName(string productid)
    {
        DataTable dt = new DataTable();
        try
        {
            dt = local_product.getSubCategoryNameById(productid);
            if (dt.Rows.Count > 0)
            {
                //rpSubCategoryName.DataSource = dt;
                //rpSubCategoryName.DataBind();
            }
            else
            {
                //lblMessageName.Text = "<br/><br/><br/>There Is No Product Found.";
                //lblMessageName.Font.Size = 20;
            }
        }

        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }

   
    private void BindProductDetails(string productid)
    {
        DataTable dt = new DataTable();
        try
        {
            dt = local_product.getProductDetailsByProductid(productid);
            if (dt.Rows.Count > 0)
            {
                rpProductDetails.DataSource = dt;
                rpProductDetails.DataBind();
            }
            else
            {
                lblMessage.Text = "<br/><br/><br/>There is no product found.";
                lblMessage.Font.Size = 20;
            }
        }

        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }
}