Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Roof            aRoof                = (Roof)Session["completedRoof"];
            RoofModule      aRoofModule          = aRoof.RoofModules[0];
            RoofModule      aGableModule         = aRoof.RoofModules[1];
            List <RoofItem> aRoofModuleItemList  = aRoofModule.RoofItems;
            List <RoofItem> aGableModuleItemList = aGableModule.RoofItems;

            Label aLabel = new Label();

            aLabel.Text = "Roof is of sizes: Projection: " + aRoof.Projection + ", Width: " + aRoof.Width;
            testHolder.Controls.Add(aLabel);
            testHolder.Controls.Add(new LiteralControl("<br/><br/>"));

            for (int i = 0; i < aRoofModuleItemList.Count; i++)
            {
                aLabel      = new Label();
                aLabel.Text = "Type: " + aRoofModuleItemList[i].ItemType + ", Projection: " + aRoofModuleItemList[i].Projection + ", Width: " + aRoofModuleItemList[i].Width;
                testHolder.Controls.Add(aLabel);
                testHolder.Controls.Add(new LiteralControl("<br/>"));
            }

            testHolder.Controls.Add(new LiteralControl("<br/><br/>"));

            for (int i = 0; i < aGableModuleItemList.Count; i++)
            {
                aLabel      = new Label();
                aLabel.Text = "Type: " + aGableModuleItemList[i].ItemType + ", Projection: " + aGableModuleItemList[i].Projection + ", Width: " + aGableModuleItemList[i].Width;
                testHolder.Controls.Add(aLabel);
                testHolder.Controls.Add(new LiteralControl("<br/>"));
            }
        }
Example #2
0
        protected void btnQuestion1_Click(object sender, EventArgs e)
        {
            Roof aRoof = (Roof)Session["completedRoof"];
            List <RoofModule> moduleList = aRoof.RoofModules;

            //Array of panel sizes which will be passed to javascript
            List <float> panelSizeArray  = new List <float>();
            int          panelsProcessed = 0;
            int          numberOfPanels  = 0;

            //Loop for each roof module
            for (int i = 0; i < aRoof.RoofModules.Count; i++)
            {
                //At i's roof module, loop for all roof items to find number of panels
                for (int j = 0; j < aRoof.RoofModules[i].RoofItems.Count(); j++)
                {
                    if (aRoof.RoofModules[i].RoofItems[j].ItemType.Contains("Panel"))
                    {
                        numberOfPanels++;
                        panelSizeArray.Add(aRoof.RoofModules[i].RoofItems[j].Width);
                    }
                }
                for (int j = 0; j < numberOfPanels; j++)
                {
                    panelsProcessed++;

                    if (Request.Form["MainContent_hidHasBeam" + panelsProcessed] == "Yes")
                    {
                        aRoof.RoofModules[i].RoofItems[j].FanBeam = Convert.ToSingle(Request.Form["MainContent_hidBeamStart" + panelsProcessed]);
                    }
                    if (Request.Form["MainContent_hidHasSkylight" + panelsProcessed] == "Yes")
                    {
                        aRoof.RoofModules[i].RoofItems[j].FanBeam = Convert.ToSingle(Request.Form["MainContent_hidSkylightStart" + panelsProcessed]);
                    }
                }
            }

            Session["completedRoof"] = aRoof;
            if (Session["newProjectPrefabFloor"].ToString() == "Yes")
            {
                Response.Redirect("WizardFloors.aspx");
            }
            else
            {
                Response.Redirect("ProjectPreview.aspx");
            }
        }
Example #3
0
        //
        protected void btnFinalButton_Click(object sender, EventArgs e)
        {
            //Check roof type
            //Get room projection and width from session and set our roofs projection and width to those
            float roofProjection = Convert.ToSingle(Session["sunroomProjection"]);
            float roofProjection1 = Convert.ToSingle(Session["sunroomProjection"]);
            float roofProjection2 = Convert.ToSingle(Session["sunroomProjection"]);
            float roofWidth = Convert.ToSingle(Session["sunroomWidth"]);

            //We also get slope of room, and soffit length
            float roofSlope = Convert.ToSingle(Session["roofSlope"]);
            float soffitLength = Convert.ToSingle(Session["soffitLength"]);

            Session.Add("roofLedgerSetback", hidLedgerSetback.Value);
            Session.Add("roofFrontSetback", hidFrontSetback.Value);
            Session.Add("roofSidesSetback", hidSidesSetback.Value);
            Session.Add("roofJointSetback", hidJointSetback.Value);

            #region Gable System
            //if gable, we need two studio roof systems and additional logic
            if (Session["newProjectRoofType"] == "Dealer Gable" || Session["newProjectRoofType"] == "Sunspace Gable")
            {
                #region Old Symmetrical Gable Code
                ////If they've entered manual dimensions, we don't need to calculate overhang
                //if (hidProjection.Value != "")
                //{
                //    //However, if its smaller than the room, we need to throw an error
                //    if (Convert.ToSingle(hidProjection.Value) >= roofProjection)
                //    {
                //        //Since its valid, just set our sizes to the specified
                //        roofProjection = Convert.ToSingle(hidProjection.Value);
                //        roofWidth = Convert.ToSingle(hidWidth.Value);
                //    }
                //}
                //else
                //{
                //    roofProjection += (Convert.ToSingle(hidOverhang.Value) * 2);
                //    roofWidth += (Convert.ToSingle(hidOverhang.Value) * 2);
                //}

                ////Convert the room projection into actual roof projection
                //roofProjection = (float)Math.Sqrt(Math.Pow(2*roofProjection, 2));
                //roofProjection /= 2; //divide by 2 for each part of a gable

                ////Convert to nearest eighth inch
                //roofProjection *= 8;
                //int intRoofProjection = Convert.ToInt32(roofProjection);
                //roofProjection = intRoofProjection / 8f;
                //roofProjection *= 2; //remultiply to get whole projection

                //Now that we have roof rojection and width, add it to session.
                //Session.Add("roofProjection", (roofProjection));
                //Session.Add("roofWidth", roofWidth);
                #endregion

                List<Wall> listOfWalls = (List<Wall>)Session["listOfWalls"];

                //Loop through walls to find gable post
                for (int i = 0; i < listOfWalls.Count; i++)
                {
                    float foundBoxHeaderReceiver = 0f;
                    BoxHeader aBoxHeader = null;

                    for (int j = 0; j < listOfWalls[i].LinearItems.Count; j++)
                    {
                        if (listOfWalls[i].LinearItems[j].ItemType == "BoxHeader")
                        {
                            aBoxHeader = (BoxHeader)listOfWalls[i].LinearItems[j];
                            if (aBoxHeader.IsReceiver == true)
                            {
                                foundBoxHeaderReceiver = aBoxHeader.FixedLocation;
                                break;
                            }
                        }
                    }

                    //If start != end, it's part of a sloped front wall on Dealer Gables
                    if (listOfWalls[i].StartHeight < listOfWalls[i].EndHeight)
                    {
                        //roofProjection1 = Convert.ToSingle(hidOverhang.Value) + listOfWalls[i].Length + 2.125f;
                        //roofProjection2 = Convert.ToSingle(hidOverhang.Value) + listOfWalls[i+1].Length + 2.125f;
                        break;
                    }

                    //If it found a boxheader receiever, then it is the gable-frontwall of a sunspace gable
                    if (foundBoxHeaderReceiver > 0f)
                    {
                        //a^2 + b^2 = c^2, +overhang value, gives projection of a roof panel

                        roofProjection1 = GlobalFunctions.RoundDownToNearestEighthInch(Convert.ToSingle(hidOverhang.Value) + (float)Math.Sqrt((float)Math.Pow((foundBoxHeaderReceiver + (aBoxHeader.Length/2)),2) + (float)Math.Pow(listOfWalls[i].GablePeak - listOfWalls[i].StartHeight, 2)));
                        roofProjection2 = GlobalFunctions.RoundDownToNearestEighthInch(Convert.ToSingle(hidOverhang.Value) + (float)Math.Sqrt((float)Math.Pow((listOfWalls[i].Length - (aBoxHeader.Length / 2) - foundBoxHeaderReceiver), 2) + (float)Math.Pow(listOfWalls[i].GablePeak - listOfWalls[i].StartHeight, 2)));
                        break;
                    }
                }

                Session.Add("roofProjection1", (roofProjection1));
                Session.Add("roofProjection2", (roofProjection2));
                Session.Add("roofWidth", roofWidth);

                //A studio roof will only have one list entry, while a gable will have two
                List<RoofModule> gableModules = buildGableRoofModule(roofProjection1, roofProjection2, roofWidth);

                bool isFireProtected = false;
                bool isThermadeck = false;
                bool hasGutters = false;
                bool gutterPro = false;

                if (hidPanelType.Value.Contains("FP") && hidSystem.Value == "Traditional")
                {
                    isFireProtected = true;
                }

                if (hidSystem.Value == "Thermadeck")
                {
                    if (chkBarrier.Checked == true)
                    {
                        isFireProtected = true;
                    }
                    isThermadeck = true;
                }

                if (hidGutterPresence.Value == "Yes")
                {
                    hasGutters = true;
                }

                if (hidGutterPro.Value == "Yes")
                {
                    gutterPro = true;
                }

                string gutterColour = hidGutterColour.Value;
                if (hasGutters == false)
                {
                    gutterColour = "NA";
                }

                if (hidExtraDownspouts.Value == "")
                {
                    hidExtraDownspouts.Value = "0";
                }

                //changeme hardcoded supports to 0
                Roof aRoof = new Roof("Dealer Gable", hidInteriorRoofSkin.Value, hidExteriorRoofSkin.Value, Convert.ToSingle(hidThickness.Value), isFireProtected, isThermadeck, hasGutters, gutterPro, gutterColour, hidStripeColour.Value, hidAcrylicColour.Value, 0, Convert.ToInt32(hidExtraDownspouts.Value), roofProjection, roofWidth, gableModules);
                Session.Add("completedRoof", aRoof);

                Response.Redirect("SkylightWizard.aspx");
            }
            #endregion

            #region Studio System
            //studio system
            else
            {
                //Subtract soffit length as that will be the true start point of the roof
                roofProjection -= Convert.ToSingle(Session["soffitLength"]);

                //If they've entered manual dimensions, we don't need to calculate overhang
                if (hidProjection.Value != "")
                {
                    //However, if its smaller than the room, we need to throw an error
                    if (Convert.ToSingle(hidProjection.Value) >= roofProjection)
                    {
                        //Since its valid, just set our sizes to the specified
                        roofProjection = Convert.ToSingle(hidProjection.Value);
                        roofWidth = Convert.ToSingle(hidWidth.Value);
                    }
                }
                else
                {
                    roofProjection += (Convert.ToSingle(hidOverhang.Value));
                    roofWidth += (Convert.ToSingle(hidOverhang.Value) * 2);
                }

                //Convert the room projection into actual roof projection
                float actualSlope = (Convert.ToSingle(Session["roofSlope"])) / 12;
                float roofRise = actualSlope * roofProjection;

                roofProjection = (float)Math.Sqrt(Math.Pow(roofRise,2) + Math.Pow(roofProjection, 2));

                //Convert to nearest eighth inch
                roofProjection *= 8;
                int intRoofProjection = Convert.ToInt32(roofProjection);
                roofProjection = intRoofProjection/8f;

                //Now that we have roof rojection and width, add it to session.
                Session.Add("roofProjection", roofProjection);
                Session.Add("roofWidth", roofWidth);

                //A studio roof will only have one list entry, while a gable will have two
                List<RoofModule> aModuleList = new List<RoofModule>();
                aModuleList.Add(buildStudioRoofModule(roofProjection, roofWidth));

                bool isFireProtected = false;
                bool isThermadeck = false;
                bool hasGutters = false;
                bool gutterPro = false;

                if (hidPanelType.Value.Contains("FP") && hidSystem.Value == "Traditional")
                {
                    isFireProtected = true;
                }

                if (hidSystem.Value == "Thermadeck")
                {
                    if (chkBarrier.Checked == true)
                    {
                        isFireProtected = true;
                    }
                    isThermadeck = true;
                }

                if (hidGutterPresence.Value == "Yes")
                {
                    hasGutters = true;
                }

                if (hidGutterPro.Value == "Yes")
                {
                    gutterPro = true;
                }

                string gutterColour = hidGutterColour.Value;
                if (hasGutters == false)
                {
                    gutterColour = "NA";
                }

                if (hidExtraDownspouts.Value == "")
                {
                    hidExtraDownspouts.Value = "0";
                }

                //changeme hardcoded supports to 0
                Roof aRoof = new Roof("Studio", hidInteriorRoofSkin.Value, hidExteriorRoofSkin.Value, Convert.ToSingle(hidThickness.Value), isFireProtected, isThermadeck, hasGutters, gutterPro, gutterColour, hidStripeColour.Value, hidAcrylicColour.Value, 0, Convert.ToInt32(hidExtraDownspouts.Value), roofProjection, roofWidth, aModuleList);
                Session.Add("completedRoof", aRoof);

                Response.Redirect("SkylightWizard.aspx");
            }
            #endregion
        }
Example #4
0
        protected void btnFinalButton_Click(object sender, EventArgs e)//
        {
            //Check roof type
            //Get room projection and width from session and set our roofs projection and width to those
            float roofProjection  = Convert.ToSingle(Session["sunroomProjection"]);
            float roofProjection1 = Convert.ToSingle(Session["sunroomProjection"]);
            float roofProjection2 = Convert.ToSingle(Session["sunroomProjection"]);
            float roofWidth       = Convert.ToSingle(Session["sunroomWidth"]);

            //We also get slope of room, and soffit length
            float roofSlope    = Convert.ToSingle(Session["roofSlope"]);
            float soffitLength = Convert.ToSingle(Session["soffitLength"]);

            Session.Add("roofLedgerSetback", hidLedgerSetback.Value);
            Session.Add("roofFrontSetback", hidFrontSetback.Value);
            Session.Add("roofSidesSetback", hidSidesSetback.Value);
            Session.Add("roofJointSetback", hidJointSetback.Value);

            #region Gable System
            //if gable, we need two studio roof systems and additional logic
            if (Session["newProjectRoofType"] == "Dealer Gable" || Session["newProjectRoofType"] == "Sunspace Gable")
            {
                #region Old Symmetrical Gable Code
                ////If they've entered manual dimensions, we don't need to calculate overhang
                //if (hidProjection.Value != "")
                //{
                //    //However, if its smaller than the room, we need to throw an error
                //    if (Convert.ToSingle(hidProjection.Value) >= roofProjection)
                //    {
                //        //Since its valid, just set our sizes to the specified
                //        roofProjection = Convert.ToSingle(hidProjection.Value);
                //        roofWidth = Convert.ToSingle(hidWidth.Value);
                //    }
                //}
                //else
                //{
                //    roofProjection += (Convert.ToSingle(hidOverhang.Value) * 2);
                //    roofWidth += (Convert.ToSingle(hidOverhang.Value) * 2);
                //}

                ////Convert the room projection into actual roof projection
                //roofProjection = (float)Math.Sqrt(Math.Pow(2*roofProjection, 2));
                //roofProjection /= 2; //divide by 2 for each part of a gable

                ////Convert to nearest eighth inch
                //roofProjection *= 8;
                //int intRoofProjection = Convert.ToInt32(roofProjection);
                //roofProjection = intRoofProjection / 8f;
                //roofProjection *= 2; //remultiply to get whole projection

                //Now that we have roof rojection and width, add it to session.
                //Session.Add("roofProjection", (roofProjection));
                //Session.Add("roofWidth", roofWidth);
                #endregion

                List <Wall> listOfWalls = (List <Wall>)Session["listOfWalls"];

                //Loop through walls to find gable post
                for (int i = 0; i < listOfWalls.Count; i++)
                {
                    float     foundBoxHeaderReceiver = 0f;
                    BoxHeader aBoxHeader             = null;

                    for (int j = 0; j < listOfWalls[i].LinearItems.Count; j++)
                    {
                        if (listOfWalls[i].LinearItems[j].ItemType == "BoxHeader")
                        {
                            aBoxHeader = (BoxHeader)listOfWalls[i].LinearItems[j];
                            if (aBoxHeader.IsReceiver == true)
                            {
                                foundBoxHeaderReceiver = aBoxHeader.FixedLocation;
                                break;
                            }
                        }
                    }

                    //If start != end, it's part of a sloped front wall on Dealer Gables
                    if (listOfWalls[i].StartHeight < listOfWalls[i].EndHeight)
                    {
                        //roofProjection1 = Convert.ToSingle(hidOverhang.Value) + listOfWalls[i].Length + 2.125f;
                        //roofProjection2 = Convert.ToSingle(hidOverhang.Value) + listOfWalls[i+1].Length + 2.125f;
                        break;
                    }

                    //If it found a boxheader receiever, then it is the gable-frontwall of a sunspace gable
                    if (foundBoxHeaderReceiver > 0f)
                    {
                        //a^2 + b^2 = c^2, +overhang value, gives projection of a roof panel

                        roofProjection1 = GlobalFunctions.RoundDownToNearestEighthInch(Convert.ToSingle(hidOverhang.Value) + (float)Math.Sqrt((float)Math.Pow((foundBoxHeaderReceiver + (aBoxHeader.Length / 2)), 2) + (float)Math.Pow(listOfWalls[i].GablePeak - listOfWalls[i].StartHeight, 2)));
                        roofProjection2 = GlobalFunctions.RoundDownToNearestEighthInch(Convert.ToSingle(hidOverhang.Value) + (float)Math.Sqrt((float)Math.Pow((listOfWalls[i].Length - (aBoxHeader.Length / 2) - foundBoxHeaderReceiver), 2) + (float)Math.Pow(listOfWalls[i].GablePeak - listOfWalls[i].StartHeight, 2)));
                        break;
                    }
                }

                Session.Add("roofProjection1", (roofProjection1));
                Session.Add("roofProjection2", (roofProjection2));
                Session.Add("roofWidth", roofWidth);

                //A studio roof will only have one list entry, while a gable will have two
                List <RoofModule> gableModules = buildGableRoofModule(roofProjection1, roofProjection2, roofWidth);

                bool isFireProtected = false;
                bool isThermadeck    = false;
                bool hasGutters      = false;
                bool gutterPro       = false;

                if (hidPanelType.Value.Contains("FP") && hidSystem.Value == "Traditional")
                {
                    isFireProtected = true;
                }

                if (hidSystem.Value == "Thermadeck")
                {
                    if (chkBarrier.Checked == true)
                    {
                        isFireProtected = true;
                    }
                    isThermadeck = true;
                }

                if (hidGutterPresence.Value == "Yes")
                {
                    hasGutters = true;
                }

                if (hidGutterPro.Value == "Yes")
                {
                    gutterPro = true;
                }

                string gutterColour = hidGutterColour.Value;
                if (hasGutters == false)
                {
                    gutterColour = "NA";
                }

                if (hidExtraDownspouts.Value == "")
                {
                    hidExtraDownspouts.Value = "0";
                }

                //changeme hardcoded supports to 0
                Roof aRoof = new Roof("Dealer Gable", hidInteriorRoofSkin.Value, hidExteriorRoofSkin.Value, Convert.ToSingle(hidThickness.Value), isFireProtected, isThermadeck, hasGutters, gutterPro, gutterColour, hidStripeColour.Value, hidAcrylicColour.Value, 0, Convert.ToInt32(hidExtraDownspouts.Value), roofProjection, roofWidth, gableModules);
                Session.Add("completedRoof", aRoof);

                Response.Redirect("SkylightWizard.aspx");
            }
            #endregion

            #region Studio System
            //studio system
            else
            {
                //Subtract soffit length as that will be the true start point of the roof
                roofProjection -= Convert.ToSingle(Session["soffitLength"]);

                //If they've entered manual dimensions, we don't need to calculate overhang
                if (hidProjection.Value != "")
                {
                    //However, if its smaller than the room, we need to throw an error
                    if (Convert.ToSingle(hidProjection.Value) >= roofProjection)
                    {
                        //Since its valid, just set our sizes to the specified
                        roofProjection = Convert.ToSingle(hidProjection.Value);
                        roofWidth      = Convert.ToSingle(hidWidth.Value);
                    }
                }
                else
                {
                    roofProjection += (Convert.ToSingle(hidOverhang.Value));
                    roofWidth      += (Convert.ToSingle(hidOverhang.Value) * 2);
                }

                //Convert the room projection into actual roof projection
                float actualSlope = (Convert.ToSingle(Session["roofSlope"])) / 12;
                float roofRise    = actualSlope * roofProjection;

                roofProjection = (float)Math.Sqrt(Math.Pow(roofRise, 2) + Math.Pow(roofProjection, 2));

                //Convert to nearest eighth inch
                roofProjection *= 8;
                int intRoofProjection = Convert.ToInt32(roofProjection);
                roofProjection = intRoofProjection / 8f;

                //Now that we have roof rojection and width, add it to session.
                Session.Add("roofProjection", roofProjection);
                Session.Add("roofWidth", roofWidth);

                //A studio roof will only have one list entry, while a gable will have two
                List <RoofModule> aModuleList = new List <RoofModule>();
                aModuleList.Add(buildStudioRoofModule(roofProjection, roofWidth));

                bool isFireProtected = false;
                bool isThermadeck    = false;
                bool hasGutters      = false;
                bool gutterPro       = false;

                if (hidPanelType.Value.Contains("FP") && hidSystem.Value == "Traditional")
                {
                    isFireProtected = true;
                }

                if (hidSystem.Value == "Thermadeck")
                {
                    if (chkBarrier.Checked == true)
                    {
                        isFireProtected = true;
                    }
                    isThermadeck = true;
                }

                if (hidGutterPresence.Value == "Yes")
                {
                    hasGutters = true;
                }

                if (hidGutterPro.Value == "Yes")
                {
                    gutterPro = true;
                }

                string gutterColour = hidGutterColour.Value;
                if (hasGutters == false)
                {
                    gutterColour = "NA";
                }

                if (hidExtraDownspouts.Value == "")
                {
                    hidExtraDownspouts.Value = "0";
                }

                //changeme hardcoded supports to 0
                Roof aRoof = new Roof("Studio", hidInteriorRoofSkin.Value, hidExteriorRoofSkin.Value, Convert.ToSingle(hidThickness.Value), isFireProtected, isThermadeck, hasGutters, gutterPro, gutterColour, hidStripeColour.Value, hidAcrylicColour.Value, 0, Convert.ToInt32(hidExtraDownspouts.Value), roofProjection, roofWidth, aModuleList);
                Session.Add("completedRoof", aRoof);

                Response.Redirect("SkylightWizard.aspx");
            }
            #endregion
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Roof aRoof = (Roof)Session["completedRoof"];
                List <RoofModule> moduleList = aRoof.RoofModules;

                //Array of panel sizes which will be passed to javascript
                List <float> panelSizeArray  = new List <float>();
                int          panelsProcessed = 0;
                int          numberOfPanels  = 0;
                //Loop for each roof module
                for (int i = 0; i < aRoof.RoofModules.Count; i++)
                {
                    //At i's roof module, loop for all roof items to find number of panels
                    for (int j = 0; j < aRoof.RoofModules[i].RoofItems.Count(); j++)
                    {
                        if (aRoof.RoofModules[i].RoofItems[j].ItemType.Contains("Panel"))
                        {
                            numberOfPanels++;
                            panelSizeArray.Add(aRoof.RoofModules[i].RoofItems[j].Width);
                        }
                    }
                    for (int j = 0; j < numberOfPanels; j++)
                    {
                        panelsProcessed++;
                        //Add all the controls a panel will need
                        RadioButton aRadioButton = new RadioButton();
                        aRadioButton.ID        = "radPanel" + (panelsProcessed);
                        aRadioButton.GroupName = "question1";
                        aRadioButton.Attributes.Add("OnClick", "skylightWizardCheckQuestion1()");

                        Label radioLabel = new Label();
                        radioLabel.ID = "lblPanel" + (panelsProcessed) + "Radio";
                        radioLabel.AssociatedControlID = "radPanel" + (panelsProcessed);

                        Label textLabel = new Label();
                        textLabel.ID = "lblPanel" + (panelsProcessed);
                        textLabel.AssociatedControlID = "radPanel" + (panelsProcessed);
                        textLabel.Text = "Panel " + (panelsProcessed) + " - " + panelSizeArray[j].ToString();

                        panelOptionPlaceholder.Controls.Add(new LiteralControl("<li>"));
                        panelOptionPlaceholder.Controls.Add(aRadioButton);
                        panelOptionPlaceholder.Controls.Add(radioLabel);
                        panelOptionPlaceholder.Controls.Add(textLabel);

                        panelOptionPlaceholder.Controls.Add(new LiteralControl("<div class=\"toggleContent\">"));
                        panelOptionPlaceholder.Controls.Add(new LiteralControl("<ul>"));

                        //Add controls for each panel here, inside LI /LI tags
                        panelOptionPlaceholder.Controls.Add(new LiteralControl("<li>"));

                        CheckBox chkFanBeam = new CheckBox();
                        chkFanBeam.ID = "chkFanBeam" + panelsProcessed;
                        chkFanBeam.Attributes.Add("OnClick", "skylightWizardCheckQuestion1()");
                        panelOptionPlaceholder.Controls.Add(chkFanBeam);

                        Label lblFanBeamCheck = new Label();
                        lblFanBeamCheck.ID = "lblFanBeamCheck" + panelsProcessed;
                        lblFanBeamCheck.AssociatedControlID = "chkFanBeam" + panelsProcessed;
                        panelOptionPlaceholder.Controls.Add(lblFanBeamCheck);

                        Label lblFanBeam = new Label();
                        lblFanBeam.ID   = "lblFanBeam" + panelsProcessed;
                        lblFanBeam.Text = "Fan Beam";
                        //lblFanBeam.ToolTip = "The fan beam, as the name implies, is a beam that runs along projection of the roof panel in order to have a fan attached. It may be anywhere along the width of the panel as long as it is 12 inches away from either edge.";
                        lblFanBeam.AssociatedControlID = "chkFanBeam" + panelsProcessed;
                        panelOptionPlaceholder.Controls.Add(lblFanBeam);

                        panelOptionPlaceholder.Controls.Add(new LiteralControl("<br/>"));

                        Label lblFanBeamPosition = new Label();
                        lblFanBeamPosition.ID   = "lblFanBeamPosition" + panelsProcessed;
                        lblFanBeamPosition.Text = "Start Width:";
                        panelOptionPlaceholder.Controls.Add(lblFanBeamPosition);

                        TextBox txtFanBeam = new TextBox();
                        txtFanBeam.ID        = "txtFanBeam" + panelsProcessed;
                        txtFanBeam.MaxLength = 3;
                        txtFanBeam.CssClass  = "txtField txtInput";
                        txtFanBeam.Attributes.Add("onkeyup", "skylightWizardCheckQuestion1()");
                        txtFanBeam.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
                        panelOptionPlaceholder.Controls.Add(txtFanBeam);

                        DropDownList ddlFanBeamInches = new DropDownList();
                        ddlFanBeamInches.Items.Add(lst0);
                        ddlFanBeamInches.Items.Add(lst18);
                        ddlFanBeamInches.Items.Add(lst14);
                        ddlFanBeamInches.Items.Add(lst38);
                        ddlFanBeamInches.Items.Add(lst12);
                        ddlFanBeamInches.Items.Add(lst58);
                        ddlFanBeamInches.Items.Add(lst34);
                        ddlFanBeamInches.Items.Add(lst78);
                        ddlFanBeamInches.ID = "ddlFanBeamInches" + panelsProcessed;
                        ddlFanBeamInches.Attributes.Add("OnChange", "skylightWizardCheckQuestion1()");
                        panelOptionPlaceholder.Controls.Add(ddlFanBeamInches);

                        Button btnFanBeamCenter = new Button();
                        btnFanBeamCenter.ID       = "btnFanBeamCenter" + panelsProcessed;
                        btnFanBeamCenter.Text     = "Centered";
                        btnFanBeamCenter.CssClass = "btnSubmit";
                        btnFanBeamCenter.Attributes.Add("OnClick", "skylightWizardCenterFanBeam(" + panelsProcessed + "); return false");
                        btnFanBeamCenter.CausesValidation  = false;
                        btnFanBeamCenter.UseSubmitBehavior = false;

                        panelOptionPlaceholder.Controls.Add(btnFanBeamCenter);

                        panelOptionPlaceholder.Controls.Add(new LiteralControl("<br/><br/>"));

                        CheckBox chkSkylight = new CheckBox();
                        chkSkylight.ID = "chkSkylight" + panelsProcessed;
                        chkSkylight.Attributes.Add("OnClick", "skylightWizardCheckQuestion1()");
                        panelOptionPlaceholder.Controls.Add(chkSkylight);

                        Label lblSkylightCheck = new Label();
                        lblSkylightCheck.ID = "lblSkylightCheck" + panelsProcessed;
                        lblSkylightCheck.AssociatedControlID = "chkSkylight" + panelsProcessed;
                        panelOptionPlaceholder.Controls.Add(lblSkylightCheck);

                        Label lblSkylight = new Label();
                        lblSkylight.ID   = "lblSkylight" + panelsProcessed;
                        lblSkylight.Text = "Skylight";
                        lblSkylight.AssociatedControlID = "chkSkylight" + panelsProcessed;
                        panelOptionPlaceholder.Controls.Add(lblSkylight);

                        panelOptionPlaceholder.Controls.Add(new LiteralControl("<br/>"));

                        Label lblSkylightPosition = new Label();
                        lblSkylightPosition.ID   = "lblSkylightPosition" + panelsProcessed;
                        lblSkylightPosition.Text = "Start Width:";
                        panelOptionPlaceholder.Controls.Add(lblSkylightPosition);

                        TextBox txtSkylight = new TextBox();
                        txtSkylight.ID        = "txtSkylight" + panelsProcessed;
                        txtSkylight.MaxLength = 3;
                        txtSkylight.CssClass  = "txtField txtInput";
                        txtSkylight.Attributes.Add("onkeyup", "skylightWizardCheckQuestion1()");
                        txtSkylight.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
                        panelOptionPlaceholder.Controls.Add(txtSkylight);

                        DropDownList ddlSkylightInches = new DropDownList();
                        ddlSkylightInches.Items.Add(lst0);
                        ddlSkylightInches.Items.Add(lst18);
                        ddlSkylightInches.Items.Add(lst14);
                        ddlSkylightInches.Items.Add(lst38);
                        ddlSkylightInches.Items.Add(lst12);
                        ddlSkylightInches.Items.Add(lst58);
                        ddlSkylightInches.Items.Add(lst34);
                        ddlSkylightInches.Items.Add(lst78);
                        ddlSkylightInches.ID = "ddlSkylightInches" + panelsProcessed;
                        ddlSkylightInches.Attributes.Add("OnChange", "skylightWizardCheckQuestion1()");
                        panelOptionPlaceholder.Controls.Add(ddlSkylightInches);

                        Button btnSkylightCenter = new Button();
                        btnSkylightCenter.ID       = "btnSkylightCenter" + panelsProcessed;
                        btnSkylightCenter.Text     = "Centered";
                        btnSkylightCenter.CssClass = "btnSubmit";
                        btnSkylightCenter.Attributes.Add("OnClick", "skylightWizardCenterSkylight(" + panelsProcessed + "); return false");
                        btnSkylightCenter.CausesValidation  = false;
                        btnSkylightCenter.UseSubmitBehavior = false;
                        panelOptionPlaceholder.Controls.Add(btnSkylightCenter);

                        HtmlInputHidden hidHasBeam = new HtmlInputHidden();
                        hidHasBeam.ID = "hidHasBeam" + panelsProcessed;
                        hiddenInputPlaceholder.Controls.Add(hidHasBeam);

                        HtmlInputHidden hidBeamStart = new HtmlInputHidden();
                        hidBeamStart.ID = "hidBeamStart" + panelsProcessed;
                        hiddenInputPlaceholder.Controls.Add(hidBeamStart);

                        HtmlInputHidden hidHasSkylight = new HtmlInputHidden();
                        hidHasSkylight.ID = "hidHasSkylight" + panelsProcessed;
                        hiddenInputPlaceholder.Controls.Add(hidHasSkylight);

                        HtmlInputHidden hidSkylightStart = new HtmlInputHidden();
                        hidSkylightStart.ID = "hidSkylightStart" + panelsProcessed;
                        hiddenInputPlaceholder.Controls.Add(hidSkylightStart);

                        panelOptionPlaceholder.Controls.Add(new LiteralControl("</li>"));

                        panelOptionPlaceholder.Controls.Add(new LiteralControl("</ul>"));
                        panelOptionPlaceholder.Controls.Add(new LiteralControl("</div>"));
                        panelOptionPlaceholder.Controls.Add(new LiteralControl("</li>"));
                    }
                    totalPanels   += numberOfPanels;
                    numberOfPanels = 0;
                }

                panelSizes = new JavaScriptSerializer().Serialize(panelSizeArray);
            }
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            projectId = Convert.ToInt32(HttpContext.Current.Session["project_id"].ToString());

            #region hit the DB

            using (SqlConnection aConnection = new SqlConnection(sdsDBConnection.ConnectionString))
            {

                aConnection.Open();
                SqlCommand aCommand = aConnection.CreateCommand();
                SqlTransaction aTransaction;
                SqlDataReader aReader;

                // Start a local transaction.
                aTransaction = aConnection.BeginTransaction("SampleTransaction");

                // Must assign both transaction object and connection
                // to Command object for a pending local transaction
                aCommand.Connection = aConnection;
                aCommand.Transaction = aTransaction;

                try
                {
                    //get number of walls floors and roofs
                    aCommand.CommandText = "SELECT number_walls, number_floors, number_roofs FROM sunrooms WHERE project_id = '" + projectId + "'";
                    aReader = aCommand.ExecuteReader();

                    if (aReader.HasRows)
                    {
                        aReader.Read();

                        wallCount = Convert.ToInt32(aReader[0]);
                        floorCount = Convert.ToInt32(aReader[1]);
                        roofCount = Convert.ToInt32(aReader[2]);
                    }
                    aReader.Close();

                    #region walls
                    //for each wall in the project

                    //aCommand.CommandText = "SELECT wall_type, model_type, total_length, orientation, set_back, name, first_item_index, last_item_index, start_height, end_height, soffit_length, gable_peak, obstructions, fire_protection, wall_index "
                    //    + "FROM walls WHERE project_id = '" + projectId + "'";

                    //SqlDataReader wallReader = aCommand.ExecuteReader();

                    //if (wallReader.HasRows)
                    //{
                    //    while (wallReader.Read())
                    for (int i = 0; i < wallCount; i++)
                    {
                            aCommand.CommandText = "SELECT wall_type, model_type, total_length, orientation, set_back, name, first_item_index, last_item_index, start_height, end_height, soffit_length, gable_peak, obstructions, fire_protection, wall_index "
                            + "FROM walls WHERE project_id = '" + projectId + "' AND wall_index = '" + i + "'";

                            aReader = aCommand.ExecuteReader();
                            aReader.Read();

                            //create a new instance of a wall and set all its attributes from the db
                            Wall aWall = new Wall();
                            aWall.WallType = Convert.ToString(aReader[0]);
                            aWall.ModelType = Convert.ToString(aReader[1]);
                            aWall.Length = Convert.ToSingle(aReader[2]);
                            aWall.Orientation = Convert.ToString(aReader[3]);
                            aWall.SetBack = Convert.ToSingle(aReader[4]);
                            aWall.Name = Convert.ToString(aReader[5]);
                            aWall.FirstItemIndex = Convert.ToInt32(aReader[6]);
                            aWall.LastItemIndex = Convert.ToInt32(aReader[7]);
                            aWall.StartHeight = Convert.ToSingle(aReader[8]);
                            aWall.EndHeight = Convert.ToSingle(aReader[9]);
                            aWall.SoffitLength = Convert.ToSingle(aReader[10]);
                            aWall.GablePeak = Convert.ToSingle(aReader[11]);
                            aWall.FireProtection = Convert.ToBoolean(aReader[13]);
                            int wallIndex = Convert.ToInt32(aReader[14]);

                            aReader.Close();

                            List<LinearItem> listOfLinearItems = new List<LinearItem>();

                            //Get linear items
                            //aCommand.CommandText = "SELECT linear_index, linear_type, start_height, end_height, length, frame_colour, sex, fixed_location, attached_to "
                            //                        + "FROM linear_items WHERE project_id = '" + projectId + "' AND last_item_index < '" + aWall.LastItemIndex + "' AND first_item_index > '" + aWall.FirstItemIndex + "'";
                            //aReader = aCommand.ExecuteReader();

                            //for each linear item/mod in the wall

                            //if (linearItemReader.HasRows)
                            //{
                            //    while (linearItemReader.Read())
                            //    {
                        for (int j = aWall.FirstItemIndex; j < aWall.LastItemIndex; j++)
                        {
                                    //Get linear items
                                    aCommand.CommandText = "SELECT linear_index, linear_type, start_height, end_height, length, frame_colour, sex, fixed_location, attached_to "
                                                            + "FROM linear_items WHERE project_id = '" + projectId + "' AND linear_index = '" + j + "'";
                                    aReader = aCommand.ExecuteReader();
                                    aReader.Read();

                                    int linearIndex = Convert.ToInt32(aReader[0]);
                                    string linearItemType = Convert.ToString(aReader[1]);
                                    float startHeight = Convert.ToSingle(aReader[2]);
                                    float endHeight = Convert.ToSingle(aReader[3]);
                                    float length = Convert.ToSingle(aReader[4]);
                                    string frameColour = Convert.ToString(aReader[5]);
                                    string sex = Convert.ToString(aReader[6]);
                                    float fixedLocation = Convert.ToSingle(aReader[7]);
                                    bool attachedTo = Convert.ToBoolean(aReader[8]);

                                    aReader.Close();

                                    switch (linearItemType)
                                    {
                                        case "Mod":
                                            #region Mod

                                            List<ModuleItem> listOfModuleItems = new List<ModuleItem>();

                                            Mod aMod = new Mod();

                                            aMod.LinearIndex = linearIndex;
                                            aMod.ItemType = linearItemType;
                                            aMod.StartHeight = startHeight;
                                            aMod.EndHeight = endHeight;
                                            aMod.Length = length;
                                            aMod.FrameColour = frameColour;
                                            aMod.Sex = sex;
                                            aMod.FixedLocation = fixedLocation;
                                            aMod.AttachedTo = attachedTo;

                                            //get number of mods
                                            aCommand.CommandText = "SELECT COUNT(*) FROM module_items WHERE project_id = '" + projectId + "' "
                                                                                    + " AND linear_index = '" + aMod.LinearIndex + "'";
                                            aReader = aCommand.ExecuteReader();
                                            aReader.Read();
                                            int modCount = Convert.ToInt32(aReader[0]); //get the number of walls in the project

                                            aReader.Close();

                                            //aCommand.CommandText = "SELECT module_index, item_type, start_height, end_height, length FROM moduleItems "
                                            //                    + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "'";

                                            //SqlDataReader moduleItemReader = aCommand.ExecuteReader();

                                            //for each modular item in the mod

                                            //if (moduleItemReader.HasRows)
                                            //{
                                            //    while (moduleItemReader.Read())
                                            for (int k = 0; k < modCount; k++)
                                            {
                                                    //Get module items
                                                     aCommand.CommandText = "SELECT module_index, item_type, start_height, end_height, length FROM module_items "
                                                                    + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + k + "'";

                                                    aReader = aCommand.ExecuteReader();
                                                    aReader.Read();

                                                    int moduleIndex = Convert.ToInt32(aReader[0]);
                                                    string itemType = Convert.ToString(aReader[1]);
                                                    float fStartHeight = Convert.ToSingle(aReader[2]);
                                                    float fEndHeight = Convert.ToSingle(aReader[3]);
                                                    float fLength = Convert.ToSingle(aReader[4]);

                                                    aReader.Close();

                                                    //different types of mods
                                                    switch (itemType)
                                                    {
                                                        case "Kneewall":
                                                        case "Window":
                                                            #region Window
                                                            //Get window
                                                            aCommand.CommandText = "SELECT window_type, screen_type, start_height, end_height, length, window_colour, number_vents FROM windows "
                                                                                    + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'";

                                                            aReader = aCommand.ExecuteReader();

                                                            //if (windowReader.HasRows)
                                                            //{
                                                                aReader.Read();

                                                                string windowStyle = Convert.ToString(aReader[0]);
                                                                string screenType = Convert.ToString(aReader[1]);
                                                                float windowStartHeight = Convert.ToSingle(aReader[2]);
                                                                float windowEndHeight = Convert.ToSingle(aReader[3]);
                                                                float windowLength = Convert.ToSingle(aReader[4]);
                                                                string windowColour = Convert.ToString(aReader[5]);
                                                                int numVents = Convert.ToInt32(aReader[6]);

                                                                aReader.Close();

                                                                //types of windows
                                                                switch (windowStyle)
                                                                {
                                                                    case "Double Slider": //glass model 300
                                                                    case "Single Slider": //glass model 400
                                                                    case "Horizontal Roller XX": //glass model 300
                                                                    case "Horizontal Roller":
                                                                    case "Horizontal 2 Track":
                                                                    case "H2T":
                                                                    case "Vertical 4 Track":
                                                                    case "Vertical Four Track":
                                                                    case "V4T":
                                                                    case "Vinyl":
                                                                        #region Vinyl Window

                                                                        VinylWindow aVinylWindow = new VinylWindow();
                                                                        aVinylWindow.ModuleIndex = moduleIndex;
                                                                        aVinylWindow.ItemType = itemType;
                                                                        aVinylWindow.FStartHeight = fStartHeight;
                                                                        aVinylWindow.FEndHeight = fEndHeight;
                                                                        aVinylWindow.FLength = fLength;
                                                                        //aVinylWindow.Colour = windowColour; //replaced by FrameColour
                                                                        aVinylWindow.WindowStyle = windowStyle;
                                                                        aVinylWindow.ScreenType = screenType;
                                                                        aVinylWindow.LeftHeight = windowStartHeight;
                                                                        aVinylWindow.RightHeight = windowEndHeight;
                                                                        aVinylWindow.Width = windowLength;
                                                                        aVinylWindow.FrameColour = windowColour; //
                                                                        aVinylWindow.VinylTint = ""; // tint of each vent will be concatenated
                                                                        //numVents = (numVents == 0) ? 1 : numVents;
                                                                        aVinylWindow.NumVents = numVents;
                                                                        List<float> listOfVentHeights = new List<float>();

                                                                        //Get vinyl item
                                                                        //aCommand.CommandText = "SELECT start_height, vinyl_tint, spreader_bar FROM vinyl_items "
                                                                        //                        + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'";

                                                                        //aReader = aCommand.ExecuteReader();

                                                                        //if (vinylReader.HasRows)
                                                                        //{
                                                                            //while (vinylReader.Read())
                                                                            //for each vinyl item in the in the vinyl window
                                                                            for (int l = 0; l < numVents; l++)
                                                                            {
                                                                                aCommand.CommandText = "SELECT start_height, vinyl_tint, spreader_bar FROM vinyl_items "
                                                                                                + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "' AND vent_index = '" + l + "'";

                                                                        aReader = aCommand.ExecuteReader();
                                                                        aReader.Read();

                                                                                listOfVentHeights.Add(Convert.ToSingle(aReader[0]));
                                                                                aVinylWindow.VinylTint += Convert.ToString(aReader[1]);
                                                                                aVinylWindow.SpreaderBar = Convert.ToSingle(aReader[2]);

                                                                        aReader.Close();
                                                                            }

                                                                        //vinylReader.Close();

                                                                        aVinylWindow.VentHeights = listOfVentHeights;

                                                                        listOfModuleItems.Add(aVinylWindow);

                                                                        #endregion
                                                                        break;
                                                                    case "Screen":
                                                                        #region Screen Window

                                                                        Window aWindow = new Window();
                                                                        aWindow.ModuleIndex = moduleIndex;
                                                                        aWindow.ItemType = itemType;
                                                                        aWindow.FStartHeight = fStartHeight;
                                                                        aWindow.FEndHeight = fEndHeight;
                                                                        aWindow.FLength = fLength;
                                                                        //aWindow.Colour = windowColour; //replaced by FrameColour
                                                                        aWindow.WindowStyle = windowStyle;
                                                                        aWindow.ScreenType = screenType;
                                                                        aWindow.LeftHeight = windowStartHeight;
                                                                        aWindow.RightHeight = windowEndHeight;
                                                                        aWindow.Width = windowLength;
                                                                        aWindow.FrameColour = windowColour; //
                                                                        //aWindow.VinylTint = ""; // tint of each vent will be concatenated
                                                                        //aWindow.NumVents = numVents;

                                                                        listOfModuleItems.Add(aWindow);

                                                                        #endregion
                                                                        break;
                                                                    case "Glass":
                                                                    case "Fixed Glass 2\"":
                                                                        #region Glass Window

                                                                        GlassWindow aGlassWindow = new GlassWindow();
                                                                        aGlassWindow.ModuleIndex = moduleIndex;
                                                                        aGlassWindow.ItemType = itemType;
                                                                        aGlassWindow.FStartHeight = fStartHeight;
                                                                        aGlassWindow.FEndHeight = fEndHeight;
                                                                        aGlassWindow.FLength = fLength;
                                                                        //aGlassWindow.Colour = windowColour; //replaced by frameColour
                                                                        aGlassWindow.WindowStyle = windowStyle;
                                                                        aGlassWindow.ScreenType = screenType;
                                                                        aGlassWindow.LeftHeight = windowStartHeight;
                                                                        aGlassWindow.RightHeight = windowEndHeight;
                                                                        aGlassWindow.Width = windowLength;
                                                                        aGlassWindow.FrameColour = windowColour; //
                                                                        aGlassWindow.GlassTint = ""; // tint of each vent will be concatenated
                                                                        aGlassWindow.Operation = ""; // XX, XO, OX will be concatenated
                                                                        aGlassWindow.NumVents = numVents;

                                                                        //Get glass item
                                                                        //aCommand.CommandText = "SELECT glass_type, glass_tint, tempered, operation FROM glass_items "
                                                                        //                        + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'";

                                                                        //SqlDataReader glassReader = aCommand.ExecuteReader();

                                                                        for (int l = 0; l < numVents; l++)
                                                                        {
                                                                        //if (glassReader.HasRows)
                                                                        //{
                                                                        //    while (glassReader.Read())
                                                                        //    {

                                                                             aCommand.CommandText = "SELECT glass_type, glass_tint, tempered, operation FROM glass_items "
                                                                                                + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "' AND vent_index = '" + l + "'";

                                                                            aReader = aCommand.ExecuteReader();
                                                                            aReader.Read();
                                                                                aGlassWindow.GlassType = Convert.ToString(aReader[0]);
                                                                                aGlassWindow.GlassTint += Convert.ToString(aReader[1]);
                                                                                aGlassWindow.Tempered = Convert.ToBoolean(aReader[2]);
                                                                                aGlassWindow.Operation += Convert.ToString(aReader[3]);

                                                                            aReader.Close();
                                                                            }

                                                                        //glassReader.Close();

                                                                        listOfModuleItems.Add(aGlassWindow);

                                                                        #endregion
                                                                        break;
                                                                    case "Open":
                                                                        #region Open Window
                                                                        Window openWindow = new Window();
                                                                        openWindow.ModuleIndex = moduleIndex;
                                                                        openWindow.ItemType = itemType;
                                                                        openWindow.FStartHeight = fStartHeight;
                                                                        openWindow.FEndHeight = fEndHeight;
                                                                        openWindow.FLength = fLength;
                                                                        openWindow.WindowStyle = windowStyle;
                                                                        openWindow.ScreenType = screenType;
                                                                        openWindow.LeftHeight = windowStartHeight;
                                                                        openWindow.RightHeight = windowEndHeight;
                                                                        openWindow.Width = windowLength;
                                                                        openWindow.FrameColour = windowColour;

                                                                        listOfModuleItems.Add(openWindow); //add the modular item to the list
                                                                        #endregion
                                                                        break;
                                                                    case "Panel":
                                                                    case "Solid Wall":
                                                                        #region Open Window
                                                                        Window panel = new Window();
                                                                        panel.ModuleIndex = moduleIndex;
                                                                        panel.ItemType = itemType;
                                                                        panel.FStartHeight = fStartHeight;
                                                                        panel.FEndHeight = fEndHeight;
                                                                        panel.FLength = fLength;
                                                                        panel.WindowStyle = windowStyle;
                                                                        panel.ScreenType = screenType;
                                                                        panel.LeftHeight = windowStartHeight;
                                                                        panel.RightHeight = windowEndHeight;
                                                                        panel.Width = windowLength;
                                                                        panel.FrameColour = windowColour;

                                                                        listOfModuleItems.Add(panel); //add the modular item to the list
                                                                        #endregion
                                                                        break;
                                                                }

                                                            //windowReader.Close();
                                                            #endregion
                                                            break;
                                                        case "Door":
                                                            #region Door
                                                            //Get door
                                                            //aCommand.CommandText = "SELECT door_type, door_style, screen_type, height, length, door_colour, kick_plate FROM doors "
                                                            //                        + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'";

                                                            //SqlDataReader doorReader = aCommand.ExecuteReader();

                                                            //if (doorReader.HasRows)
                                                            //{
                                                            //    while (doorReader.Read())

                                                                    aCommand.CommandText = "SELECT door_type, door_style, screen_type, height, length, door_colour, kick_plate FROM doors "
                                                                                    + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'";

                                                                    aReader = aCommand.ExecuteReader();
                                                                    aReader.Read();

                                                                    string doorType = Convert.ToString(aReader[0]);
                                                                    string doorStyle = Convert.ToString(aReader[1]);
                                                                    string doorScreenType = Convert.ToString(aReader[2]);
                                                                    float doorFrameHeight = Convert.ToSingle(aReader[3]);
                                                                    float doorFrameLength = Convert.ToSingle(aReader[4]);
                                                                    string doorColour = Convert.ToString(aReader[5]);
                                                                    float doorKickPlate = Convert.ToSingle(aReader[6]);

                                                                    aReader.Close();

                                                                    //get the window in this door
                                                                    aCommand.CommandText = "SELECT door_index, window_type, screen_type, start_height, end_height, length, window_colour, number_vents FROM windows "
                                                                                            + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'";

                                                                    aReader = aCommand.ExecuteReader();

                                                                    VinylWindow aDoorWindow = new VinylWindow();

                                                                    if (aReader.HasRows)
                                                                    {
                                                                        while (aReader.Read())
                                                                        {
                                                                            //int doorIndex = Convert.ToInt32(aReader[0]);
                                                                            aDoorWindow.WindowStyle = Convert.ToString(aReader[1]);
                                                                            aDoorWindow.ScreenType = Convert.ToString(aReader[2]);
                                                                            aDoorWindow.LeftHeight = Convert.ToSingle(aReader[3]);
                                                                            aDoorWindow.RightHeight = Convert.ToSingle(aReader[4]);
                                                                            aDoorWindow.Width = Convert.ToSingle(aReader[5]);
                                                                            aDoorWindow.FrameColour = Convert.ToString(aReader[6]);
                                                                            aDoorWindow.NumVents = Convert.ToInt32(aReader[7]);
                                                                        }
                                                                    }
                                                                    aReader.Close();

                                                                    switch (aDoorWindow.WindowStyle) //door/window style
                                                                    {
                                                                        case "Full Screen": //screen
                                                                            break;
                                                                        case "Vertical Four Track": //vinyl
                                                                            #region V4T
                                                                            List<float> listOfV4TVentHeights = new List<float>();

                                                                            //for each vinyl item in the in the vinyl window
                                                                            //for (int l = 0; l < aDoorWindow.NumVents; l++)
                                                                            //Get vinyl item
                                                                            aCommand.CommandText = "SELECT start_height, vinyl_tint, spreader_bar FROM vinyl_items "
                                                                                                    + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'";

                                                                            SqlDataReader vinylReader = aCommand.ExecuteReader();

                                                                            if (vinylReader.HasRows)
                                                                            {
                                                                                while (vinylReader.Read())
                                                                                {
                                                                                    listOfV4TVentHeights.Add(Convert.ToSingle(vinylReader[0]));
                                                                                    aDoorWindow.VinylTint += Convert.ToString(vinylReader[1]);
                                                                                    aDoorWindow.SpreaderBar = Convert.ToSingle(vinylReader[2]);
                                                                                }
                                                                            }
                                                                            vinylReader.Close();

                                                                            aDoorWindow.VentHeights = listOfV4TVentHeights;
                                                                            #endregion
                                                                            break;
                                                                        case "Full View": //glass
                                                                            break;
                                                                        case "Full View Colonial": //glass
                                                                            break;
                                                                        case "Half Lite": //glass
                                                                            break;
                                                                        case "Half Lite Venting": //glass
                                                                            break;
                                                                        case "Half Lite with Mini Blinds": //glass
                                                                            break;
                                                                        case "Full View with Mini Blinds": //glass
                                                                            break;
                                                                        case "Aluminum Storm Screen": //screen
                                                                            break;
                                                                        case "Aluminum Storm Glass": //glass
                                                                            break;
                                                                        case "Vinyl Guard": //vinyl
                                                                            break;
                                                                    }
                                                                    //types of doors
                                                                    switch (doorType)
                                                                    {
                                                                        case "Cabana":
                                                                        case "Cabana Door":
                                                                            #region Cabana Door

                                                                            aCommand.CommandText = "SELECT glass_tint, hinge, swing, hardware_type, screen_type FROM cabana_doors "
                                                                                            + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'";

                                                                            SqlDataReader cabanaReader = aCommand.ExecuteReader();

                                                                            if (cabanaReader.HasRows)
                                                                            {
                                                                                cabanaReader.Read();

                                                                                CabanaDoor aCabanaDoor = new CabanaDoor();
                                                                                aCabanaDoor.ModuleIndex = moduleIndex;
                                                                                aCabanaDoor.ItemType = itemType;
                                                                                aCabanaDoor.FStartHeight = fStartHeight;
                                                                                aCabanaDoor.FEndHeight = fEndHeight;
                                                                                aCabanaDoor.FLength = fLength;
                                                                                aCabanaDoor.DoorType = doorType;
                                                                                aCabanaDoor.DoorStyle = doorStyle;
                                                                                aCabanaDoor.ScreenType = doorScreenType;
                                                                                aCabanaDoor.Height = doorFrameHeight;
                                                                                aCabanaDoor.Length = doorFrameLength;
                                                                                aCabanaDoor.Colour = doorColour; //
                                                                                aCabanaDoor.Kickplate = doorKickPlate; //
                                                                                aCabanaDoor.GlassTint = Convert.ToString(cabanaReader[0]);
                                                                                aCabanaDoor.Hinge = Convert.ToString(cabanaReader[1]);
                                                                                aCabanaDoor.Swing = Convert.ToString(cabanaReader[2]);
                                                                                aCabanaDoor.HardwareType = Convert.ToString(cabanaReader[3]);
                                                                                aCabanaDoor.ScreenType = Convert.ToString(cabanaReader[4]);

                                                                                aCabanaDoor.DoorWindow = aDoorWindow;

                                                                                listOfModuleItems.Add(aCabanaDoor); //add the modular item to the list
                                                                            }
                                                                            cabanaReader.Close();

                                                                            #endregion
                                                                            break;
                                                                        case "French":
                                                                        case "French Door":
                                                                            #region French Door

                                                                            aCommand.CommandText = "SELECT glass_tint, swing, operator, hardware_type, screen_type FROM french_doors "
                                                                                            + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'";

                                                                            SqlDataReader frenchReader = aCommand.ExecuteReader();

                                                                            if (frenchReader.HasRows)
                                                                            {

                                                                                frenchReader.Read();

                                                                                FrenchDoor aFrenchDoor = new FrenchDoor();
                                                                                aFrenchDoor.ModuleIndex = moduleIndex;
                                                                                aFrenchDoor.ItemType = itemType;
                                                                                aFrenchDoor.FStartHeight = fStartHeight;
                                                                                aFrenchDoor.FEndHeight = fEndHeight;
                                                                                aFrenchDoor.FLength = fLength;
                                                                                aFrenchDoor.DoorType = doorType;
                                                                                aFrenchDoor.DoorStyle = doorStyle;
                                                                                aFrenchDoor.ScreenType = doorScreenType;
                                                                                aFrenchDoor.Height = doorFrameHeight;
                                                                                aFrenchDoor.Length = doorFrameLength;
                                                                                aFrenchDoor.Colour = doorColour; //
                                                                                aFrenchDoor.Kickplate = doorKickPlate; //
                                                                                aFrenchDoor.GlassTint = Convert.ToString(frenchReader[0]);
                                                                                aFrenchDoor.Swing = Convert.ToString(frenchReader[1]);
                                                                                aFrenchDoor.OperatingDoor = Convert.ToString(frenchReader[2]); ///this needs to be fixed, operator in db is bool and C# is string
                                                                                aFrenchDoor.HardwareType = Convert.ToString(frenchReader[3]);
                                                                                aFrenchDoor.ScreenType = Convert.ToString(frenchReader[4]);

                                                                                aFrenchDoor.DoorWindow = aDoorWindow;

                                                                                listOfModuleItems.Add(aFrenchDoor); //add the modular item to the list
                                                                            }
                                                                            frenchReader.Close();

                                                                            #endregion
                                                                            break;
                                                                        case "Patio":
                                                                        case "Patio Door":
                                                                            #region Patio Door

                                                                            aCommand.CommandText = "SELECT glass_tint, moving_door FROM patio_doors "
                                                                                            + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; //change k to moduleIndex. Couldn't compile other pages.

                                                                            SqlDataReader patioReader = aCommand.ExecuteReader();

                                                                            if (patioReader.HasRows)
                                                                            {
                                                                                patioReader.Read();

                                                                                PatioDoor aPatioDoor = new PatioDoor();
                                                                                aPatioDoor.ModuleIndex = moduleIndex;
                                                                                aPatioDoor.ItemType = itemType;
                                                                                aPatioDoor.FStartHeight = fStartHeight;
                                                                                aPatioDoor.FEndHeight = fEndHeight;
                                                                                aPatioDoor.FLength = fLength;
                                                                                aPatioDoor.DoorType = doorType;
                                                                                aPatioDoor.DoorStyle = doorStyle;
                                                                                aPatioDoor.ScreenType = doorScreenType;
                                                                                aPatioDoor.Height = doorFrameHeight;
                                                                                aPatioDoor.Length = doorFrameLength;
                                                                                aPatioDoor.Colour = doorColour; //
                                                                                aPatioDoor.Kickplate = doorKickPlate; //
                                                                                aPatioDoor.GlassTint = Convert.ToString(patioReader[0]);
                                                                                aPatioDoor.MovingDoor = Convert.ToString(patioReader[1]); ///this needs to be fixed, operator in db is bool and C# is string

                                                                                aPatioDoor.DoorWindow = aDoorWindow;

                                                                                listOfModuleItems.Add(aPatioDoor); //add the modular item to the list
                                                                            }
                                                                            patioReader.Close();

                                                                            #endregion
                                                                            break;
                                                                        case "Half Lite":
                                                                        case "Half Lite Venting":
                                                                        case "Half Lite With Mini Blinds":
                                                                        case "Full View With Mini Blinds":
                                                                            break;
                                                                        case "NoDoor":
                                                                        case "No Door":
                                                                            #region No Door

                                                                            Door aDoor = new Door();
                                                                            aDoor.ModuleIndex = moduleIndex;
                                                                            aDoor.ItemType = itemType;
                                                                            aDoor.FStartHeight = fStartHeight;
                                                                            aDoor.FEndHeight = fEndHeight;
                                                                            aDoor.FLength = fLength;
                                                                            aDoor.DoorType = doorType;
                                                                            //aDoor.DoorStyle = doorStyle;
                                                                            //aDoor.ScreenType = doorScreenType;
                                                                            aDoor.Height = doorFrameHeight;
                                                                            aDoor.Length = doorFrameLength;
                                                                            //aDoor.Colour = doorColour; //
                                                                            //aDoor.Kickplate = doorKickPlate; //

                                                                            listOfModuleItems.Add(aDoor); //add the modular item to the list

                                                                            //aReader.Close();

                                                                            #endregion
                                                                            break;
                                                                    }

                                                            //doorReader.Close();
                                                            #endregion
                                                            break;
                                                        case "Box Header": //
                                                            #region H BoxHeader
                                                            HBoxHeader hBoxHeader = new HBoxHeader();
                                                            hBoxHeader.ModuleIndex = moduleIndex;
                                                            hBoxHeader.ItemType = itemType;
                                                            hBoxHeader.FStartHeight = fStartHeight;
                                                            hBoxHeader.FEndHeight = fEndHeight;
                                                            hBoxHeader.FLength = fLength;

                                                            listOfModuleItems.Add(hBoxHeader); //add the modular item to the list
                                                            #endregion
                                                            break; //
                                                        case "Receiver": //
                                                            #region H Receiver
                                                            HReceiver hReceiver = new HReceiver();
                                                            hReceiver.ModuleIndex = moduleIndex;
                                                            hReceiver.ItemType = itemType;
                                                            hReceiver.FStartHeight = fStartHeight;
                                                            hReceiver.FEndHeight = fEndHeight;
                                                            hReceiver.FLength = fLength;

                                                            listOfModuleItems.Add(hReceiver); //add the modular item to the list
                                                            #endregion
                                                            break;
                                                        case "Panel": // same as open wall window
                                                            #region Solid Wall Window
                                                            Window solid = new Window();
                                                            solid.ModuleIndex = moduleIndex;
                                                            solid.ItemType = itemType;
                                                            solid.FStartHeight = fStartHeight;
                                                            solid.FEndHeight = fEndHeight;
                                                            solid.FLength = fLength;

                                                            listOfModuleItems.Add(solid); //add the modular item to the list
                                                            #endregion
                                                            break;
                                                    }
                                                    aMod.ModularItems = listOfModuleItems;
                                                }
                                                listOfLinearItems.Add(aMod);//add the linear item to the list

                                            //moduleItemReader.Close();
                                            #endregion
                                            break;
                                        case "Receiver":
                                        case "Receiever":
                                            #region Receiver
                                            BoxHeader aBoxHeader = new BoxHeader();
                                            aBoxHeader.LinearIndex = linearIndex;
                                            aBoxHeader.ItemType = linearItemType;
                                            aBoxHeader.StartHeight = startHeight;
                                            aBoxHeader.EndHeight = endHeight;
                                            aBoxHeader.Length = length;
                                            aBoxHeader.FrameColour = frameColour;
                                            aBoxHeader.Sex = sex;
                                            aBoxHeader.FixedLocation = fixedLocation;
                                            aBoxHeader.AttachedTo = attachedTo;
                                            aBoxHeader.IsReceiver = true;
                                            aBoxHeader.IsTwoPiece = false;

                                            listOfLinearItems.Add(aBoxHeader);//add the linear item to the list
                                            #endregion
                                            break;
                                        case "2 Piece Receiver":
                                        case "2PieceReceiver":
                                            #region 2 Piece Receiver
                                            aBoxHeader = new BoxHeader();
                                            aBoxHeader.LinearIndex = linearIndex;
                                            aBoxHeader.ItemType = linearItemType;
                                            aBoxHeader.StartHeight = startHeight;
                                            aBoxHeader.EndHeight = endHeight;
                                            aBoxHeader.Length = length;
                                            aBoxHeader.FrameColour = frameColour;
                                            aBoxHeader.Sex = sex;
                                            aBoxHeader.FixedLocation = fixedLocation;
                                            aBoxHeader.AttachedTo = attachedTo;
                                            aBoxHeader.IsReceiver = true;
                                            aBoxHeader.IsTwoPiece = true;

                                            listOfLinearItems.Add(aBoxHeader);//add the linear item to the list
                                            #endregion
                                            break;
                                        case "BoxHeader": //
                                        case "Box Header": //
                                            #region Box Header
                                            aBoxHeader = new BoxHeader();
                                            aBoxHeader.LinearIndex = linearIndex;
                                            aBoxHeader.ItemType = linearItemType;
                                            aBoxHeader.StartHeight = startHeight;
                                            aBoxHeader.EndHeight = endHeight;
                                            aBoxHeader.Length = length;
                                            aBoxHeader.FrameColour = frameColour;
                                            aBoxHeader.Sex = sex;
                                            aBoxHeader.FixedLocation = fixedLocation;
                                            aBoxHeader.AttachedTo = attachedTo;
                                            aBoxHeader.IsReceiver = false;
                                            //aBoxHeader.IsTwoPiece = false;

                                            listOfLinearItems.Add(aBoxHeader);//add the linear item to the list
                                            #endregion
                                            break;
                                        case "BoxHeaderReceiver":
                                        case "Box Header Receiver": //
                                            #region Box Header Receiver
                                            aBoxHeader = new BoxHeader();
                                            aBoxHeader.LinearIndex = linearIndex;
                                            aBoxHeader.ItemType = linearItemType;
                                            aBoxHeader.StartHeight = startHeight;
                                            aBoxHeader.EndHeight = endHeight;
                                            aBoxHeader.Length = length;
                                            aBoxHeader.FrameColour = frameColour;
                                            aBoxHeader.Sex = sex;
                                            aBoxHeader.FixedLocation = fixedLocation;
                                            aBoxHeader.AttachedTo = attachedTo;
                                            aBoxHeader.IsReceiver = true;
                                            //aBoxHeader.IsTwoPiece = false;

                                            listOfLinearItems.Add(aBoxHeader);//add the linear item to the list
                                            #endregion
                                            break;
                                        case "Filler":
                                            #region Filler
                                            Filler aFiller = new Filler();
                                            aFiller.LinearIndex = linearIndex;
                                            aFiller.ItemType = linearItemType;
                                            aFiller.StartHeight = startHeight;
                                            aFiller.EndHeight = endHeight;
                                            aFiller.Length = length;
                                            //aFiller.FrameColour = frameColour;
                                            aFiller.Sex = "MM";
                                            aFiller.FixedLocation = fixedLocation;
                                            aFiller.AttachedTo = attachedTo;

                                            listOfLinearItems.Add(aFiller);//add the linear item to the list
                                            #endregion
                                            break;
                                        case "Corner Post":
                                        case "Corner":
                                            #region Corner Post
                                            Corner aCorner = new Corner();
                                            aCorner.LinearIndex = linearIndex;
                                            aCorner.ItemType = linearItemType;
                                            aCorner.StartHeight = startHeight;
                                            aCorner.EndHeight = endHeight;
                                            aCorner.Length = length;
                                            aCorner.FrameColour = frameColour;
                                            aCorner.Sex = sex;
                                            aCorner.FixedLocation = fixedLocation;
                                            aCorner.AttachedTo = attachedTo;
                                            //aCorner.AngleIs90 = true; //hard coded, because I don't know where its coming from
                                            //aCorner.OutsideCorner = true; // hard coded because I don't know where its coming from

                                            listOfLinearItems.Add(aCorner); //add the linear item to the list
                                            #endregion
                                            break;
                                        case "ElectricalChase":
                                        case "Electrical Chase":
                                            #region ElectricalChase
                                            ElectricalChase aElectricalChase = new ElectricalChase();
                                            aElectricalChase.LinearIndex = linearIndex;
                                            aElectricalChase.ItemType = linearItemType;
                                            aElectricalChase.StartHeight = startHeight;
                                            aElectricalChase.EndHeight = endHeight;
                                            aElectricalChase.Length = length;
                                            //aElectricalChase.FrameColour = frameColour;
                                            aElectricalChase.Sex = "MM";
                                            aElectricalChase.FixedLocation = fixedLocation;
                                            aElectricalChase.AttachedTo = attachedTo;

                                            listOfLinearItems.Add(aElectricalChase);//add the linear item to the list
                                            #endregion
                                            break;
                                        case "HChannel":
                                        case "H Channel":
                                            #region H Channel
                                            HChannel aHChannel = new HChannel();
                                            aHChannel.LinearIndex = linearIndex;
                                            aHChannel.ItemType = linearItemType;
                                            aHChannel.StartHeight = startHeight;
                                            aHChannel.EndHeight = endHeight;
                                            aHChannel.Length = length;
                                            aHChannel.FrameColour = frameColour;
                                            aHChannel.Sex = sex;
                                            aHChannel.FixedLocation = fixedLocation;
                                            aHChannel.AttachedTo = attachedTo;

                                            listOfLinearItems.Add(aHChannel);//add the linear item to the list
                                            #endregion
                                            break;
                                    }
                                }

                                aWall.LinearItems = listOfLinearItems;

                                listOfWalls.Add(aWall); //add the wall to the list
                            }
                            //linearItemReader.Close();

                    //wallReader.Close();
                    #endregion

                    #region floors
                    if (floorCount != 0)
                    {

                    }
                    #endregion

                    #region roofs
                    //if there is a roof in the project

                    if (roofCount != 0)
                    {
                        for(int i = 0; i < roofCount; i++)
                        {
                        aCommand.CommandText = "SELECT roof_type, interior_skin, exterior_skin, thickness, fire_protection, thermadeck, acrylic, gutter, gutter_pro, gutter_colour, number_supports, stripe_colour, projection, width, roof_index "
                                + "FROM roofs WHERE project_id = '" + projectId + "' roof_index = '" + i + "'";

                        aReader = aCommand.ExecuteReader();
                        aReader.Read();

                        //if (roofReader.HasRows)
                        //{
                        //    while (roofReader.Read())
                        //    {

                                //create a new instance of a wall and set all its attributes from the db
                                aRoof = new Roof();
                                aRoof.Type = Convert.ToString(aReader[0]);
                                aRoof.InteriorSkin = Convert.ToString(aReader[1]);
                                aRoof.ExteriorSkin = Convert.ToString(aReader[2]);
                                aRoof.Thickness = Convert.ToDouble(aReader[3]);
                                aRoof.FireProtection = Convert.ToBoolean(aReader[4]);
                                aRoof.Thermadeck = Convert.ToBoolean(aReader[5]);
                                aRoof.Acrylic = Convert.ToBoolean(aReader[6]);
                                aRoof.Gutters = Convert.ToBoolean(aReader[7]);
                                aRoof.GutterPro = Convert.ToBoolean(aReader[8]);
                                aRoof.GutterColour = Convert.ToString(aReader[9]);
                                aRoof.NumberSupports = Convert.ToInt32(aReader[10]);
                                aRoof.StripeColour = Convert.ToString(aReader[11]);
                                aRoof.Projection = Convert.ToDouble(aReader[12]); //how do we deal with obstructions
                                aRoof.Width = Convert.ToDouble(aReader[13]);
                                int roofIndex = Convert.ToInt32(aReader[14]);

                            aReader.Close();
                                List<RoofModule> listOfRoofModules = new List<RoofModule>();

                                aCommand.CommandText = "SELECT COUNT(*) FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "'";
                                aReader = aCommand.ExecuteReader();
                                aReader.Read();
                                int roofModCount = Convert.ToInt32(aReader[0]);

                                //aCommand.CommandText = "SELECT projection, width, interior_skin, exterior_skin, roof_view "
                                //+ "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "'";

                                //SqlDataReader moduleReader = aCommand.ExecuteReader();

                                //if (moduleReader.HasRows)
                                //{
                                //    while (moduleReader.Read())
                                    for(int j = 0; j < roofModCount; j++)
                                    {

                                        aCommand.CommandText = "SELECT projection, width, interior_skin, exterior_skin, roof_view "
                                                    + "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "'";

                                         aReader = aCommand.ExecuteReader();
                                         aReader.Read();

                                        RoofModule aModule = new RoofModule();
                                        aModule.Projection = Convert.ToDouble(aReader[0]);
                                        aModule.Width = Convert.ToDouble(aReader[1]);
                                        aModule.InteriorSkin = Convert.ToString(aReader[2]);
                                        aModule.ExteriorSkin = Convert.ToString(aReader[3]);
                                        int roofView = Convert.ToInt32(aReader[4]);

                                        aReader.Close();

                                        List<RoofItem> listOfRoofItems = new List<RoofItem>();

                                        aCommand.CommandText = "SELECT COUNT(*) FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "'";
                                        aReader = aCommand.ExecuteReader();
                                        aReader.Read();
                                        int roofItemCount = Convert.ToInt32(aReader[0]);

                                        //aCommand.CommandText = "SELECT roof_item, projection, width, item_index "
                                        //+ "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "'";

                                        //SqlDataReader itemReader = aCommand.ExecuteReader();

                                        //if (itemReader.HasRows)
                                        //{
                                        //    while(itemReader.Read())
                                            for (int k = 0; k < roofItemCount; k++)
                                            {

                                                aCommand.CommandText = "SELECT roof_item, projection, width, item_index "
                                                    + "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "' AND item_index = '" + k + "'";

                                                aReader = aCommand.ExecuteReader();
                                                aReader.Read();

                                                // store in an object
                                                RoofItem aRoofItem = new RoofItem();
                                                aRoofItem.ItemType = Convert.ToString(aReader[0]);
                                                aRoofItem.Projection = Convert.ToSingle(aReader[1]);
                                                aRoofItem.Width = Convert.ToSingle(aReader[2]);
                                                int itemIndex = Convert.ToInt32(aReader[3]);

                                                aReader.Close();

                                                ///different types of roof items
                                                switch (aRoofItem.ItemType)
                                                {
                                                    case "Receiver": //no class.. what to do .. same as panel receiver?
                                                        break;
                                                    case "Awning Track": //no class.. what to do
                                                        break;
                                                    case "I-Beam": //no class.. what to do
                                                        break;
                                                    case "Pressure Cap I-Beam": //no class.. what to do
                                                        break;
                                                    case "T-Bar": //no class.. what to do
                                                        break;
                                                    case "Acrylic Panel": //no class.. no class ... where is colour, width, setback, projection being stored?
                                                        break;
                                                    case "Foam Panel": //no class ... where is colour, width, setback, projection being stored?
                                                        //accordding the to db, this is the only item in which you can have fanbeams and skylight
                                                        //check for skylight in this roof item

                                                        //are all skylights the same? length/width etc? ..
                                                        //there is no skylight object.. roof item should have a attribute for a skylight object

                                                        aCommand.CommandText = "SELECT skylight_type, set_back, operator "
                                                        + "FROM skylights WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "' AND item_index '" + itemIndex + "'";

                                                        SqlDataReader skylightReader = aCommand.ExecuteReader();

                                                        if (skylightReader.HasRows)
                                                        {
                                                            while (skylightReader.Read())
                                                            {
                                                                //Skylight aSkylight = new Skylight(); //create object and set attribute if required
                                                                aRoofItem.SkyLight = Convert.ToSingle(skylightReader[1]);
                                                            }

                                                        }
                                                        else
                                                        {
                                                            aRoofItem.SkyLight = -1;
                                                        }
                                                        skylightReader.Close();

                                                        //check for fanbeams in this roof item
                                                        //no info in the db or in C#
                                                        aCommand.CommandText = "SELECT skylight_type, set_back, operator "
                                                        + "FROM fanbeams WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "' AND item_index = '" + itemIndex + "'";

                                                        SqlDataReader fanbeamReader = aCommand.ExecuteReader();

                                                        if (fanbeamReader.HasRows)
                                                        {
                                                            while (fanbeamReader.Read())
                                                            {
                                                                //Skylight aSkylight = new Skylight(); //create object and set attribute if required
                                                                aRoofItem.FanBeam = Convert.ToSingle(skylightReader[1]);
                                                            }

                                                        }
                                                        else
                                                        {
                                                            aRoofItem.FanBeam = -1;
                                                        }
                                                        fanbeamReader.Close();
                                                        break;
                                                }

                                                listOfRoofItems.Add(aRoofItem);
                                            }

                                        //itemReader.Close();

                                        aModule.RoofItems = listOfRoofItems;

                                        listOfRoofModules.Add(aModule);
                                    }

                                //moduleReader.Close();

                                aRoof.RoofModules = listOfRoofModules;
                            }

                        //roofReader.Close();
                    }

                    #endregion

                    aTransaction.Commit();

                    hidJsonObjects.Value = JsonConvert.SerializeObject(listOfWalls);
            }

                 catch (Exception ex)
                {
                    //lblError.Text = "Commit Exception Type: " + ex.GetType();
                    //lblError.Text += "  Message: " + ex.Message;

                    // Attempt to roll back the transaction.
                    try
                    {
                        aTransaction.Rollback();
                    }
                    catch (Exception ex2)
                    {
                         //This catch block will handle any errors that may have occurred
                         //on the server that would cause the rollback to fail, such as
                         //a closed connection.
                        //lblError.Text = "Rollback Exception Type: " + ex2.GetType();
                        //lblError.Text += "  Message: " + ex2.Message;
                    }
                }
            }

            #endregion

            hidJsonObjects.Value = JsonConvert.SerializeObject(listOfWalls);
            PopulateDropdown(floorCount, roofCount);
            PopulateModOptions();
            //lnkUpdateSunroom.Attributes.Add("onclick", "updateSunroom()");
            //lnkSubmitSunroom.Attributes.Add("onclick", "submitSunroom()");
            //lnkEditorNavMods.Attributes.Add("onclick", "$('.overlayContainer').slideToggle()");
            //lnkEditorNavTools.Attributes.Add("onclick", "$('#saveButtons').fadeToggle(); $('.btnTools').slideToggle();");
            lnkEditorNavSave.Attributes.Add("onclick", "updateSunroom()");
            lnkEditorNavUndo.Attributes.Add("onclick", "undo()");
            lnkEditorNavRedo.Attributes.Add("onclick", "redo()");

            //Add list of all objects to session, for use by other pages accessed through project editor
            try
            {
                Session.Add("listOfWalls", listOfWalls);
            }
            catch (Exception ex)
            {
                Session["listOfWalls"] = listOfWalls;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Loop to display roof types as radio buttons

            //For loop to get through all the possible roof types: Cabana, French, Patio, Opening Only (No Roof)
            for (int typeCount = 0; typeCount < Constants.ROOF_TYPES.Count(); typeCount++)
            {
                //Conditional operator to set the current roof type with the right label
                string title = Constants.ROOF_TYPES[typeCount]; //(typeCount == 1) ? "Cabana" : (typeCount == 2) ? "French" : (typeCount == 3) ? "Patio" : "NoRoof";

                RoofOptions.Controls.Add(new LiteralControl("<li>"));

                //Roof type radio button
                RadioButton typeRadio = new RadioButton();
                typeRadio.ID = "radType" + title; //Adding appropriate id to roof type radio button
                typeRadio.GroupName = "roofTypeRadios";         //Adding group name for all roof types
                //typeRadio.Attributes.Add("onclick", "typeRowsDisplayed('" + title + "')"); //On click event to display the proper fields/rows

                //Roof type radio button label for clickable area
                Label typeLabelRadio = new Label();
                typeLabelRadio.AssociatedControlID = "radType" + title;   //Tying this label to the radio button

                //Roof type radio button label text
                Label typeLabel = new Label();
                typeLabel.AssociatedControlID = "radType" + title;    //Tying this label to the radio button
                typeLabel.Text = title;     //Displaying the proper texted based on current title variable

                RoofOptions.Controls.Add(typeRadio);        //Adding radio button control to placeholder RoofOptions
                RoofOptions.Controls.Add(typeLabelRadio);   //Adding label control to placeholder RoofOptions
                RoofOptions.Controls.Add(typeLabel);        //Adding label control to placeholder RoofOptions

                //Adding literal control div tag to hold the table, add to RoofOptions placeholder
                RoofOptions.Controls.Add(new LiteralControl("<div class=\"toggleContent\" id=\"div_" + title + "\">"));

                RoofOptions.Controls.Add(new LiteralControl("<ul>"));

                //Adding literal control li to keep proper page look and format
                RoofOptions.Controls.Add(new LiteralControl("<li>"));

                #region Roof Styles Loop
                RoofOptions.Controls.Add(new LiteralControl("<ul class='toggleOptions'>"));

                for (int roofStyle = 0; roofStyle < 3; roofStyle++)
                {
                    string radioTitle = Constants.ROOF_STYLE[roofStyle];

                    #region Studio Dimensions and Specifics
                    if (roofStyle == 0 && title == "Studio")
                    {
                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        Label widthLabel = new Label();
                        widthLabel.ID = "lblWidth" + title;
                        widthLabel.Text = "Width: ";
                        widthLabel.AssociatedControlID = "txtWidth" + title;
                        widthLabel.CssClass = "labelFormatting";

                        TextBox widthTextbox = new TextBox();
                        widthTextbox.ID = "txtWidth" + title;
                        widthTextbox.CssClass = "txtField txtInput";
                        widthTextbox.MaxLength = 3;
                        widthTextbox.Attributes.Add("onblur", "validateDimensions('" + title + "')");

                        DropDownList ddlWidthInchSpecific = new DropDownList();
                        ddlWidthInchSpecific.ID = "ddlWidthInchSpecific" + title;
                        ddlWidthInchSpecific.CssClass = "txtField txtInput";
                        ddlWidthInchSpecific.Attributes.Add("style", "width:50px");

                        for (int i = 0; i < fractionList.Count; i++)
                        {
                            ddlWidthInchSpecific.Items.Add(fractionList[i]);
                        }

                        RoofOptions.Controls.Add(widthLabel);
                        RoofOptions.Controls.Add(widthTextbox);
                        RoofOptions.Controls.Add(ddlWidthInchSpecific);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        Label projectionLabel = new Label();
                        projectionLabel.ID = "lblProjection" + title;
                        projectionLabel.Text = "Projection: ";
                        projectionLabel.AssociatedControlID = "txtProjection" + title;
                        projectionLabel.CssClass = "labelFormatting";

                        TextBox projectionTextbox = new TextBox();
                        projectionTextbox.ID = "txtProjection" + title;
                        projectionTextbox.CssClass = "txtField txtInput";
                        projectionTextbox.MaxLength = 3;
                        projectionTextbox.Attributes.Add("onblur", "validateDimensions('" + title + "')");

                        DropDownList ddlProjectionInchSpecific = new DropDownList();
                        ddlProjectionInchSpecific.ID = "ddlProjectionInchSpecific" + title;
                        ddlProjectionInchSpecific.CssClass = "txtField txtInput";
                        ddlProjectionInchSpecific.Attributes.Add("style", "width:50px");

                        for (int i = 0; i < fractionList.Count; i++)
                        {
                            ddlProjectionInchSpecific.Items.Add(fractionList[i]);
                        }

                        RoofOptions.Controls.Add(projectionLabel);
                        RoofOptions.Controls.Add(projectionTextbox);
                        RoofOptions.Controls.Add(ddlProjectionInchSpecific);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                    }
                    #endregion

                    #region Gable Dimensions and Specifics
                    else if (roofStyle == 0 && title == "Gable")
                    {
                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        Label widthLabel = new Label();
                        widthLabel.ID = "lblWidth" + title;
                        widthLabel.Text = "Width: ";
                        widthLabel.AssociatedControlID = "txtWidth" + title;
                        widthLabel.CssClass = "labelFormatting";

                        TextBox widthTextbox = new TextBox();
                        widthTextbox.ID = "txtWidth" + title;
                        widthTextbox.CssClass = "txtField txtInput";
                        widthTextbox.MaxLength = 3;
                        widthTextbox.Attributes.Add("onblur", "validateDimensions('" + title + "')");

                        DropDownList ddlWidthInchSpecific = new DropDownList();
                        ddlWidthInchSpecific.ID = "ddlWidthInchSpecific" + title;
                        ddlWidthInchSpecific.CssClass = "txtField txtInput";
                        ddlWidthInchSpecific.Attributes.Add("style", "width:50px");

                        for (int i = 0; i < fractionList.Count; i++)
                        {
                            ddlWidthInchSpecific.Items.Add(fractionList[i]);
                        }

                        RoofOptions.Controls.Add(widthLabel);
                        RoofOptions.Controls.Add(widthTextbox);
                        RoofOptions.Controls.Add(ddlWidthInchSpecific);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        Label leftProjectionLabel = new Label();
                        leftProjectionLabel.ID = "lblLeftProjection" + title;
                        leftProjectionLabel.Text = "Left Projection: ";
                        leftProjectionLabel.AssociatedControlID = "txtLeftProjection" + title;
                        leftProjectionLabel.CssClass = "labelFormatting";

                        TextBox leftProjectionTextbox = new TextBox();
                        leftProjectionTextbox.ID = "txtLeftProjection" + title;
                        leftProjectionTextbox.CssClass = "txtField txtInput";
                        leftProjectionTextbox.MaxLength = 3;
                        leftProjectionTextbox.Attributes.Add("onblur", "validateDimensions('" + title + "')");
                        leftProjectionTextbox.ToolTip = "Left projection is the width of wall section under the left side of the gable roof";

                        DropDownList ddlProjectionLeftInchSpecific = new DropDownList();
                        ddlProjectionLeftInchSpecific.ID = "ddlProjectionLeftInchSpecific" + title;
                        ddlProjectionLeftInchSpecific.CssClass = "txtField txtInput";
                        ddlProjectionLeftInchSpecific.Attributes.Add("style", "width:50px");

                        for (int i = 0; i < fractionList.Count; i++)
                        {
                            ddlProjectionLeftInchSpecific.Items.Add(fractionList[i]);
                        }

                        RoofOptions.Controls.Add(leftProjectionLabel);
                        RoofOptions.Controls.Add(leftProjectionTextbox);
                        RoofOptions.Controls.Add(ddlProjectionLeftInchSpecific);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        Label rightProjectionLabel = new Label();
                        rightProjectionLabel.ID = "lblRightProjection" + title;
                        rightProjectionLabel.Text = "Right Projection: ";
                        rightProjectionLabel.AssociatedControlID = "txtRightProjection" + title;
                        rightProjectionLabel.CssClass = "labelFormatting";

                        TextBox rightProjectionTextbox = new TextBox();
                        rightProjectionTextbox.ID = "txtRightProjection" + title;
                        rightProjectionTextbox.CssClass = "txtField txtInput";
                        rightProjectionTextbox.MaxLength = 3;
                        rightProjectionTextbox.Attributes.Add("onblur", "validateDimensions('" + title + "')");
                        rightProjectionTextbox.ToolTip = "Right projection is the width of wall section under the right side of the gable roof";

                        DropDownList ddlProjectionRightInchSpecific = new DropDownList();
                        ddlProjectionRightInchSpecific.ID = "ddlProjectionRightInchSpecific" + title;
                        ddlProjectionRightInchSpecific.CssClass = "txtField txtInput";
                        ddlProjectionRightInchSpecific.Attributes.Add("style", "width:50px");

                        for (int i = 0; i < fractionList.Count; i++)
                        {
                            ddlProjectionRightInchSpecific.Items.Add(fractionList[i]);
                        }

                        RoofOptions.Controls.Add(rightProjectionLabel);
                        RoofOptions.Controls.Add(rightProjectionTextbox);
                        RoofOptions.Controls.Add(ddlProjectionRightInchSpecific);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                    }
                    #endregion

                    #region Roof Number of Supports, Style Title, Gutter, and Fascia Options

                    if (roofStyle == 0)
                    {
                        RoofOptions.Controls.Add(new LiteralControl("<li id='liNumberOfSupports1" + title + "' style='display:inherit'>"));

                        Label numberOfSupportsLabel1 = new Label();
                        numberOfSupportsLabel1.ID = "lblNumberOfSupports1" + title;
                        numberOfSupportsLabel1.Text = "Number Of Supports: ";
                        numberOfSupportsLabel1.AssociatedControlID = "txtNumberOfSupports1" + title;
                        numberOfSupportsLabel1.CssClass = "labelFormatting";

                        TextBox numberOfSupportsTextbox1 = new TextBox();
                        numberOfSupportsTextbox1.ID = "txtNumberOfSupports1" + title;
                        numberOfSupportsTextbox1.Text = "0";
                        numberOfSupportsTextbox1.CssClass = "txtField txtInput";
                        numberOfSupportsTextbox1.MaxLength = 2;
                        numberOfSupportsTextbox1.Attributes.Add("style", "width:150px");
                        numberOfSupportsTextbox1.Attributes.Add("onkeyup", "displayButton('" + 1 + "','" + title + "')");
                        numberOfSupportsTextbox1.ToolTip = "This is the number of supports to hold up the studio roof";

                        DropDownList ddlRoofSupports1 = new DropDownList();
                        ddlRoofSupports1.ID = "ddlRoofSupports1" + title;
                        ddlRoofSupports1.CssClass = "txtField txtInput";
                        ddlRoofSupports1.Attributes.Add("style", "width:50px");
                        ddlRoofSupports1.Attributes.Add("onchange", "disableSelectedIndices('" + title + "')");

                        for (int i = 0; i < Constants.ROOF_SUPPORT_HEIGHTS.Length; i++)
                        {
                            ddlRoofSupports1.Items.Add(new ListItem(Constants.ROOF_SUPPORT_HEIGHTS[i] + "'", Constants.ROOF_SUPPORT_HEIGHTS[i]));
                        }

                        DropDownList ddlRoofSupportsType1 = new DropDownList();
                        ddlRoofSupportsType1.ID = "ddlRoofSupportsType1" + title;
                        ddlRoofSupportsType1.CssClass = "txtField txtInput";
                        ddlRoofSupportsType1.Attributes.Add("style", "width:100px");

                        for (int i = 0; i < Constants.ROOF_SUPPORT_TYPES.Length; i++)
                        {
                            ddlRoofSupportsType1.Items.Add(new ListItem(Constants.ROOF_SUPPORT_TYPES[i], Constants.ROOF_SUPPORT_TYPES[i]));
                        }

                        RoofOptions.Controls.Add(numberOfSupportsLabel1);
                        RoofOptions.Controls.Add(numberOfSupportsTextbox1);
                        RoofOptions.Controls.Add(ddlRoofSupports1);
                        RoofOptions.Controls.Add(ddlRoofSupportsType1);
                        RoofOptions.Controls.Add(new LiteralControl("<br/>"));
                        RoofOptions.Controls.Add(new LiteralControl("<input type='button' id='btnAddAnotherSize1" + title + "' value='Add Another Support Size' class='btnSubmit' style='display:none' onclick='displayMoreSizes(\"" + 2 + "\", \"" + title + "\")' title='This will open new textboxes for other sized supports'>"));

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li id='liNumberOfSupports2" + title + "' style='display:none'>"));

                        Label numberOfSupportsLabel2 = new Label();
                        numberOfSupportsLabel2.ID = "lblNumberOfSupports2" + title;
                        numberOfSupportsLabel2.Text = "Number Of Supports: ";
                        numberOfSupportsLabel2.AssociatedControlID = "txtNumberOfSupports2" + title;
                        numberOfSupportsLabel2.CssClass = "labelFormatting";

                        TextBox numberOfSupportsTextbox2 = new TextBox();
                        numberOfSupportsTextbox2.ID = "txtNumberOfSupports2" + title;
                        numberOfSupportsTextbox2.CssClass = "txtField txtInput";
                        numberOfSupportsTextbox2.MaxLength = 2;
                        numberOfSupportsTextbox2.Attributes.Add("style", "width:150px");
                        numberOfSupportsTextbox2.ToolTip = "This is the number of supports to hold up the studio roof";

                        DropDownList ddlRoofSupports2 = new DropDownList();
                        ddlRoofSupports2.ID = "ddlRoofSupports2" + title;
                        ddlRoofSupports2.CssClass = "txtField txtInput";
                        ddlRoofSupports2.Attributes.Add("style", "width:50px");
                        ddlRoofSupports2.Attributes.Add("onchange", "disableSelectedIndices('" + title + "')");

                        for (int i = 0; i < Constants.ROOF_SUPPORT_HEIGHTS.Length; i++)
                        {
                            ddlRoofSupports2.Items.Add(new ListItem(Constants.ROOF_SUPPORT_HEIGHTS[i] + "'", Constants.ROOF_SUPPORT_HEIGHTS[i]));
                        }

                        DropDownList ddlRoofSupportsType2 = new DropDownList();
                        ddlRoofSupportsType2.ID = "ddlRoofSupportsType2" + title;
                        ddlRoofSupportsType2.CssClass = "txtField txtInput";
                        ddlRoofSupportsType2.Attributes.Add("style", "width:100px");

                        for (int i = 0; i < Constants.ROOF_SUPPORT_TYPES.Length; i++)
                        {
                            ddlRoofSupportsType2.Items.Add(new ListItem(Constants.ROOF_SUPPORT_TYPES[i], Constants.ROOF_SUPPORT_TYPES[i]));
                        }

                        RoofOptions.Controls.Add(numberOfSupportsLabel2);
                        RoofOptions.Controls.Add(numberOfSupportsTextbox2);
                        RoofOptions.Controls.Add(ddlRoofSupports2);
                        RoofOptions.Controls.Add(ddlRoofSupportsType2);
                        RoofOptions.Controls.Add(new LiteralControl("<br/>"));
                        RoofOptions.Controls.Add(new LiteralControl("<input type='button' id='btnAddAnotherSize2" + title + "' value='Add Another Support Size' class='btnSubmit' onclick='displayMoreSizes(\"" + 3 + "\", \"" + title + "\")' title='This will open new textboxes for other sized supports'>"));
                        RoofOptions.Controls.Add(new LiteralControl("<input type='button' id='btnLessSizes2" + title + "' value='Less Support Sizes' class='btnSubmit' onclick='displayLessSizes(\"" + 2 + "\", \"" + title + "\"); disableSelectedIndices(\"" + title + "\")'>"));

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li id='liNumberOfSupports3" + title + "' style='display:none'>"));

                        Label numberOfSupportsLabel3 = new Label();
                        numberOfSupportsLabel3.ID = "lblNumberOfSupports3" + title;
                        numberOfSupportsLabel3.Text = "Number Of Supports: ";
                        numberOfSupportsLabel3.AssociatedControlID = "txtNumberOfSupports3" + title;
                        numberOfSupportsLabel3.CssClass = "labelFormatting";

                        TextBox numberOfSupportsTextbox3 = new TextBox();
                        numberOfSupportsTextbox3.ID = "txtNumberOfSupports3" + title;
                        numberOfSupportsTextbox3.CssClass = "txtField txtInput";
                        numberOfSupportsTextbox3.MaxLength = 2;
                        numberOfSupportsTextbox3.Attributes.Add("style", "width:150px");
                        numberOfSupportsTextbox3.ToolTip = "This is the number of supports to hold up the studio roof";

                        DropDownList ddlRoofSupports3 = new DropDownList();
                        ddlRoofSupports3.ID = "ddlRoofSupports3" + title;
                        ddlRoofSupports3.CssClass = "txtField txtInput";
                        ddlRoofSupports3.Attributes.Add("style", "width:50px");
                        ddlRoofSupports3.Attributes.Add("onchange", "disableSelectedIndices('" + title + "')");

                        for (int i = 0; i < Constants.ROOF_SUPPORT_HEIGHTS.Length; i++)
                        {
                            ddlRoofSupports3.Items.Add(new ListItem(Constants.ROOF_SUPPORT_HEIGHTS[i] + "'", Constants.ROOF_SUPPORT_HEIGHTS[i]));
                        }

                        DropDownList ddlRoofSupportsType3 = new DropDownList();
                        ddlRoofSupportsType3.ID = "ddlRoofSupportsType3" + title;
                        ddlRoofSupportsType3.CssClass = "txtField txtInput";
                        ddlRoofSupportsType3.Attributes.Add("style", "width:100px");

                        for (int i = 0; i < Constants.ROOF_SUPPORT_TYPES.Length; i++)
                        {
                            ddlRoofSupportsType3.Items.Add(new ListItem(Constants.ROOF_SUPPORT_TYPES[i], Constants.ROOF_SUPPORT_TYPES[i]));
                        }

                        RoofOptions.Controls.Add(numberOfSupportsLabel3);
                        RoofOptions.Controls.Add(numberOfSupportsTextbox3);
                        RoofOptions.Controls.Add(ddlRoofSupports3);
                        RoofOptions.Controls.Add(ddlRoofSupportsType3);
                        RoofOptions.Controls.Add(new LiteralControl("<br/>"));
                        RoofOptions.Controls.Add(new LiteralControl("<input type='button' id='btnAddAnotherSize3" + title + "' value='Add Another Support Size' class='btnSubmit' onclick='displayMoreSizes(\"" + 4 + "\", \"" + title + "\")' title='This will open new textboxes for other sized supports'>"));
                        RoofOptions.Controls.Add(new LiteralControl("<input type='button' id='btnLessSizes3" + title + "' value='Less Support Sizes' class='btnSubmit' onclick='displayLessSizes(\"" + 3 + "\", \"" + title + "\")'>"));

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li id='liNumberOfSupports4" + title + "' style='display:none'>"));

                        Label numberOfSupportsLabel4 = new Label();
                        numberOfSupportsLabel4.ID = "lblNumberOfSupports4" + title;
                        numberOfSupportsLabel4.Text = "Number Of Supports: ";
                        numberOfSupportsLabel4.AssociatedControlID = "txtNumberOfSupports4" + title;
                        numberOfSupportsLabel4.CssClass = "labelFormatting";

                        TextBox numberOfSupportsTextbox4 = new TextBox();
                        numberOfSupportsTextbox4.ID = "txtNumberOfSupports4" + title;
                        numberOfSupportsTextbox4.CssClass = "txtField txtInput";
                        numberOfSupportsTextbox4.MaxLength = 2;
                        numberOfSupportsTextbox4.Attributes.Add("style", "width:150px");
                        numberOfSupportsTextbox4.ToolTip = "This is the number of supports to hold up the studio roof";

                        DropDownList ddlRoofSupports4 = new DropDownList();
                        ddlRoofSupports4.ID = "ddlRoofSupports4" + title;
                        ddlRoofSupports4.CssClass = "txtField txtInput";
                        ddlRoofSupports4.Attributes.Add("style", "width:50px");
                        ddlRoofSupports4.Attributes.Add("onchange", "disableSelectedIndices('" + title + "')");

                        for (int i = 0; i < Constants.ROOF_SUPPORT_HEIGHTS.Length; i++)
                        {
                            ddlRoofSupports4.Items.Add(new ListItem(Constants.ROOF_SUPPORT_HEIGHTS[i] + "'", Constants.ROOF_SUPPORT_HEIGHTS[i]));
                        }

                        DropDownList ddlRoofSupportsType4 = new DropDownList();
                        ddlRoofSupportsType4.ID = "ddlRoofSupportsType4" + title;
                        ddlRoofSupportsType4.CssClass = "txtField txtInput";
                        ddlRoofSupportsType4.Attributes.Add("style", "width:100px");

                        for (int i = 0; i < Constants.ROOF_SUPPORT_TYPES.Length; i++)
                        {
                            ddlRoofSupportsType4.Items.Add(new ListItem(Constants.ROOF_SUPPORT_TYPES[i], Constants.ROOF_SUPPORT_TYPES[i]));
                        }

                        RoofOptions.Controls.Add(numberOfSupportsLabel4);
                        RoofOptions.Controls.Add(numberOfSupportsTextbox4);
                        RoofOptions.Controls.Add(ddlRoofSupports4);
                        RoofOptions.Controls.Add(ddlRoofSupportsType4);
                        RoofOptions.Controls.Add(new LiteralControl("<br/>"));
                        RoofOptions.Controls.Add(new LiteralControl("<input type='button' id='btnLessSizes4" + title + "' value='Less Support Sizes' class='btnSubmit' onclick='displayLessSizes(\"" + 4 + "\", \"" + title + "\")'>"));

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        Label gutterFasciaLabel = new Label();
                        gutterFasciaLabel.ID = "lblGutterFascia" + title;
                        gutterFasciaLabel.Text = "Gutter/Fascia Colours:";

                        RoofOptions.Controls.Add(gutterFasciaLabel);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        DropDownList ddlGutterColours = new DropDownList();
                        ddlGutterColours.ID = "ddlGutterColours" + title;
                        ddlGutterColours.CssClass = "txtField txtInput";

                        for (int i = 0; i < Constants.GUTTER_COLOUR.Length; i++)
                        {
                            ddlGutterColours.Items.Add(new ListItem(Constants.GUTTER_COLOUR[i], Constants.GUTTER_COLOUR[i]));
                        }

                        RoofOptions.Controls.Add(ddlGutterColours);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        RadioButton gutterYesRadio = new RadioButton();
                        gutterYesRadio.ID = "radGutterYes" + title;
                        gutterYesRadio.GroupName = "roofGutterRadios" + title;

                        Label gutterYesLabelRadio = new Label();
                        gutterYesLabelRadio.AssociatedControlID = "radGutterYes" + title;

                        Label gutterYesLabel = new Label();
                        gutterYesLabel.AssociatedControlID = "radGutterYes" + title;
                        gutterYesLabel.Text = "Yes";

                        RoofOptions.Controls.Add(gutterYesRadio);
                        RoofOptions.Controls.Add(gutterYesLabelRadio);
                        RoofOptions.Controls.Add(gutterYesLabel);

                        #region Gutter Options
                        RoofOptions.Controls.Add(new LiteralControl("<div class=\"toggleContent\">"));

                        RoofOptions.Controls.Add(new LiteralControl("<ul>"));

                        //RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        //CheckBox roofBuiltIntoOverhangCHK = new CheckBox();
                        //roofBuiltIntoOverhangCHK.ID = "chkRoofBuiltIntoOverhang" + title;
                        //Label roofBuiltIntoOverhangLBLCheck = new Label();
                        //roofBuiltIntoOverhangLBLCheck.ID = "lblBuiltIntoOverhangCheck" + title;
                        //roofBuiltIntoOverhangLBLCheck.AssociatedControlID = "chkRoofBuiltIntoOverhang" + title;
                        //Label roofBuiltIntoOverhangLBL = new Label();
                        //roofBuiltIntoOverhangLBL.ID = "lblBuiltIntoOverhang" + title + radioTitle;
                        //roofBuiltIntoOverhangLBL.AssociatedControlID = "chkRoofBuiltIntoOverhang" + title;
                        //roofBuiltIntoOverhangLBL.Text = "Built Into Overhang";

                        //RoofOptions.Controls.Add(roofBuiltIntoOverhangCHK);
                        //RoofOptions.Controls.Add(roofBuiltIntoOverhangLBLCheck);
                        //RoofOptions.Controls.Add(roofBuiltIntoOverhangLBL);

                        //RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        CheckBox roofGutterProGuttersCHK = new CheckBox();
                        roofGutterProGuttersCHK.ID = "chkRoofGutterProGutters" + title;
                        Label roofGutterProGuttersLBLCheck = new Label();
                        roofGutterProGuttersLBLCheck.ID = "lblGutterProGuttersCheck" + title;
                        roofGutterProGuttersLBLCheck.AssociatedControlID = "chkRoofGutterProGutters" + title;
                        Label roofGutterProGuttersLBL = new Label();
                        roofGutterProGuttersLBL.ID = "lblGutterProGutters" + title;
                        roofGutterProGuttersLBL.AssociatedControlID = "chkRoofGutterProGutters" + title;
                        roofGutterProGuttersLBL.Text = "Gutter Pro Gutters";

                        RoofOptions.Controls.Add(roofGutterProGuttersCHK);
                        RoofOptions.Controls.Add(roofGutterProGuttersLBLCheck);
                        RoofOptions.Controls.Add(roofGutterProGuttersLBL);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        Label lblExtraDownspouts = new Label();
                        lblExtraDownspouts.ID = "lblExtraDownspouts" + title;
                        lblExtraDownspouts.Text = "Extra Downspouts: ";
                        lblExtraDownspouts.AssociatedControlID = "ddlExtraDownspouts" + title;

                        DropDownList ddlExtraDownspouts = new DropDownList();
                        ddlExtraDownspouts.ID = "ddlExtraDownspouts" + title;
                        ddlExtraDownspouts.CssClass = "txtField txtInput";

                        for (int i = 0; i <= 10; i++)
                        {
                            ddlExtraDownspouts.Items.Add(new ListItem(i.ToString(), i.ToString()));
                        }

                        RoofOptions.Controls.Add(lblExtraDownspouts);
                        RoofOptions.Controls.Add(ddlExtraDownspouts);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("</ul>"));

                        RoofOptions.Controls.Add(new LiteralControl("</div>"));
                        #endregion

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        RadioButton gutterNoRadio = new RadioButton();
                        gutterNoRadio.ID = "radGutterNo" + title + radioTitle;
                        gutterNoRadio.GroupName = "roofGutterRadios" + title;
                        gutterNoRadio.Checked = true;

                        Label gutterNoLabelRadio = new Label();
                        gutterNoLabelRadio.AssociatedControlID = "radGutterNo" + title + radioTitle;

                        Label gutterNoLabel = new Label();
                        gutterNoLabel.AssociatedControlID = "radGutterNo" + title + radioTitle;
                        gutterNoLabel.Text = "No";

                        RoofOptions.Controls.Add(gutterNoRadio);
                        RoofOptions.Controls.Add(gutterNoLabelRadio);
                        RoofOptions.Controls.Add(gutterNoLabel);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                        RoofOptions.Controls.Add(new LiteralControl("<li>"));

                        Label styleTitleLabel = new Label();
                        styleTitleLabel.ID = "lblStyle" + title + radioTitle;
                        styleTitleLabel.Text = "Roof Styles:";

                        RoofOptions.Controls.Add(styleTitleLabel);

                        RoofOptions.Controls.Add(new LiteralControl("</li>"));

                    }
                    #endregion

                    //New instance of a table for every roof type
                    Table tblRoofDetails = new Table();

                    tblRoofDetails.ID = "tblRoofDetails" + title + radioTitle; //Adding appropriate id to the table
                    tblRoofDetails.CssClass = "tblTextFields";                  //Adding CssClass to the table for styling

                    RoofOptions.Controls.Add(new LiteralControl("<li>"));

                    //Roof style radio button
                    RadioButton styleRadio = new RadioButton();
                    styleRadio.ID = "radStyle" + title + radioTitle; //Adding appropriate id to roof style radio button
                    styleRadio.GroupName = "roofStyleRadios" + title;         //Adding group name for all roof styles

                    //Roof style radio button label for clickable area
                    Label styleLabelRadio = new Label();
                    styleLabelRadio.AssociatedControlID = "radStyle" + title + radioTitle;   //Tying this label to the radio button

                    //Roof style radio button label text
                    Label styleLabel = new Label();
                    styleLabel.AssociatedControlID = "radStyle" + title + radioTitle;    //Tying this label to the radio button
                    styleLabel.Text = radioTitle;     //Displaying the proper texted based on current title variable

                    RoofOptions.Controls.Add(styleRadio);        //Adding radio button control to placeholder RoofOptions
                    RoofOptions.Controls.Add(styleLabelRadio);   //Adding label control to placeholder RoofOptions
                    RoofOptions.Controls.Add(styleLabel);        //Adding label control to placeholder RoofOptions

                    RoofOptions.Controls.Add(new LiteralControl("<div class='toggleContent'>"));

                    RoofOptions.Controls.Add(new LiteralControl("<ul>"));

                    RoofOptions.Controls.Add(new LiteralControl("<li>"));

                    //Creating cells and controls for rows
                    #region Table:Default Row Title Current Roof (tblRoofDetails)

                    TableRow roofTitleRow = new TableRow();
                    roofTitleRow.ID = "rowRoofTitle" + title + radioTitle;
                    roofTitleRow.Attributes.Add("style", "display:none;");
                    TableCell roofTitleLBLCell = new TableCell();

                    Label roofTitleLBL = new Label();
                    roofTitleLBL.ID = "lblRoofTitle" + title + radioTitle;
                    roofTitleLBL.Text = "Select roof details:";
                    roofTitleLBL.Attributes.Add("style", "font-weight:bold;");

                    roofTitleLBLCell.Controls.Add(roofTitleLBL);

                    tblRoofDetails.Rows.Add(roofTitleRow);

                    roofTitleRow.Cells.Add(roofTitleLBLCell);

                    #endregion

                    #region Panel Thickness DropDown, Cells, and Row Declarations
                    TableRow roofPanelThicknessRow = new TableRow();
                    TableCell roofPanelThicknessLBLCell = new TableCell();
                    TableCell roofPanelThicknessDDLCell = new TableCell();

                    Label roofPanelThicknessLBL = new Label();
                    roofPanelThicknessLBL.ID = "lblRoofPanelThickness" + title + radioTitle;
                    roofPanelThicknessLBL.Text = "Panel Thicknesses: ";

                    DropDownList roofPanelThicknessDDL = new DropDownList();
                    roofPanelThicknessDDL.ID = "ddlRoofPanelThickness" + title + radioTitle;
                    #endregion

                    #region Alum. Skin or O.S.B. options
                    if (radioTitle == "Alum. Skin or O.S.B.") {
                        for (int i = 0; i < Constants.ROOF_TRADITIONAL_THICKNESSES.Count(); i++) {
                            roofPanelThicknessDDL.Items.Add(new ListItem(Constants.ROOF_TRADITIONAL_THICKNESSES[i], Constants.ROOF_TRADITIONAL_THICKNESSES[i]));
                        }

                        TableRow roofStripeColourRow = new TableRow();
                        TableCell roofStripeColourLBLCell = new TableCell();
                        TableCell roofStripeColourDDLCell = new TableCell();

                        Label roofStripeColourLBL = new Label();
                        roofStripeColourLBL.ID = "lblRoofStripeColour" + title + radioTitle;
                        roofStripeColourLBL.Text = "Stripe Colour: ";

                        DropDownList roofStripeColourDDL = new DropDownList();
                        roofStripeColourDDL.ID = "ddlRoofStripeColour" + title + radioTitle;

                        roofStripeColourLBLCell.Controls.Add(roofStripeColourLBL);

                        roofStripeColourDDLCell.Controls.Add(roofStripeColourDDL);

                        tblRoofDetails.Rows.Add(roofStripeColourRow);

                        roofStripeColourRow.Cells.Add(roofStripeColourLBLCell);

                        roofStripeColourRow.Cells.Add(roofStripeColourDDLCell);

                        for (int i = 0; i < Constants.ROOF_STRIPE_COLOURS.Count(); i++)
                        {
                            roofStripeColourDDL.Items.Add(new ListItem(Constants.ROOF_STRIPE_COLOURS[i], Constants.ROOF_STRIPE_COLOURS[i]));
                        }

                        TableRow roofPanelTypeRow = new TableRow();
                        TableCell roofPanelTypeLBLCell = new TableCell();
                        TableCell roofPanelTypeDDLCell = new TableCell();

                        Label panelTypeLabel = new Label();
                        panelTypeLabel.ID = "lblPanelType" + title;
                        panelTypeLabel.Text = "Panel Type: ";
                        panelTypeLabel.AssociatedControlID = "ddlPanelType" + title;
                        panelTypeLabel.CssClass = "labelFormatting";

                        DropDownList panelTypeDropDown = new DropDownList();
                        panelTypeDropDown.ID = "ddlPanelType" + title;
                        panelTypeDropDown.CssClass = "txtField txtInput";

                        for (int i = 0; i < Constants.ROOF_EXTRUSION_TYPE.Length; i++)
                        {
                            panelTypeDropDown.Items.Add(new ListItem(Constants.ROOF_EXTRUSION_TYPE[i], Constants.ROOF_EXTRUSION_TYPE[i]));
                        }

                        roofPanelTypeLBLCell.Controls.Add(panelTypeLabel);

                        roofPanelTypeDDLCell.Controls.Add(panelTypeDropDown);

                        tblRoofDetails.Rows.Add(roofPanelTypeRow);

                        roofPanelTypeRow.Cells.Add(roofPanelTypeLBLCell);

                        roofPanelTypeRow.Cells.Add(roofPanelTypeDDLCell);

                        TableRow roofInteriorSkinRow = new TableRow();
                        TableCell roofInteriorSkinLBLCell = new TableCell();
                        TableCell roofInteriorSkinDDLCell = new TableCell();

                        Label interiorSkinLabel = new Label();
                        interiorSkinLabel.ID = "lblInteriorSkin" + title;
                        interiorSkinLabel.Text = "Interior Skin: ";
                        interiorSkinLabel.AssociatedControlID = "ddlInteriorSkin" + title;
                        interiorSkinLabel.CssClass = "labelFormatting";

                        DropDownList interiorSkinDropDown = new DropDownList();
                        interiorSkinDropDown.ID = "ddlInteriorSkin" + title;
                        interiorSkinDropDown.CssClass = "txtField txtInput";

                        for (int i = 0; i < Constants.ROOF_INTERIOR_SKIN_TYPES.Length; i++)
                        {
                            interiorSkinDropDown.Items.Add(new ListItem(Constants.ROOF_INTERIOR_SKIN_TYPES[i], Constants.ROOF_INTERIOR_SKIN_TYPES[i]));
                        }

                        roofInteriorSkinLBLCell.Controls.Add(interiorSkinLabel);

                        roofInteriorSkinDDLCell.Controls.Add(interiorSkinDropDown);

                        tblRoofDetails.Rows.Add(roofInteriorSkinRow);

                        roofInteriorSkinRow.Cells.Add(roofInteriorSkinLBLCell);

                        roofInteriorSkinRow.Cells.Add(roofInteriorSkinDDLCell);

                        TableRow roofExteriorSkinRow = new TableRow();
                        TableCell roofExteriorSkinLBLCell = new TableCell();
                        TableCell roofExteriorSkinDDLCell = new TableCell();

                        Label exteriorSkinLabel = new Label();
                        exteriorSkinLabel.ID = "lblExteriorSkin" + title;
                        exteriorSkinLabel.Text = "Exterior Skin: ";
                        exteriorSkinLabel.AssociatedControlID = "ddlExteriorSkin" + title;
                        exteriorSkinLabel.CssClass = "labelFormatting";

                        DropDownList exteriorSkinDropDown = new DropDownList();
                        exteriorSkinDropDown.ID = "ddlExteriorSkin" + title;
                        exteriorSkinDropDown.CssClass = "txtField txtInput";

                        for (int i = 0; i < Constants.ROOF_EXTERIOR_SKIN_TYPES.Length; i++)
                        {
                            exteriorSkinDropDown.Items.Add(new ListItem(Constants.ROOF_EXTERIOR_SKIN_TYPES[i], Constants.ROOF_EXTERIOR_SKIN_TYPES[i]));
                        }

                        roofExteriorSkinLBLCell.Controls.Add(exteriorSkinLabel);

                        roofExteriorSkinDDLCell.Controls.Add(exteriorSkinDropDown);

                        tblRoofDetails.Rows.Add(roofExteriorSkinRow);

                        roofExteriorSkinRow.Cells.Add(roofExteriorSkinLBLCell);

                        roofExteriorSkinRow.Cells.Add(roofExteriorSkinDDLCell);

                    }
                    #endregion
                    #region Acrylic T-Bar System options
                    else if (radioTitle == "Acrylic T-Bar System"){

                        TableRow roofAcrylicColourRow = new TableRow();
                        TableCell roofAcrylicColourLBLCell = new TableCell();
                        TableCell roofAcrylicColourDDLCell = new TableCell();

                        Label roofAcrylicColourLBL = new Label();
                        roofAcrylicColourLBL.ID = "lblRoofAcrylicColour" + title + radioTitle;
                        roofAcrylicColourLBL.Text = "Acrylic Colour: ";

                        DropDownList roofAcrylicColourDDL = new DropDownList();
                        roofAcrylicColourDDL.ID = "ddlRoofAcrylicColour" + title + radioTitle;

                        for (int i = 0; i < Constants.ROOF_ACRYLIC_COLOURS.Count(); i++)
                        {
                            roofAcrylicColourDDL.Items.Add(new ListItem(Constants.ROOF_ACRYLIC_COLOURS[i], Constants.ROOF_ACRYLIC_COLOURS[i]));
                        }

                        roofAcrylicColourLBLCell.Controls.Add(roofAcrylicColourLBL);

                        roofAcrylicColourDDLCell.Controls.Add(roofAcrylicColourDDL);

                        tblRoofDetails.Rows.Add(roofAcrylicColourRow);

                        roofAcrylicColourRow.Cells.Add(roofAcrylicColourLBLCell);

                        roofAcrylicColourRow.Cells.Add(roofAcrylicColourDDLCell);

                        for (int i = 0; i < Constants.ROOF_ACRYLIC_THICKNESSES.Count(); i++) {
                            roofPanelThicknessDDL.Items.Add(new ListItem(Constants.ROOF_ACRYLIC_THICKNESSES[i], Constants.ROOF_ACRYLIC_THICKNESSES[i]));
                        }
                    }
                    #endregion
                    #region Thermadeck Sytem options
                    else
                    {

                        TableRow roofBarrierRow = new TableRow();
                        TableCell roofBarrierCHKCell = new TableCell();

                        CheckBox roofBarrierCHK = new CheckBox();
                        roofBarrierCHK.ID = "chkRoofBarrier" + title + radioTitle;
                        Label roofBarrierLBLCheck = new Label();
                        roofBarrierLBLCheck.ID = "lblBarrierCheck" + title + radioTitle;
                        roofBarrierLBLCheck.AssociatedControlID = "chkRoofBarrier" + title + radioTitle;
                        Label roofBarrierLBL = new Label();
                        roofBarrierLBL.ID = "lblBarrier" + title + radioTitle;
                        roofBarrierLBL.AssociatedControlID = "chkRoofBarrier" + title + radioTitle;
                        roofBarrierLBL.Text = "Metal Vapour Barrier";

                        roofBarrierCHKCell.Controls.Add(roofBarrierCHK);

                        roofBarrierCHKCell.Controls.Add(roofBarrierLBLCheck);

                        roofBarrierCHKCell.Controls.Add(roofBarrierLBL);

                        tblRoofDetails.Rows.Add(roofBarrierRow);

                        roofBarrierRow.Cells.Add(roofBarrierCHKCell);

                        for (int i = 0; i < Constants.ROOF_THERMADECK_THICKNESSES.Count(); i++) {
                            roofPanelThicknessDDL.Items.Add(new ListItem(Constants.ROOF_THERMADECK_THICKNESSES[i], Constants.ROOF_THERMADECK_THICKNESSES[i]));
                        }
                    }
                    #endregion

                    #region Panel Thickness DropDown, Cells, Row being added to the table
                    roofPanelThicknessLBLCell.Controls.Add(roofPanelThicknessLBL);

                    roofPanelThicknessDDLCell.Controls.Add(roofPanelThicknessDDL);

                    tblRoofDetails.Rows.Add(roofPanelThicknessRow);

                    roofPanelThicknessRow.Cells.Add(roofPanelThicknessLBLCell);

                    roofPanelThicknessRow.Cells.Add(roofPanelThicknessDDLCell);
                    #endregion

                    #region Table:# Row Add This Roof (tblRoofDetails)

                    TableRow roofButtonRow = new TableRow();
                    roofButtonRow.ID = "rowAddRoof" + title + radioTitle;
                    roofButtonRow.Attributes.Add("style", "display:inherit;");
                    TableCell roofAddButtonCell = new TableCell();
                    TableCell roofFillButtonCell = new TableCell();

                    Button roofButton = new Button();
                    roofButton.ID = "btnAdd" + title + radioTitle;
                    roofButton.Text = "Add this " + radioTitle + " roof";
                    roofButton.CssClass = "btnSubmit";

                    //roofAddButtonCell.Controls.Add(new LiteralControl("<input id='btnAddthisRoof" + title + "' type='button' onclick='addRoof(\"" + title + "\")' class='btnSubmit' style='display:inherit;' value='Add This " + title + " Roof'/>"));
                    roofAddButtonCell.Controls.Add(roofButton);

                    tblRoofDetails.Rows.Add(roofButtonRow);

                    roofButtonRow.Cells.Add(roofAddButtonCell);

                    #endregion

                    //Adding table to placeholder RoofOptions
                    RoofOptions.Controls.Add(tblRoofDetails);

                    RoofOptions.Controls.Add(new LiteralControl("</li>"));

                    RoofOptions.Controls.Add(new LiteralControl("</ul>"));

                    RoofOptions.Controls.Add(new LiteralControl("</div>"));

                    //Start of loop closing tags
                    RoofOptions.Controls.Add(new LiteralControl("</li>"));

                }

                RoofOptions.Controls.Add(new LiteralControl("</ul>"));
                #endregion

                //Closing necessary tags
                RoofOptions.Controls.Add(new LiteralControl("</li>"));

                RoofOptions.Controls.Add(new LiteralControl("</ul>"));

                RoofOptions.Controls.Add(new LiteralControl("</div>"));

                RoofOptions.Controls.Add(new LiteralControl("</li>"));

            }
            #endregion

            #region PostBack functionality to store roofs
            if (IsPostBack)
            {
                Roof aRoof = new Roof();

                if (Request.Form["ctl00$MainContent$roofTypeRadios"] == "radTypeStudio")
                {
                    aRoof = buildStudioRoof();
                }
                else if (Request.Form["ctl00$MainContent$roofTypeRadios"] == "radTypeGable")
                {
                    aRoof = buildGableRoof();
                }

                Session["completedRoof"] = aRoof;
                // Hit the database
                using (SqlConnection aConnection = new SqlConnection(sdsDBConnection.ConnectionString))
                {
                    aConnection.Open();
                    SqlCommand aCommand = aConnection.CreateCommand();
                    SqlTransaction aTransaction;
                    SqlDataReader aReader;

                    // Start a local transaction.
                    aTransaction = aConnection.BeginTransaction("SampleTransaction");

                    // Must assign both transaction object and connection
                    // to Command object for a pending local transaction
                    aCommand.Connection = aConnection;
                    aCommand.Transaction = aTransaction;

                    try
                    {
                        //Project
                        #region Project

                        var newGuid = Guid.NewGuid();

                        aCommand.CommandText = "INSERT INTO projects(project_type, installation_type, project_name, customer_id, user_id, date_created, status, revised_date, revised_user_id, msrp, project_notes, "
                                                + "hidden, cut_pitch) VALUES ("
                                                + "'Roof', "
                                                + "'None', "
                            //+ "'" + Session["newProjectProjectName"] + "', "
                                                + "'" + newGuid + "', "
                            //+ Session["customer_id"] + ", "
                                                + "1, "
                            //+ Session["user_id"] + ", "
                                                + "1, "
                                                + "'" + DateTime.Now.ToString("yyyy/MM/dd") + "', "
                                                + "'" + "Active" + "', "
                                                + "'" + DateTime.Now.ToString("yyyy/MM/dd") + "', "
                            //+ Session["user_id"] + ", "
                                                + "1, "
                                                + 0 + ", "
                                                + 0 + ", "
                                                + 0 + ", "
                                                + 1
                                                + ");";
                        aCommand.ExecuteNonQuery(); //Execute a command that does not return anything
                        #endregion

                        //Get project_id for use in below statements
                        aCommand.CommandText = "SELECT project_id FROM projects WHERE project_name = '" + newGuid + "'"; // Replace newGuid with Session["newProjectProjectName"]
                        aReader = aCommand.ExecuteReader();
                        aReader.Read();

                        int project_id = Convert.ToInt32(aReader[0]);
                        aReader.Close();

                        aTransaction.Commit();

                        #region Roof
                        if (Session["newProjectHasRoof"].ToString() == "Yes")
                        {
                            int fireProtection = 0;
                            if (aRoof.FireProtection == true)
                            {
                                fireProtection = 1;
                            }

                            int thermadeck = 0;
                            if (aRoof.Thermadeck == true)
                            {
                                thermadeck = 1;
                            }

                            int acrylicBool = 0;
                            if (aRoof.Type.Contains("Acrylic"))
                            {
                                acrylicBool = 1;
                            }

                            int gutterBool = 0;
                            if (aRoof.Gutters == true)
                            {
                                gutterBool = 1;
                            }

                            int gutterProBool = 0;
                            if (aRoof.GutterPro == true)
                            {
                                gutterProBool = 1;
                            }

                            string roofType = Session["newProjectRoofType"].ToString();
                            if (roofType.Contains("Gable"))
                            {
                                roofType = "Gable";
                            }
                            aCommand.CommandText = "INSERT INTO roofs(project_id, roof_index, roof_type, interior_skin, exterior_skin, thickness, fire_protection, thermadeck, acrylic, gutter, gutter_pro, gutter_colour, number_supports, stripe_colour, projection, width) VALUES("
                                                    + project_id + ", "
                                                    + 0 + ", '"
                                                    + roofType + "', '"
                                                    + aRoof.InteriorSkin + "', '"
                                                    + aRoof.ExteriorSkin + "', "
                                                    + aRoof.Thickness + ", "
                                                    + fireProtection + ", "
                                                    + thermadeck + ", "
                                                    + acrylicBool + ", "
                                                    + gutterBool + ", "
                                                    + gutterProBool + ", '"
                                                    + aRoof.GutterColour + "', "
                                                    + aRoof.NumberSupports + ", '"
                                                    + aRoof.StripeColour + "', "
                                                    + aRoof.Projection + ", "
                                                    + aRoof.Width
                                                    + ");";
                            aCommand.ExecuteNonQuery();

                            //Now insert the needed roof modules

                            for (int roofModules = 0; roofModules < aRoof.RoofModules.Count; roofModules++)
                            {
                                string roof_view;
                                if (Session["newProjectRoofType"].ToString() == "Studio")
                                {
                                    //If it's a studio roof, we have a single studio roof module
                                    roof_view = "S";
                                }
                                else if (roofModules == 0)
                                {
                                    //If it's not studio, and it's the first module, it's gable left
                                    roof_view = "GL";
                                }
                                else
                                {
                                    //Otherwise it's gable right
                                    roof_view = "GR";
                                }

                                aCommand.CommandText = "INSERT INTO roof_modules(project_id, roof_index, roof_view, interior_skin, exterior_skin, number_items, projection, width) VALUES("
                                                    + project_id + ", "
                                                    + (roofModules) + ", '"
                                                    + roof_view + "', '"
                                                    + aRoof.InteriorSkin + "', '"
                                                    + aRoof.ExteriorSkin + "', "
                                                    + aRoof.RoofModules[roofModules].RoofItems.Count + ", "
                                                    + aRoof.RoofModules[roofModules].Projection + ", "
                                                    + aRoof.RoofModules[roofModules].Width
                                                    + ");";
                                aCommand.ExecuteNonQuery();

                                //We also enter the roof items
                                for (int roofItems = 0; roofItems < aRoof.RoofModules[roofModules].RoofItems.Count; roofItems++)
                                {
                                    aCommand.CommandText = "INSERT INTO roof_items(project_id, roof_index, roof_view, item_index, roof_item, projection, width) VALUES("
                                                    + project_id + ", "
                                                    + 0 + ", '"
                                                    + roof_view + "', "
                                                    + roofItems + ", '"
                                                    + aRoof.RoofModules[roofModules].RoofItems[roofItems].ItemType + "', "
                                                    + aRoof.RoofModules[roofModules].RoofItems[roofItems].Projection + ", "
                                                    + aRoof.RoofModules[roofModules].RoofItems[roofItems].Width
                                                    + ");";
                                    aCommand.ExecuteNonQuery();

                                    if (aRoof.RoofModules[roofModules].RoofItems[roofItems].ItemType == "Foam Panel")
                                    {
                                        aCommand.CommandText = "INSERT INTO foam_panels(project_id, roof_index, roof_view, item_index, interior_skin, exterior_skin, projection, width, set_back, skylight, fanbeam) VALUES("
                                                    + project_id + ", "
                                                    + 0 + ", '"
                                                    + roof_view + "', "
                                                    + roofItems + ", '"
                                                    + aRoof.InteriorSkin + "', '"
                                                    + aRoof.ExteriorSkin + "', "
                                                    + aRoof.RoofModules[roofModules].RoofItems[roofItems].Projection + ", "
                                                    + aRoof.RoofModules[roofModules].RoofItems[roofItems].Width + ", "
                                                    + 0 + ", " //what is normal set_back?
                                                    + aRoof.RoofModules[roofModules].RoofItems[roofItems].SkyLight + ", "
                                                    + aRoof.RoofModules[roofModules].RoofItems[roofItems].FanBeam
                                                    + ");";
                                        aCommand.ExecuteNonQuery();
                                    }

                                    if (aRoof.RoofModules[roofModules].RoofItems[roofItems].ItemType == "Acrylic Panel")
                                    {
                                        aCommand.CommandText = "INSERT INTO acrylic_panels(project_id, roof_index, roof_view, item_index, panel_colour, projection, width, set_back) VALUES("
                                                    + project_id + ", "
                                                    + 0 + ", '"
                                                    + roof_view + "', "
                                                    + roofItems + ", '"
                                                    + Session["roofAcrylicPanelColour"] + "', "
                                                    + aRoof.RoofModules[roofModules].RoofItems[roofItems].Projection + ", "
                                                    + aRoof.RoofModules[roofModules].RoofItems[roofItems].Width + ", "
                                                    + 0 //what is normal set_back?
                                                    + ");";
                                        aCommand.ExecuteNonQuery();
                                    }

                                    if (aRoof.RoofModules[roofModules].RoofItems[roofItems].ItemType == "Thermadeck Panel")
                                    {
                                        float leftSetBack = Convert.ToSingle(Session["roofJointSetback"]);
                                        float rightSetBack = Convert.ToSingle(Session["roofJointSetback"]);

                                        if (roofItems == aRoof.RoofModules[roofModules].RoofItems.Count - 1)
                                        {
                                            rightSetBack = Convert.ToSingle(Session["roofSidesSetback"]);
                                        }

                                        if (roofItems == 0)
                                        {
                                            leftSetBack = Convert.ToSingle(Session["roofSidesSetback"]);
                                        }

                                        aCommand.CommandText = "INSERT INTO thermadeck_panels(project_id, roof_index, roof_view, item_index, projection, width, set_back, back_setback, front_setback, right_setback, left_setback) VALUES("
                                                            + project_id + ", "
                                                            + 0 + ", '"
                                                            + roof_view + "', "
                                                            + roofItems + ", "
                                                            + aRoof.RoofModules[roofModules].RoofItems[roofItems].Projection + ", "
                                                            + aRoof.RoofModules[roofModules].RoofItems[roofItems].Width + ", "
                                                            + 0 + ", " //What is normal set_back? Soffit length?
                                                            + Convert.ToSingle(Session["roofLedgerSetback"]) + ", "
                                                            + Convert.ToSingle(Session["roofFrontSetback"]) + ", "
                                                            + rightSetBack + ", "
                                                            + leftSetBack
                                                            + ");";
                                        aCommand.ExecuteNonQuery();
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        int hi;
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                        //lblError.Text = "Commit Exception Type: " + ex.GetType();
                        //lblError.Text += "  Message: " + ex.Message;

                        // Attempt to roll back the transaction.
                        try
                        {
                            aTransaction.Rollback();
                        }
                        catch (Exception ex2)
                        {
                            // This catch block will handle any errors that may have occurred
                            // on the server that would cause the rollback to fail, such as
                            // a closed connection.
                            //lblError.Text = "Rollback Exception Type: " + ex2.GetType();
                            //lblError.Text += "  Message: " + ex2.Message;
                        }
                    }
                }
            }
            #endregion
        }
        private Roof buildStudioRoof()
        {
            Roof aRoof;

            bool isFireProtected = false;
            bool isThermadeck = false;
            bool hasGutters = false;
            bool gutterPro = false;

            int extraDownSpouts = int.Parse(Request.Form["ctl00$MainContent$ddlExtraDownspoutsStudio"]);
            float roofWidth = float.Parse(Request.Form["ctl00$MainContent$txtWidthStudio"]);
            float roofProjection = float.Parse(Request.Form["ctl00$MainContent$txtProjectionStudio"]);

            string roofSupportType = Request.Form["ctl00$MainContent$txtProjectionStudio"];
            List<RoofSupport> supportList = new List<RoofSupport>();

            for (int i = 1; i <= 4; i++)
            {
                if (Request.Form["ctl00$MainContent$txtNumberOfSupports" + i + "Studio"] != "")
                {
                    int roofSupports = int.Parse(Request.Form["ctl00$MainContent$txtNumberOfSupports" + Convert.ToString(i) + "Studio"]);
                    int roofSupportsSize = int.Parse(Request.Form["ctl00$MainContent$ddlRoofSupports" + Convert.ToString(i) + "Studio"]);

                    if (roofSupports != 0)
                        supportList.AddRange(buildRoofSupports(roofSupports, roofSupportsSize, roofSupportType));
                }
            }

            //float overhang = float.Parse(Request.Form["ctl00$MainContent$txtOverhangStudio"]);

            string stripeColour;
            string acrylicColour;

            string gutter = Request.Form["ctl00$MainContent$roofGutterRadios"];
            string gutterProField = Request.Form["ctl00$MainContent$chkRoofGutterProGuttersStudio"];
            string gutterColour = Request.Form["ctl00$MainContent$ddlGutterColoursStudio"];

            string roofStyle = Request.Form["ctl00$MainContent$roofStyleRadiosStudio"];

            float panelThickness;
            string panelExteriorSkin;
            string panelInteriorSkin;
            string panelType;

            if (roofStyle == "Alum. Skin or O.S.B.")
            {
                stripeColour = Request.Form["ctl00$MainContent$ddlRoofStripeColourStudioAlum. Skin or O.S.B."];
                acrylicColour = "";
                panelType = Request.Form["ctl00$MainContent$ddlPanelTypeStudio"];
                panelExteriorSkin = Request.Form["ctl00$MainContent$ddlExteriorSkinStudio"];
                panelInteriorSkin = Request.Form["ctl00$MainContent$ddlInteriorSkinStudio"];
                panelThickness = Convert.ToSingle(Request.Form["ctl00$MainContent$ddlRoofPanelThicknessStudioAlum. Skin or O.S.B."]);
            }
            else if (roofStyle == "Acrylic T-Bar System")
            {
                stripeColour = "";
                acrylicColour = Request.Form["ctl00$MainContent$ddlRoofAcrylicColourStudioAcrylic T-Bar System"];
                panelType = "Pressure Cap";
                panelExteriorSkin = Request.Form["ctl00$MainContent$ddlExteriorSkinStudio"];
                panelInteriorSkin = Request.Form["ctl00$MainContent$ddlInteriorSkinStudio"];
                panelThickness = Convert.ToSingle(Request.Form["ctl00$MainContent$ddlRoofPanelThicknessStudioAcrylic T-Bar System"]);
            }
            else
            {
                stripeColour = "";
                acrylicColour = "";
                panelType = "Pressure Cap";
                //Thermadeck systems must be osb/osb
                panelExteriorSkin = "OSB";
                panelInteriorSkin = "OSB";
                panelThickness = Convert.ToSingle(Request.Form["ctl00$MainContent$ddlRoofPanelThicknessStudioThermadeck System"]);
            }

            //Calculate actual width and projection based on overhang value
            //roofProjection += (overhang);
            //roofWidth += (overhang * 2);

            //Now that we have roof rojection and width, add it to session.
            Session.Add("roofProjection", roofProjection);
            Session.Add("roofWidth", roofWidth);

            //A studio roof will only have one list entry, while a gable will have two
            List<RoofModule> aModuleList = new List<RoofModule>();
            aModuleList.Add(buildStudioRoofModule(roofProjection, roofWidth));

            if (panelType.Contains("FP"))
            {
                isFireProtected = true;
            }

            if (roofStyle == "Thermadeck System")
            {
                isThermadeck = true;
            }

            if (gutter == "radGutterYesStudio")
            {
                hasGutters = true;
            }

            if (gutterProField == "on")
            {
                gutterPro = true;
            }

            if (hasGutters == false)
            {
                gutterColour = "NA";
                extraDownSpouts = 0;
            }

            aRoof = new Roof("Studio", panelInteriorSkin, panelExteriorSkin, panelThickness, isFireProtected, isThermadeck, hasGutters, gutterPro, gutterColour, stripeColour, acrylicColour, extraDownSpouts, roofProjection, roofWidth, supportList, aModuleList);
            Session.Add("completedRoof", aRoof);

            Response.Redirect("WizardRoofOnlySkylight.aspx");

            return aRoof;
        }
        private Roof buildGableRoof()
        {
            Roof aRoof;

            bool isFireProtected = false;
            bool isThermadeck = false;
            bool hasGutters = false;
            bool gutterPro = false;

            int extraDownSpouts = int.Parse(Request.Form["ctl00$MainContent$ddlExtraDownspoutsGable"]);
            float roofWidth = float.Parse(Request.Form["ctl00$MainContent$txtWidthGable"]);
            float roofLeftProjection = float.Parse(Request.Form["ctl00$MainContent$txtLeftProjectionGable"]);
            float roofRightProjection = float.Parse(Request.Form["ctl00$MainContent$txtRightProjectionGable"]);
            float roofProjection;

            string roofSupportType = Request.Form["ctl00$MainContent$txtProjectionGable"];
            List<RoofSupport> supportList = new List<RoofSupport>();

            for (int i = 1; i <= 4; i++)
            {
                if (Request.Form["ctl00$MainContent$txtNumberOfSupports" + i + "Gable"] != "")
                {
                    int roofSupports = int.Parse(Request.Form["ctl00$MainContent$txtNumberOfSupports" + Convert.ToString(i) + "Gable"]);
                    int roofSupportsSize = int.Parse(Request.Form["ctl00$MainContent$ddlRoofSupports" + Convert.ToString(i) + "Gable"]);

                    if (roofSupports != 0)
                        supportList.AddRange(buildRoofSupports(roofSupports, roofSupportsSize, roofSupportType));
                }
            }

            //float overhang = float.Parse(Request.Form["ctl00$MainContent$txtOverhangGable"]);

            string stripeColour;
            string acrylicColour;

            string gutter = Request.Form["ctl00$MainContent$roofGutterRadios"];
            string gutterProField = Request.Form["ctl00$MainContent$chkRoofGutterProGuttersGable"];
            string gutterColour = Request.Form["ctl00$MainContent$ddlGutterColoursGable"];

            string roofStyle = Request.Form["ctl00$MainContent$roofStyleRadiosGable"];

            float panelThickness;
            string panelExteriorSkin;
            string panelInteriorSkin;
            string panelType;

            if (roofStyle == "Alum. Skin or O.S.B.")
            {
                stripeColour = Request.Form["ctl00$MainContent$ddlRoofStripeColourGableAlum. Skin or O.S.B."];
                acrylicColour = "";
                panelType = Request.Form["ctl00$MainContent$ddlPanelTypeGable"];
                panelExteriorSkin = Request.Form["ctl00$MainContent$ddlExteriorSkinGable"];
                panelInteriorSkin = Request.Form["ctl00$MainContent$ddlInteriorSkinGable"];
                panelThickness = Convert.ToSingle(Request.Form["ctl00$MainContent$ddlRoofPanelThicknessGableAlum. Skin or O.S.B."]);
            }
            else if (roofStyle == "Acrylic T-Bar System")
            {
                stripeColour = "";
                acrylicColour = Request.Form["ctl00$MainContent$ddlRoofAcrylicColourGableAcrylic T-Bar System"];
                panelType = "Pressure Cap";
                panelExteriorSkin = Request.Form["ctl00$MainContent$ddlExteriorSkinGable"];
                panelInteriorSkin = Request.Form["ctl00$MainContent$ddlInteriorSkinGable"];
                panelThickness = Convert.ToSingle(Request.Form["ctl00$MainContent$ddlRoofPanelThicknessGableAcrylic T-Bar System"]);
            }
            else
            {
                stripeColour = "";
                acrylicColour = "";
                panelType = "Pressure Cap";
                //Thermadeck systems must be osb/osb
                panelExteriorSkin = "OSB";
                panelInteriorSkin = "OSB";
                panelThickness = Convert.ToSingle(Request.Form["ctl00$MainContent$ddlRoofPanelThicknessGableThermadeck System"]);
            }

            Session.Add("roofLeftProjection", roofLeftProjection);
            Session.Add("roofRightProjection", roofRightProjection);
            Session.Add("roofWidth", roofWidth);

            //A studio roof will only have one list entry, while a gable will have two
            List<RoofModule> gableModules = buildGableRoofModule(roofLeftProjection, roofRightProjection, roofWidth);

            if (panelType.Contains("FP"))
            {
                isFireProtected = true;
            }

            if (roofStyle == "Thermadeck System")
            {
                isThermadeck = true;
            }

            if (gutter == "radGutterYesGable")
            {
                hasGutters = true;
            }

            if (gutterProField == "on")
            {
                gutterPro = true;
            }

            if (hasGutters == false)
            {
                gutterColour = "NA";
                extraDownSpouts = 0;
            }

            roofProjection = roofLeftProjection + roofRightProjection;

            //changeme hardcoded supports to 0
            aRoof = new Roof("Gable", panelInteriorSkin, panelExteriorSkin, panelThickness, isFireProtected, isThermadeck, hasGutters, gutterPro, gutterColour, stripeColour, acrylicColour, extraDownSpouts, roofProjection, roofWidth, supportList, gableModules);
            Session.Add("completedRoof", aRoof);

            Response.Redirect("WizardRoofOnlySkylight.aspx");

            return aRoof;
        }