예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Label firstLabel = (Label)Master.FindControl("lblUpdate");

            if (firstLabel != null)
            {
                firstLabel.Text = "VIEWING";
            }

            Label secondLabel = (Label)Master.FindControl("lblPartNumTitle");

            if (secondLabel != null)
            {
                secondLabel.Text = Session["partNumber"].ToString();
            }

            if (Session["updateSelected"] != null)
            {
                btnInsert.CssClass = "removeElement";
            }

            if (Session["user_type"].ToString() != "S")
            {
                btnUpdate.Visible = false;
                btnInsert.Visible = false;
            }

            //prevent backdoor
            if (Session["tableName"] == null)
            {
                Response.Redirect("ProductSelect.aspx");
            }
            else
            {
                //load dropdowns
                if (!Page.IsPostBack)
                {
                    Session.Add("UpdatePartList", "true");
                    //set up a dataview object to hold table names for the first drop down
                    System.Data.DataView tableList = new System.Data.DataView();

                    //select table names
                    datSelectDataSource.SelectCommand = "SELECT name FROM sys.tables WHERE name != 'tblColor' AND name != 'tblSchematicParts' AND name != 'tblParts' "
                                                        + " AND name != 'tblLengthUnits'  AND name != 'tblAudits' AND name != 'tblSalesOrders' AND name != 'tblSalesOrderItems' "
                                                        + " AND SUBSTRING(name,1,3) = 'tbl' "
                                                        + "ORDER BY name ASC";                    //assign the table names to the dataview object
                    tableList = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                    //variable to determine amount of rows in the dataview object
                    int rowCount = tableList.Count;

                    ddlCategory.Items.Add("");
                    //populate first drop down
                    for (int i = 0; i < rowCount; i++)
                    {
                        string textString   = tableList[i][0].ToString();
                        string newString    = textString.Substring(3);
                        string outputString = "";
                        foreach (char character in newString)
                        {
                            if (char.IsUpper(character))
                            {
                                outputString += " " + character;
                            }
                            else if (character.ToString() == "1" || character.ToString() == "3" || character.ToString() == "4")
                            {
                                outputString += " " + character;
                            }
                            else
                            {
                                outputString += character;
                            }
                        }

                        ddlCategory.Items.Add(outputString.Trim());
                    }

                    //select category dropdown default value
                    ddlCategory.SelectedIndex = (int)Session["categoryIndex"];

                    //load part list
                    if (ddlCategory.SelectedValue != "")
                    {
                        //get table name selected
                        string tableName = "tbl" + ddlCategory.SelectedValue.Replace(" ", "");

                        //set up a dataview object to hold part numbers for the second drop down
                        System.Data.DataView partsList = new System.Data.DataView();

                        if (tableName != "tblSchematics")
                        {
                            //select part numbers
                            datSelectDataSource.SelectCommand = "SELECT partNumber, partName FROM " + tableName + " ORDER BY partNumber ASC";
                        }
                        else
                        {
                            datSelectDataSource.SelectCommand = "SELECT schematicNumber, partName FROM " + tableName + " ORDER BY schematicNumber ASC";
                        }
                        //assign the table names to the dataview object
                        partsList = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                        //clear second drop down
                        ddlPart.Items.Clear();

                        //Insert empty string to first row of second drop down
                        ddlPart.Items.Add("");

                        rowCount = partsList.Count;
                        //populate second drop down
                        for (int i = 0; i < rowCount; i++)
                        {
                            ddlPart.Items.Add(partsList[i][0].ToString() + " (" + partsList[i][1].ToString() + ")");
                        }


                        Session.Add("displayChanged", "true");
                    }
                }

                //only run if the display has changed, to allow display postback changes
                if (Session["displayChanged"] != null)
                {
                    //we're running this, so the display has been updated, and is not set for change
                    Session.Remove("displayChanged");
                    //select part dropdown default value
                    ddlPart.SelectedIndex = (int)Session["partIndex"];

                    //show navigation arrows
                    imgPrevArrow.CssClass = "prevArrow";
                    imgNextArrow.CssClass = "nextArrow";

                    if (ddlPart.SelectedIndex == (ddlPart.Items.Count - 1))
                    {
                        //if last item, don't show 'next' arrow
                        imgNextArrow.CssClass = "removeElement";
                    }
                    else if (ddlPart.SelectedIndex == 1)
                    {
                        //if first item, don't show 'prev' arrow
                        imgPrevArrow.CssClass = "removeElement";
                    }

                    //load appropriate image
                    imgPart.ImageUrl        = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                    imgPartLink.NavigateUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                    //remove all non-product panels, whichw ill be shown on switch case below
                    pnlAccessories.CssClass         = "removeElement";
                    pnlDecorativeColumn.CssClass    = "removeElement";
                    pnlDoorFrameExtrusions.CssClass = "removeElement";
                    pnlInsulatedFloors.CssClass     = "removeElement";
                    pnlRoofExtrusions.CssClass      = "removeElement";
                    pnlRoofPanels.CssClass          = "removeElement";
                    pnlScreenRoll.CssClass          = "removeElement";
                    pnlSuncrylicRoof.CssClass       = "removeElement";
                    pnlSunrail1000.CssClass         = "removeElement";
                    pnlSunrail300.CssClass          = "removeElement";
                    pnlSunrail400.CssClass          = "removeElement";
                    pnlVinylRoll.CssClass           = "removeElement";
                    pnlWallExtrusions.CssClass      = "removeElement";
                    pnlWallPanel.CssClass           = "removeElement";
                    pnlSchematicsDisplay.CssClass   = "removeElement";

                    //Uncomment for checks with login

                    /*
                     * if (Session["loggedCountry"] == null)
                     * {
                     *  pnlPriceDisplay.CssClass = "removeElement";
                     * }
                     * else if (Session["loggedCountry"] == "US")
                     * {
                     *  rowCadPrice.CssClass = "removeElement";
                     * }
                     * else
                     * {
                     *  rowUsdPrice.CssClass = "removeElement";
                     * }
                     */

                    //if value was changed on display page, we

                    string tableName = Session["tableName"].ToString();

                    switch (tableName)
                    {
                        #region Accessories
                    case "tblAccessories":
                    {
                        pnlAccessories.CssClass = "dimensionsTableDisplay";
                        rowLegend.CssClass      = "removeElement";
                        rowComposition.CssClass = "removeElement";
                        rowStandard.CssClass    = "removeElement";
                        lblPartName.Text        = "Part Name:";
                        lblPartNum.Text         = "Part Number:";

                        Accessories anAccessory = new Accessories();

                        //call select all function to populate object
                        anAccessory.Populate(anAccessory.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartNum.Text         = anAccessory.AccessoryNumber;
                        txtPartName.Text        = anAccessory.AccessoryName;
                        txtPartDesc.Text        = anAccessory.AccessoryDescription;
                        txtColor.Text           = anAccessory.AccessoryColor;
                        txtPackQuantity.Text    = anAccessory.AccessoryPackQuantity.ToString();
                        txtAccessorySize.Text   = anAccessory.AccessorySize.ToString() + " " + anAccessory.AccessorySizeUnits;
                        txtAccessoryWidth.Text  = anAccessory.AccessoryWidth.ToString() + " " + anAccessory.AccessoryWidthUnits;
                        txtAccessoryLength.Text = anAccessory.AccessoryLength.ToString() + " " + anAccessory.AccessoryLengthUnits;

                        if (txtPackQuantity.Text == "0" || txtPackQuantity.Text == "")
                        {
                            rowPackQuantity.CssClass = "removeElement";
                        }

                        if (anAccessory.AccessorySize == 0)        //a space is added above, so check for one space, not blank
                        {
                            rowAccessorySize.CssClass = "removeElement";
                        }

                        if (anAccessory.AccessoryLength == 0)
                        {
                            rowAccessoryMaxLength.CssClass = "removeElement";
                        }

                        if (anAccessory.AccessoryWidth == 0)
                        {
                            rowAccessoryMaxWidth.CssClass = "removeElement";
                        }

                        if (txtColor.Text == "")
                        {
                            rowColor.CssClass = "removeElement";
                        }

                        txtUsdPrice.Text = anAccessory.AccessoryUsdPrice.ToString("N2");
                        txtCadPrice.Text = anAccessory.AccessoryCadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region DecorativeColumn
                    case "tblDecorativeColumn":
                    {
                        pnlDecorativeColumn.CssClass = "dimensionsTableDisplay";
                        rowLegend.CssClass           = "removeElement";
                        rowComposition.CssClass      = "removeElement";
                        rowStandard.CssClass         = "removeElement";
                        rowPackQuantity.CssClass     = "removeElement";

                        DecorativeColumn aColumn = new DecorativeColumn();

                        //call select all function to populate object
                        aColumn.Populate(aColumn.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text     = aColumn.ColumnName;
                        txtPartDesc.Text     = aColumn.ColumnDescription;
                        txtPartNum.Text      = aColumn.PartNumber;
                        txtColor.Text        = aColumn.ColumnColor;
                        txtDecColLength.Text = aColumn.ColumnLength.ToString() + " " + aColumn.ColumnLengthUnits;

                        txtUsdPrice.Text = aColumn.ColumnUsdPrice.ToString("N2");
                        txtCadPrice.Text = aColumn.ColumnCadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region Door Frame Extrusion
                    case "tblDoorFrameExtrusion":
                    {
                        pnlDoorFrameExtrusions.CssClass = "dimensionsTableDisplay";
                        rowLegend.CssClass       = "removeElement";
                        rowComposition.CssClass  = "removeElement";
                        rowStandard.CssClass     = "removeElement";
                        rowPackQuantity.CssClass = "removeElement";

                        DoorFrameExtrusion aFrameExtrusion = new DoorFrameExtrusion();

                        //call select all function to populate object
                        aFrameExtrusion.Populate(aFrameExtrusion.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text = aFrameExtrusion.DfeName;
                        if (aFrameExtrusion.DfeDescription != "")
                        {
                            txtPartDesc.Text = aFrameExtrusion.DfeDescription;
                        }
                        else
                        {
                            rowDescription.CssClass = "removeElement";
                        }
                        txtPartNum.Text            = aFrameExtrusion.PartNumber;
                        txtColor.Text              = aFrameExtrusion.DfeColor;
                        txtDoorFrExtMaxLength.Text = aFrameExtrusion.DfeMaxLength.ToString() + " " + aFrameExtrusion.DfeMaxLengthUnits;

                        txtUsdPrice.Text = aFrameExtrusion.UsdPrice.ToString("N2");
                        txtCadPrice.Text = aFrameExtrusion.CadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region InsulatedFloors
                    case "tblInsulatedFloors":
                    {
                        pnlInsulatedFloors.CssClass = "dimensionsTableDisplay";
                        rowLegend.CssClass          = "removeElement";
                        rowStandard.CssClass        = "removeElement";
                        rowPackQuantity.CssClass    = "removeElement";
                        rowColor.CssClass           = "removeElement";

                        InsulatedFloors aFloor = new InsulatedFloors();

                        //call select all function to populate object
                        aFloor.Populate(aFloor.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text          = aFloor.InsulatedFloorName;
                        txtPartDesc.Text          = aFloor.InsulatedFloorDescription;
                        txtPartNum.Text           = aFloor.PartNumber;
                        txtInsFloorSize.Text      = aFloor.InsulatedFloorSize.ToString() + " " + aFloor.InsulatedFloorSizeUnits;
                        txtInsFloorMaxWidth.Text  = aFloor.InsulatedFloorMaxWidth.ToString() + " " + aFloor.InsulatedFloorMaxWidthUnits;
                        txtInsFloorMaxLength.Text = aFloor.InsulatedFloorMaxLength.ToString();

                        txtUsdPrice.Text = aFloor.InsulatedFloorUsdPrice.ToString("N2");
                        txtCadPrice.Text = aFloor.InsulatedFloorCadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region RoofPanels
                    case "tblRoofPanels":
                    {
                        pnlRoofPanels.CssClass   = "dimensionsTableDisplay";
                        rowLegend.CssClass       = "removeElement";
                        rowPackQuantity.CssClass = "removeElement";

                        RoofPanels aRoofPanel = new RoofPanels();

                        //call select all function to populate object
                        aRoofPanel.Populate(aRoofPanel.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text    = aRoofPanel.PanelName;
                        txtPartDesc.Text    = aRoofPanel.PanelDescription;
                        txtPartNum.Text     = aRoofPanel.PartNumber;
                        txtComposition.Text = aRoofPanel.PanelComposition;
                        txtStandard.Text    = aRoofPanel.PanelStandard;



                        txtColor.Text            = aRoofPanel.PanelColor;
                        txtRoofPnlSize.Text      = aRoofPanel.PanelSize.ToString() + " " + aRoofPanel.PanelSizeUnits;
                        txtRoofPnlMaxWidth.Text  = aRoofPanel.PanelMaxWidth.ToString() + " " + aRoofPanel.MaxWidthUnits;
                        txtRoofPnlMaxLength.Text = aRoofPanel.PanelMaxLength;

                        txtUsdPrice.Text = aRoofPanel.UsdPrice.ToString("N2");
                        txtCadPrice.Text = aRoofPanel.CadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region Schematics
                    case "tblSchematics":
                    {
                        pnlSchematicsDisplay.CssClass = "schematicsTableDisplay";
                        rowComposition.CssClass       = "removeElement";
                        rowStandard.CssClass          = "removeElement";
                        rowPackQuantity.CssClass      = "removeElement";
                        rowColor.CssClass             = "removeElement";
                        lblLegend.Text = "Legend:";
                        Schematics aSchematic = new Schematics();
                        Part       aPart      = new Part();

                        //call select all function to populate object
                        aSchematic.Populate(aSchematic.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartNum.Text = aSchematic.SchematicNumber;

                        if (Session["UpdatePartList"].ToString() == "true" || !Page.IsPostBack)
                        {
                            UpdatePartsList();
                            Session.Remove("UpdatePartList");
                        }

                        if (Session["part"] != null)
                        {
                            aPart = (Part)Session["part"];
                            txtSchemPartKey.Text  = aPart.PartKeyNumber.ToString();
                            txtSchemPartName.Text = aPart.PartName;
                            txtSchemPartNum.Text  = aPart.PartNumber;
                        }
                        else
                        {
                            txtSchemPartKey.Text  = "";
                            txtSchemPartName.Text = "";
                            txtSchemPartNum.Text  = "";
                        }

                        lblPartName.Text = "Schematic Name:";
                        txtPartName.Text = aSchematic.SchematicName.ToString();
                        txtPartDesc.Text = aSchematic.SchematicDescription.ToString();
                        lblPartNum.Text  = "Schematic Number:";
                        txtPartNum.Text  = aSchematic.SchematicNumber.ToString();

                        if (txtPartDesc.Text == "")
                        {
                            txtPartDesc.Text = "No Description";
                        }

                        txtUsdPrice.Text = aSchematic.SchematicUsdPrice.ToString("N2");
                        txtCadPrice.Text = aSchematic.SchematicCadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region Screen Roll
                    case "tblScreenRoll":
                    {
                        pnlScreenRoll.CssClass   = "dimensionsTableDisplay";
                        rowLegend.CssClass       = "removeElement";
                        rowDescription.CssClass  = "removeElement";
                        rowComposition.CssClass  = "removeElement";
                        rowStandard.CssClass     = "removeElement";
                        rowPackQuantity.CssClass = "removeElement";
                        rowColor.CssClass        = "removeElement";

                        ScreenRoll aScreenRoll = new ScreenRoll();

                        //call select all function to populate object
                        aScreenRoll.Populate(aScreenRoll.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text         = aScreenRoll.ScreenRollName;
                        txtPartNum.Text          = aScreenRoll.PartNumber;
                        txtScreenRollWidth.Text  = aScreenRoll.ScreenRollWidth + " " + aScreenRoll.ScreenRollWidthUnits;
                        txtScreenRollLength.Text = aScreenRoll.ScreenRollLength + " " + aScreenRoll.ScreenRollLengthUnits;

                        txtUsdPrice.Text = aScreenRoll.UsdPrice.ToString("N2");
                        txtCadPrice.Text = aScreenRoll.CadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region Suncrylic Roof
                    case "tblSuncrylicRoof":
                    {
                        pnlSuncrylicRoof.CssClass = "dimensionsTableDisplay";
                        rowLegend.CssClass        = "removeElement";
                        rowComposition.CssClass   = "removeElement";
                        rowStandard.CssClass      = "removeElement";
                        rowPackQuantity.CssClass  = "removeElement";

                        SuncrylicRoof aSuncrylicRoof = new SuncrylicRoof();

                        //call select all function to populate object
                        aSuncrylicRoof.Populate(aSuncrylicRoof.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text           = aSuncrylicRoof.SuncrylicName;
                        txtPartDesc.Text           = aSuncrylicRoof.SuncrylicDescription;
                        txtPartNum.Text            = aSuncrylicRoof.PartNumber;
                        txtColor.Text              = aSuncrylicRoof.SuncrylicColor;
                        txtSunRoofMaxLength.Text   = aSuncrylicRoof.SuncrylicMaxLength + " " + aSuncrylicRoof.SuncrylicLengthUnits;
                        txtSunRoofMaxWidthStr.Text = "Varies";

                        txtUsdPrice.Text = aSuncrylicRoof.UsdPrice.ToString("N2");
                        txtCadPrice.Text = aSuncrylicRoof.CadPrice.ToString("N2");

                        break;
                    }
                        #endregion

                        #region Sunrail1000
                    case "tblSunrail1000":
                    {
                        pnlSunrail1000.CssClass  = "dimensionsTableDisplay";
                        rowLegend.CssClass       = "removeElement";
                        rowComposition.CssClass  = "removeElement";
                        rowStandard.CssClass     = "removeElement";
                        rowPackQuantity.CssClass = "removeElement";

                        Sunrail1000 aSunrail = new Sunrail1000();

                        //call select all function to populate object
                        aSunrail.Populate(aSunrail.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text         = aSunrail.Sunrail1000Name;
                        txtPartDesc.Text         = aSunrail.Sunrail1000Description;
                        txtPartNum.Text          = aSunrail.PartNumber;
                        txtColor.Text            = aSunrail.Sunrail1000Color;
                        txtSun1000MaxLength.Text = aSunrail.Sunrail1000MaxLengthFeet.ToString() + " " + aSunrail.Sunrail1000MaxLengthFeetUnits + " "
                                                   + aSunrail.Sunrail1000MaxLengthInches.ToString() + " " + aSunrail.Sunrail1000MaxLengthInchesUnits;

                        txtUsdPrice.Text = aSunrail.Sunrail1000UsdPrice.ToString("N2");
                        txtCadPrice.Text = aSunrail.Sunrail1000CadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region Sunrail300
                    case "tblSunrail300":
                    {
                        pnlSunrail300.CssClass   = "dimensionsTableDisplay";
                        rowLegend.CssClass       = "removeElement";
                        rowComposition.CssClass  = "removeElement";
                        rowStandard.CssClass     = "removeElement";
                        rowPackQuantity.CssClass = "removeElement";

                        Sunrail300 aSunrail300 = new Sunrail300();

                        //call select all function to populate object
                        aSunrail300.Populate(aSunrail300.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text        = aSunrail300.Sunrail300Name;
                        txtPartDesc.Text        = aSunrail300.Sunrail300Description;
                        txtPartNum.Text         = aSunrail300.PartNumber;
                        txtColor.Text           = aSunrail300.Sunrail300Color;
                        txtSun300MaxLength.Text = aSunrail300.Sunrail300MaxLengthFeet.ToString() + " " + aSunrail300.Sunrail300MaxLengthFeetUnits + " "
                                                  + aSunrail300.Sunrail300MaxLengthInches.ToString() + " " + aSunrail300.Sunrail300MaxLengthInchesUnits;

                        txtUsdPrice.Text = aSunrail300.Sunrail300UsdPrice.ToString("N2");
                        txtCadPrice.Text = aSunrail300.Sunrail300CadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region Sunrail300Accessories
                    case "tblSunrail300Accessories":
                    {
                        rowLegend.CssClass       = "removeElement";
                        rowComposition.CssClass  = "removeElement";
                        rowStandard.CssClass     = "removeElement";
                        rowPackQuantity.CssClass = "removeElement";

                        Sunrail300Accessories aSunrail300Accessory = new Sunrail300Accessories();

                        //call select all function to populate object
                        aSunrail300Accessory.Populate(aSunrail300Accessory.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text = aSunrail300Accessory.Sunrail300AccessoriesName;
                        txtPartDesc.Text = aSunrail300Accessory.Sunrail300AccessoriesDescription;
                        txtPartNum.Text  = aSunrail300Accessory.PartNumber;
                        txtColor.Text    = aSunrail300Accessory.Sunrail300AccessoriesColor;

                        txtUsdPrice.Text = aSunrail300Accessory.Sunrail300AccessoriesUsdPrice.ToString("N2");
                        txtCadPrice.Text = aSunrail300Accessory.Sunrail300AccessoriesCadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region Sunrail400
                    case "tblSunrail400":
                    {
                        pnlSunrail400.CssClass   = "dimensionsTableDisplay";
                        rowLegend.CssClass       = "removeElement";
                        rowComposition.CssClass  = "removeElement";
                        rowStandard.CssClass     = "removeElement";
                        rowPackQuantity.CssClass = "removeElement";

                        Sunrail400 aSunrail400 = new Sunrail400();

                        //call select all function to populate object
                        aSunrail400.Populate(aSunrail400.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text        = aSunrail400.Sunrail400Name;
                        txtPartDesc.Text        = aSunrail400.Sunrail400Description;
                        txtPartNum.Text         = aSunrail400.PartNumber;
                        txtColor.Text           = aSunrail400.Sunrail400Color;
                        txtSun400MaxLength.Text = aSunrail400.Sunrail400MaxLengthFeet.ToString() + " " + aSunrail400.Sunrail400MaxLengthFeetUnits + " "
                                                  + aSunrail400.Sunrail400MaxLengthInches.ToString() + " " + aSunrail400.Sunrail400MaxLengthInchesUnits;

                        txtUsdPrice.Text = aSunrail400.Sunrail400UsdPrice.ToString("N2");
                        txtCadPrice.Text = aSunrail400.Sunrail400CadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region VinylRoll
                    case "tblVinylRoll":
                    {
                        pnlVinylRoll.CssClass    = "dimensionsTableDisplay";
                        rowLegend.CssClass       = "removeElement";
                        rowDescription.CssClass  = "removeElement";
                        rowComposition.CssClass  = "removeElement";
                        rowStandard.CssClass     = "removeElement";
                        rowPackQuantity.CssClass = "removeElement";

                        rowVinylRollLength.CssClass = "removeElement";

                        VinylRoll aVinylRoll = new VinylRoll();

                        //call select all function to populate object
                        aVinylRoll.Populate(aVinylRoll.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text        = aVinylRoll.VinylRollName;
                        txtPartNum.Text         = aVinylRoll.PartNumber;
                        txtColor.Text           = aVinylRoll.VinylRollColor;
                        txtVinylRollWeight.Text = aVinylRoll.VinylRollWeight.ToString() + " " + aVinylRoll.VinylRollWeightUnits;
                        txtVinylRollWidth.Text  = aVinylRoll.VinylRollWidth.ToString() + " " + aVinylRoll.VinylRollWidthUnits;


                        txtUsdPrice.Text = aVinylRoll.UsdPrice.ToString("N2");
                        txtCadPrice.Text = aVinylRoll.CadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region WallExtrusions
                    case "tblWallExtrusions":
                    {
                        pnlWallExtrusions.CssClass = "dimensionsTableDisplay";
                        rowLegend.CssClass         = "removeElement";
                        rowComposition.CssClass    = "removeElement";
                        rowStandard.CssClass       = "removeElement";
                        rowPackQuantity.CssClass   = "removeElement";

                        WallExtrusions aWallExtrusion = new WallExtrusions();

                        //call select all function to populate object
                        aWallExtrusion.Populate(aWallExtrusion.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text         = aWallExtrusion.WallExtrusionName;
                        txtPartDesc.Text         = aWallExtrusion.WallExtrusionDescription;
                        txtPartNum.Text          = aWallExtrusion.PartNumber;
                        txtColor.Text            = aWallExtrusion.WallExtrusionColor;
                        txtWallExtMaxLength.Text = aWallExtrusion.WallExtrusionMaxLength.ToString() + " " + aWallExtrusion.LengthUnits;

                        txtUsdPrice.Text = aWallExtrusion.UsdPrice.ToString("N2");
                        txtCadPrice.Text = aWallExtrusion.CadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region WallPanels
                    case "tblWallPanels":
                    {
                        pnlWallPanel.CssClass    = "dimensionsTableDisplay";
                        rowLegend.CssClass       = "removeElement";
                        rowPackQuantity.CssClass = "removeElement";

                        WallPanels aWallPanel = new WallPanels();

                        //call select all function to populate object
                        aWallPanel.Populate(aWallPanel.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartName.Text         = aWallPanel.WallPanelName;
                        txtPartDesc.Text         = aWallPanel.WallPanelDescription;
                        txtComposition.Text      = aWallPanel.WallPanelComposition;
                        txtStandard.Text         = aWallPanel.WallPanelStandard;
                        txtPartNum.Text          = aWallPanel.WallPanelNumber;
                        txtColor.Text            = aWallPanel.WallPanelColor;
                        txtWallPnlSize.Text      = aWallPanel.WallPanelSize.ToString() + " " + aWallPanel.SizeUnits;
                        txtWallPnlMaxWidth.Text  = aWallPanel.WallPanelMaxWidth.ToString() + " " + aWallPanel.WidthUnits;
                        txtWallPnlMaxLength.Text = aWallPanel.WallPanelMaxLength.ToString() + " " + aWallPanel.LengthUnits;


                        txtUsdPrice.Text = aWallPanel.UsdPrice.ToString("N2");
                        txtCadPrice.Text = aWallPanel.CadPrice.ToString("N2");

                        break;
                    }

                        #endregion
                        #region RoofExtrusions
                    case "tblRoofExtrusions":
                    {
                        rowLegend.CssClass         = "removeElement";
                        rowComposition.CssClass    = "removeElement";
                        rowStandard.CssClass       = "removeElement";
                        rowPackQuantity.CssClass   = "removeElement";
                        pnlRoofExtrusions.CssClass = "dimensionsTableDisplay";

                        RoofExtrusion aRoofExtrusion = new RoofExtrusion();

                        //call select all function to populate object
                        aRoofExtrusion.Populate(aRoofExtrusion.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                        txtPartNum.Text     = aRoofExtrusion.ExtrusionNumber;
                        txtPartName.Text    = aRoofExtrusion.ExtrusionName;
                        txtPartDesc.Text    = aRoofExtrusion.ExtrusionDescription;
                        txtColor.Text       = aRoofExtrusion.ExtrusionColor;
                        txtRoofExtSize.Text = aRoofExtrusion.ExtrusionSize.ToString() + " " + aRoofExtrusion.SizeUnits;

                        if (aRoofExtrusion.AngleA != 0)
                        {
                            txtRoofExtAngleA.Text = aRoofExtrusion.AngleA.ToString() + " " + aRoofExtrusion.AngleAUnits;
                        }
                        else
                        {
                            rowRoofExtAngleA.CssClass = "removeElement";
                        }

                        if (aRoofExtrusion.AngleB != 0)
                        {
                            txtRoofExtAngleB.Text = aRoofExtrusion.AngleB.ToString() + " " + aRoofExtrusion.AngleBUnits;
                        }
                        else
                        {
                            rowRoofExtAngleB.CssClass = "removeElement";
                        }

                        if (aRoofExtrusion.AngleC != 0)
                        {
                            txtRoofExtAngleC.Text = aRoofExtrusion.AngleC.ToString() + " " + aRoofExtrusion.AngleCUnits;
                        }
                        else
                        {
                            rowRoofExtAngleC.CssClass = "removeElement";
                        }

                        txtRoofExtMaxLength.Text = aRoofExtrusion.ExtrusionMaxLength.ToString() + " " + aRoofExtrusion.MaxLengthUnits;

                        txtUsdPrice.Text = aRoofExtrusion.UsdPrice.ToString("N2");
                        txtCadPrice.Text = aRoofExtrusion.CadPrice.ToString("N2");

                        break;
                    }
                        #endregion
                    }
                }
            }

            /*
             * if (Session["picChanged"] != null)
             * {
             *  imgPart.ImageUrl = "Images/catalogue/temp.jpg";
             *  Session.Remove("picChanged");
             * }
             */
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) //only on first load
            {
                //set default values to declared empty variables
                Session.Add("categoryIndex", 0);
                radIncreaseDecrease.SelectedIndex = 0;
                radPercentDollar.SelectedIndex = 0;
                totalElements = 0;
                lblHeaderPriceAdjust.Text = "Price Increase by %";

                //set up a dataview object to hold table names for the first drop down
                System.Data.DataView tableList = new System.Data.DataView();

                //select table names
                datSelectDataSource.SelectCommand = "SELECT name FROM sys.tables WHERE name != 'tblColor' AND name != 'tblSchematicParts' AND name != 'tblParts' "
                                                                        + " AND name != 'tblLengthUnits'  AND name != 'tblAudits' AND name != 'tblSalesOrders' AND name != 'tblSalesOrderItems' "
                                                                        + " AND SUBSTRING(name,1,3) = 'tbl' "
                                                                        + "ORDER BY name ASC"; tableList = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                //variable to determine amount of rows in the dataview object
                int rowCount = tableList.Count;

                ddlCategory.Items.Add("All");
                //populate first drop down
                for (int i = 0; i < rowCount; i++)
                {
                    string textString = tableList[i][0].ToString();
                    string newString = textString.Substring(3);
                    string outputString = "";
                    foreach (char character in newString)
                    {
                        if (char.IsUpper(character))
                        {
                            outputString += " " + character;
                        }
                        else if (character.ToString() == "1" || character.ToString() == "3" || character.ToString() == "4")
                        {
                            outputString += " " + character;
                        }
                        else
                        {
                            outputString += character;
                        }
                    }

                    ddlCategory.Items.Add(outputString.Trim());
                }

                //select category dropdown default value
                ddlCategory.SelectedIndex = (int)Session["categoryIndex"];
            }

                #region populateViews

            //Dataviews for each table
            System.Data.DataView tblAccessories = new System.Data.DataView();
            System.Data.DataView tblDecorativeColumn = new System.Data.DataView();
            System.Data.DataView tblDoorFrameExtrusion = new System.Data.DataView();
            System.Data.DataView tblInsulatedFloors = new System.Data.DataView();
            System.Data.DataView tblRoofExtrusions = new System.Data.DataView();
            System.Data.DataView tblRoofPanels = new System.Data.DataView();
            System.Data.DataView tblScreenRoll = new System.Data.DataView();
            System.Data.DataView tblSuncrylicRoof = new System.Data.DataView();
            System.Data.DataView tblSunrail1000 = new System.Data.DataView();
            System.Data.DataView tblSunrail300 = new System.Data.DataView();
            System.Data.DataView tblSunrail300Accessories = new System.Data.DataView();
            System.Data.DataView tblSunrail400 = new System.Data.DataView();
            System.Data.DataView tblVinylRoll = new System.Data.DataView();
            System.Data.DataView tblWallExtrusions = new System.Data.DataView();
            System.Data.DataView tblWallPanels = new System.Data.DataView();

            //If all, or specific table name (will display only this table)
            if (ddlCategory.SelectedValue == "Accessories" || ddlCategory.SelectedValue == "All")
            {
                datSelectDataSource.SelectCommand = "SELECT * FROM tblAccessories"; //select all data from table
                tblAccessories = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty); //put data into the data view for later
                totalElements += tblAccessories.Count;//increase total counter
                tableStarts[tableCounter] = 0; //starts at 0 since first table
                tableNames[tableCounter] = "tblAccessories"; //set the table name in this array
                tableCounter++; //and increase amount of tables populated by one
            }

            if (ddlCategory.SelectedValue == "Decorative Column" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblDecorativeColumn";
                tblDecorativeColumn = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblDecorativeColumn.Count;
                tableNames[tableCounter] = "tblDecorativeColumn";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Door Frame Extrusion" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblDoorFrameExtrusion";
                tblDoorFrameExtrusion = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblDoorFrameExtrusion.Count;
                tableNames[tableCounter] = "tblDoorFrameExtrusion";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Insulated Floors" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblInsulatedFloors";
                tblInsulatedFloors = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblInsulatedFloors.Count;
                tableNames[tableCounter] = "tblInsulatedFloors";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Roof Extrusions" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblRoofExtrusions";
                tblRoofExtrusions = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblRoofExtrusions.Count;
                tableNames[tableCounter] = "tblRoofExtrusions";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Roof Panels" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblRoofPanels";
                tblRoofPanels = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblRoofPanels.Count;
                tableNames[tableCounter] = "tblRoofPanels";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Screen Roll" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblScreenRoll";
                tblScreenRoll = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblScreenRoll.Count;
                tableNames[tableCounter] = "tblScreenRoll";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Suncrylic Roof" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblSuncrylicRoof";
                tblSuncrylicRoof = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblSuncrylicRoof.Count;
                tableNames[tableCounter] = "tblSuncrylicRoof";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Sunrail 1000" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblSunrail1000";
                tblSunrail1000 = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblSunrail1000.Count;
                tableNames[tableCounter] = "tblSunrail1000";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Sunrail 300" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblSunrail300";
                tblSunrail300 = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblSunrail300.Count;
                //          CHANGETHISCODE, need to uncomment upon Sunrail300 fix
                 tableNames[tableCounter] = "tblSunrail300";
                 tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Sunrail 300 Accessories" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblSunrail300Accessories";
                tblSunrail300Accessories = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblSunrail300Accessories.Count;
                tableNames[tableCounter] = "tblSunrail300Accessories";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Sunrail 400" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblSunrail400";
                tblSunrail400 = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblSunrail400.Count;
                tableNames[tableCounter] = "tblSunrail400";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Vinyl Roll" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblVinylRoll";
                tblVinylRoll = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblVinylRoll.Count;
                tableNames[tableCounter] = "tblVinylRoll";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Wall Extrusions" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblWallExtrusions";
                tblWallExtrusions = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblWallExtrusions.Count;
                tableNames[tableCounter] = "tblWallExtrusions";
                tableCounter++;
            }

            if (ddlCategory.SelectedValue == "Wall Panels" || ddlCategory.SelectedValue == "All")
            {
                tableStarts[tableCounter] = totalElements;  //will start at the current # of elements
                datSelectDataSource.SelectCommand = "SELECT * FROM tblWallPanels";
                tblWallPanels = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                totalElements += tblWallPanels.Count;
                tableNames[tableCounter] = "tblWallPanels";
                tableCounter++;
            }
                #endregion

                #region declareArrays
                //generate array based on total # of elements calculated
                checkboxArray = new CheckBox[totalElements];
                partNumArray = new Label[totalElements];
                partNameArray = new Label[totalElements];
                currentUSArray = new Label[totalElements];
                currentCanArray = new Label[totalElements];
                priceUSArray = new TextBox[totalElements];
                priceCanArray = new TextBox[totalElements];
                previewUSArray = new TextBox[totalElements];
                previewCanArray = new TextBox[totalElements];
                lastCalculatedUS = new string[totalElements];
                lastCalculatedCan = new string[totalElements];
                lastAdjustedUS = new string[totalElements];
                lastAdjustedCan = new string[totalElements];

                Session.Add("totalElements", totalElements);
                #endregion

                #region populateArrays
                //Need a class instantiated per table so call populate functions
                Accessories tempAccessory = new Accessories();
                DecorativeColumn tempDecorativeColumn = new DecorativeColumn();
                DoorFrameExtrusion tempDoorFrameExtrusion = new DoorFrameExtrusion();
                InsulatedFloors tempInsulatedFloors = new InsulatedFloors();
                RoofExtrusion tempRoofExtrusions = new RoofExtrusion();
                RoofPanels tempRoofPanels = new RoofPanels();
                ScreenRoll tempScreenRoll = new ScreenRoll();
                SuncrylicRoof tempSuncrylicRoof = new SuncrylicRoof();
                Sunrail1000 tempSunrail1000 = new Sunrail1000();
                Sunrail300 tempSunrail300 = new Sunrail300();
                Sunrail300Accessories tempSunrail300Accessories = new Sunrail300Accessories();
                Sunrail400 tempSunrail400 = new Sunrail400();
                VinylRoll tempVinylRoll = new VinylRoll();
                WallExtrusions tempWallExtrusions = new WallExtrusions();
                WallPanels tempWallPanels = new WallPanels();

                //a temp data view for use with populate function
                System.Data.DataView tempDataView = new System.Data.DataView();
                int elementCounter = 0; //for use with keeping track of where we are in totalElements, while not resetting to 0 for each table
                int pastTablesTotal = 0; //used to make sure we access element 0 of at the start of each table, not the counter's value

                if (ddlCategory.SelectedValue == "Accessories" || ddlCategory.SelectedValue == "All")
                {
                    #region Accessories
                    for (int i = elementCounter; i < tblAccessories.Count; i++)
                    {
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblAccessories WHERE accID=" + i; //select statement from database
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty); //results from select command are placed in temp data view
                        tempAccessory.Populate(tempAccessory.SelectAll(datDisplayDataSource, "tblAccessories", tblAccessories[i][3].ToString())); //temp dataview calls populate from the class

                        checkboxArray[i] = new CheckBox(); //add a control for this record
                        checkboxArray[i].ID = "tblAccessoriesCheckBox" + i.ToString(); //give it an ID

                        partNumArray[i] = new Label();//add a control for this record
                        partNumArray[i].ID = "tblAccessoriesPartNumLabel" + i.ToString();//give it an ID
                        partNumArray[i].Text = tempAccessory.AccessoryNumber; //set it's default value based on data retrieved from class population

                        partNameArray[i] = new Label();//add a control for this record
                        partNameArray[i].ID = "tblAccessoriesPartNameLabel" + i.ToString();//give it an ID
                        partNameArray[i].Text = tempAccessory.AccessoryName; //set it's default value based on data retrieved from class population

                        currentUSArray[i] = new Label();//add a control for this record
                        currentUSArray[i].ID = "tblAccessoriesCurrentUSLabel" + i.ToString();//give it an ID
                        currentUSArray[i].Text = tempAccessory.AccessoryUsdPrice.ToString("N2"); //set it's default value based on data retrieved from class population

                        currentCanArray[i] = new Label();//add a control for this record
                        currentCanArray[i].ID = "tblAccessoriesCurrentCanLabel" + i.ToString();//give it an ID
                        currentCanArray[i].Text = tempAccessory.AccessoryCadPrice.ToString("N2"); //set it's default value based on data retrieved from class population

                        priceUSArray[i] = new TextBox();//add a control for this record
                        priceUSArray[i].ID = "tblAccessoriesPriceUSTextBox" + i.ToString();//give it an ID
                        priceUSArray[i].CssClass = "txtInputField"; //set CSS and height/width
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();//add a control for this record
                        priceCanArray[i].ID = "tblAccessoriesPriceCanTextBox" + i.ToString();//give it an ID
                        priceCanArray[i].CssClass = "txtInputField";//set CSS and height/width
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();//add a control for this record
                        previewUSArray[i].ID = "tblAccessoriesPreviewUSLabel" + i.ToString();//give it an ID
                        previewUSArray[i].CssClass = "txtInputField";//set CSS and height/width
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblAccessoriesPreviewCanLabel" + i.ToString();//give it an ID
                        previewCanArray[i].CssClass = "txtInputField";//set CSS and height/width
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblAccessories.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Decorative Column" || ddlCategory.SelectedValue == "All")
                {
                    #region DecorativeColumn
                    for (int i = elementCounter; i < (tblDecorativeColumn.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblDecorativeColumn WHERE columnID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempDecorativeColumn.Populate(tempDecorativeColumn.SelectAll(datDisplayDataSource, "tblDecorativeColumn", tblDecorativeColumn[i - pastTablesTotal][3].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblDecorativeColumnCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblDecorativeColumnPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempDecorativeColumn.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblDecorativeColumnPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempDecorativeColumn.ColumnName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblDecorativeColumnCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempDecorativeColumn.ColumnUsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblDecorativeColumnCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempDecorativeColumn.ColumnCadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblDecorativeColumnPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblDecorativeColumnPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblDecorativeColumnPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblDecorativeColumnPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblDecorativeColumn.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Door Frame Extrusion" || ddlCategory.SelectedValue == "All")
                {
                    #region DoorFrameExtrusion
                    for (int i = elementCounter; i < (tblDoorFrameExtrusion.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblDoorFrameExtrusion WHERE dfeID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempDoorFrameExtrusion.Populate(tempDoorFrameExtrusion.SelectAll(datDisplayDataSource, "tblDoorFrameExtrusion", tblDoorFrameExtrusion[i - pastTablesTotal][3].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblDoorFrameExtrusionCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblDoorFrameExtrusionPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempDoorFrameExtrusion.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblDoorFrameExtrusionPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempDoorFrameExtrusion.DfeName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblDoorFrameExtrusionCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempDoorFrameExtrusion.UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblDoorFrameExtrusionCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempDoorFrameExtrusion.CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblDoorFrameExtrusionPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblDoorFrameExtrusionPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblDoorFrameExtrusionPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblDoorFrameExtrusionPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblDoorFrameExtrusion.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Insulated Floors" || ddlCategory.SelectedValue == "All")
                {
                    #region InsulatedFloors
                    for (int i = elementCounter; i < (tblInsulatedFloors.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblInsulatedFloors WHERE insulatedFloorID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempInsulatedFloors.Populate(tempInsulatedFloors.SelectAll(datDisplayDataSource, "tblInsulatedFloors", tblInsulatedFloors[i - pastTablesTotal][4].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblInsulatedFloorsCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblInsulatedFloorsPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempInsulatedFloors.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblInsulatedFloorsPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempInsulatedFloors.InsulatedFloorName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblInsulatedFloorsCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempInsulatedFloors.InsulatedFloorUsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblInsulatedFloorsCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempInsulatedFloors.InsulatedFloorCadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblInsulatedFloorsPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblInsulatedFloorsPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblInsulatedFloorsPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblInsulatedFloorsPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblInsulatedFloors.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Roof Extrusions" || ddlCategory.SelectedValue == "All")
                {
                    #region RoofExtrusions
                    for (int i = elementCounter; i < (tblRoofExtrusions.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblRoofExtrusions WHERE extrusionID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempRoofExtrusions.Populate(tempRoofExtrusions.SelectAll(datDisplayDataSource, "tblRoofExtrusions", tblRoofExtrusions[i - pastTablesTotal][3].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblRoofExtrusionsCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblRoofExtrusionsPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempRoofExtrusions.ExtrusionNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblRoofExtrusionsPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempRoofExtrusions.ExtrusionName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblRoofExtrusionsCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempRoofExtrusions.UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblRoofExtrusionsCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempRoofExtrusions.CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblRoofExtrusionsPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblRoofExtrusionsPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblRoofExtrusionsPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblRoofExtrusionsPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblRoofExtrusions.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Roof Panels" || ddlCategory.SelectedValue == "All")
                {
                    #region RoofPanels
                    for (int i = elementCounter; i < (tblRoofPanels.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblRoofPanels WHERE panelId=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempRoofPanels.Populate(tempRoofPanels.SelectAll(datDisplayDataSource, "tblRoofPanels", tblRoofPanels[i - pastTablesTotal][6].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblRoofPanelsCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblRoofPanelsPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempRoofPanels.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblRoofPanelsPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempRoofPanels.PanelName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblRoofPanelsCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempRoofPanels.UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblRoofPanelsCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempRoofPanels.CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblRoofPanelsPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblRoofPanelsPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblRoofPanelsPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblRoofPanelsPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblRoofPanels.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Screen Roll" || ddlCategory.SelectedValue == "All")
                {
                    #region ScreenRoll
                    for (int i = elementCounter; i < (tblScreenRoll.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblScreenRoll WHERE rollID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempScreenRoll.Populate(tempScreenRoll.SelectAll(datDisplayDataSource, "tblScreenRoll", tblScreenRoll[i - pastTablesTotal][2].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblScreenRollCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblScreenRollPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempScreenRoll.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblScreenRollPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempScreenRoll.ScreenRollName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblScreenRollCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempScreenRoll.UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblScreenRollCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempScreenRoll.CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblScreenRollPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblScreenRollPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblScreenRollPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblScreenRollPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblScreenRoll.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Suncrylic Roof" || ddlCategory.SelectedValue == "All")
                {
                    #region SuncrylicRoof
                    for (int i = elementCounter; i < (tblSuncrylicRoof.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblSuncrylicRoof WHERE suncrylicRoofID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempSuncrylicRoof.Populate(tempSuncrylicRoof.SelectAll(datDisplayDataSource, "tblSuncrylicRoof", tblSuncrylicRoof[i - pastTablesTotal][3].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblSuncrylicRoofCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblSuncrylicRoofPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempSuncrylicRoof.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblSuncrylicRoofPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempSuncrylicRoof.SuncrylicName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblSuncrylicRoofCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempSuncrylicRoof.UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblSuncrylicRoofCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempSuncrylicRoof.CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblSuncrylicRoofPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblSuncrylicRoofPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblSuncrylicRoofPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblSuncrylicRoofPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblSuncrylicRoof.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Sunrail 1000" || ddlCategory.SelectedValue == "All")
                {
                    #region Sunrail1000
                    for (int i = elementCounter; i < (tblSunrail1000.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblSunrail1000 WHERE sr1000ID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempSunrail1000.Populate(tempSunrail1000.SelectAll(datDisplayDataSource, "tblSunrail1000", tblSunrail1000[i - pastTablesTotal][3].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblSunrail1000CheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblSunrail1000PartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempSunrail1000.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblSunrail1000PartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempSunrail1000.Sunrail1000Name;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblSunrail1000CurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempSunrail1000.Sunrail1000UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblSunrail1000CurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempSunrail1000.Sunrail1000CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblSunrail1000PriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblSunrail1000PriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblSunrail1000PreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblSunrail1000PreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblSunrail1000.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Sunrail 300" || ddlCategory.SelectedValue == "All")
                {
                    #region Sunrail300

                    for (int i = elementCounter; i < (tblSunrail300.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblSunrail300 WHERE sr300ID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempSunrail300.Populate(tempSunrail300.SelectAll(datDisplayDataSource, "tblSunrail300", tblSunrail300[i - pastTablesTotal][3].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblSunrail300CheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblSunrail300PartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempSunrail300.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblSunrail300PartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempSunrail300.Sunrail300Name;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblSunrail300CurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempSunrail300.Sunrail300UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblSunrail300CurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempSunrail300.Sunrail300CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblSunrail300PriceUSTextBox" + i.ToString();
                            priceUSArray[i].CssClass = "txtInputField";
                            priceUSArray[i].Height = TEXTBOX_HEIGHT;
                            priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblSunrail300PriceCanTextBox" + i.ToString();
                            priceCanArray[i].CssClass = "txtInputField";
                            priceCanArray[i].Height = TEXTBOX_HEIGHT;
                            priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblSunrail300PreviewUSLabel" + i.ToString();
                            previewUSArray[i].CssClass = "txtInputField";
                            previewUSArray[i].Height = TEXTBOX_HEIGHT;
                            previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblSunrail300PreviewCanLabel" + i.ToString();
                            previewCanArray[i].CssClass = "txtInputField";
                            previewCanArray[i].Height = TEXTBOX_HEIGHT;
                            previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblSunrail300.Count;

                    #endregion
                }

                if (ddlCategory.SelectedValue == "Sunrail 300 Accessories" || ddlCategory.SelectedValue == "All")
                {
                    #region Sunrail300Accessories
                    for (int i = elementCounter; i < (tblSunrail300Accessories.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblSunrail300Accessories WHERE srAccID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempSunrail300Accessories.Populate(tempSunrail300Accessories.SelectAll(datDisplayDataSource, "tblSunrail300Accessories", tblSunrail300Accessories[i - pastTablesTotal][3].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblSunrail300AccessoriesCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblSunrail300AccessoriesPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempSunrail300Accessories.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblSunrail300AccessoriesPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempSunrail300Accessories.Sunrail300AccessoriesName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblSunrail300AccessoriesCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempSunrail300Accessories.Sunrail300AccessoriesUsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblSunrail300AccessoriesCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempSunrail300Accessories.Sunrail300AccessoriesCadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblSunrail300AccessoriesPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblSunrail300AccessoriesPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblSunrail300AccessoriesPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblSunrail300AccessoriesPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblSunrail300Accessories.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Sunrail 400" || ddlCategory.SelectedValue == "All")
                {
                    #region Sunrail400
                    for (int i = elementCounter; i < (tblSunrail400.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblSunrail400 WHERE sr400ID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempSunrail400.Populate(tempSunrail400.SelectAll(datDisplayDataSource, "tblSunrail400", tblSunrail400[i - pastTablesTotal][3].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblSunrail400CheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblSunrail400PartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempSunrail400.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblSunrail400PartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempSunrail400.Sunrail400Name;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblSunrail400CurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempSunrail400.Sunrail400UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblSunrail400CurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempSunrail400.Sunrail400CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblSunrail400PriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblSunrail400PriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblSunrail400PreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblSunrail400PreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblSunrail400.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Vinyl Roll" || ddlCategory.SelectedValue == "All")
                {
                    #region VinylRoll
                    for (int i = elementCounter; i < (tblVinylRoll.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblVinylRoll WHERE rollID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempVinylRoll.Populate(tempVinylRoll.SelectAll(datDisplayDataSource, "tblVinylRoll", tblVinylRoll[i - pastTablesTotal][2].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblVinylRollCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblVinylRollPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempVinylRoll.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblVinylRollPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempVinylRoll.VinylRollName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblVinylRollCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempVinylRoll.UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblVinylRollCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempVinylRoll.CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblVinylRollPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblVinylRollPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblVinylRollPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblVinylRollPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblVinylRoll.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Wall Extrusions" || ddlCategory.SelectedValue == "All")
                {
                    #region WallExtrusions
                    for (int i = elementCounter; i < (tblWallExtrusions.Count + pastTablesTotal); i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblWallExtrusions WHERE wallExtrusionID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempWallExtrusions.Populate(tempWallExtrusions.SelectAll(datDisplayDataSource, "tblWallExtrusions", tblWallExtrusions[i - pastTablesTotal][3].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblWallExtrusionsCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblWallExtrusionsPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempWallExtrusions.PartNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblWallExtrusionsPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempWallExtrusions.WallExtrusionName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblWallExtrusionsCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempWallExtrusions.UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblVinylRollCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempWallExtrusions.CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblWallExtrusionsPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblWallExtrusionsPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblWallExtrusionsPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblWallExtrusionsPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblWallExtrusions.Count;
                    #endregion
                }

                if (ddlCategory.SelectedValue == "Wall Panels" || ddlCategory.SelectedValue == "All")
                {
                    #region WallPanels
                    //
                    //
                    //
                    // CHANGETHISCODE - hardcoded for sunrail300 fixing
                    //
                    //totalElements = 440;
                    //
                    //
                    //
                    //
                    //
                    for (int i = elementCounter; i < totalElements; i++) //adding elementCounter so that, if it starts above 0, will just do the .count value
                    {                                                                                    //past tables total is there so that the ending condition is in the proper # away from the start
                        datSelectDataSource.SelectCommand = "SELECT * FROM tblWallPanels WHERE wallPanelID=" + (i - pastTablesTotal);
                        tempDataView = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);
                        tempWallPanels.Populate(tempWallPanels.SelectAll(datDisplayDataSource, "tblWallPanels", tblWallPanels[i - pastTablesTotal][6].ToString()));

                        checkboxArray[i] = new CheckBox();
                        checkboxArray[i].ID = "tblWallPanelsCheckBox" + i.ToString();

                        partNumArray[i] = new Label();
                        partNumArray[i].ID = "tblWallPanelsPartNumLabel" + i.ToString();
                        partNumArray[i].Text = tempWallPanels.WallPanelNumber;

                        partNameArray[i] = new Label();
                        partNameArray[i].ID = "tblWallPanelsPartNameLabel" + i.ToString();
                        partNameArray[i].Text = tempWallPanels.WallPanelName;

                        currentUSArray[i] = new Label();
                        currentUSArray[i].ID = "tblWallPanelsCurrentUSLabel" + i.ToString();
                        currentUSArray[i].Text = tempWallPanels.UsdPrice.ToString("N2");

                        currentCanArray[i] = new Label();
                        currentCanArray[i].ID = "tblWallPanelsCurrentCanLabel" + i.ToString();
                        currentCanArray[i].Text = tempWallPanels.CadPrice.ToString("N2");

                        priceUSArray[i] = new TextBox();
                        priceUSArray[i].ID = "tblWallPanelsPriceUSTextBox" + i.ToString();
                        priceUSArray[i].CssClass = "txtInputField";
                        priceUSArray[i].Height = TEXTBOX_HEIGHT;
                        priceUSArray[i].Width = TEXTBOX_WIDTH;

                        priceCanArray[i] = new TextBox();
                        priceCanArray[i].ID = "tblWallPanelsPriceCanTextBox" + i.ToString();
                        priceCanArray[i].CssClass = "txtInputField";
                        priceCanArray[i].Height = TEXTBOX_HEIGHT;
                        priceCanArray[i].Width = TEXTBOX_WIDTH;

                        previewUSArray[i] = new TextBox();
                        previewUSArray[i].ID = "tblWallPanelsPreviewUSLabel" + i.ToString();
                        previewUSArray[i].CssClass = "txtInputField";
                        previewUSArray[i].Height = TEXTBOX_HEIGHT;
                        previewUSArray[i].Width = TEXTBOX_WIDTH;

                        previewCanArray[i] = new TextBox();
                        previewCanArray[i].ID = "tblWallPanelsPreviewCanLabel" + i.ToString();
                        previewCanArray[i].CssClass = "txtInputField";
                        previewCanArray[i].Height = TEXTBOX_HEIGHT;
                        previewCanArray[i].Width = TEXTBOX_WIDTH;

                        elementCounter++;
                    }
                    pastTablesTotal += tblWallPanels.Count;
                    #endregion
                }
                #endregion

                #region generateRows

                //create table row and cells for adding record to the page
                TableRow tempRow;
                TableCell checkboxArrayCell;
                TableCell partNumArrayCell;
                TableCell partNameArrayCell;
                TableCell currentUSArrayCell;
                TableCell currentCanArrayCell;
                TableCell priceUSArrayCell;
                TableCell priceCanArrayCell;
                TableCell previewUSArrayCell;
                TableCell previewCanArrayCell;

                for (int i = 0; i < totalElements; i++) //hard coded 501 until Sunrail300 fixed CHANGETHISCODE
                {
                    tempRow = new TableRow(); //create a new row

                    //add each control by creating a new cell for the row, and adding to it.
                    checkboxArrayCell = new TableCell();
                    checkboxArrayCell.Controls.Add(checkboxArray[i]);
                    tempRow.Cells.Add(checkboxArrayCell);

                    partNumArrayCell = new TableCell();
                    partNumArrayCell.Controls.Add(partNumArray[i]);
                    tempRow.Cells.Add(partNumArrayCell);

                    partNameArrayCell = new TableCell();
                    partNameArrayCell.Controls.Add(partNameArray[i]);
                    tempRow.Cells.Add(partNameArrayCell);

                    currentUSArrayCell = new TableCell();
                    currentUSArrayCell.CssClass = "align-center";
                    currentUSArrayCell.Controls.Add(currentUSArray[i]);
                    tempRow.Cells.Add(currentUSArrayCell);

                    currentCanArrayCell = new TableCell();
                    currentCanArrayCell.CssClass = "align-center";
                    currentCanArrayCell.Controls.Add(currentCanArray[i]);
                    tempRow.Cells.Add(currentCanArrayCell);

                    priceUSArrayCell = new TableCell();
                    priceUSArrayCell.Controls.Add(priceUSArray[i]);
                    tempRow.CssClass = "tdTxtInputUS";
                    tempRow.Cells.Add(priceUSArrayCell);

                    priceCanArrayCell = new TableCell();
                    priceCanArrayCell.Controls.Add(priceCanArray[i]);
                    tempRow.CssClass = "tdTxtInputCAN";
                    tempRow.Cells.Add(priceCanArrayCell);

                    previewUSArrayCell = new TableCell();
                    previewUSArrayCell.Controls.Add(previewUSArray[i]);
                    tempRow.CssClass = "tdTxtInputUS";
                    tempRow.Cells.Add(previewUSArrayCell);

                    previewCanArrayCell = new TableCell();
                    previewCanArrayCell.Controls.Add(previewCanArray[i]);
                    tempRow.CssClass = "tdTxtInputCAN";
                    tempRow.Cells.Add(previewCanArrayCell);

                    tblPriceGrid.Controls.Add(tempRow);
                }
                #endregion

            for (int i = 0; i < totalElements; i++) //fill the 'last' arrays, which are used in checking for changes.  Blank for first time
            {
                lastAdjustedUS[i] = priceUSArray[i].Text;
                lastAdjustedCan[i] = priceCanArray[i].Text;
                lastCalculatedUS[i] = previewUSArray[i].Text;
                lastCalculatedCan[i] = previewCanArray[i].Text;
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Label firstLabel = (Label)Master.FindControl("lblUpdate");
            if (firstLabel != null)
            {
                firstLabel.Text = "VIEWING";
            }

            Label secondLabel = (Label)Master.FindControl("lblPartNumTitle");
            if (secondLabel != null)
            {
                secondLabel.Text = Session["partNumber"].ToString();
            }

            if (Session["updateSelected"] != null)
            {
                btnInsert.CssClass = "removeElement";
            }

            if (Session["user_type"].ToString() != "S")
            {
                btnUpdate.Visible = false;
                btnInsert.Visible = false;
            }

            //prevent backdoor
            if (Session["tableName"] == null)
            {
                Response.Redirect("ProductSelect.aspx");
            }
            else
            {
                //load dropdowns
                if (!Page.IsPostBack)
                {
                    Session.Add("UpdatePartList", "true");
                    //set up a dataview object to hold table names for the first drop down
                    System.Data.DataView tableList = new System.Data.DataView();

                    //select table names
                    datSelectDataSource.SelectCommand = "SELECT name FROM sys.tables WHERE name != 'tblColor' AND name != 'tblSchematicParts' AND name != 'tblParts' "
                                                        + " AND name != 'tblLengthUnits'  AND name != 'tblAudits' AND name != 'tblSalesOrders' AND name != 'tblSalesOrderItems' "
                                                        + " AND SUBSTRING(name,1,3) = 'tbl' "
                                                        + "ORDER BY name ASC";                    //assign the table names to the dataview object
                    tableList = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                    //variable to determine amount of rows in the dataview object
                    int rowCount = tableList.Count;

                    ddlCategory.Items.Add("");
                    //populate first drop down
                    for (int i = 0; i < rowCount; i++)
                    {
                        string textString = tableList[i][0].ToString();
                        string newString = textString.Substring(3);
                        string outputString = "";
                        foreach (char character in newString)
                        {
                            if (char.IsUpper(character))
                            {
                                outputString += " " + character;
                            }
                            else if (character.ToString() == "1" || character.ToString() == "3" || character.ToString() == "4")
                            {
                                outputString += " " + character;
                            }
                            else
                            {
                                outputString += character;
                            }
                        }

                        ddlCategory.Items.Add(outputString.Trim());
                    }

                    //select category dropdown default value
                    ddlCategory.SelectedIndex = (int)Session["categoryIndex"];

                    //load part list
                    if (ddlCategory.SelectedValue != "")
                    {
                        //get table name selected
                        string tableName = "tbl" + ddlCategory.SelectedValue.Replace(" ", "");

                        //set up a dataview object to hold part numbers for the second drop down
                        System.Data.DataView partsList = new System.Data.DataView();

                        if (tableName != "tblSchematics")
                        {
                            //select part numbers
                            datSelectDataSource.SelectCommand = "SELECT partNumber, partName FROM " + tableName + " ORDER BY partNumber ASC";
                        }
                        else
                        {
                            datSelectDataSource.SelectCommand = "SELECT schematicNumber, partName FROM " + tableName + " ORDER BY schematicNumber ASC";
                        }
                        //assign the table names to the dataview object
                        partsList = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                        //clear second drop down
                        ddlPart.Items.Clear();

                        //Insert empty string to first row of second drop down
                        ddlPart.Items.Add("");

                        rowCount = partsList.Count;
                        //populate second drop down
                        for (int i = 0; i < rowCount; i++)
                        {

                            ddlPart.Items.Add(partsList[i][0].ToString() + " (" + partsList[i][1].ToString() + ")");
                        }

                        Session.Add("displayChanged", "true");
                    }
                }

                //only run if the display has changed, to allow display postback changes
                if (Session["displayChanged"] != null)
                {
                    //we're running this, so the display has been updated, and is not set for change
                    Session.Remove("displayChanged");
                    //select part dropdown default value
                    ddlPart.SelectedIndex = (int)Session["partIndex"];

                    //show navigation arrows
                    imgPrevArrow.CssClass = "prevArrow";
                    imgNextArrow.CssClass = "nextArrow";

                    if (ddlPart.SelectedIndex == (ddlPart.Items.Count-1))
                    {
                        //if last item, don't show 'next' arrow
                        imgNextArrow.CssClass = "removeElement";
                    }
                    else if (ddlPart.SelectedIndex == 1)
                    {
                        //if first item, don't show 'prev' arrow
                        imgPrevArrow.CssClass = "removeElement";
                    }

                    //load appropriate image
                    imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                    imgPartLink.NavigateUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                    //remove all non-product panels, whichw ill be shown on switch case below
                    pnlAccessories.CssClass = "removeElement";
                    pnlDecorativeColumn.CssClass = "removeElement";
                    pnlDoorFrameExtrusions.CssClass = "removeElement";
                    pnlInsulatedFloors.CssClass = "removeElement";
                    pnlRoofExtrusions.CssClass = "removeElement";
                    pnlRoofPanels.CssClass = "removeElement";
                    pnlScreenRoll.CssClass = "removeElement";
                    pnlSuncrylicRoof.CssClass = "removeElement";
                    pnlSunrail1000.CssClass = "removeElement";
                    pnlSunrail300.CssClass = "removeElement";
                    pnlSunrail400.CssClass = "removeElement";
                    pnlVinylRoll.CssClass = "removeElement";
                    pnlWallExtrusions.CssClass = "removeElement";
                    pnlWallPanel.CssClass = "removeElement";
                    pnlSchematicsDisplay.CssClass = "removeElement";

                    //Uncomment for checks with login
                    /*
                    if (Session["loggedCountry"] == null)
                    {
                        pnlPriceDisplay.CssClass = "removeElement";
                    }
                    else if (Session["loggedCountry"] == "US")
                    {
                        rowCadPrice.CssClass = "removeElement";
                    }
                    else
                    {
                        rowUsdPrice.CssClass = "removeElement";
                    }
                    */

                    //if value was changed on display page, we

                    string tableName = Session["tableName"].ToString();

                    switch (tableName)
                    {
                        #region Accessories
                        case "tblAccessories":
                            {
                                pnlAccessories.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowComposition.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                lblPartName.Text = "Part Name:";
                                lblPartNum.Text = "Part Number:";

                                Accessories anAccessory = new Accessories();

                                //call select all function to populate object
                                anAccessory.Populate(anAccessory.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartNum.Text = anAccessory.AccessoryNumber;
                                txtPartName.Text = anAccessory.AccessoryName;
                                txtPartDesc.Text = anAccessory.AccessoryDescription;
                                txtColor.Text = anAccessory.AccessoryColor;
                                txtPackQuantity.Text = anAccessory.AccessoryPackQuantity.ToString();
                                txtAccessorySize.Text = anAccessory.AccessorySize.ToString() + " " + anAccessory.AccessorySizeUnits;
                                txtAccessoryWidth.Text = anAccessory.AccessoryWidth.ToString() + " " + anAccessory.AccessoryWidthUnits;
                                txtAccessoryLength.Text = anAccessory.AccessoryLength.ToString() + " " + anAccessory.AccessoryLengthUnits;

                                if (txtPackQuantity.Text == "0" || txtPackQuantity.Text == "")
                                {
                                    rowPackQuantity.CssClass = "removeElement";
                                }

                                if (anAccessory.AccessorySize == 0)//a space is added above, so check for one space, not blank
                                {
                                    rowAccessorySize.CssClass = "removeElement";
                                }

                                if (anAccessory.AccessoryLength == 0)
                                {
                                    rowAccessoryMaxLength.CssClass = "removeElement";
                                }

                                if (anAccessory.AccessoryWidth == 0)
                                {
                                    rowAccessoryMaxWidth.CssClass = "removeElement";
                                }

                                if (txtColor.Text == "")
                                {
                                    rowColor.CssClass = "removeElement";
                                }

                                txtUsdPrice.Text = anAccessory.AccessoryUsdPrice.ToString("N2");
                                txtCadPrice.Text = anAccessory.AccessoryCadPrice.ToString("N2");

                                break;
                            }
                        #endregion
                        #region DecorativeColumn
                        case "tblDecorativeColumn":
                            {
                                pnlDecorativeColumn.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowComposition.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";

                                DecorativeColumn aColumn = new DecorativeColumn();

                                //call select all function to populate object
                                aColumn.Populate(aColumn.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartName.Text = aColumn.ColumnName;
                                txtPartDesc.Text = aColumn.ColumnDescription;
                                txtPartNum.Text = aColumn.PartNumber;
                                txtColor.Text = aColumn.ColumnColor;
                                txtDecColLength.Text = aColumn.ColumnLength.ToString() + " " + aColumn.ColumnLengthUnits;

                                txtUsdPrice.Text = aColumn.ColumnUsdPrice.ToString("N2");
                                txtCadPrice.Text = aColumn.ColumnCadPrice.ToString("N2");

                                break;
                            }
                        #endregion
                        #region Door Frame Extrusion
                        case "tblDoorFrameExtrusion":
                            {
                                pnlDoorFrameExtrusions.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowComposition.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";

                                DoorFrameExtrusion aFrameExtrusion = new DoorFrameExtrusion();

                                //call select all function to populate object
                                aFrameExtrusion.Populate(aFrameExtrusion.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartName.Text = aFrameExtrusion.DfeName;
                                if (aFrameExtrusion.DfeDescription != "")
                                {
                                    txtPartDesc.Text = aFrameExtrusion.DfeDescription;
                                }
                                else
                                {
                                    rowDescription.CssClass = "removeElement";
                                }
                                txtPartNum.Text = aFrameExtrusion.PartNumber;
                                txtColor.Text = aFrameExtrusion.DfeColor;
                                txtDoorFrExtMaxLength.Text = aFrameExtrusion.DfeMaxLength.ToString() + " " + aFrameExtrusion.DfeMaxLengthUnits;

                                txtUsdPrice.Text = aFrameExtrusion.UsdPrice.ToString("N2");
                                txtCadPrice.Text = aFrameExtrusion.CadPrice.ToString("N2");

                                break;
                            }
                        #endregion
                        #region InsulatedFloors
                        case "tblInsulatedFloors":
                            {
                                pnlInsulatedFloors.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";
                                rowColor.CssClass = "removeElement";

                                InsulatedFloors aFloor = new InsulatedFloors();

                                //call select all function to populate object
                                aFloor.Populate(aFloor.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartName.Text = aFloor.InsulatedFloorName;
                                txtPartDesc.Text = aFloor.InsulatedFloorDescription;
                                txtPartNum.Text = aFloor.PartNumber;
                                txtInsFloorSize.Text = aFloor.InsulatedFloorSize.ToString() + " " + aFloor.InsulatedFloorSizeUnits;
                                txtInsFloorMaxWidth.Text = aFloor.InsulatedFloorMaxWidth.ToString() + " " + aFloor.InsulatedFloorMaxWidthUnits;
                                txtInsFloorMaxLength.Text = aFloor.InsulatedFloorMaxLength.ToString();

                                txtUsdPrice.Text = aFloor.InsulatedFloorUsdPrice.ToString("N2");
                                txtCadPrice.Text = aFloor.InsulatedFloorCadPrice.ToString("N2");

                                break;
                            }
                        #endregion
                        #region RoofPanels
                        case "tblRoofPanels":
                            {
                                pnlRoofPanels.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";

                                RoofPanels aRoofPanel = new RoofPanels();

                                //call select all function to populate object
                                aRoofPanel.Populate(aRoofPanel.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartName.Text = aRoofPanel.PanelName;
                                txtPartDesc.Text = aRoofPanel.PanelDescription;
                                txtPartNum.Text = aRoofPanel.PartNumber;
                                txtComposition.Text = aRoofPanel.PanelComposition;
                                txtStandard.Text = aRoofPanel.PanelStandard;

                                txtColor.Text = aRoofPanel.PanelColor;
                                txtRoofPnlSize.Text = aRoofPanel.PanelSize.ToString() + " " + aRoofPanel.PanelSizeUnits;
                                txtRoofPnlMaxWidth.Text = aRoofPanel.PanelMaxWidth.ToString() + " " + aRoofPanel.MaxWidthUnits;
                                txtRoofPnlMaxLength.Text = aRoofPanel.PanelMaxLength;

                                txtUsdPrice.Text = aRoofPanel.UsdPrice.ToString("N2");
                                txtCadPrice.Text = aRoofPanel.CadPrice.ToString("N2");

                                break;
                            }
                        #endregion
                        #region Schematics
                        case "tblSchematics":
                            {
                                pnlSchematicsDisplay.CssClass = "schematicsTableDisplay";
                                rowComposition.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";
                                rowColor.CssClass = "removeElement";
                                lblLegend.Text = "Legend:";
                                Schematics aSchematic = new Schematics();
                                Part aPart = new Part();

                                //call select all function to populate object
                                aSchematic.Populate(aSchematic.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartNum.Text = aSchematic.SchematicNumber;

                                if (Session["UpdatePartList"].ToString() == "true" || !Page.IsPostBack)
                                {
                                    UpdatePartsList();
                                    Session.Remove("UpdatePartList");
                                }

                                if (Session["part"] != null)
                                {
                                    aPart = (Part)Session["part"];
                                    txtSchemPartKey.Text = aPart.PartKeyNumber.ToString();
                                    txtSchemPartName.Text = aPart.PartName;
                                    txtSchemPartNum.Text = aPart.PartNumber;
                                }
                                else
                                {
                                    txtSchemPartKey.Text = "";
                                    txtSchemPartName.Text = "";
                                    txtSchemPartNum.Text = "";
                                }

                                lblPartName.Text = "Schematic Name:";
                                txtPartName.Text = aSchematic.SchematicName.ToString();
                                txtPartDesc.Text = aSchematic.SchematicDescription.ToString();
                                lblPartNum.Text = "Schematic Number:";
                                txtPartNum.Text = aSchematic.SchematicNumber.ToString();

                                if (txtPartDesc.Text == "")
                                {
                                    txtPartDesc.Text = "No Description";
                                }

                                txtUsdPrice.Text = aSchematic.SchematicUsdPrice.ToString("N2");
                                txtCadPrice.Text = aSchematic.SchematicCadPrice.ToString("N2");

                                break;
                            }
                        #endregion
                        #region Screen Roll
                        case "tblScreenRoll":
                            {
                                pnlScreenRoll.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowDescription.CssClass = "removeElement";
                                rowComposition.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";
                                rowColor.CssClass = "removeElement";

                                ScreenRoll aScreenRoll = new ScreenRoll();

                                //call select all function to populate object
                                aScreenRoll.Populate(aScreenRoll.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartName.Text = aScreenRoll.ScreenRollName;
                                txtPartNum.Text = aScreenRoll.PartNumber;
                                txtScreenRollWidth.Text = aScreenRoll.ScreenRollWidth + " " + aScreenRoll.ScreenRollWidthUnits;
                                txtScreenRollLength.Text = aScreenRoll.ScreenRollLength + " " + aScreenRoll.ScreenRollLengthUnits;

                                txtUsdPrice.Text = aScreenRoll.UsdPrice.ToString("N2");
                                txtCadPrice.Text = aScreenRoll.CadPrice.ToString("N2");

                                break;
                            }
                        #endregion
                        #region Suncrylic Roof
                        case "tblSuncrylicRoof":
                            {
                                pnlSuncrylicRoof.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowComposition.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";

                                SuncrylicRoof aSuncrylicRoof = new SuncrylicRoof();

                                //call select all function to populate object
                                aSuncrylicRoof.Populate(aSuncrylicRoof.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartName.Text = aSuncrylicRoof.SuncrylicName;
                                txtPartDesc.Text = aSuncrylicRoof.SuncrylicDescription;
                                txtPartNum.Text = aSuncrylicRoof.PartNumber;
                                txtColor.Text = aSuncrylicRoof.SuncrylicColor;
                                txtSunRoofMaxLength.Text = aSuncrylicRoof.SuncrylicMaxLength + " " + aSuncrylicRoof.SuncrylicLengthUnits;
                                txtSunRoofMaxWidthStr.Text = "Varies";

                                txtUsdPrice.Text = aSuncrylicRoof.UsdPrice.ToString("N2");
                                txtCadPrice.Text = aSuncrylicRoof.CadPrice.ToString("N2");

                                break;
                            }
                        #endregion

                        #region Sunrail1000
                        case "tblSunrail1000":
                        {
                            pnlSunrail1000.CssClass = "dimensionsTableDisplay";
                            rowLegend.CssClass = "removeElement";
                            rowComposition.CssClass = "removeElement";
                            rowStandard.CssClass = "removeElement";
                            rowPackQuantity.CssClass = "removeElement";

                            Sunrail1000 aSunrail = new Sunrail1000();

                            //call select all function to populate object
                            aSunrail.Populate(aSunrail.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                            txtPartName.Text = aSunrail.Sunrail1000Name;
                            txtPartDesc.Text = aSunrail.Sunrail1000Description;
                            txtPartNum.Text = aSunrail.PartNumber;
                            txtColor.Text = aSunrail.Sunrail1000Color;
                            txtSun1000MaxLength.Text = aSunrail.Sunrail1000MaxLengthFeet.ToString() + " " + aSunrail.Sunrail1000MaxLengthFeetUnits + " "
                                + aSunrail.Sunrail1000MaxLengthInches.ToString() + " " + aSunrail.Sunrail1000MaxLengthInchesUnits;

                            txtUsdPrice.Text = aSunrail.Sunrail1000UsdPrice.ToString("N2");
                            txtCadPrice.Text = aSunrail.Sunrail1000CadPrice.ToString("N2");

                            break;
                        }
                        #endregion
                    #region Sunrail300
                        case "tblSunrail300":
                        {
                            pnlSunrail300.CssClass = "dimensionsTableDisplay";
                            rowLegend.CssClass = "removeElement";
                            rowComposition.CssClass = "removeElement";
                            rowStandard.CssClass = "removeElement";
                            rowPackQuantity.CssClass = "removeElement";

                            Sunrail300 aSunrail300 = new Sunrail300();

                            //call select all function to populate object
                            aSunrail300.Populate(aSunrail300.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                            txtPartName.Text = aSunrail300.Sunrail300Name;
                            txtPartDesc.Text = aSunrail300.Sunrail300Description;
                            txtPartNum.Text = aSunrail300.PartNumber;
                            txtColor.Text = aSunrail300.Sunrail300Color;
                            txtSun300MaxLength.Text = aSunrail300.Sunrail300MaxLengthFeet.ToString() + " " + aSunrail300.Sunrail300MaxLengthFeetUnits + " "
                                                        + aSunrail300.Sunrail300MaxLengthInches.ToString() + " " + aSunrail300.Sunrail300MaxLengthInchesUnits;

                            txtUsdPrice.Text = aSunrail300.Sunrail300UsdPrice.ToString("N2");
                            txtCadPrice.Text = aSunrail300.Sunrail300CadPrice.ToString("N2");

                            break;
                        }
                    #endregion
                    #region Sunrail300Accessories
                    case "tblSunrail300Accessories":
                        {
                            rowLegend.CssClass = "removeElement";
                            rowComposition.CssClass = "removeElement";
                            rowStandard.CssClass = "removeElement";
                            rowPackQuantity.CssClass = "removeElement";

                            Sunrail300Accessories aSunrail300Accessory = new Sunrail300Accessories();

                            //call select all function to populate object
                            aSunrail300Accessory.Populate(aSunrail300Accessory.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                            txtPartName.Text = aSunrail300Accessory.Sunrail300AccessoriesName;
                            txtPartDesc.Text = aSunrail300Accessory.Sunrail300AccessoriesDescription;
                            txtPartNum.Text = aSunrail300Accessory.PartNumber;
                            txtColor.Text = aSunrail300Accessory.Sunrail300AccessoriesColor;

                            txtUsdPrice.Text = aSunrail300Accessory.Sunrail300AccessoriesUsdPrice.ToString("N2");
                            txtCadPrice.Text = aSunrail300Accessory.Sunrail300AccessoriesCadPrice.ToString("N2");

                            break;
                        }
                    #endregion
                    #region Sunrail400
                    case "tblSunrail400":
                        {
                            pnlSunrail400.CssClass = "dimensionsTableDisplay";
                            rowLegend.CssClass = "removeElement";
                            rowComposition.CssClass = "removeElement";
                            rowStandard.CssClass = "removeElement";
                            rowPackQuantity.CssClass = "removeElement";

                            Sunrail400 aSunrail400 = new Sunrail400();

                            //call select all function to populate object
                            aSunrail400.Populate(aSunrail400.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                            txtPartName.Text = aSunrail400.Sunrail400Name;
                            txtPartDesc.Text = aSunrail400.Sunrail400Description;
                            txtPartNum.Text = aSunrail400.PartNumber;
                            txtColor.Text = aSunrail400.Sunrail400Color;
                            txtSun400MaxLength.Text = aSunrail400.Sunrail400MaxLengthFeet.ToString() + " " + aSunrail400.Sunrail400MaxLengthFeetUnits + " "
                                                        + aSunrail400.Sunrail400MaxLengthInches.ToString() + " " + aSunrail400.Sunrail400MaxLengthInchesUnits;

                            txtUsdPrice.Text = aSunrail400.Sunrail400UsdPrice.ToString("N2");
                            txtCadPrice.Text = aSunrail400.Sunrail400CadPrice.ToString("N2");

                            break;
                        }
                    #endregion
                    #region VinylRoll
                    case "tblVinylRoll":
                            {
                                pnlVinylRoll.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowDescription.CssClass = "removeElement";
                                rowComposition.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";

                                rowVinylRollLength.CssClass = "removeElement";

                                VinylRoll aVinylRoll = new VinylRoll();

                                //call select all function to populate object
                                aVinylRoll.Populate(aVinylRoll.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartName.Text = aVinylRoll.VinylRollName;
                                txtPartNum.Text = aVinylRoll.PartNumber;
                                txtColor.Text = aVinylRoll.VinylRollColor;
                                txtVinylRollWeight.Text = aVinylRoll.VinylRollWeight.ToString() + " " + aVinylRoll.VinylRollWeightUnits;
                                txtVinylRollWidth.Text = aVinylRoll.VinylRollWidth.ToString() + " " + aVinylRoll.VinylRollWidthUnits;

                                txtUsdPrice.Text = aVinylRoll.UsdPrice.ToString("N2");
                                txtCadPrice.Text = aVinylRoll.CadPrice.ToString("N2");

                                break;
                            }
                    #endregion
                    #region WallExtrusions
                    case "tblWallExtrusions":
                            {
                                pnlWallExtrusions.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowComposition.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";

                                WallExtrusions aWallExtrusion = new WallExtrusions();

                                //call select all function to populate object
                                aWallExtrusion.Populate(aWallExtrusion.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartName.Text = aWallExtrusion.WallExtrusionName;
                                txtPartDesc.Text = aWallExtrusion.WallExtrusionDescription;
                                txtPartNum.Text = aWallExtrusion.PartNumber;
                                txtColor.Text = aWallExtrusion.WallExtrusionColor;
                                txtWallExtMaxLength.Text = aWallExtrusion.WallExtrusionMaxLength.ToString() + " " + aWallExtrusion.LengthUnits;

                                txtUsdPrice.Text = aWallExtrusion.UsdPrice.ToString("N2");
                                txtCadPrice.Text = aWallExtrusion.CadPrice.ToString("N2");

                                break;
                            }
                        #endregion
                    #region WallPanels
                        case "tblWallPanels":
                            {
                                pnlWallPanel.CssClass = "dimensionsTableDisplay";
                                rowLegend.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";

                                WallPanels aWallPanel = new WallPanels();

                                //call select all function to populate object
                                aWallPanel.Populate(aWallPanel.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartName.Text = aWallPanel.WallPanelName;
                                txtPartDesc.Text = aWallPanel.WallPanelDescription;
                                txtComposition.Text = aWallPanel.WallPanelComposition;
                                txtStandard.Text = aWallPanel.WallPanelStandard;
                                txtPartNum.Text = aWallPanel.WallPanelNumber;
                                txtColor.Text = aWallPanel.WallPanelColor;
                                txtWallPnlSize.Text = aWallPanel.WallPanelSize.ToString() + " " + aWallPanel.SizeUnits;
                                txtWallPnlMaxWidth.Text = aWallPanel.WallPanelMaxWidth.ToString() + " " + aWallPanel.WidthUnits;
                                txtWallPnlMaxLength.Text = aWallPanel.WallPanelMaxLength.ToString() + " " + aWallPanel.LengthUnits;

                                txtUsdPrice.Text = aWallPanel.UsdPrice.ToString("N2");
                                txtCadPrice.Text = aWallPanel.CadPrice.ToString("N2");

                                break;
                            }
                        #endregion
                    #region RoofExtrusions
                        case "tblRoofExtrusions":
                            {
                                rowLegend.CssClass = "removeElement";
                                rowComposition.CssClass = "removeElement";
                                rowStandard.CssClass = "removeElement";
                                rowPackQuantity.CssClass = "removeElement";
                                pnlRoofExtrusions.CssClass = "dimensionsTableDisplay";

                                RoofExtrusion aRoofExtrusion = new RoofExtrusion();

                                //call select all function to populate object
                                aRoofExtrusion.Populate(aRoofExtrusion.SelectAll(datDisplayDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                txtPartNum.Text = aRoofExtrusion.ExtrusionNumber;
                                txtPartName.Text = aRoofExtrusion.ExtrusionName;
                                txtPartDesc.Text = aRoofExtrusion.ExtrusionDescription;
                                txtColor.Text = aRoofExtrusion.ExtrusionColor;
                                txtRoofExtSize.Text = aRoofExtrusion.ExtrusionSize.ToString() + " " + aRoofExtrusion.SizeUnits;

                                if (aRoofExtrusion.AngleA != 0)
                                {
                                    txtRoofExtAngleA.Text = aRoofExtrusion.AngleA.ToString() + " " + aRoofExtrusion.AngleAUnits;
                                }
                                else
                                {
                                    rowRoofExtAngleA.CssClass = "removeElement";
                                }

                                if (aRoofExtrusion.AngleB != 0)
                                {
                                    txtRoofExtAngleB.Text = aRoofExtrusion.AngleB.ToString() + " " + aRoofExtrusion.AngleBUnits;
                                }
                                else
                                {
                                    rowRoofExtAngleB.CssClass = "removeElement";
                                }

                                if (aRoofExtrusion.AngleC != 0)
                                {
                                    txtRoofExtAngleC.Text = aRoofExtrusion.AngleC.ToString() + " " + aRoofExtrusion.AngleCUnits;
                                }
                                else
                                {
                                    rowRoofExtAngleC.CssClass = "removeElement";
                                }

                                txtRoofExtMaxLength.Text = aRoofExtrusion.ExtrusionMaxLength.ToString() + " " + aRoofExtrusion.MaxLengthUnits;

                                txtUsdPrice.Text = aRoofExtrusion.UsdPrice.ToString("N2");
                                txtCadPrice.Text = aRoofExtrusion.CadPrice.ToString("N2");

                                break;
                            }
                        #endregion

                    }
                }
            }
            /*
            if (Session["picChanged"] != null)
            {
                imgPart.ImageUrl = "Images/catalogue/temp.jpg";
                Session.Remove("picChanged");
            }
             */
        }
예제 #4
0
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            string errorMessage ="";

            if (Page.IsPostBack)
            {
                                    //get selected table from the session
                    string tableName = Session["tableName"].ToString();

                    //select case statement for each possible objects
                    switch (tableName)
                    {
                        #region RoofExtrusions

                        //when roof extrusion is selected
                        case "tblRoofExtrusions":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("roofExtrusion");

                                if (Page.IsValid == true)
                                {

                                    //create new object
                                    RoofExtrusion aRoofExtrusion = new RoofExtrusion();

                                    aRoofExtrusion.ExtrusionName = txtPartName.Text;
                                    aRoofExtrusion.ExtrusionNumber = txtPartNum.Text;
                                    aRoofExtrusion.ExtrusionDescription = txtPartDesc.Text;
                                    aRoofExtrusion.CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aRoofExtrusion.UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    aRoofExtrusion.AngleA = Convert.ToInt32(txtRoofExtAngleA.Text);
                                    aRoofExtrusion.AngleAUnits = "Inches";
                                    aRoofExtrusion.AngleB = Convert.ToInt32(txtRoofExtAngleB.Text);
                                    aRoofExtrusion.AngleBUnits = "Inches";
                                    aRoofExtrusion.AngleC = Convert.ToInt32(txtRoofExtAngleC.Text);
                                    aRoofExtrusion.AngleCUnits = "Inches";

                                    aRoofExtrusion.ExtrusionColor = ddlColors.SelectedValue;

                                    aRoofExtrusion.ExtrusionMaxLength = Convert.ToInt32(txtRoofExtMaxLength.Text);
                                    aRoofExtrusion.MaxLengthUnits = ddlRoofExtMaxLengtUnits.SelectedValue;
                                    aRoofExtrusion.ExtrusionSize = Convert.ToInt32(txtRoofExtSize.Text);
                                    aRoofExtrusion.SizeUnits = ddlRoofExtSizeUnits.SelectedValue;

                                    if (Part_Exists("tblRoofExtrusions", aRoofExtrusion.ExtrusionNumber) == true)
                                    {

                                    }
                                    else
                                    {
                                        //Insert
                                        aRoofExtrusion.Insert(datInsertDataSource, "tblRoofExtrusions");

                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 5;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aRoofExtrusion.ExtrusionNumber;
                                        //whatever happens here
                                    }
                                }

                                break;

                                //more cases here

                            }
                        #endregion
                        #region Accessory
                        case "tblAccessories":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("accessories");

                                if (Page.IsValid == true)
                                {

                                    TextBox tempTxt;
                                    Accessories anAccessory = new Accessories();

                                    Session.Add("Accessory", anAccessory);

                                    anAccessory.AccessoryName = txtPartName.Text;
                                    anAccessory.AccessoryNumber = txtPartNum.Text;
                                    anAccessory.AccessoryDescription = txtPartDesc.Text;
                                    anAccessory.AccessoryCadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    anAccessory.AccessoryUsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    //tempTxt = (TextBox)pnlColor.FindControl("txtColor");
                                    //anAccessory.AccessoryColor = tempTxt.Text;

                                    tempTxt = (TextBox)pnlAccessories.FindControl("txtAccessoryWidth");
                                    if (tempTxt.Text.Trim() != "")
                                    {
                                        anAccessory.AccessoryWidth = Convert.ToInt16(tempTxt.Text);
                                    }
                                    else
                                    {
                                        anAccessory.AccessoryWidth = 0;
                                    }

                                    if (txtPackQuantity.Text.Trim() != "")
                                    {
                                        anAccessory.AccessoryPackQuantity = Convert.ToInt16(txtPackQuantity.Text);
                                    }
                                    else
                                    {
                                        anAccessory.AccessoryPackQuantity = 0;
                                    }

                                    tempTxt = (TextBox)pnlAccessories.FindControl("txtAccessoryLength");
                                    if (tempTxt.Text.Trim() != "")
                                    {
                                        anAccessory.AccessoryLength = Convert.ToInt16(tempTxt.Text);
                                    }
                                    else
                                    {
                                        anAccessory.AccessoryLength = 0;
                                    }

                                    anAccessory.AccessoryColor = ddlColors.SelectedValue;
                                    anAccessory.AccessoryWidthUnits = ddlAccessoryWidthUnits.SelectedValue;
                                    anAccessory.AccessoryLengthUnits = ddlAccessoryLengthUnits.SelectedValue;
                                    tempTxt = (TextBox)pnlAccessories.FindControl("txtAccessorySize");

                                    //If they don't enter a size then make it 0
                                    if (tempTxt.Text.Trim() == "")
                                    {
                                        anAccessory.AccessorySize = 0;
                                    }
                                    else
                                    {
                                        anAccessory.AccessorySize = Convert.ToInt16(tempTxt.Text);
                                    }

                                    anAccessory.AccessorySizeUnits = ddlAccessorySizeUnits.SelectedValue;

                                    if (Part_Exists("tblAccessories", anAccessory.AccessoryNumber) == true)
                                    {

                                        //part does exist, set error message
                                        errorMessage = "Could not add" + anAccessory.AccessoryNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;

                                    }
                                    else
                                    {
                                        //Insert
                                        anAccessory.Insert(datInsertDataSource, "tblAccessories");

                                        //Set Required Session Variables for Display Page
                                        Session["categoryIndex"] = 1;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = anAccessory.AccessoryNumber;
                                    }
                                }

                            }
                            break;
                        #endregion
                        #region DecorativeColumn
                        case "tblDecorativeColumn":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("decorativeColumn");

                                if (Page.IsValid == true)
                                {

                                    DecorativeColumn aDecorativeColumn = new DecorativeColumn();

                                    Session.Add("DecorativeColumn", aDecorativeColumn);

                                    aDecorativeColumn.ColumnLength = Convert.ToInt32(txtDecColLength.Text);
                                    aDecorativeColumn.ColumnName = txtPartName.Text;
                                    aDecorativeColumn.PartNumber = txtPartNum.Text;
                                    aDecorativeColumn.ColumnDescription = txtPartDesc.Text;
                                    aDecorativeColumn.ColumnCadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aDecorativeColumn.ColumnUsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    aDecorativeColumn.ColumnLength = Convert.ToInt32(txtDecColLength.Text);
                                    aDecorativeColumn.ColumnLengthUnits = ddlDecColLengthUnits.SelectedValue;

                                    aDecorativeColumn.ColumnColor = ddlColors.SelectedValue;

                                    if (Part_Exists("tblDecorativeColumn", aDecorativeColumn.PartNumber) == true)
                                    {
                                        //part does not exist, set error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aDecorativeColumn.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        //Insert
                                        aDecorativeColumn.Insert(datInsertDataSource, "tblDecorativeColumn");

                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 2;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aDecorativeColumn.PartNumber;
                                    }
                                }
                            }
                            break;
                        #endregion
                        #region DoorFrameExtrusion
                        case "tblDoorFrameExtrusion":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("doorFrameExtrusion");

                                if (Page.IsValid == true)
                                {
                                    DoorFrameExtrusion aDfe = new DoorFrameExtrusion();

                                    Session.Add("DoorFrameExtrusion", aDfe);

                                    aDfe.DfeMaxLength = Convert.ToInt32(txtDoorFrExtMaxLength.Text);
                                    aDfe.DfeName = txtPartName.Text;

                                    aDfe.PartNumber = txtPartNum.Text;
                                    aDfe.DfeDescription = txtPartDesc.Text;
                                    aDfe.CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aDfe.UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    aDfe.DfeColor = ddlColors.SelectedValue;
                                    aDfe.DfeMaxLength = Convert.ToInt32(txtDoorFrExtMaxLength.Text);
                                    aDfe.DfeMaxLengthUnits = ddlDoorFrExtMaxLengthUnits.SelectedValue;

                                    if (Part_Exists("tblDoorFrameExtrusion", aDfe.PartNumber) == true)
                                    {
                                        //part already exists, set error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aDfe.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        //Insert
                                        aDfe.Insert(datInsertDataSource, "tblDoorFrameExtrusion");

                                        //Set required session variables for display page
                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 3;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aDfe.PartNumber;
                                    }
                                }
                            }
                            break;
                        #endregion
                        #region InsulatedFloors
                        case "tblInsulatedFloors":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("insulatedFloor");
                                Page.Validate("compstand");

                                if (Page.IsValid == true)
                                {
                                    InsulatedFloors anInsulatedFloor = new InsulatedFloors();

                                    Session.Add("InsulatedFloor", anInsulatedFloor);

                                    anInsulatedFloor.InsulatedFloorName = txtPartName.Text;
                                    anInsulatedFloor.PartNumber = txtPartNum.Text;
                                    anInsulatedFloor.InsulatedFloorDescription = txtPartDesc.Text;
                                    anInsulatedFloor.InsulatedFloorCadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    anInsulatedFloor.InsulatedFloorUsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    anInsulatedFloor.InsulatedFloorComposition = txtComposition.Text;
                                    anInsulatedFloor.InsulatedFloorMaxLength = txtInsulatedFloorMaxLength.Text;
                                    anInsulatedFloor.InsulatedFloorMaxWidth = Convert.ToInt32(txtInsFloorPnlMaxWidth.Text);
                                    anInsulatedFloor.InsulatedFloorMaxWidthUnits = ddlInsFloorPnlMaxWidthUnits.SelectedValue;
                                    anInsulatedFloor.InsulatedFloorSize = Convert.ToInt32(txtInsFloorSize.Text);
                                    anInsulatedFloor.InsulatedFloorSizeUnits = ddlInsFloorSizeUnits.SelectedValue;
                                    if (Part_Exists("tblInsulatedFloors", anInsulatedFloor.PartNumber) == true)
                                    {
                                        //error messae would go here
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + anInsulatedFloor.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        //Insert
                                        anInsulatedFloor.Insert(datInsertDataSource, "tblInsulatedFloors");
                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 4;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = anInsulatedFloor.PartNumber;
                                    }
                                }
                            }
                            break;
                        #endregion
                        #region aRoofPanel
                        case "tblRoofPanels":
                            {
                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("roofPanel");
                                Page.Validate("compstand");

                                if (Page.IsValid == true)
                                {
                                    RoofPanels aRoofPanel = new RoofPanels();
                                    Session.Add("RoofPanel", aRoofPanel);

                                    aRoofPanel.PanelName = txtPartName.Text;
                                    aRoofPanel.PartNumber = txtPartNum.Text;
                                    aRoofPanel.PanelDescription = txtPartDesc.Text;
                                    aRoofPanel.CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aRoofPanel.UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    aRoofPanel.PanelComposition = txtComposition.Text;
                                    //aRoofPanel.PanelMaxLength = txtRoofPnlMaxLength.Text;
                                    aRoofPanel.PanelMaxWidth = Convert.ToInt32(txtRoofPnlMaxWidth.Text);
                                    aRoofPanel.PanelMaxLength = txtRoofPanelMaxLength.Text;
                                    aRoofPanel.MaxWidthUnits = "Inches";
                                    aRoofPanel.PanelSize = Convert.ToInt32(txtRoofPnlSize.Text);
                                    aRoofPanel.PanelSizeUnits = "Inches";
                                    aRoofPanel.PanelColor = ddlColors.SelectedValue;
                                    aRoofPanel.PanelStandard = txtStandard.Text;

                                    if (Part_Exists("tblRoofPanels", aRoofPanel.PartNumber) == true)
                                    {
                                        //error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aRoofPanel.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        aRoofPanel.Insert(datInsertDataSource, "tblRoofPanels");
                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 6;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aRoofPanel.PartNumber;
                                    }
                                }

                            }
                            break;
                        #endregion
                        #region ScreenRoll
                        case "tblScreenRoll":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("screenroll");

                                if (Page.IsValid == true)
                                {
                                    ScreenRoll aScreenRoll = new ScreenRoll();

                                    Session.Add("ScreenRoll", aScreenRoll);

                                    aScreenRoll.ScreenRollName = txtPartName.Text;
                                    aScreenRoll.PartNumber = txtPartNum.Text;
                                    aScreenRoll.ScreenRollWidth = Convert.ToInt32(txtScreenRollWidth.Text);
                                    aScreenRoll.ScreenRollWidthUnits = ddlScreenRollWidthUnits.SelectedValue;
                                    aScreenRoll.ScreenRollLength = Convert.ToInt32(txtScreenRollLength.Text);
                                    aScreenRoll.ScreenRollLengthUnits = ddlScreenRollLengthUnits.SelectedValue;
                                    aScreenRoll.CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aScreenRoll.UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    if (Part_Exists("tblScreenRoll", aScreenRoll.PartNumber) == true)
                                    {
                                        //error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aScreenRoll.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        //insert
                                        aScreenRoll.Insert(datInsertDataSource, "tblScreenRoll");
                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 8;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aScreenRoll.PartNumber;
                                    }
                                }

                            }
                            break;
                        #endregion
                        #region SunrcylicRoof
                        case "tblSuncrylicRoof":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("suncrylicroof");

                                if (Page.IsValid == true)
                                {
                                    SuncrylicRoof aSuncrylicRoof = new SuncrylicRoof();

                                    Session.Add("SunCrylicRoof", aSuncrylicRoof);

                                    aSuncrylicRoof.SuncrylicName = txtPartName.Text;
                                    aSuncrylicRoof.PartNumber = txtPartNum.Text;
                                    aSuncrylicRoof.SuncrylicDescription = txtPartDesc.Text;
                                    aSuncrylicRoof.CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aSuncrylicRoof.UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    aSuncrylicRoof.SuncrylicColor = ddlColors.SelectedValue;
                                    aSuncrylicRoof.SuncrylicMaxLength = Convert.ToInt32(txtSunRoofMaxLength.Text);
                                    aSuncrylicRoof.SuncrylicLengthUnits = ddlSunRoofMaxLengthUnits.SelectedValue;

                                    if (Part_Exists("tblSuncrylicRoof", aSuncrylicRoof.PartNumber) == true)
                                    {
                                        //error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aSuncrylicRoof.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        //Insert
                                        aSuncrylicRoof.Insert(datInsertDataSource, "tblSuncrylicRoof");

                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 9;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aSuncrylicRoof.PartNumber;
                                    }
                                }

                            }
                            break;
                        #endregion
                        #region Sunrail1000
                        case "tblSunrail1000":
                            {
                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("sunrail1000");

                                if (Page.IsValid == true)
                                {
                                    Sunrail1000 aSunrail1000 = new Sunrail1000();

                                    Session.Add("Sunrail1000", aSunrail1000);

                                    aSunrail1000.Sunrail1000Name = txtPartName.Text;
                                    aSunrail1000.PartNumber = txtPartNum.Text;
                                    aSunrail1000.Sunrail1000Description = txtPartDesc.Text;
                                    aSunrail1000.Sunrail1000CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aSunrail1000.Sunrail1000UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    aSunrail1000.Sunrail1000Color = ddlColors.SelectedValue;

                                    //Check if they entered a value
                                    //If not then insert null into the database
                                    if (((txtSun1000MaxLengthFt.Text.Trim()) == "") || Convert.ToInt32(txtSun1000MaxLengthFt.Text) == 0)
                                    {
                                        aSunrail1000.Sunrail1000MaxLengthFeet = 0;
                                        aSunrail1000.Sunrail1000MaxLengthFeetUnits = null;

                                    }
                                    else //insert data they entered
                                    {
                                        aSunrail1000.Sunrail1000MaxLengthFeet = Convert.ToInt32(txtSun1000MaxLengthFt.Text);
                                        aSunrail1000.Sunrail1000MaxLengthFeetUnits = "Feet";
                                    }

                                    if ((txtSun1000PnlMaxLengthInch.Text.Trim() == "") || (Convert.ToInt32(txtSun1000PnlMaxLengthInch.Text) == 0))
                                    {
                                        aSunrail1000.Sunrail1000MaxLengthInches = null;
                                        aSunrail1000.Sunrail1000MaxLengthInchesUnits = null;
                                    }
                                    else
                                    {
                                        aSunrail1000.Sunrail1000MaxLengthInches = Convert.ToInt32(txtSun1000PnlMaxLengthInch.Text);

                                        aSunrail1000.Sunrail1000MaxLengthInchesUnits = "Inches";
                                    }

                                    if (Part_Exists("tblSunrail1000", aSunrail1000.PartNumber) == true)
                                    {
                                        //error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aSunrail1000.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        //insert
                                        aSunrail1000.Insert(datInsertDataSource, "tblSunrail1000");

                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 10;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aSunrail1000.PartNumber;
                                    }
                                }
                            }
                            break;
                        #endregion
                        #region Sunrail300
                        case "tblSunrail300":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("sunrail300");

                                if (Page.IsValid == true)
                                {
                                    Sunrail300 aSunrail300 = new Sunrail300();

                                    Session.Add("Sunrail300", aSunrail300);

                                    //Name
                                    aSunrail300.Sunrail300Name = txtPartName.Text;
                                    //Part Number
                                    aSunrail300.PartNumber = txtPartNum.Text;
                                    //Descriptions
                                    aSunrail300.Sunrail300Description = txtPartDesc.Text;
                                    //Prices
                                    aSunrail300.Sunrail300CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aSunrail300.Sunrail300UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    //Color
                                    aSunrail300.Sunrail300Color = ddlColors.SelectedValue;

                                    //Max Length Feet
                                    aSunrail300.Sunrail300MaxLengthFeet = Convert.ToInt32(txtSun300MaxLengthFt.Text);
                                    aSunrail300.Sunrail300MaxLengthFeetUnits = "Feet";

                                    //Max Length Inch

                                    //If user enters nothing or 0, place a null in the Inches field
                                    if (txtSun300PnlMaxLengthInch.Text == "" || Convert.ToInt32(txtSun300PnlMaxLengthInch.Text) == 0)
                                    {
                                        aSunrail300.Sunrail300MaxLengthInches = null;
                                        aSunrail300.Sunrail300MaxLengthInchesUnits = null;
                                        //place nulls
                                    }
                                    else
                                    {
                                        aSunrail300.Sunrail300MaxLengthInches = Convert.ToInt32(txtSun300PnlMaxLengthInch.Text);
                                        aSunrail300.Sunrail300MaxLengthInchesUnits = "Inches";
                                    }

                                    //Set Session Variables for Display Page

                                    if (Part_Exists("tblSunrail300", aSunrail300.PartNumber) == true)
                                    {
                                        //error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aSunrail300.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;

                                    }
                                    else
                                    {
                                        Session["categoryIndex"] = 11;
                                        Session["partIndex"] = 1;
                                        Session["tableName"] = "tblSunrail300";
                                        Session["partNumber"] = aSunrail300.PartNumber;

                                        aSunrail300.Insert(datInsertDataSource, "tblSunrail300");
                                    }
                                }

                            }
                            break;
                        #endregion
                        #region Sunrail300Accessory
                        case "tblSunrail300Accessories":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("sunrail300accessories");

                                if (Page.IsValid == true)
                                {

                                    Sunrail300Accessories aSunrail300Accessory = new Sunrail300Accessories();

                                    Session.Add("Sunrail300Accessory", aSunrail300Accessory);

                                    aSunrail300Accessory.Sunrail300AccessoriesName = txtPartName.Text;
                                    aSunrail300Accessory.PartNumber = txtPartNum.Text;
                                    aSunrail300Accessory.Sunrail300AccessoriesDescription = txtPartDesc.Text;
                                    aSunrail300Accessory.Sunrail300AccessoriesCadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aSunrail300Accessory.Sunrail300AccessoriesUsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    aSunrail300Accessory.Sunrail300AccessoriesColor = ddlColors.SelectedValue;

                                    if (Part_Exists("tblSunrail300Accessories", aSunrail300Accessory.PartNumber) == true)
                                    {
                                        //error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aSunrail300Accessory.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        aSunrail300Accessory.Insert(datInsertDataSource, "tblSunrail300Accessories");

                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 12;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aSunrail300Accessory.PartNumber;
                                    }
                                }
                            }
                            break;
                        #endregion
                        #region Sunrail400
                        case "tblSunrail400":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("sunrail400");

                                if (Page.IsValid == true)
                                {
                                    Sunrail400 aSunrail400 = new Sunrail400();

                                    Session.Add("Sunrail400", aSunrail400);

                                    //Name
                                    aSunrail400.Sunrail400Name = txtPartName.Text;
                                    //Number
                                    aSunrail400.PartNumber = txtPartNum.Text;
                                    //Description
                                    aSunrail400.Sunrail400Description = txtPartDesc.Text;
                                    //Prices
                                    aSunrail400.Sunrail400CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aSunrail400.Sunrail400UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    //Max Length in Feet
                                    aSunrail400.Sunrail400MaxLengthFeet = Convert.ToInt32(txtSun400MaxLengthFt.Text);
                                    aSunrail400.Sunrail400MaxLengthFeetUnits = "Feet";

                                    //Color
                                    aSunrail400.Sunrail400Color = ddlColors.SelectedValue;

                                    //Max Length in Inches

                                    //If user enters 0 or nothiung for the inches, we don't want the display page to show it
                                    //So set both to null in the object.
                                    if ((txtSun400PnlMaxLengthInch.Text == "") || (Convert.ToInt32(txtSun400PnlMaxLengthInch.Text) == 0))
                                    {
                                        aSunrail400.Sunrail400MaxLengthInches = null;
                                        aSunrail400.Sunrail400MaxLengthInchesUnits = null;
                                    }
                                    else
                                    //Insert the values they entered for inches into the database
                                    {
                                        aSunrail400.Sunrail400MaxLengthInches = Convert.ToInt32(txtSun400PnlMaxLengthInch.Text);
                                        aSunrail400.Sunrail400MaxLengthInchesUnits = "Inches";
                                    }

                                    //Check if part number already exists
                                    if (Part_Exists("tblSunrail400", aSunrail400.PartNumber) == true)
                                    {
                                        //error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aSunrail400.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        //Insert into the database
                                        aSunrail400.Insert(datInsertDataSource, "tblSunrail400");

                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 13;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aSunrail400.PartNumber;
                                    }
                                }

                            }
                            break;
                        #endregion
                        #region VinylRoll
                        case "tblVinylRoll":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("vinylroll");

                                if (Page.IsValid == true)
                                {
                                    VinylRoll aVinylRoll = new VinylRoll();

                                    Session.Add("VinylRoll", aVinylRoll);

                                    //Name
                                    aVinylRoll.VinylRollName = txtPartName.Text;
                                    //Number
                                    aVinylRoll.PartNumber = txtPartNum.Text;
                                    //Prices
                                    aVinylRoll.CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aVinylRoll.UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    //Length

                                    //Weight
                                    aVinylRoll.VinylRollWeight = Convert.ToInt32(txtVinylRollWeight.Text);
                                    aVinylRoll.VinylRollWeightUnits = ddlVinylRollWeightUnits.SelectedValue;

                                    //Width
                                    aVinylRoll.VinylRollWidth = Convert.ToInt32(txtVinylRollWidth.Text);
                                    aVinylRoll.VinylRollWidthUnits = ddlVinylRollWidthUnits.SelectedValue;

                                    //Color
                                    aVinylRoll.VinylRollColor = ddlColors.SelectedValue;

                                    //Check is part number is already in database
                                    if (Part_Exists("tblVinylRoll", aVinylRoll.PartNumber) == true)
                                    {
                                        //error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aVinylRoll.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        //Insert into the database
                                        aVinylRoll.Insert(datInsertDataSource, "tblVinylRoll");
                                    }

                                    //Set Session Variables for Display Page
                                    Session["categoryIndex"] = 14;
                                    Session["partIndex"] = 1;
                                    Session["partNumber"] = aVinylRoll.PartNumber;

                                }
                            }
                            break;
                        #endregion
                        #region WallExtrusions
                        case "tblWallExtrusions":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("wallExtrusion");

                                if (Page.IsValid == true)
                                {
                                    WallExtrusions aWallExtrusion = new WallExtrusions();

                                    Session.Add("WallExtrusions", aWallExtrusion);

                                    aWallExtrusion.WallExtrusionName = txtPartName.Text;
                                    aWallExtrusion.PartNumber = txtPartNum.Text;
                                    aWallExtrusion.WallExtrusionDescription = txtPartDesc.Text;
                                    aWallExtrusion.CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aWallExtrusion.UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    aWallExtrusion.WallExtrusionColor = ddlColors.SelectedValue;
                                    aWallExtrusion.WallExtrusionMaxLength = Convert.ToInt32(txtWallExtLength.Text);
                                    aWallExtrusion.LengthUnits = ddlWallExtLengthUnits.SelectedValue;

                                    if (Part_Exists("tblWallExtrusions", aWallExtrusion.PartNumber) == true)
                                    {
                                        //error message
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aWallExtrusion.PartNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        //insert
                                        aWallExtrusion.Insert(datInsertDataSource, "tblWallExtrusions");

                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 15;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aWallExtrusion.PartNumber;
                                    }
                                }
                            }
                            break;
                        #endregion
                        #region WallPanels
                        case "tblWallPanels":
                            {

                                Page.Validate("productInfo");
                                Page.Validate("pricing");
                                Page.Validate("wallPanel");
                                Page.Validate("compstand");

                                if (Page.IsValid == true)
                                {
                                    WallPanels aWallPanel = new WallPanels();

                                    Session.Add("WallPanel", aWallPanel);

                                    //Name
                                    aWallPanel.WallPanelName = txtPartName.Text;

                                    //Number
                                    aWallPanel.WallPanelNumber = txtPartNum.Text;

                                    //Description
                                    aWallPanel.WallPanelDescription = txtPartDesc.Text;

                                    //Prices
                                    aWallPanel.CadPrice = Convert.ToDecimal(txtCadPrice.Text);
                                    aWallPanel.UsdPrice = Convert.ToDecimal(txtUsdPrice.Text);

                                    //Color
                                    aWallPanel.WallPanelColor = ddlColors.SelectedValue;

                                    //Composition
                                    aWallPanel.WallPanelComposition = txtComposition.Text;
                                    //Standard
                                    aWallPanel.WallPanelStandard = txtStandard.Text;

                                    //Size
                                    aWallPanel.WallPanelSize = Convert.ToInt32(txtWallPnlSize.Text);
                                    aWallPanel.SizeUnits = ddlWallPnlSizeUnits.SelectedValue;

                                    //Max Length
                                    aWallPanel.WallPanelMaxLength = Convert.ToInt32(txtWallPnlMaxLength.Text);
                                    aWallPanel.LengthUnits = ddlWallPnlMaxLengthUnits.SelectedValue;

                                    //Max Width
                                    aWallPanel.WallPanelMaxWidth = Convert.ToInt32(txtWallPnlMaxWidth.Text);
                                    aWallPanel.WidthUnits = ddlWallPnlMaxWidthUnits.SelectedValue;

                                    if (Part_Exists("tblWallPanels", aWallPanel.WallPanelNumber) == true)
                                    {
                                        //error
                                        //part does exist, set error message
                                        errorMessage = "Could not add" + aWallPanel.WallPanelNumber + ". Part Number already exists.";
                                        valPartExists.Text = errorMessage;
                                    }
                                    else
                                    {
                                        aWallPanel.Insert(datInsertDataSource, "tblWallPanels");

                                        //Set Session Variables for Display Page
                                        Session["categoryIndex"] = 16;
                                        Session["partIndex"] = 1;
                                        Session["partNumber"] = aWallPanel.WallPanelNumber;
                                    }

                                }

                                break;
                            }
                        #endregion

                    }

                    if ((Page.IsValid == true) && (errorMessage==""))
                    {

                        //Check to see if temp picture exists
                        if (System.IO.File.Exists(Server.MapPath("Images/catalogue/temp.jpg")))
                        {
                            //Save picture
                            System.IO.File.Copy(Server.MapPath("Images/catalogue/temp.jpg"), Server.MapPath("Images/catalogue/" + Session["partNumber"].ToString() + ".jpg"), true);
                        }
                        //redirect to Display.aspx
                        Response.Redirect("Display.aspx");
                    }

            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Label firstLabel = (Label)Master.FindControl("lblUpdate");
            if (firstLabel != null)
            {
                firstLabel.Text = "UPDATE";
            }

            Label secondLabel = (Label)Master.FindControl("lblPartNumTitle");
            if (secondLabel != null)
            {
                secondLabel.Text = Session["partNumber"].ToString();
            }
            if (!Page.IsPostBack)
            {
                //prevent backdoor
                if (Session["tableName"] == null)
                {
                    Response.Redirect("ProductSelect.aspx");
                }
                else
                {
                    //load dropdowns
                    if (!Page.IsPostBack)
                    {
                        //set up a dataview object to hold table names for the first drop down
                        System.Data.DataView tableList = new System.Data.DataView();

                        //select table names
                        datSelectDataSource.SelectCommand = "SELECT name FROM sys.tables WHERE name != 'tblColor' AND name != 'tblSchematicParts' AND name != 'tblParts' "
                                                                                + " AND name != 'tblLengthUnits'  AND name != 'tblAudits' AND name != 'tblSalesOrders' AND name != 'tblSalesOrderItems' "
                                                                                + " AND SUBSTRING(name,1,3) = 'tbl' "
                                                                                + "ORDER BY name ASC"; tableList = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                        //variable to determine amount of rows in the dataview object
                        int rowCount = tableList.Count;

                        ddlCategory.Items.Add("");
                        //populate first drop down
                        for (int i = 0; i < rowCount; i++)
                        {
                            string textString = tableList[i][0].ToString();
                            string newString = textString.Substring(3);
                            string outputString = "";
                            foreach (char character in newString)
                            {
                                if (char.IsUpper(character))
                                {
                                    outputString += " " + character;
                                }
                                else if (character.ToString() == "1" || character.ToString() == "3" || character.ToString() == "4")
                                {
                                    outputString += " " + character;
                                }
                                else
                                {
                                    outputString += character;
                                }
                            }

                            ddlCategory.Items.Add(outputString.Trim());
                        }

                        //select category dropdown default value
                        ddlCategory.SelectedIndex = (int)Session["categoryIndex"];

                        //load part list
                        if (ddlCategory.SelectedValue != "")
                        {
                            //get table name selected
                            string tableName = "tbl" + ddlCategory.SelectedValue.Replace(" ", "");

                            //set up a dataview object to hold part numbers for the second drop down
                            System.Data.DataView partsList = new System.Data.DataView();

                            if (tableName != "tblSchematics")
                            {
                                //select part numbers
                                datSelectDataSource.SelectCommand = "SELECT partNumber, partName FROM " + tableName + " ORDER BY partNumber ASC";
                            }
                            else
                            {
                                datSelectDataSource.SelectCommand = "SELECT schematicNumber, partName FROM " + tableName + " ORDER BY schematicNumber ASC";
                            }
                            //assign the table names to the dataview object
                            partsList = (System.Data.DataView)datSelectDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                            //clear second drop down
                            ddlPart.Items.Clear();

                            //Insert empty string to first row of second drop down
                            ddlPart.Items.Add("");

                            rowCount = partsList.Count;
                            //populate second drop down
                            for (int i = 0; i < rowCount; i++)
                            {
                                ddlPart.Items.Add(partsList[i][0].ToString() + " (" + partsList[i][1].ToString() + ")");
                            }

                            Session.Add("updateChanged", "true");
                        }
                    }

                    //only run if the display has changed, to allow display postback changes
                    if (Session["updateChanged"] != null)
                    {
                        //we're running this, so the display has been updated, and is not set for change
                        Session.Remove("updateChanged");
                        //select part dropdown default value
                        ddlPart.SelectedIndex = (int)Session["partIndex"];

                        //show navigation arrows
                        imgPrevArrow.CssClass = "prevArrow";
                        imgNextArrow.CssClass = "nextArrow";

                        if (ddlPart.SelectedIndex == (ddlPart.Items.Count - 1))
                        {
                            //if last item, don't show 'next' arrow
                            imgNextArrow.CssClass = "removeElement";
                        }
                        else if (ddlPart.SelectedIndex == 1)
                        {
                            //if first item, don't show 'prev' arrow
                            imgPrevArrow.CssClass = "removeElement";
                        }

                        //Clear updated object in session
                        if (Session["updatedObject"] != null)
                        {
                            Session.Remove("updatedObject");
                        }

                        //get table selected from session
                        string tableName = Session["tableName"].ToString();
                        #region Display Pricing Only
                        if (Session["pricingOnly"] != null)
                        {
                            lblPartKey.CssClass = "removeElement";
                            pnlPackQuantity.CssClass = "removeElement";
                            pnlComposition.CssClass = "removeElement";
                            pnlStandard.CssClass = "removeElement";
                            pnlDimensions.CssClass = "removeElement";
                            pnlStatus.CssClass = "removeElement";
                            btnUploadImg.CssClass = "removeElement";
                            txtPartDesc.CssClass = "txtInputFieldDisabled";
                            pnlSchematics.CssClass = "removeElement";
                            pnlPricingSchematics.CssClass = "removeElement";
                            //Switch statement for displaying according to selected product

                            switch (tableName)
                            {
                                #region RoofExtrusion
                                //When Roof Extrusions is selected
                                case "tblRoofExtrusions":
                                    {
                                        //create RoofExtrusion object
                                        RoofExtrusion aRoofExtrusion = new RoofExtrusion();

                                        //call select all function to populate object
                                        aRoofExtrusion.Populate(aRoofExtrusion.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aRoofExtrusion.ExtrusionName;
                                        txtPartDesc.Text = aRoofExtrusion.ExtrusionDescription;
                                        lblPartNum.Text = aRoofExtrusion.ExtrusionNumber;
                                        lblColorInput.Text = aRoofExtrusion.ExtrusionColor;
                                        txtUsdPrice.Text = aRoofExtrusion.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aRoofExtrusion.CadPrice.ToString("N2");

                                        break;
                                    }
                                #endregion
                                #region Accessories
                                //When Accessories is selected
                                case "tblAccessories":
                                    {
                                        //create Accessories object
                                        Accessories anAccessory = new Accessories();

                                        //call select all function to populate object
                                        anAccessory.Populate(anAccessory.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //add Accessories Object to the session
                                        Session.Add("accessories", anAccessory);

                                        //populate fields
                                        lblPartName.Text = anAccessory.AccessoryName;
                                        txtPartDesc.Text = anAccessory.AccessoryDescription;
                                        lblPartNum.Text = anAccessory.AccessoryNumber;
                                        txtUsdPrice.Text = anAccessory.AccessoryUsdPrice.ToString("N2");
                                        txtCadPrice.Text = anAccessory.AccessoryCadPrice.ToString("N2");
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";

                                        if (anAccessory.AccessoryColor != "")
                                        {
                                            lblColorInput.Text = anAccessory.AccessoryColor;
                                        }
                                        else
                                        {
                                            lblColorInput.CssClass = "removeElement";
                                            lblColor.CssClass = "removeElement";
                                        }

                                        break;
                                    }
                                #endregion

                                #region DecorativeColumn
                                //When Decorative Column is selected
                                case "tblDecorativeColumn":
                                    {
                                        //create DecorativeColumn object
                                        DecorativeColumn aColumn = new DecorativeColumn();

                                        //call select all function to populate object
                                        aColumn.Populate(aColumn.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //add DecorativeColumn Object to the session
                                        Session.Add("decorativeColumn", aColumn);

                                        //populate fields
                                        lblPartName.Text = aColumn.ColumnName;
                                        txtPartDesc.Text = aColumn.ColumnDescription;
                                        lblPartNum.Text = aColumn.PartNumber;
                                        lblColorInput.Text = aColumn.ColumnColor;
                                        txtUsdPrice.Text = aColumn.ColumnUsdPrice.ToString("N2");
                                        txtCadPrice.Text = aColumn.ColumnCadPrice.ToString("N2");
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";

                                        break;
                                    }
                                #endregion

                                #region DoorFrameExtrusion
                                //When Door Frame Extrusion is selected
                                case "tblDoorFrameExtrusion":
                                    {
                                        //create DoorFrameExtrusion object
                                        DoorFrameExtrusion aFrameExtrusion = new DoorFrameExtrusion();

                                        //call select all function to populate object
                                        aFrameExtrusion.Populate(aFrameExtrusion.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields

                                        lblPartName.Text = aFrameExtrusion.DfeName;
                                        txtPartDesc.Text = aFrameExtrusion.DfeDescription;
                                        lblPartNum.Text = aFrameExtrusion.PartNumber;
                                        lblColorInput.Text = aFrameExtrusion.DfeColor;
                                        txtUsdPrice.Text = aFrameExtrusion.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aFrameExtrusion.CadPrice.ToString("N2");
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";

                                        break;
                                    }
                                #endregion

                                #region InsulatedFloors
                                //When Insulated Floors is selected
                                case "tblInsulatedFloors":
                                    {
                                        lblColor.CssClass = "removeElement";
                                        lblColorInput.CssClass = "removeElement";

                                        //create InsulatedFloors object
                                        InsulatedFloors aFloor = new InsulatedFloors();

                                        //call select all function to populate object
                                        aFloor.Populate(aFloor.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        lblPartName.Text = aFloor.InsulatedFloorName;
                                        txtPartDesc.Text = aFloor.InsulatedFloorDescription;
                                        lblPartNum.Text = aFloor.PartNumber;
                                        txtUsdPrice.Text = aFloor.InsulatedFloorUsdPrice.ToString("N2");
                                        txtCadPrice.Text = aFloor.InsulatedFloorCadPrice.ToString("N2");
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";

                                        break;
                                    }
                                #endregion

                                #region RoofPanels
                                //When Roof Panels is selected
                                case "tblRoofPanels":
                                    {
                                        //create RoofPanels object
                                        RoofPanels aPanel = new RoofPanels();

                                        //call select all function to populate object
                                        aPanel.Populate(aPanel.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        lblPartName.Text = aPanel.PanelName;
                                        txtPartDesc.Text = aPanel.PanelDescription;
                                        lblPartNum.Text = aPanel.PartNumber;
                                        lblColorInput.Text = aPanel.PanelColor;

                                        txtUsdPrice.Text = aPanel.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aPanel.CadPrice.ToString("N2");
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";

                                        break;
                                    }
                                #endregion

                                #region ScreenRoll
                                //When Screen Roll is selected
                                case "tblScreenRoll":
                                    {
                                        lblColor.CssClass = "removeElement";
                                        lblColorInput.CssClass = "removeElement";

                                        //create ScreenRoll object
                                        ScreenRoll aScreenRoll = new ScreenRoll();

                                        //call select all function to populate object
                                        aScreenRoll.Populate(aScreenRoll.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aScreenRoll.ScreenRollName;
                                        lblPartNum.Text = aScreenRoll.PartNumber;

                                        txtUsdPrice.Text = aScreenRoll.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aScreenRoll.CadPrice.ToString("N2");
                                        break;
                                    }
                                #endregion

                                #region SuncrylicRoof
                                //When Suncrylic roof is selected
                                case "tblSuncrylicRoof":
                                    {
                                        //create ScreenRoll object
                                        SuncrylicRoof aSunRoof = new SuncrylicRoof();

                                        //call select all function to populate object
                                        aSunRoof.Populate(aSunRoof.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunRoof.SuncrylicName;
                                        lblPartNum.Text = aSunRoof.PartNumber;

                                        txtUsdPrice.Text = aSunRoof.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunRoof.CadPrice.ToString("N2");
                                        break;
                                    }
                                #endregion

                                #region VinylRoll
                                //When Vinyl Roll is selected
                                case "tblVinylRoll":
                                    {
                                        //create ScreenRoll object
                                        VinylRoll aVinylRoll = new VinylRoll();

                                        //call select all function to populate object
                                        aVinylRoll.Populate(aVinylRoll.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aVinylRoll.VinylRollName;
                                        lblPartNum.Text = aVinylRoll.PartNumber;
                                        lblColorInput.Text = aVinylRoll.VinylRollColor;
                                        txtUsdPrice.Text = aVinylRoll.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aVinylRoll.CadPrice.ToString("N2");

                                        break;
                                    }
                                #endregion

                                #region Sunrail300
                                //When Sunrail 300 is selected
                                case "tblSunrail300":
                                    {
                                        //create Sunrail300 object
                                        Sunrail300 aSunrail300 = new Sunrail300();

                                        //call select all function to populate object
                                        aSunrail300.Populate(aSunrail300.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunrail300.Sunrail300Name;
                                        lblPartNum.Text = aSunrail300.PartNumber;
                                        lblColorInput.Text = aSunrail300.Sunrail300Color;
                                        txtUsdPrice.Text = aSunrail300.Sunrail300UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunrail300.Sunrail300CadPrice.ToString("N2");

                                        break;
                                    }
                                #endregion

                                #region Sunrail300Accessories
                                //When Sunrail 300 Accessories is selected
                                case "tblSunrail300Accessories":
                                    {
                                        //create Sunrail300Accessories object
                                        Sunrail300Accessories aSunrail300Accessories = new Sunrail300Accessories();

                                        //call select all function to populate object
                                        aSunrail300Accessories.Populate(aSunrail300Accessories.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunrail300Accessories.Sunrail300AccessoriesName;
                                        lblPartNum.Text = aSunrail300Accessories.PartNumber;
                                        lblColorInput.Text = aSunrail300Accessories.Sunrail300AccessoriesColor;
                                        txtUsdPrice.Text = aSunrail300Accessories.Sunrail300AccessoriesUsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunrail300Accessories.Sunrail300AccessoriesCadPrice.ToString("N2");

                                        break;
                                    }
                                #endregion

                                #region Sunrail400
                                //When Sunrail 400 is selected
                                case "tblSunrail400":
                                    {
                                        //create Sunrail400 object
                                        Sunrail400 aSunrail400 = new Sunrail400();

                                        //call select all function to populate object
                                        aSunrail400.Populate(aSunrail400.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunrail400.Sunrail400Name;
                                        lblPartNum.Text = aSunrail400.PartNumber;
                                        lblColorInput.Text = aSunrail400.Sunrail400Color;
                                        txtUsdPrice.Text = aSunrail400.Sunrail400UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunrail400.Sunrail400CadPrice.ToString("N2");
                                        break;
                                    }
                                #endregion

                                #region Sunrail1000
                                //When Sunrail 1000 is selected
                                case "tblSunrail1000":
                                    {
                                        //create Sunrail1000 object
                                        Sunrail1000 aSunrail1000 = new Sunrail1000();

                                        //call select all function to populate object
                                        aSunrail1000.Populate(aSunrail1000.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunrail1000.Sunrail1000Name;
                                        lblPartNum.Text = aSunrail1000.PartNumber;
                                        lblColorInput.Text = aSunrail1000.Sunrail1000Color;
                                        txtUsdPrice.Text = aSunrail1000.Sunrail1000UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunrail1000.Sunrail1000CadPrice.ToString("N2");
                                        break;
                                    }
                                #endregion

                                #region WallExtrusions
                                case "tblWallExtrusions":
                                    {
                                        //create Sunrail1000 object
                                        WallExtrusions aWallExtrusion = new WallExtrusions();

                                        //call select all function to populate object
                                        aWallExtrusion.Populate(aWallExtrusion.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aWallExtrusion.WallExtrusionName;
                                        lblPartNum.Text = aWallExtrusion.PartNumber;
                                        lblColorInput.Text = aWallExtrusion.WallExtrusionColor;
                                        txtUsdPrice.Text = aWallExtrusion.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aWallExtrusion.CadPrice.ToString("N2");
                                        break;
                                    }
                                #endregion

                                #region WallPanels
                                case "tblWallPanels":
                                    {
                                        //create Sunrail1000 object
                                        WallPanels aWallPanel = new WallPanels();

                                        //call select all function to populate object
                                        aWallPanel.Populate(aWallPanel.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aWallPanel.WallPanelName;
                                        lblPartNum.Text = aWallPanel.WallPanelNumber;
                                        lblColorInput.Text = aWallPanel.WallPanelColor;
                                        txtUsdPrice.Text = aWallPanel.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aWallPanel.CadPrice.ToString("N2");
                                        break;
                                    }
                                #endregion

                                #region Schematics
                                case "tblSchematics":
                                    {
                                        rowPart1.CssClass = "removeElement";
                                        rowPart1Val.CssClass = "removeElement";
                                        rowPart2.CssClass = "removeElement";
                                        rowPart2Val.CssClass = "removeElement";
                                        rowPart3.CssClass = "removeElement";
                                        rowPart3Val.CssClass = "removeElement";
                                        rowPart4.CssClass = "removeElement";
                                        rowPart4Val.CssClass = "removeElement";
                                        rowPart5.CssClass = "removeElement";
                                        rowPart5Val.CssClass = "removeElement";
                                        rowPart6.CssClass = "removeElement";
                                        rowPart6Val.CssClass = "removeElement";
                                        rowPart7.CssClass = "removeElement";
                                        rowPart7Val.CssClass = "removeElement";
                                        rowPart8.CssClass = "removeElement";
                                        rowPart8Val.CssClass = "removeElement";
                                        rowPart9.CssClass = "removeElement";
                                        rowPart9Val.CssClass = "removeElement";
                                        rowPart10.CssClass = "removeElement";
                                        rowPart10Val.CssClass = "removeElement";
                                        rowPart11.CssClass = "removeElement";
                                        rowPart11Val.CssClass = "removeElement";
                                        rowPart12.CssClass = "removeElement";
                                        rowPart12Val.CssClass = "removeElement";
                                        rowPart13.CssClass = "removeElement";
                                        rowPart13Val.CssClass = "removeElement";
                                        rowPart14.CssClass = "removeElement";
                                        rowPart14Val.CssClass = "removeElement";
                                        rowPart15.CssClass = "removeElement";
                                        rowPart15Val.CssClass = "removeElement";
                                        rowPart16.CssClass = "removeElement";
                                        rowPart16Val.CssClass = "removeElement";
                                        rowPart17.CssClass = "removeElement";
                                        rowPart17Val.CssClass = "removeElement";
                                        rowPart18.CssClass = "removeElement";
                                        rowPart18Val.CssClass = "removeElement";
                                        rowPart19.CssClass = "removeElement";
                                        rowPart19Val.CssClass = "removeElement";
                                        rowPart20.CssClass = "removeElement";
                                        rowPart20Val.CssClass = "removeElement";
                                        rowPart21.CssClass = "removeElement";
                                        rowPart21Val.CssClass = "removeElement";
                                        rowPart22.CssClass = "removeElement";
                                        rowPart22Val.CssClass = "removeElement";
                                        rowPart23.CssClass = "removeElement";
                                        rowPart23Val.CssClass = "removeElement";

                                        lblSchemPartNum.CssClass = "removeElement";
                                        lblSchemPartKey.CssClass = "removeElement";
                                        lblSchemPartKeyNum.CssClass = "removeElement";
                                        lblSchemPartName.CssClass = "removeElement";

                                        lblColor.CssClass = "removeElement";
                                        lblColorInput.CssClass = "removeElement";
                                        pnlDimensions.CssClass = "removeElement";
                                        pnlPricing.CssClass = "removeElement";

                                        //show pnlSchematics and pricingSchemTable
                                        pnlSchematics.CssClass = "showElementNoClass";
                                        pnlPricingSchematics.CssClass = "pnlPricing";

                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";

                                        //create Schematics object
                                        Schematics aSchematic = new Schematics();

                                        //call select all function to populate object
                                        aSchematic.Populate(aSchematic.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //add RoofPanels Object to the session
                                        Session.Add("schematic", aSchematic);

                                        //populate fields

                                        //set up a dataview object for object member data
                                        System.Data.DataView aPartsTable = new System.Data.DataView();

                                        //select row based on table name and part number
                                        datUpdateDataSource.SelectCommand = "SELECT partNumber FROM tblSchematicParts WHERE schematicNumber='" + Session["partNumber"] + "' ORDER BY keyNumber ASC";

                                        //assign the row to the dataview object
                                        aPartsTable = (System.Data.DataView)datUpdateDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                                        ddlSchem.Items.Clear();
                                        ddlSchem.Items.Add("");

                                        for (int i = 0; i < aPartsTable.Count; i++)
                                        {
                                            ddlSchem.Items.Add(aPartsTable[i][0].ToString());
                                        }

                                        lblPartName.Text = aSchematic.SchematicName.ToString();
                                        txtPartDesc.Text = aSchematic.SchematicDescription.ToString();
                                        lblPartNum.Text = aSchematic.SchematicNumber.ToString();

                                        txtUsdPriceSchematic.Text = aSchematic.SchematicUsdPrice.ToString("N2");
                                        txtCadPriceSchematic.Text = aSchematic.SchematicCadPrice.ToString("N2");

                                        rfvSchemWholeUsd.ValidationGroup = "pricing";
                                        cmpSchemWholeUsd.ValidationGroup = "pricing";
                                        rfvSchemWholeCad.ValidationGroup = "pricing";
                                        cmpSchemWholeCad.ValidationGroup = "pricing";

                                        break;
                                    }
                                #endregion
                            }
                        }
                        #endregion
                        else
                        #region Display Pricing and Product Info
                        {
                            //Hide selected 'product' panels
                            lblPartKey.CssClass = "removeElement";
                            pnlPackQuantity.CssClass = "removeElement";
                            pnlComposition.CssClass = "removeElement";
                            pnlStandard.CssClass = "removeElement";
                            txtPartDesc.CssClass = "txtInputFieldDesc";
                            //Hide all 'dimension' panels
                            pnlAccessories.CssClass = "removeElement";
                            pnlDecorativeColumn.CssClass = "removeElement";
                            pnlDoorFrameExtrusions.CssClass = "removeElement";
                            pnlInsulatedFloors.CssClass = "removeElement";
                            pnlRoofExtrusions.CssClass = "removeElement";
                            pnlRoofPanels.CssClass = "removeElement";
                            pnlSchematics.CssClass = "removeElement";
                            pnlScreenRoll.CssClass = "removeElement";
                            pnlSuncrylicRoof.CssClass = "removeElement";
                            pnlSunrail1000.CssClass = "removeElement";
                            pnlSunrail300.CssClass = "removeElement";
                            pnlSunrail400.CssClass = "removeElement";
                            pnlVinylRoll.CssClass = "removeElement";
                            pnlWallExtrusions.CssClass = "removeElement";
                            pnlWallPanel.CssClass = "removeElement";
                            pnlPricingSchematics.CssClass = "removeElement";
                            //Switch statement for displaying according to selected product
                            switch (tableName)
                            {
                                #region RoofExtrusions
                                //when tblRoofExtrusions is selected
                                case "tblRoofExtrusions":

                                    if (Session["roofExtrusion"] != null)
                                    {
                                        Session.Remove("roofExtrusion");
                                    }

                                    //show pnlRoofExtrusion
                                    pnlRoofExtrusions.CssClass = "dimensionsTable";

                                    //create RoofExtrusion object
                                    RoofExtrusion aRoofExtrusion = new RoofExtrusion();

                                    //add RoofExtrusion Object to the session
                                    Session.Add("roofExtrusion", aRoofExtrusion);

                                    //call select all function to populate object
                                    aRoofExtrusion.Populate(aRoofExtrusion.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                    //populate fields
                                    imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";

                                    lblPartName.Text = aRoofExtrusion.ExtrusionName;
                                    txtPartDesc.Text = aRoofExtrusion.ExtrusionDescription;
                                    lblPartNum.Text = aRoofExtrusion.ExtrusionNumber;
                                    lblColorInput.Text = aRoofExtrusion.ExtrusionColor;

                                    //conditional field display, based on whether members have default values or not
                                    if (aRoofExtrusion.ExtrusionSize != 0)
                                    {
                                        lblRoofExtSizeUnits.Text = aRoofExtrusion.SizeUnits.ToString();
                                        txtRoofExtSize.Text = aRoofExtrusion.ExtrusionSize.ToString();
                                        rfvRoofExtSize.ValidationGroup = "roofExtrusion";
                                        cmpRoofExtSize.ValidationGroup = "roofExtrusion";
                                    }
                                    else
                                    {
                                        rowRoofExtSize.CssClass = "removeElement";
                                    }

                                    if (aRoofExtrusion.AngleA != 0)
                                    {
                                        lblRoofExtAngleAUnits.Text = aRoofExtrusion.AngleAUnits.ToString();
                                        txtRoofExtAngleA.Text = aRoofExtrusion.AngleA.ToString();
                                        rfvRoofExtAngleA.ValidationGroup = "roofExtrusion";
                                        cmpRoofExtAngleA.ValidationGroup = "roofExtrusion";
                                    }
                                    else
                                    {
                                        rowRoofExtAngleA.CssClass = "removeElement";
                                    }

                                    if (aRoofExtrusion.AngleB != 0)
                                    {
                                        lblRoofExtAngleBUnits.Text = aRoofExtrusion.AngleBUnits.ToString();
                                        txtRoofExtAngleB.Text = aRoofExtrusion.AngleB.ToString();
                                        rfvRoofExtAngleB.ValidationGroup = "roofExtrusion";
                                        cmpRoofExtAngleB.ValidationGroup = "roofextrusion";
                                    }
                                    else
                                    {
                                        rowRoofExtAngleB.CssClass = "removeElement";
                                    }

                                    if (aRoofExtrusion.AngleC != 0)
                                    {
                                        lblRoofExtAngleCUnits.Text = aRoofExtrusion.AngleCUnits.ToString();
                                        txtRoofExtAngleC.Text = aRoofExtrusion.AngleC.ToString();
                                        rfvRoofExtAngleC.ValidationGroup = "roofExtrusion";
                                        cmpRoofExtAngleC.ValidationGroup = "roofExtrusion";
                                    }
                                    else
                                    {
                                        rowRoofExtAngleC.CssClass = "removeElement";
                                    }

                                    txtRoofExtMaxLength.Text = aRoofExtrusion.ExtrusionMaxLength.ToString();
                                    lblRoofExtMaxLengthUnits.Text = aRoofExtrusion.MaxLengthUnits.ToString();
                                    rfvRoofExtMaxLength.ValidationGroup = "roofExtrusion";
                                    cmpRoofExtMaxLength.ValidationGroup = "roofExtrusion";

                                    txtUsdPrice.Text = aRoofExtrusion.UsdPrice.ToString("N2");
                                    txtCadPrice.Text = aRoofExtrusion.CadPrice.ToString("N2");

                                    if (aRoofExtrusion.Status)
                                    {
                                        radActive.Checked = true;
                                    }
                                    else
                                    {
                                        radInactive.Checked = true;
                                    }

                                    break;
                                #endregion
                                #region Accessories
                                //when tblAccessories is selected
                                case "tblAccessories":

                                    if (Session["accessories"] != null)
                                    {
                                        Session.Remove("accessories");
                                    }

                                    //show pnlAccessories
                                    pnlPackQuantity.CssClass = "showPanelNoClass";
                                    pnlAccessories.CssClass = "dimensionsTable";

                                    //create Accessories object
                                    Accessories anAccessory = new Accessories();

                                    //call select all function to populate object
                                    anAccessory.Populate(anAccessory.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                    //add Accessories Object to the session
                                    Session.Add("accessories", anAccessory);

                                    //populate fields
                                    imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                    lblPartName.Text = anAccessory.AccessoryName;
                                    txtPartDesc.Text = anAccessory.AccessoryDescription;
                                    lblPartNum.Text = anAccessory.AccessoryNumber;

                                    //conditional field display, based on whether members have default values or not
                                    if (anAccessory.AccessoryColor != "")
                                    {
                                        lblColorInput.Text = anAccessory.AccessoryColor;
                                    }
                                    else
                                    {
                                        lblColorInput.CssClass = "removeElement";
                                        lblColor.CssClass = "removeElement";
                                    }

                                    if (anAccessory.AccessoryPackQuantity != 0)
                                    {
                                        txtPackQuantity.Text = anAccessory.AccessoryPackQuantity.ToString();
                                        rfvPackQuantity.ValidationGroup = "accessories";
                                        cmpPackQuantity.ValidationGroup = "accessories";
                                    }
                                    else
                                    {
                                        pnlPackQuantity.CssClass = "removeElement";
                                    }

                                    if (anAccessory.AccessoryWidth != 0)
                                    {
                                        lblAccessoryWidthUnits.Text = anAccessory.AccessoryWidthUnits;
                                        txtAccessoryWidth.Text = anAccessory.AccessoryWidth.ToString();
                                        rfvAccessoryWidth.ValidationGroup = "accessories";
                                        cmpAccessoryWidth.ValidationGroup = "accessories";
                                    }
                                    else
                                    {
                                        rowAccessoryMaxWidth.CssClass = "removeElement";
                                    }

                                    if (anAccessory.AccessoryLength != 0)
                                    {
                                        lblAccessoryLengthUnits.Text = anAccessory.AccessoryLengthUnits;
                                        txtAccessoryLength.Text = anAccessory.AccessoryLength.ToString();
                                        rfvAccessoryLength.ValidationGroup = "accessories";
                                        cmpAccessoryLength.ValidationGroup = "accessories";
                                    }
                                    else
                                    {
                                        rowAccessoryMaxLength.CssClass = "removeElement";
                                    }

                                    if (anAccessory.AccessorySize != 0)
                                    {
                                        lblAccessorySizeUnits.Text = anAccessory.AccessorySizeUnits;
                                        txtAccessorySize.Text = anAccessory.AccessorySize.ToString();
                                        rfvAccessorySize.ValidationGroup = "accessories";
                                        cmpAccessorySize.ValidationGroup = "accessories";
                                    }
                                    else
                                    {
                                        rowAccessorySize.CssClass = "removeElement";
                                    }

                                    txtUsdPrice.Text = anAccessory.AccessoryUsdPrice.ToString("N2");
                                    txtCadPrice.Text = anAccessory.AccessoryCadPrice.ToString("N2");

                                    if ((txtAccessoryLength.Text == "") && (txtAccessorySize.Text == "") && (txtAccessoryWidth.Text == ""))
                                    {
                                        pnlDimensions.CssClass = "removeElement";
                                    }

                                    if (anAccessory.AccessoryStatus)
                                    {
                                        radActive.Checked = true;
                                    }
                                    else
                                    {
                                        radInactive.Checked = true;
                                    }

                                    break;
                                #endregion
                                #region DecorativeColumn
                                //when tblDecorativeColumn is selected
                                case "tblDecorativeColumn":

                                    if (Session["decorativeColumn"] != null)
                                    {
                                        Session.Remove("decorativeColumn");
                                    }

                                    //show pnlDecorativeColumn
                                    pnlDecorativeColumn.CssClass = "dimensionsTable";

                                    //create DecorativeColumn object
                                    DecorativeColumn aColumn = new DecorativeColumn();

                                    //call select all function to populate object
                                    aColumn.Populate(aColumn.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                    //add DecorativeColumn Object to the session
                                    Session.Add("decorativeColumn", aColumn);

                                    //populate fields
                                    imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                    lblPartName.Text = aColumn.ColumnName;
                                    txtPartDesc.Text = aColumn.ColumnDescription;
                                    lblPartNum.Text = aColumn.PartNumber;
                                    lblColorInput.Text = aColumn.ColumnColor;
                                    txtRoofDecColLength.Text = aColumn.ColumnLength.ToString();
                                    lblRoofDecColLengthUnits.Text = aColumn.ColumnLengthUnits;

                                    rfvRoofDecColLength.ValidationGroup = "decorativeColumn";
                                    cmpRoofDecColLength.ValidationGroup = "decorativeColumn";

                                    txtUsdPrice.Text = aColumn.ColumnUsdPrice.ToString("N2");
                                    txtCadPrice.Text = aColumn.ColumnCadPrice.ToString("N2");

                                    if (aColumn.ColumnStatus)
                                    {
                                        radActive.Checked = true;
                                    }
                                    else
                                    {
                                        radInactive.Checked = true;
                                    }

                                    break;
                                #endregion
                                #region DoorFrameExtrusion
                                //when tblDoorFrameExtrusion is selected
                                case "tblDoorFrameExtrusion":

                                    if (Session["doorFrameExtrusion"] != null)
                                    {
                                        Session.Remove("doorFrameExtrusion");
                                    }

                                    //show pnlDoorFrameExtrusions
                                    pnlDoorFrameExtrusions.CssClass = "dimensionsTable";

                                    //create DoorFrameExtrusion object
                                    DoorFrameExtrusion aFrameExtrusion = new DoorFrameExtrusion();

                                    //call select all function to populate object
                                    aFrameExtrusion.Populate(aFrameExtrusion.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                    //add DoorFrameExtrusion Object to the session
                                    Session.Add("doorFrameExtrusion", aFrameExtrusion);

                                    //populate fields
                                    imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                    txtDoorFrExtMaxLength.Text = aFrameExtrusion.DfeMaxLength.ToString();
                                    lblDoorFrExtMaxLengthUnits.Text = aFrameExtrusion.DfeMaxLengthUnits.ToString();

                                    rfvDoorFrExtMaxLength.ValidationGroup = "doorFrameExtrusion";
                                    cmpDoorFrExtMaxLength.ValidationGroup = "doorFrameExtrusion";

                                    lblPartName.Text = aFrameExtrusion.DfeName;
                                    txtPartDesc.Text = aFrameExtrusion.DfeDescription;
                                    lblPartNum.Text = aFrameExtrusion.PartNumber;
                                    lblColorInput.Text = aFrameExtrusion.DfeColor;

                                    txtUsdPrice.Text = aFrameExtrusion.UsdPrice.ToString("N2");
                                    txtCadPrice.Text = aFrameExtrusion.CadPrice.ToString("N2");

                                    if (aFrameExtrusion.DfeStatus)
                                    {
                                        radActive.Checked = true;
                                    }
                                    else
                                    {
                                        radInactive.Checked = true;
                                    }

                                    break;
                                #endregion
                                #region InsulatedFloors
                                //when tblInsulatedFloors is selected
                                case "tblInsulatedFloors":

                                    if (Session["insulatedFloors"] != null)
                                    {
                                        Session.Remove("insulatedFloors");
                                    }

                                    //show pnlInsulatedFloors and pnlComposition
                                    pnlInsulatedFloors.CssClass = "dimensionsTable";
                                    pnlComposition.CssClass = "showPanelNoClass";
                                    lblColor.CssClass = "removeElement";
                                    lblColorInput.CssClass = "removeElement";

                                    //create InsulatedFloors object
                                    InsulatedFloors aFloor = new InsulatedFloors();

                                    //call select all function to populate object
                                    aFloor.Populate(aFloor.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                    //add InsulatedFloors Object to the session
                                    Session.Add("insulatedFloors", aFloor);

                                    //populate fields
                                    imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                    lblPartName.Text = aFloor.InsulatedFloorName;
                                    txtPartDesc.Text = aFloor.InsulatedFloorDescription;
                                    lblPartNum.Text = aFloor.PartNumber;
                                    txtComposition.Text = aFloor.InsulatedFloorComposition;
                                    txtInsFloorSize.Text = aFloor.InsulatedFloorSize.ToString();
                                    lblInsFloorSizeUnits.Text = aFloor.InsulatedFloorSizeUnits;
                                    txtInsFloorPnlMaxWidth.Text = aFloor.InsulatedFloorMaxWidth.ToString();
                                    lblInsFloorPnlMaxWidthUnits.Text = aFloor.InsulatedFloorMaxWidthUnits;

                                    rfvInsFloorSize.ValidationGroup = "insulatedFloors";
                                    cmpInsFloorSize.ValidationGroup = "insulatedFloors";
                                    rfvInsFloorPnlMaxWidth.ValidationGroup = "insulatedFloors";
                                    cmpInsFloorPnlMaxWidth.ValidationGroup = "insulatedFloors";

                                    txtUsdPrice.Text = aFloor.InsulatedFloorUsdPrice.ToString("N2");
                                    txtCadPrice.Text = aFloor.InsulatedFloorCadPrice.ToString("N2");

                                    if (aFloor.InsulatedFloorStatus)
                                    {
                                        radActive.Checked = true;
                                    }
                                    else
                                    {
                                        radInactive.Checked = true;
                                    }
                                    break;
                                #endregion
                                #region RoofPanels
                                //when tblRoofPanels is selected
                                case "tblRoofPanels":

                                    if (Session["roofPanels"] != null)
                                    {
                                        Session.Remove("roofPanels");
                                    }

                                    //show pnlRoofPanels and pnlStandard
                                    pnlStandard.CssClass = "showPanelNoClass";
                                    pnlComposition.CssClass = "showPanelNoClass";
                                    pnlRoofPanels.CssClass = "dimensionsTable";
                                    rowRoofPanelsMaxLength.CssClass = "removeElement";

                                    //create RoofPanels object
                                    RoofPanels aPanel = new RoofPanels();

                                    //call select all function to populate object
                                    aPanel.Populate(aPanel.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                    //add RoofPanels Object to the session
                                    Session.Add("roofPanels", aPanel);

                                    //populate fields
                                    imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                    lblPartName.Text = aPanel.PanelName;
                                    txtPartDesc.Text = aPanel.PanelDescription;
                                    txtStandard.Text = aPanel.PanelStandard;
                                    txtComposition.Text = aPanel.PanelComposition;
                                    lblPartNum.Text = aPanel.PartNumber;
                                    lblColorInput.Text = aPanel.PanelColor;

                                    txtRoofPnlMaxWidth.Text = aPanel.PanelMaxWidth.ToString();
                                    lblRoofPnlMaxWidthUnits.Text = aPanel.MaxWidthUnits;

                                    rfvRoofPnlMaxWidth.ValidationGroup = "roofPanels";
                                    cmpRoofPnlMaxWidth.ValidationGroup = "roofPanels";
                                    rfvRoofPnlSize.ValidationGroup = "roofPanels";
                                    cmpRoofPnlSize.ValidationGroup = "roofPanels";

                                    txtRoofPnlSize.Text = aPanel.PanelSize.ToString();
                                    lblRoofPnlSizeUnits.Text = aPanel.PanelSizeUnits;

                                    if (aPanel.PanelMaxLength != "Site Determined")
                                    {
                                        rowRoofPanelsMaxLengthStr.CssClass = "removeElement";
                                        rowRoofPanelsMaxLength.CssClass = "showElementNoClass";
                                        rfvRoofPnlMaxLength.ValidationGroup = "roofPanels";
                                        cmpRoofPnlMaxLength.ValidationGroup = "roofPanels";
                                    }

                                    txtUsdPrice.Text = aPanel.UsdPrice.ToString("N2");
                                    txtCadPrice.Text = aPanel.CadPrice.ToString("N2");

                                    if (aPanel.Status)
                                    {
                                        radActive.Checked = true;
                                    }
                                    else
                                    {
                                        radInactive.Checked = true;
                                    }
                                    break;
                                #endregion
                                #region ScreenRoll
                                case "tblScreenRoll":
                                    {
                                        if (Session["screenRoll"] != null)
                                        {
                                            Session.Remove("screenRoll");
                                        }
                                        pnlScreenRoll.CssClass = "dimensionsTable";
                                        lblColor.CssClass = "removeElement";
                                        lblColorInput.CssClass = "removeElement";

                                        //create ScreenRoll object
                                        ScreenRoll aScreenRoll = new ScreenRoll();

                                        //call select all function to populate object
                                        aScreenRoll.Populate(aScreenRoll.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //add RoofPanels Object to the session
                                        Session.Add("screenRoll", aScreenRoll);

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aScreenRoll.ScreenRollName;
                                        lblPartNum.Text = aScreenRoll.PartNumber;
                                        txtScreenRollWidth.Text = aScreenRoll.ScreenRollWidth.ToString();
                                        lblScreenRollWidthUnits.Text = aScreenRoll.ScreenRollWidthUnits.ToString();
                                        txtScreenRollLength.Text = aScreenRoll.ScreenRollLength.ToString();
                                        lblScreenRollLengthUnits.Text = aScreenRoll.ScreenRollLengthUnits.ToString();

                                        rfvScreenRollWidth.ValidationGroup = "screenRoll";
                                        cmpScreenRollWidth.ValidationGroup = "screenRoll";

                                        rfvScreenRollLength.ValidationGroup = "screenRoll";
                                        cmpScreenRollLength.ValidationGroup = "screenRoll";

                                        txtUsdPrice.Text = aScreenRoll.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aScreenRoll.CadPrice.ToString("N2");

                                        if (aScreenRoll.Status)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }

                                        break;
                                    }
                                #endregion
                                #region SuncrylicRoof
                                case "tblSuncrylicRoof":
                                    {
                                        if (Session["suncrylicRoof"] != null)
                                        {
                                            Session.Remove("suncrylicRoof");
                                        }

                                        //show pnlRoofExtrusion
                                        pnlSuncrylicRoof.CssClass = "dimensionsTable";

                                        //create RoofExtrusion object
                                        SuncrylicRoof aSunRoof = new SuncrylicRoof();

                                        //add RoofExtrusion Object to the session
                                        Session.Add("suncrylicRoof", aSunRoof);

                                        //call select all function to populate object
                                        aSunRoof.Populate(aSunRoof.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunRoof.SuncrylicName;
                                        txtPartDesc.Text = aSunRoof.SuncrylicDescription;
                                        lblPartNum.Text = aSunRoof.PartNumber;
                                        lblColorInput.Text = aSunRoof.SuncrylicColor;

                                        rowSunRoofMaxWidthStr.CssClass = "removeElement";

                                        if (aSunRoof.SuncrylicMaxLength != 0)
                                        {
                                            rowSunRoofMaxLengthStr.CssClass = "removeElement";
                                            rowSunRoofMaxLength.CssClass = "showElementNoClass";
                                            txtSunRoofMaxLength.Text = aSunRoof.SuncrylicMaxLength.ToString();
                                            lblSunRoofMaxLengthUnits.Text = aSunRoof.SuncrylicLengthUnits;
                                            rfvSunRoofMaxLength.ValidationGroup = "suncrylicRoof";
                                            cmpSunRoofMaxLength.ValidationGroup = "suncrylicRoof";
                                        }

                                        txtUsdPrice.Text = aSunRoof.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunRoof.CadPrice.ToString("N2");

                                        if (aSunRoof.Status)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }
                                        break;
                                    }
                                #endregion
                                #region VinylRoll
                                case "tblVinylRoll":
                                    {
                                        if (Session["vinylRoll"] != null)
                                        {
                                            Session.Remove("vinylRoll");
                                        }

                                        pnlDescription.CssClass = "removeElement";
                                        //show pnlRoofExtrusion
                                        pnlVinylRoll.CssClass = "dimensionsTable";

                                        //create RoofExtrusion object
                                        VinylRoll aVinylRoll = new VinylRoll();

                                        //add RoofExtrusion Object to the session
                                        Session.Add("vinylRoll", aVinylRoll);

                                        //call select all function to populate object
                                        aVinylRoll.Populate(aVinylRoll.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aVinylRoll.VinylRollName;
                                        lblPartNum.Text = aVinylRoll.PartNumber;
                                        lblColorInput.Text = aVinylRoll.VinylRollColor;

                                        rowVinylRollLength.CssClass = "removeElement";

                                        txtVinylRollWeight.Text = aVinylRoll.VinylRollWeight.ToString();
                                        lblVinylRollWeightUnits.Text = aVinylRoll.VinylRollWeightUnits;
                                        txtVinylRollWidth.Text = aVinylRoll.VinylRollWidth.ToString();
                                        lblVinylRollWidthUnits.Text = aVinylRoll.VinylRollWidthUnits;

                                        rfvVinylRollWidth.ValidationGroup = "vinylRoll";
                                        cmpVinylRollWidth.ValidationGroup = "vinylRoll";
                                        rfvVinylRollWeight.ValidationGroup = "vinylRoll";
                                        cmpVinylRollWeight.ValidationGroup = "vinylRoll";

                                        txtUsdPrice.Text = aVinylRoll.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aVinylRoll.CadPrice.ToString("N2");

                                        if (aVinylRoll.Status)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }
                                        break;
                                    }
                                #endregion
                                #region Sunrail300
                                case "tblSunrail300":
                                    {
                                        if (Session["sunrail300"] != null)
                                        {
                                            Session.Remove("sunrail300");
                                        }

                                        //show pnlRoofExtrusion
                                        pnlSunrail300.CssClass = "dimensionsTable";

                                        //create RoofExtrusion object
                                        Sunrail300 aSunrail300 = new Sunrail300();

                                        //add RoofExtrusion Object to the session
                                        Session.Add("sunrail300", aSunrail300);

                                        //call select all function to populate object
                                        aSunrail300.Populate(aSunrail300.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunrail300.Sunrail300Name;
                                        txtPartDesc.Text = aSunrail300.Sunrail300Description;
                                        lblPartNum.Text = aSunrail300.PartNumber;
                                        lblColorInput.Text = aSunrail300.Sunrail300Color;

                                        txtSun300MaxLengthFt.Text = aSunrail300.Sunrail300MaxLengthFeet.ToString();
                                        lblSun300MaxLengthFtUnits.Text = aSunrail300.Sunrail300MaxLengthFeetUnits;
                                        txtSun300PnlMaxLengthInch.Text = aSunrail300.Sunrail300MaxLengthInches.ToString();
                                        lblSun300PnlMaxLengthInchUnits.Text = aSunrail300.Sunrail300MaxLengthInchesUnits;

                                        rfvSun300MaxLengthFt.ValidationGroup = "sunrail300";
                                        cmpSun300MaxLengthFt.ValidationGroup = "sunrail300";
                                        cmpSun300PnlMaxLengthInch.ValidationGroup = "sunrail300";

                                        txtUsdPrice.Text = aSunrail300.Sunrail300UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunrail300.Sunrail300CadPrice.ToString("N2");

                                        if (aSunrail300.Sunrail300Status)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }
                                        break;
                                    }
                                #endregion
                                #region Sunrail300Accessories
                                case "tblSunrail300Accessories":
                                    {
                                        if (Session["sunrail300Acc"] != null)
                                        {
                                            Session.Remove("sunrail300Acc");
                                        }

                                        pnlDimensions.CssClass = "removeElement";

                                        //create RoofExtrusion object
                                        Sunrail300Accessories aSunrail300Acc = new Sunrail300Accessories();

                                        //add RoofExtrusion Object to the session
                                        Session.Add("sunrail300Acc", aSunrail300Acc);

                                        //call select all function to populate object
                                        aSunrail300Acc.Populate(aSunrail300Acc.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunrail300Acc.Sunrail300AccessoriesName;
                                        txtPartDesc.Text = aSunrail300Acc.Sunrail300AccessoriesDescription;
                                        lblPartNum.Text = aSunrail300Acc.PartNumber;
                                        lblColorInput.Text = aSunrail300Acc.Sunrail300AccessoriesColor;

                                        txtUsdPrice.Text = aSunrail300Acc.Sunrail300AccessoriesUsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunrail300Acc.Sunrail300AccessoriesCadPrice.ToString("N2");

                                        if (aSunrail300Acc.Sunrail300AccessoriesStatus)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }
                                        break;
                                    }
                                #endregion
                                #region Sunrail400
                                case "tblSunrail400":
                                    {
                                        if (Session["sunrail400"] != null)
                                        {
                                            Session.Remove("sunrail400");
                                        }

                                        //show pnlRoofExtrusion
                                        pnlSunrail400.CssClass = "dimensionsTable";

                                        //create RoofExtrusion object
                                        Sunrail400 aSunrail400 = new Sunrail400();

                                        //add RoofExtrusion Object to the session
                                        Session.Add("sunrail400", aSunrail400);

                                        //call select all function to populate object
                                        aSunrail400.Populate(aSunrail400.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunrail400.Sunrail400Name;
                                        txtPartDesc.Text = aSunrail400.Sunrail400Description;
                                        lblPartNum.Text = aSunrail400.PartNumber;
                                        lblColorInput.Text = aSunrail400.Sunrail400Color;

                                        txtSun400MaxLengthFt.Text = aSunrail400.Sunrail400MaxLengthFeet.ToString();
                                        lblSun400MaxLengthFtUnits.Text = aSunrail400.Sunrail400MaxLengthFeetUnits;
                                        txtSun400PnlMaxLengthInch.Text = aSunrail400.Sunrail400MaxLengthInches.ToString();
                                        lblSun400PnlMaxLengthInchUnits.Text = aSunrail400.Sunrail400MaxLengthInchesUnits;

                                        rfvSun400MaxLengthFt.ValidationGroup = "sunrail400";
                                        cmpSun400MaxLengthFt.ValidationGroup = "sunrail400";
                                        cmpSun400PnlMaxLengthInch.ValidationGroup = "sunrail400";

                                        txtUsdPrice.Text = aSunrail400.Sunrail400UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunrail400.Sunrail400CadPrice.ToString("N2");

                                        if (aSunrail400.Sunrail400Status)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }
                                        break;
                                    }
                                #endregion
                                #region Sunrail1000
                                case "tblSunrail1000":
                                    {
                                        if (Session["sunrail1000"] != null)
                                        {
                                            Session.Remove("sunrail1000");
                                        }

                                        //show pnlRoofExtrusion
                                        pnlSunrail1000.CssClass = "dimensionsTable";

                                        //create RoofExtrusion object
                                        Sunrail1000 aSunrail1000 = new Sunrail1000();

                                        //add RoofExtrusion Object to the session
                                        Session.Add("sunrail1000", aSunrail1000);

                                        //call select all function to populate object
                                        aSunrail1000.Populate(aSunrail1000.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aSunrail1000.Sunrail1000Name;
                                        txtPartDesc.Text = aSunrail1000.Sunrail1000Description;
                                        lblPartNum.Text = aSunrail1000.PartNumber;
                                        lblColorInput.Text = aSunrail1000.Sunrail1000Color;

                                        txtSun1000MaxLengthFt.Text = aSunrail1000.Sunrail1000MaxLengthFeet.ToString();
                                        lblSun1000MaxLengthFtUnits.Text = aSunrail1000.Sunrail1000MaxLengthFeetUnits;
                                        txtSun1000PnlMaxLengthInch.Text = aSunrail1000.Sunrail1000MaxLengthInches.ToString();
                                        lblSun1000PnlMaxLengthInchUnits.Text = aSunrail1000.Sunrail1000MaxLengthInchesUnits;

                                        rfvSun1000MaxLengthFt.ValidationGroup = "sunrail1000";
                                        cmpSun1000MaxLengthFt.ValidationGroup = "sunrail1000";
                                        cmpSun1000PnlMaxLengthInch.ValidationGroup = "sunrail1000";

                                        txtUsdPrice.Text = aSunrail1000.Sunrail1000UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aSunrail1000.Sunrail1000CadPrice.ToString("N2");

                                        if (aSunrail1000.Sunrail1000Status)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }
                                        break;
                                    }
                                #endregion
                                #region WallExtrusions
                                case "tblWallExtrusions":
                                    {
                                        if (Session["wallExtrusions"] != null)
                                        {
                                            Session.Remove("wallExtrusions");
                                        }

                                        //show pnlRoofExtrusion
                                        pnlWallExtrusions.CssClass = "dimensionsTable";

                                        //create RoofExtrusion object
                                        WallExtrusions aWallExtrusion = new WallExtrusions();

                                        //add RoofExtrusion Object to the session
                                        Session.Add("wallExtrusions", aWallExtrusion);

                                        //call select all function to populate object
                                        aWallExtrusion.Populate(aWallExtrusion.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aWallExtrusion.WallExtrusionName;
                                        txtPartDesc.Text = aWallExtrusion.WallExtrusionDescription;
                                        lblPartNum.Text = aWallExtrusion.PartNumber;
                                        lblColorInput.Text = aWallExtrusion.WallExtrusionColor;

                                        txtWallExtMaxLength.Text = aWallExtrusion.WallExtrusionMaxLength.ToString();
                                        lblWallExtMaxLengthUnits.Text = aWallExtrusion.LengthUnits;

                                        rfvWallExtMaxLength.ValidationGroup = "wallExtrusions";
                                        cmpWallExtMaxLength.ValidationGroup = "wallExtrusions";

                                        txtUsdPrice.Text = aWallExtrusion.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aWallExtrusion.CadPrice.ToString("N2");

                                        if (aWallExtrusion.Status)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }
                                        break;
                                    }
                                #endregion
                                #region WallPanels
                                case "tblWallPanels":
                                    {
                                        if (Session["wallPanels"] != null)
                                        {
                                            Session.Remove("wallPanels");
                                        }

                                        //show pnlRoofExtrusion
                                        pnlWallExtrusions.CssClass = "dimensionsTable";
                                        pnlComposition.CssClass = "showPanelNoClass";
                                        pnlStandard.CssClass = "showPanelNoClass";

                                        //create RoofExtrusion object
                                        WallPanels aWallPanel = new WallPanels();

                                        //add RoofExtrusion Object to the session
                                        Session.Add("wallPanels", aWallPanel);

                                        //call select all function to populate object
                                        aWallPanel.Populate(aWallPanel.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //populate fields
                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";
                                        lblPartName.Text = aWallPanel.WallPanelName;
                                        txtPartDesc.Text = aWallPanel.WallPanelDescription;
                                        txtStandard.Text = aWallPanel.WallPanelStandard;
                                        txtComposition.Text = aWallPanel.WallPanelComposition;
                                        lblPartNum.Text = aWallPanel.WallPanelNumber;
                                        lblColorInput.Text = aWallPanel.WallPanelColor;

                                        txtWallPnlSize.Text = aWallPanel.WallPanelSize.ToString();
                                        lblWallPnlSizeUnits.Text = aWallPanel.SizeUnits;

                                        txtWallPnlMaxLength.Text = aWallPanel.WallPanelMaxLength.ToString();
                                        lblWallPnlMaxLengthUnits.Text = aWallPanel.LengthUnits;

                                        txtWallPnlMaxWidth.Text = aWallPanel.WallPanelMaxWidth.ToString();
                                        lblWallPnlMaxWidthUnits.Text = aWallPanel.WidthUnits;

                                        txtUsdPrice.Text = aWallPanel.UsdPrice.ToString("N2");
                                        txtCadPrice.Text = aWallPanel.CadPrice.ToString("N2");

                                        if (aWallPanel.Status)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }
                                        break;
                                    }
                                #endregion
                                #region Schematics
                                case "tblSchematics":
                                    {
                                        if (Session["schematic"] != null)
                                        {
                                            Session.Remove("schematic");
                                        }

                                        if (Session["part"] != null)
                                        {
                                            Session.Remove("part");
                                        }

                                        rowPart1.CssClass = "removeElement";
                                        rowPart1Val.CssClass = "removeElement";
                                        rowPart2.CssClass = "removeElement";
                                        rowPart2Val.CssClass = "removeElement";
                                        rowPart3.CssClass = "removeElement";
                                        rowPart3Val.CssClass = "removeElement";
                                        rowPart4.CssClass = "removeElement";
                                        rowPart4Val.CssClass = "removeElement";
                                        rowPart5.CssClass = "removeElement";
                                        rowPart5Val.CssClass = "removeElement";
                                        rowPart6.CssClass = "removeElement";
                                        rowPart6Val.CssClass = "removeElement";
                                        rowPart7.CssClass = "removeElement";
                                        rowPart7Val.CssClass = "removeElement";
                                        rowPart8.CssClass = "removeElement";
                                        rowPart8Val.CssClass = "removeElement";
                                        rowPart9.CssClass = "removeElement";
                                        rowPart9Val.CssClass = "removeElement";
                                        rowPart10.CssClass = "removeElement";
                                        rowPart10Val.CssClass = "removeElement";
                                        rowPart11.CssClass = "removeElement";
                                        rowPart11Val.CssClass = "removeElement";
                                        rowPart12.CssClass = "removeElement";
                                        rowPart12Val.CssClass = "removeElement";
                                        rowPart13.CssClass = "removeElement";
                                        rowPart13Val.CssClass = "removeElement";
                                        rowPart14.CssClass = "removeElement";
                                        rowPart14Val.CssClass = "removeElement";
                                        rowPart15.CssClass = "removeElement";
                                        rowPart15Val.CssClass = "removeElement";
                                        rowPart16.CssClass = "removeElement";
                                        rowPart16Val.CssClass = "removeElement";
                                        rowPart17.CssClass = "removeElement";
                                        rowPart17Val.CssClass = "removeElement";
                                        rowPart18.CssClass = "removeElement";
                                        rowPart18Val.CssClass = "removeElement";
                                        rowPart19.CssClass = "removeElement";
                                        rowPart19Val.CssClass = "removeElement";
                                        rowPart20.CssClass = "removeElement";
                                        rowPart20Val.CssClass = "removeElement";
                                        rowPart21.CssClass = "removeElement";
                                        rowPart21Val.CssClass = "removeElement";
                                        rowPart22.CssClass = "removeElement";
                                        rowPart22Val.CssClass = "removeElement";
                                        rowPart23.CssClass = "removeElement";
                                        rowPart23Val.CssClass = "removeElement";

                                        lblSchemPartNum.CssClass = "removeElement";
                                        lblSchemPartKey.CssClass = "removeElement";
                                        lblSchemPartKeyNum.CssClass = "removeElement";
                                        lblSchemPartName.CssClass = "removeElement";

                                        lblColor.CssClass = "removeElement";
                                        lblColorInput.CssClass = "removeElement";
                                        pnlDimensions.CssClass = "removeElement";
                                        pnlPricing.CssClass = "removeElement";

                                        //show pnlSchematics and pricingSchemTable
                                        pnlSchematics.CssClass = "showElementNoClass";
                                        pnlPricingSchematics.CssClass = "pnlPricing";

                                        imgPart.ImageUrl = "Images/catalogue/" + Session["partNumber"].ToString() + ".jpg";

                                        //create Schematics object
                                        Schematics aSchematic = new Schematics();

                                        //call select all function to populate object
                                        aSchematic.Populate(aSchematic.SelectAll(datUpdateDataSource, Session["tableName"].ToString(), Session["partNumber"].ToString()));

                                        //add RoofPanels Object to the session
                                        Session.Add("schematic", aSchematic);

                                        //populate fields

                                        //set up a dataview object for object member data
                                        System.Data.DataView aPartsTable = new System.Data.DataView();

                                        //select row based on table name and part number
                                        datUpdateDataSource.SelectCommand = "SELECT partNumber FROM tblSchematicParts WHERE schematicNumber='" + Session["partNumber"] + "' ORDER BY keyNumber ASC";

                                        //assign the row to the dataview object
                                        aPartsTable = (System.Data.DataView)datUpdateDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                                        ddlSchem.Items.Clear();
                                        ddlSchem.Items.Add("");

                                        for (int i = 0; i < aPartsTable.Count; i++)
                                        {
                                            ddlSchem.Items.Add(aPartsTable[i][0].ToString());
                                        }

                                        lblPartName.Text = aSchematic.SchematicName.ToString();
                                        txtPartDesc.Text = aSchematic.SchematicDescription.ToString();
                                        lblPartNum.Text = aSchematic.SchematicNumber.ToString();

                                        txtUsdPriceSchematic.Text = aSchematic.SchematicUsdPrice.ToString("N2");
                                        txtCadPriceSchematic.Text = aSchematic.SchematicCadPrice.ToString("N2");
                                        rfvSchemWholeUsd.ValidationGroup = "pricing";
                                        cmpSchemWholeUsd.ValidationGroup = "pricing";
                                        rfvSchemWholeCad.ValidationGroup = "pricing";
                                        cmpSchemWholeCad.ValidationGroup = "pricing";

                                        if (aSchematic.SchematicStatus)
                                        {
                                            radActive.Checked = true;
                                        }
                                        else
                                        {
                                            radInactive.Checked = true;
                                        }
                                        break;
                                #endregion
                                    }

                            }
                        #endregion
                        }
                    }
                }
            }
            /*
            if (Session["backToUpdate"] != null)
            {
                imgPart.ImageUrl = "Images/catalogue/temp.jpg";
                System.IO.File.Delete(Server.MapPath("Images/catalogue/temp.jpg"));
                Session.Remove("backToUpdate");
            }
             * */
        }