Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string pid = "";
            string dd  = Request["PID"];
            if (dd == null)
            {
                pid = "-1";
            }
            else
            {
                pid = Request["PID"];
            }
            try
            {
                IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance();

                DataTable dt   = ibf.GetProductDetails(pid);
                int       rows = dt.Rows.Count;
                if (rows == 0)
                {
                    lblStatus.Text = "No Product ID was specified, please " +
                                     "go to View Products Page and select a product first";
                }
                else
                {
                    string catID   = dt.Rows[0]["CatID"].ToString();
                    string catDesc = ibf.getCategoryDesc(catID);
                    lblCategory.Text  = catDesc;
                    lblProductID.Text = dt.Rows[0]["ProductID"].ToString();
                    txtShortDesc.Text = dt.Rows[0]["ProductSDesc"].ToString();
                    txtLongDesc.Text  = dt.Rows[0]["ProductLDesc"].ToString();
                    txtPrice.Text     = dt.Rows[0]["Price"].ToString();
                    lblProdImage.Text = dt.Rows[0]["ProductImage"].ToString();
                    bool inStock = (bool)dt.Rows[0]["InStock"];
                    if (inStock == true)
                    {
                        chkInStock.Checked = true;
                    }
                    else
                    {
                        chkInStock.Checked = false;
                    }
                    txtInventory.Text   = dt.Rows[0]["Inventory"].ToString();
                    imgProduct.ImageUrl = "../PImages/" + lblProdImage.Text;
                }
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["MyCart"] == null)
            {
                Session["MyCart"] = myCart;
            }
            else
            {
                myCart = (Cart)Session["MyCart"];
            }
            string             PID = Request["PID"];
            IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance();

            dt = ibf.GetProductDetails(PID);
            lblProdDesc.Text = dt.Rows[0]["ProductSDesc"].ToString();
            string price = dt.Rows[0]["Price"].ToString();
            SessionFacade.PRODUCTID = dt.Rows[0]["ProductId"].ToString();
            SessionFacade.PRODNAME  = dt.Rows[0]["ProductSDesc"].ToString();
            lblPrice.Text           = "$" + price.Substring(0, 5);
            SessionFacade.PRICE     = price.Substring(0, 5);
            string shippingcost = dt.Rows[0]["ShippingCost"].ToString();
            shippingcost           = shippingcost.Substring(0, 4);
            SessionFacade.SHIPPING = shippingcost;
            if (shippingcost == "0.00")
            {
                lblShipping.Text = "Free Shipping";
            }
            else
            {
                lblShipping.Text = shippingcost;
            }
            if (!IsPostBack)
            {
                ddl.DataSource = Enumerable.Range(1, 15);
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {
            lblStatus.Text = ex.Message;
        }
    }