Example #1
0
/**
 * Display the data collected from the (previous) post_item page.  The data now resides in a general entry item object
 * Show the general info then display the specifics
 */
        private void BindData(classes.BoardItem bItem)
        {
            hdnUserDir.Value = Session["userDir"].ToString();
            hdnAdType.Value  = bItem.AdType.ToString();

            //show today's date
            lblDateData.Text = String.Format("{0:MM/dd}", DateTime.Now);

            //location-region and town
            if (bItem.Location > 0)
            {
                lblLocation.Text = Global.SwapChar(DecodeRegion(Convert.ToInt32(bItem.Location)), " ", "_");
                if (bItem.Town.Length > 0)
                {
                    lblLocation.Text += " - " + bItem.Town + " " + bItem.Zip;
                }
            }

            //brand
            lblBrandData.Text = bItem.Brand;
            if (bItem.Shaper.Length > 1)
            {
                lblBrandData.Text += " / " + bItem.Shaper;
            }
            //price
            lblPriceData.Text = "$" + bItem.Price.ToString();
            //details
            lblDetailsData.Text = bItem.Details.ToString();
            //boardtype label
            lblBoardType.Text = "Board Type: ";


            //TODO: ShowPicsForPreview(bItem)
            //TODO: dont show no image if slot 2

            //show pictures waiting in temp dir
            if (hdnAdType.Value != "2")    //1 = selling items; 2 = wanted; 3 = showcase
            {
                //Pic1
                Pic1.ImageUrl = GetPicPath(bItem.ImgPath1);
                if (Pic1.ImageUrl.IndexOf("s1x1.gif") != -1)
                {
                    Pic1.ImageUrl     = "images/noimage.gif";
                    Pic1.Width        = 400;
                    Pic1.Height       = 468;
                    hdnProcPics.Value = "False";
                }
                else //do thmbnail
                {
                    Pic1ThmbNail.ImageUrl = GetPicPath("thmbNail_" + bItem.ImgPath1);
                    Pic1ThmbNail.Visible  = true;
                    Pic1ThmbNail.Width    = 75;
                    Pic1ThmbNail.Height   = 75;
                    hdnProcPics.Value     = "True";
                }

                //Pic2
                Pic2.ImageUrl = GetPicPath(bItem.ImgPath2);
                if (Pic2.ImageUrl.IndexOf("s1x1.gif") != -1)
                {
                    Pic2.Width  = 1;
                    Pic2.Height = 1;
                }
                else
                {
                    Pic2ThmbNail.Visible  = true;
                    Pic2ThmbNail.ImageUrl = GetPicPath("thmbNail_" + bItem.ImgPath2);
                    Pic2ThmbNail.Width    = 75;
                    Pic2ThmbNail.Height   = 75;
                    hdnProcPics.Value     = "True";
                }

                //Pic3
                Pic3.ImageUrl = GetPicPath(bItem.ImgPath3);
                if (Pic3.ImageUrl.IndexOf("s1x1.gif") != -1)
                {
                    Pic3.Width  = 1;
                    Pic3.Height = 1;
                }
                else
                {
                    Pic3ThmbNail.Visible  = true;
                    Pic3ThmbNail.ImageUrl = GetPicPath("thmbNail_" + bItem.ImgPath3);
                    Pic3ThmbNail.Width    = 75;
                    Pic3ThmbNail.Height   = 75;
                    hdnProcPics.Value     = "True";
                }

                //Pic4
                Pic4.ImageUrl = GetPicPath(bItem.ImgPath4);
                if (Pic4.ImageUrl.IndexOf("s1x1.gif") != -1)
                {
                    Pic4.Width  = 1;
                    Pic4.Height = 1;
                }
                else
                {
                    Pic4ThmbNail.Visible  = true;
                    Pic4ThmbNail.ImageUrl = GetPicPath("thmbNail_" + bItem.ImgPath4);
                    Pic4ThmbNail.Width    = 75;
                    Pic4ThmbNail.Height   = 75;
                    hdnProcPics.Value     = "True";
                }
            }
            else //show wanted pic
            {
                Pic1.ImageUrl     = "images//wantedbig.gif";
                Pic1.Height       = 214;
                Pic1.Width        = 168;
                hdnProcPics.Value = "False";
            }

            //Show e-mail and possibly phone num
            ShowContactDetails();

            //board specific data
            switch (bItem.Category.ToString())
            {
            case "1":                     //surf

                //switch (bItem.BoardType)
                switch (bItem.AdType)
                {
                case 1:         //buy
                    pnlAll.Visible       = true;
                    pnlBoardType.Visible = true;
                    //fins
                    lblFinsData.Text = DecodeFins(bItem.Fins);
                    //tail
                    lblTailData.Text = Global.ProperSpace(DecodeTail(bItem.TailType));

                    //height
                    lblHeightFtData.Text = bItem.HtFt + "\'";
                    lblHeightInData.Text = bItem.HtIn + "\"";

                    //width
                    lblWidthData.Text = bItem.Width.ToString();
                    if (bItem.WidthDenum.ToString().Length > 0 && bItem.WidthNum.ToString().Length > 0)
                    {
                        lblWidthData.Text += " + " + bItem.WidthNum.ToString() + "/" + bItem.WidthDenum.ToString();
                    }
                    lblWidthData.Text += "\"";

                    //thickness
                    lblThick.Text = bItem.Thickness.ToString();
                    if (bItem.ThickNum.ToString().Length > 0 && bItem.ThickDenum.ToString().Length > 0)
                    {
                        lblThick.Text += " + " + bItem.ThickNum.ToString() + "/" + bItem.ThickDenum.ToString();
                    }
                    lblThick.Text += "\"";

                    //enable surf panels
                    pnlWidth.Visible      = true;
                    pnlSurfOnly.Visible   = true;
                    pnlGearItem.Visible   = false;
                    lblBoardTypeData.Text = DecodeBoard(bItem.Category, bItem.BoardType);
                    break;

                case 2:         //sell
                    break;

                case 3:         //showcase
                    pnlAll.Visible       = false;
                    lblWeb.Text          = bItem.WebURL;
                    pnlWeb.Visible       = true;
                    lblGenDims.Text      = bItem.GenDimensions;
                    pnlGenDims.Visible   = true;
                    lblGearItem.Text     = "&nbps;Model:&nbsp";
                    lblGearItem.Visible  = true;
                    lblGearItemData.Text = bItem.GearItem;
                    pnlGearItem.Visible  = true;

                    break;

                case 4:
                    lblPrice.Text         = "Model Price";
                    lblModelData.Text     = bItem.Model;
                    lblBoardTypeData.Text = DecodeBoard(bItem.Category, bItem.BoardType);
                    lblGenDims.Text       = bItem.GenDimensions;
                    break;

                default:
                    break;
                }

                break;

            case "2":                     //snow
                pnlBoardType.Visible = true;
                lblHeightFtData.Text = bItem.HtFt + "" + "cm";

                lblBoardTypeData.Text = DecodeBoard(bItem.Category, bItem.BoardType);
                lblBrand.Text         = "Brand:" + "";

                pnlSurfOnly.Visible = false;

                break;

            case "3":                     //other board
                pnlBoardType.Visible = true;
                lblBrand.Text        = "Brand:" + "";

                if (bItem.OtherBoardType == null || bItem.OtherBoardType == "")
                {
                    //todo: maybe set other = "" so sql doesn't complain

                    bItem.OtherBoardType  = "";
                    lblBoardTypeData.Text = DecodeBoard(bItem.Category, bItem.BoardType);
                }
                else
                {
                    lblBoardTypeData.Text = bItem.OtherBoardType;
                }
                pnlAll.Visible      = false;
                pnlSurfOnly.Visible = false;
                pnlGenDims.Visible  = true;
                lblGenDims.Text     = bItem.GenDimensions;
                break;

            case "4":                     //gear
                lblBrand.Text        = "Brand:" + "";
                pnlAll.Visible       = false;
                pnlSurfOnly.Visible  = false;
                pnlGearItem.Visible  = true;
                lblGearItem.Visible  = true;
                pnlBoardType.Visible = false;
                lblGearItemData.Text = bItem.GearItem;
                break;
            }
            SetupUIForEntryType();  //superflous?
        }