Beispiel #1
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
        }
Beispiel #2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //If either entry is blank, stop checks
            if (txtUsername.Text == "" || txtPassword.Text == "")
            {
                Session["loginErrorMessage"] = "Please enter your username and password.";
                lblError.Text = Session["loginErrorMessage"].ToString();
            }
            else
            {
                //If entered, get name and password for querying db
                string userName = GlobalFunctions.escapeSqlString(txtUsername.Text);
                string userHash = GlobalFunctions.CalculateSHAHash(txtPassword.Text);

                //Get the customers assosciated with this dealer. status=1 requires it to be an active account.
                sdsLogin.SelectCommand = "SELECT login, password, user_type, user_group, reference_id, user_id FROM users WHERE login='******' AND password='******' AND status=1";

                //assign the table names to the dataview object
                DataView dvUsers = (DataView)sdsLogin.Select(System.Web.UI.DataSourceSelectArguments.Empty);

                //If nothing was found, let them know there was an error
                if (dvUsers.Count == 0)
                {
                    Session["loginErrorMessage"] = "Username or password invalid.";
                    lblError.Text = Session["loginErrorMessage"].ToString();
                }
                else
                {
                    Session["loginErrorMessage"] = "";
                    //Sunspace
                    if (dvUsers[0][2].ToString() == "S")
                    {
                        //-1 is not a valid dealer ID, so on later checks, if -1, the user will need to spoof, which changes this
                        Session.Add("dealer_id", "-1");
                        Session.Add("user_id", dvUsers[0][5].ToString());
                        Session.Add("user_type", dvUsers[0][2].ToString());
                        Session.Add("user_group", dvUsers[0][3].ToString());
                        Session.Add("loggedIn", dvUsers[0][0].ToString());
                    }
                    //If dealer
                    else if (dvUsers[0][2].ToString() == "D")
                    {
                        Session.Add("dealer_id", dvUsers[0][4].ToString());
                        Session.Add("user_id", dvUsers[0][5].ToString());
                        Session.Add("user_type", dvUsers[0][2].ToString());
                        Session.Add("user_group", dvUsers[0][3].ToString());
                        Session.Add("loggedIn", dvUsers[0][0].ToString());
                    }

                    //Login means we need to update the last_access date
                    //get current date right now
                    DateTime aDate = DateTime.Now;
                    sdsLogin.UpdateCommand = "UPDATE users SET last_access='" + aDate.ToString("yyyy/MM/dd") + "' "
                                             + "WHERE login='******'";
                    sdsLogin.Update();

                    //Finally, we check what kind of user they are. Send sunspace users to spoof page by default, otherwise to home
                    //if (dvUsers[0][2].ToString() == "S")
                    //{
                    //    Session["dealer_id"] = 1; //changeme to sunspace internal dealer default
                    //}

                    Response.Redirect("Home.aspx");
                }
            }
        }
Beispiel #3
0
        //This function will add a new user to the customer database at an applicable time when the page is completed and has been posted back.
        protected void insertNewCustomer()
        {
            sdsCustomers.SelectCommand = "SELECT * FROM customers";;
            DataView dvCustomers = (DataView)sdsCustomers.Select(System.Web.UI.DataSourceSelectArguments.Empty);

            //If new customer is selected, lets add this customer to our customer list
            //CHANGEME Uses logged in session number as dealerID, this is likely userID in the future, and needs to be changed

            string sqlInsert = "INSERT INTO customers (dealer_id,first_name,last_name,address,city,prov_city,country,zip_postal,main_phone,cell_phone,email,accept_email)"
                               + "VALUES("
                               + Convert.ToInt32(GlobalFunctions.escapeSqlString(Session["dealer_id"].ToString())) + ",'" + GlobalFunctions.escapeSqlString(hidFirstName.Value) + "','" + GlobalFunctions.escapeSqlString(hidLastName.Value)
                               + "','" + GlobalFunctions.escapeSqlString(hidAddress.Value) + "','" + GlobalFunctions.escapeSqlString(hidCity.Value) + "','"
                               + GlobalFunctions.escapeSqlString(hidProvState.Value) + "','" + GlobalFunctions.escapeSqlString(hidCountry.Value) + "','" + GlobalFunctions.escapeSqlString(hidZip.Value) + "','" + GlobalFunctions.escapeSqlString(hidPhone.Value)
                               + "','" + GlobalFunctions.escapeSqlString(hidCell.Value) + "','" + GlobalFunctions.escapeSqlString(hidEmail.Value) + "',"
                               + 1 + ")";

            sdsCustomers.InsertCommand = sqlInsert;
            sdsCustomers.Insert();
        }
Beispiel #4
0
        protected void btnLayout_Click(object sender, EventArgs e)
        {
            if (hidExisting.Value == "")
            {
                insertNewCustomer();
            }

            //Add any post-page required info into session
            Session.Add("customer_id", hidExisting.Value.ToString());
            Session.Add("newProjectProjectName", GlobalFunctions.escapeSqlString(hidProjectName.Value.ToString()));
            Session.Add("newProjectProjectType", GlobalFunctions.escapeSqlString(hidProjectType.Value.ToString()));
            Session.Add("newProjectKneewallType", GlobalFunctions.escapeSqlString(hidKneewallType.Value.ToString()));
            Session.Add("newProjectKneewallHeight", GlobalFunctions.escapeSqlString(hidKneewallHeight.Value.ToString()));
            Session.Add("newProjectKneewallTint", GlobalFunctions.escapeSqlString(hidKneewallTint.Value.ToString()));
            Session.Add("newProjectTransomType", GlobalFunctions.escapeSqlString(hidTransomType.Value.ToString()));
            Session.Add("newProjectFramingColour", GlobalFunctions.escapeSqlString(hidFramingColour.Value.ToString()));
            Session.Add("newProjectInteriorSkin", GlobalFunctions.escapeSqlString(hidInteriorSkin.Value.ToString()));
            Session.Add("newProjectExteriorSkin", GlobalFunctions.escapeSqlString(hidExteriorSkin.Value.ToString()));
            Session.Add("newProjectPrefabFloor", GlobalFunctions.escapeSqlString(hidPrefabFloor.Value.ToString()));
            Session.Add("newProjectHasRoof", GlobalFunctions.escapeSqlString(hidRoof.Value.ToString()));
            Session.Add("newProjectRoofType", GlobalFunctions.escapeSqlString(hidRoofType.Value.ToString()));
            Session.Add("newProjectTransomTint", GlobalFunctions.escapeSqlString(hidTransomTint.Value.ToString()));

            Session.Add("model", GlobalFunctions.escapeSqlString(hidModelNumber.Value.ToString()));
            Session.Add("kneewallType", GlobalFunctions.escapeSqlString(hidKneewallType.Value.ToString()));
            Session.Add("kneewallHeight", GlobalFunctions.escapeSqlString(hidKneewallHeight.Value.ToString()));
            Session.Add("transomType", GlobalFunctions.escapeSqlString(hidTransomType.Value.ToString()));
            Session.Add("transomHeight", GlobalFunctions.escapeSqlString(hidTransomHeight.Value.ToString()));
            Session.Add("transomColour", GlobalFunctions.escapeSqlString(hidTransomTint.Value.ToString()));

            Session.Add("floorVapourBarrier", "");

            if (hidRoof.Value.ToString() == "No")
            {
                Session.Add("soffitLength", 0);
            }
            else
            {
                Session.Add("soffitLength", GlobalFunctions.escapeSqlString(hidSoffitLength.Value.ToString()));
            }

            //If custom is selected, send to drawing tool
            if (hidLayoutSelection.Value.ToString() == "Custom")
            {
                Response.Redirect("CustomDrawingTool.aspx");
            }
            else
            {
                if (hidLayoutSelection.Value.ToString() == "1")
                {
                    Session.Add("lineInfo", "0,500,50,50,E,S/25,25,50,325,P,W/25,475,325,325,P,S/475,475,325,50,P,E/");
                }
                else if (hidLayoutSelection.Value.ToString() == "2")
                {
                    Session.Add("lineInfo", "0,500,50,50,E,S/25,25,50,325,P,W/25,100,325,400,P,SW/100,400,400,400,P,S/400,475,400,325,P,SE/475,475,325,50,P,E/");
                }
                else if (hidLayoutSelection.Value.ToString() == "3")
                {
                    Session.Add("lineInfo", "0,500,50,50,E,S/25,25,50,350,P,W/25,75,350,350,P,S/75,150,350,425,P,SW/150,350,425,425,P,S/350,425,425,350,P,SE/425,475,350,350,P,S/475,475,350,50,P,E/");
                }
                else if (hidLayoutSelection.Value.ToString() == "4")
                {
                    Session.Add("lineInfo", "0,450,50,50,E,S/450,450,50,450,E,W/50,50,50,400,P,W/50,450,400,400,P,S/");
                }
                else if (hidLayoutSelection.Value.ToString() == "5")
                {
                    Session.Add("lineInfo", "150,150,0,125,E,W/150,500,125,125,E,S/150,50,75,75,P,N/50,50,75,400,P,W/50,450,400,400,P,S/450,450,400,125,P,E/");
                }
                else if (hidLayoutSelection.Value.ToString() == "6")
                {
                    Session.Add("lineInfo", "0,500,50,50,E,S/450,450,50,400,P,W/450,150,400,400,P,N/150,150,400,350,P,E/150,50,350,350,P,N/50,50,350,50,P,E/");
                }
                else if (hidLayoutSelection.Value.ToString() == "7")
                {
                    Session.Add("lineInfo", "0,450,50,50,E,S/450,450,50,500,E,W/50,50,50,375,P,W/50,125,375,450,P,SW/125,450,450,450,P,S/");
                }
                else if (hidLayoutSelection.Value.ToString() == "8")
                {
                    Session.Add("lineInfo", "150,150,0,100,E,W/150,500,100,100,E,S/150,50,50,50,P,N/50,50,50,350,P,W/50,100,350,400,P,SW/100,450,400,400,P,S/450,450,400,100,P,E/");
                }
                else if (hidLayoutSelection.Value.ToString() == "9")
                {
                    Session.Add("lineInfo", "350,350,0,100,E,W/350,0,100,100,E,N/350,450,50,50,P,S/450,450,50,400,P,W/450,150,400,400,P,N/150,150,400,350,P,E/150,50,350,350,P,N/50,50,350,100,P,E/");
                }
                else if (hidLayoutSelection.Value.ToString() == "10")
                {
                    Session.Add("lineInfo", "50,450,50,50,P,S/450,450,50,450,P,W/450,50,450,450,P,N/50,50,450,50,P,E/");
                }

                if (chkMirrored.Checked == true)
                {
                    if (hidLayoutSelection.Value.ToString() == "4")
                    {
                        Session.Add("lineInfo", "500,50,50,50,E,N/50,50,50,450,E,W/450,450,50,400,P,W/450,50,400,400,P,N/");
                    }
                    else if (hidLayoutSelection.Value.ToString() == "5")
                    {
                        Session.Add("lineInfo", "350,350,0,125,E,W/350,0,125,125,E,N/350,450,75,75,P,S/450,450,75,400,P,W/450,50,400,400,P,N/50,50,400,125,P,E/");
                    }
                    else if (hidLayoutSelection.Value.ToString() == "6")
                    {
                        Session.Add("lineInfo", "0,500,50,50,E,S/50,50,50,400,P,W/50,350,400,400,P,S/350,350,400,350,P,E/350,450,350,350,P,S/450,450,350,50,P,E/");
                    }
                    else if (hidLayoutSelection.Value.ToString() == "7")
                    {
                        Session.Add("lineInfo", "500,50,50,50,E,N/50,50,50,500,E,W/450,450,50,375,P,W/450,375,375,450,P,NW/375,50,450,450,P,N/");
                    }
                    else if (hidLayoutSelection.Value.ToString() == "8")
                    {
                        Session.Add("lineInfo", "350,350,0,100,E,W/350,0,100,100,E,N/350,450,50,50,P,S/450,450,50,350,P,W/450,400,350,400,P,NW/400,50,400,400,P,N/50,50,400,100,P,E/");
                    }
                    else if (hidLayoutSelection.Value.ToString() == "9")
                    {
                        Session.Add("lineInfo", "150,150,0,100,E,W/150,500,100,100,E,S/150,50,50,50,P,N/50,50,50,400,P,W/50,350,400,400,P,S/350,350,400,350,P,E/350,450,350,350,P,S/450,450,350,100,P,E/ ");
                    }
                }

                if (hidRoofType.Value.Contains("Gable"))
                {
                    if (hidLayoutSelection.Value.ToString() == "1")
                    {
                        Session.Add("lineInfo", "225,250,300,300,G,S/25,450,25,25,E,S/50,50,25,300,P,W/50,225,300,300,P,S/250,425,300,300,P,S/425,425,300,25,P,E");
                    }
                    else if (hidLayoutSelection.Value.ToString() == "2")
                    {
                        Session.Add("lineInfo", "225,250,300,300,G,S/25,450,25,25,E,S/50,50,25,250,P,W/50,100,250,300,P,SW/100,225,300,300,P,S/250,375,300,300,P,S/375,425,300,250,P,SE/425,425,250,25,P,E");
                    }
                    else if (hidLayoutSelection.Value.ToString() == "3")
                    {
                        Session.Add("lineInfo", "225,250,300,300,G,S/25,450,25,25,E,S/50,50,25,250,P,W/50,100,250,250,P,S/100,150,250,300,P,SW/150,225,300,300,P,S/250,325,300,300,P,S/325,375,300,250,P,SE/375,425,250,250,P,S/425,425,250,25,P,E");
                    }
                    else if (hidLayoutSelection.Value.ToString() == "5")
                    {
                    }
                    else if (hidLayoutSelection.Value.ToString() == "6")
                    {
                    }
                    else if (hidLayoutSelection.Value.ToString() == "8")
                    {
                    }
                    else if (hidLayoutSelection.Value.ToString() == "9")
                    {
                    }
                    else if (hidLayoutSelection.Value.ToString() == "10")
                    {
                    }

                    if (chkMirrored.Checked == true)
                    {
                        if (hidLayoutSelection.Value.ToString() == "5")
                        {
                        }
                        else if (hidLayoutSelection.Value.ToString() == "6")
                        {
                        }
                        else if (hidLayoutSelection.Value.ToString() == "8")
                        {
                        }
                        else if (hidLayoutSelection.Value.ToString() == "9")
                        {
                        }
                    }
                }

                Response.Redirect("WizardWallsAndMods.aspx");
            }
        }
Beispiel #5
0
        //protected int project_id = Session["newProjectProjectID"];



        protected void Page_Load(object sender, EventArgs e)
        {
            List <Wall> aListOfWalls = new List <Wall>();


            int    project_id = 10;
            string project_type;
            string installation_type;
            string project_name;

            int    wallCount;
            int    wall_index;
            string wall_type;
            string model_type;
            float  wall_length;
            string orientation;
            float  set_back;
            string name;
            int    first_item_index;
            int    last_item_index;
            float  wall_start_height;
            float  wall_end_height;
            float  soffit_length;
            float  gable_peak;
            int    obstructions;
            bool   fire_protection;

            int    linear_index = 0;
            string linear_type;
            float  linear_start_height;
            float  linear_end_height;
            float  linear_length;
            string frame_colour;
            string sex;
            float  fixed_location;
            bool   attached_to;

            int    module_index;
            string item_type;
            float  module_start_height;
            float  module_end_height;
            float  module_length;



            #region hardcode population
            //This info will all come from the database eventually

            //List<Wall> aListOfWalls = new List<Wall>();
            float  backwall       = 150.0f;
            float  frontwall      = 140.0f;
            float  slope          = 0.6f;
            string projectName    = "Joey's Super Fantastic Sunroom";
            string modelType      = "M200";
            string roofStyle      = "Studio";
            bool   cutPitch       = true;
            string installType    = "trailer";
            string framingColour  = "Driftwood";
            string interiorColour = "Driftwood";
            string exteriorColour = "Driftwood";
            string interiorSkin   = "Driftwood Aluminum Stucco";
            string exteriorSkin   = "Driftwood Aluminum Stucco";

            Wall firstWall = new Wall();
            firstWall.Length       = 200;
            firstWall.Orientation  = "WEST";
            firstWall.Name         = "Wall 1";
            firstWall.WallType     = "Proposed";
            firstWall.ModelType    = "M200";
            firstWall.StartHeight  = 150;
            firstWall.EndHeight    = 140;
            firstWall.SoffitLength = 0;
            firstWall.GablePeak    = 0;
            firstWall.SoffitLength = 0;

            Wall secondWall = new Wall();
            secondWall.Length       = 200;
            secondWall.Orientation  = "SOUTH";
            secondWall.Name         = "Wall 2";
            secondWall.WallType     = "Proposed";
            secondWall.ModelType    = "M200";
            secondWall.StartHeight  = 140;
            secondWall.EndHeight    = 140;
            secondWall.SoffitLength = 0;
            secondWall.GablePeak    = 0;
            secondWall.SoffitLength = 0;

            Wall thirdWall = new Wall();
            thirdWall.Length       = 200;
            thirdWall.Orientation  = "EAST";
            thirdWall.Name         = "Wall 3";
            thirdWall.WallType     = "Proposed";
            thirdWall.ModelType    = "M200";
            thirdWall.StartHeight  = 140;
            thirdWall.EndHeight    = 150;
            thirdWall.SoffitLength = 0;
            thirdWall.GablePeak    = 0;
            thirdWall.SoffitLength = 0;

            aListOfWalls.Add(firstWall);
            aListOfWalls.Add(secondWall);
            aListOfWalls.Add(thirdWall);
            #endregion  //hardcode population

            #region dynamic accordion population

            #region Project Wide
            accordion.Controls.Add(new LiteralControl("<h2>Project Wide Settings</h2>"));
            accordion.Controls.Add(new LiteralControl("<ul>"));

            #region Tag Name
            accordion.Controls.Add(new LiteralControl("<li>"));
            Label tagName = new Label();
            tagName.ID   = "lblTagName";
            tagName.Text = "Tag Name: ";
            accordion.Controls.Add(tagName);

            TextBox tagNameTextBox = new TextBox();
            tagNameTextBox.ID       = "txtTagName";
            tagNameTextBox.Text     = projectName.ToString();
            tagNameTextBox.CssClass = "txtField txtInput";
            tagNameTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
            tagNameTextBox.Attributes.Add("runat", "server");
            accordion.Controls.Add(tagNameTextBox);
            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion         //tag name

            #region Model Type
            accordion.Controls.Add(new LiteralControl("<li>"));
            Label modelLabel = new Label();
            modelLabel.ID   = "lblModelLabel";
            modelLabel.Text = "Model Type: ";
            accordion.Controls.Add(modelLabel);

            DropDownList modelDropDown = new DropDownList();
            modelDropDown.ID = "ddlModel";

            for (int i = 0; i < modelNumbers.Length; i++)
            {
                modelDropDown.Items.Add(modelNumbers[i].ToString());
            }

            modelDropDown.SelectedValue = modelType;
            modelDropDown.Attributes.Add("runat", "server");
            accordion.Controls.Add(modelDropDown);
            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion         //model type

            #region Roof Style
            accordion.Controls.Add(new LiteralControl("<li>"));
            Label styleLabel = new Label();
            styleLabel.ID   = "lblStyleLabel";
            styleLabel.Text = "Roof Style: ";
            accordion.Controls.Add(styleLabel);

            DropDownList styleDropDown = new DropDownList();
            styleDropDown.ID = "ddlStyle";

            for (int i = 0; i < roofTypes.Length; i++)
            {
                styleDropDown.Items.Add(roofTypes[i].ToString());
            }

            styleDropDown.SelectedValue = roofStyle;
            styleDropDown.Attributes.Add("runat", "server");
            accordion.Controls.Add(styleDropDown);
            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion         //roof style

            #region Cut Pitch
            accordion.Controls.Add(new LiteralControl("<li>"));
            Label firstCutPitchLabel = new Label();
            firstCutPitchLabel.ID   = "lblFirstCutPitch";
            firstCutPitchLabel.Text = "Cut Pitch";
            accordion.Controls.Add(firstCutPitchLabel);

            CheckBox cutPitchCheckBox = new CheckBox();
            cutPitchCheckBox.ID      = "chkCutPitch";
            cutPitchCheckBox.Checked = cutPitch;
            cutPitchCheckBox.Text    = " ";
            cutPitchCheckBox.Attributes.Add("runat", "server");
            accordion.Controls.Add(cutPitchCheckBox);

            Label secondCutPitchLabel = new Label();
            secondCutPitchLabel.ID = "lblSecondCutPitch";
            secondCutPitchLabel.AssociatedControlID = "chkCutPitch";
            secondCutPitchLabel.Attributes.Add("runat", "server");
            accordion.Controls.Add(secondCutPitchLabel);
            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion         //cut pitch

            #region Install Type
            if (installType != "standAlone")
            {
                accordion.Controls.Add(new LiteralControl("<li>"));

                accordion.Controls.Add(new LiteralControl("<br/>"));
                Label installLabel = new Label();
                installLabel.ID   = "lblInstall";
                installLabel.Text = "Install Type";
                accordion.Controls.Add(installLabel);
                accordion.Controls.Add(new LiteralControl("<br/>"));

                RadioButton installHouseRadio = new RadioButton();
                installHouseRadio.ID = "radInstallHouse";
                installHouseRadio.Attributes.Add("runat", "server");
                installHouseRadio.GroupName = "InstallType";
                installHouseRadio.Text      = " ";
                accordion.Controls.Add(installHouseRadio);

                Label firstInstallLabel = new Label();
                firstInstallLabel.ID = "lblFirstInstallLabel";
                firstInstallLabel.AssociatedControlID = "radInstallHouse";
                accordion.Controls.Add(firstInstallLabel);

                Label secondInstallLabel = new Label();
                secondInstallLabel.ID = "lblSecondInstallLabel";
                secondInstallLabel.AssociatedControlID = "radInstallHouse";
                secondInstallLabel.Text = "House";
                accordion.Controls.Add(secondInstallLabel);

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

                RadioButton installTrailerRadio = new RadioButton();
                installTrailerRadio.ID = "radInstallTrailer";
                installTrailerRadio.Attributes.Add("runat", "server");
                installTrailerRadio.GroupName = "InstallType";
                installTrailerRadio.Text      = " ";
                accordion.Controls.Add(installTrailerRadio);

                Label thirdInstallLabel = new Label();
                thirdInstallLabel.ID = "lblThirdInstallLabel";
                thirdInstallLabel.AssociatedControlID = "radInstallTrailer";
                accordion.Controls.Add(thirdInstallLabel);

                Label fourthInstallLabel = new Label();
                fourthInstallLabel.ID = "lblFourthInstallLabel";
                fourthInstallLabel.AssociatedControlID = "radInstallHouse";
                fourthInstallLabel.Text = "Trailer";
                accordion.Controls.Add(fourthInstallLabel);
                accordion.Controls.Add(new LiteralControl("</li>"));

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

                if (installType == "house")
                {
                    installHouseRadio.Checked = true;
                }
                else if (installType == "trailer")
                {
                    installTrailerRadio.Checked = true;
                }
            }
            #endregion         //Install Type

            #region Framing Colours
            accordion.Controls.Add(new LiteralControl("<li>"));

            Label coloursTitleLabel = new Label();
            coloursTitleLabel.ID   = "lblWallColours";
            coloursTitleLabel.Text = "Framing and Wall Colours";
            accordion.Controls.Add(coloursTitleLabel);

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

            Label framingColourLabel = new Label();
            framingColourLabel.ID   = "lblFramingColour";
            framingColourLabel.Text = "Framing Colour: ";
            accordion.Controls.Add(framingColourLabel);

            DropDownList framingColoursDropDown = new DropDownList();
            framingColoursDropDown.ID = "ddlFramingColours";
            framingColoursDropDown.Attributes.Add("runat", "server");

            if (modelType == "M100")
            {
                for (int i = 0; i < model100FramingColours.Length; i++)
                {
                    framingColoursDropDown.Items.Add(model100FramingColours[i].ToString());
                }
            }
            else if (modelType == "M200")
            {
                for (int i = 0; i < model200FramingColours.Length; i++)
                {
                    framingColoursDropDown.Items.Add(model200FramingColours[i].ToString());
                }
            }
            else if (modelType == "M300")
            {
                for (int i = 0; i < model300FramingColours.Length; i++)
                {
                    framingColoursDropDown.Items.Add(model300FramingColours[i].ToString());
                }
            }
            else
            {
                for (int i = 0; i < model400FramingColours.Length; i++)
                {
                    framingColoursDropDown.Items.Add(model400FramingColours[i].ToString());
                }
            }

            framingColoursDropDown.SelectedValue = framingColour;

            accordion.Controls.Add(framingColoursDropDown);

            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion

            #region Wall Colours
            accordion.Controls.Add(new LiteralControl("<li>"));

            Label wallColoursInteriorLabel = new Label();
            wallColoursInteriorLabel.ID   = "lblWallColoursInterior";
            wallColoursInteriorLabel.Text = "Interior Colour: ";
            accordion.Controls.Add(wallColoursInteriorLabel);

            DropDownList wallColoursInteriorDropDown = new DropDownList();
            wallColoursInteriorDropDown.ID = "ddlWallColoursInterior";
            wallColoursInteriorDropDown.Attributes.Add("runat", "server");

            for (int i = 0; i < interiorWallColours.Length; i++)
            {
                wallColoursInteriorDropDown.Items.Add(interiorWallColours[i].ToString());
            }

            wallColoursInteriorDropDown.SelectedValue = interiorColour;

            accordion.Controls.Add(wallColoursInteriorDropDown);

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

            Label wallColoursExteriorLabel = new Label();
            wallColoursExteriorLabel.ID   = "lblWallColoursExterior";
            wallColoursExteriorLabel.Text = "Exterior Colour: ";
            accordion.Controls.Add(wallColoursExteriorLabel);

            DropDownList wallColoursExteriorDropDown = new DropDownList();
            wallColoursExteriorDropDown.ID = "ddlWallColoursExterior";
            wallColoursExteriorDropDown.Attributes.Add("runat", "server");

            for (int i = 0; i < exteriorWallColours.Length; i++)
            {
                wallColoursExteriorDropDown.Items.Add(exteriorWallColours[i].ToString());
            }

            wallColoursExteriorDropDown.SelectedValue = exteriorColour;

            accordion.Controls.Add(wallColoursExteriorDropDown);

            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion

            #region Wall Textures
            accordion.Controls.Add(new LiteralControl("<li>"));

            Label wallTextureTitleLabel = new Label();
            wallTextureTitleLabel.ID   = "lblWallTexture";
            wallTextureTitleLabel.Text = "Skin Types";
            accordion.Controls.Add(wallTextureTitleLabel);

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

            Label wallTextureInteriorLabel = new Label();
            wallTextureInteriorLabel.ID   = "lblWallTextureInterior";
            wallTextureInteriorLabel.Text = "Interior: ";
            accordion.Controls.Add(wallTextureInteriorLabel);

            DropDownList wallTextureInteriorDropDown = new DropDownList();
            wallTextureInteriorDropDown.ID = "ddlWallTextureInterior";
            wallTextureInteriorDropDown.Attributes.Add("runat", "server");

            for (int i = 0; i < interiorWallSkinTypes.Length; i++)
            {
                wallTextureInteriorDropDown.Items.Add(interiorWallSkinTypes[i].ToString());
            }

            wallTextureInteriorDropDown.SelectedValue = interiorSkin;

            accordion.Controls.Add(wallTextureInteriorDropDown);

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

            Label wallTextureExteriorLabel = new Label();
            wallTextureExteriorLabel.ID   = "lblWallTextureExterior";
            wallTextureExteriorLabel.Text = "Exterior: ";
            accordion.Controls.Add(wallTextureExteriorLabel);

            DropDownList wallTextureExteriorDropDown = new DropDownList();
            wallTextureExteriorDropDown.ID = "ddlWallTextureExterior";
            wallTextureExteriorDropDown.Attributes.Add("runat", "server");

            for (int i = 0; i < exteriorWallSkinTypes.Length; i++)
            {
                wallTextureExteriorDropDown.Items.Add(exteriorWallSkinTypes[i].ToString());
            }

            wallTextureExteriorDropDown.SelectedValue = exteriorSkin;

            accordion.Controls.Add(wallTextureExteriorDropDown);

            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion

            #endregion     //Project Wide

            #region Wall Height Entry
            accordion.Controls.Add(new LiteralControl("<h2>Wall Heights</h2>"));
            accordion.Controls.Add(new LiteralControl("<ul>"));

            #region BackWall Height

            string[] backHeight = firstWall.StartHeight.ToString().Split('.');

            accordion.Controls.Add(new LiteralControl("<li>"));
            Label backwallHeight = new Label();
            backwallHeight.ID   = "lblBackwall";
            backwallHeight.Text = "Back Wall Height: ";
            accordion.Controls.Add(backwallHeight);

            TextBox backwallTextBox = new TextBox();
            backwallTextBox.ID       = "txtBackwall";
            backwallTextBox.Text     = backHeight[0];
            backwallTextBox.CssClass = "txtField txtInput";
            backwallTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
            backwallTextBox.Attributes.Add("runat", "server");
            accordion.Controls.Add(backwallTextBox);

            DropDownList backwallFractions = new DropDownList();
            backwallFractions.ID = "ddlBackwallFractions";

            fractionList = GlobalFunctions.FractionOptions("." + backHeight[1]);

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

            backwallFractions.Attributes.Add("runat", "server");
            accordion.Controls.Add(backwallFractions);
            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion         //backwall height

            #region FrontWall Height

            string[] frontHeight = firstWall.EndHeight.ToString().Split('.');

            accordion.Controls.Add(new LiteralControl("<li>"));
            Label frontwallHeight = new Label();
            frontwallHeight.ID   = "lblFrontwall";
            frontwallHeight.Text = "Front Wall Height: ";
            accordion.Controls.Add(frontwallHeight);

            TextBox frontwallTextBox = new TextBox();
            frontwallTextBox.ID       = "txtFrontwall";
            frontwallTextBox.Text     = frontHeight[0];
            frontwallTextBox.CssClass = "txtField txtInput";
            frontwallTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
            frontwallTextBox.Attributes.Add("runat", "server");
            accordion.Controls.Add(frontwallTextBox);

            DropDownList frontwallFractions = new DropDownList();
            frontwallFractions.ID = "ddlFrontwallFractions";

            fractionList = GlobalFunctions.FractionOptions("." + frontHeight[1]);

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

            frontwallFractions.Attributes.Add("runat", "server");
            accordion.Controls.Add(frontwallFractions);
            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion         //frontwall height

            #region Slope

            //rise = parseFloat(backWallHeight) - parseFloat(frontWallHeight);

            //return ((rise / (roomProjection - soffitLength)) * 12).toFixed(2);  //slope over 12, rounded to 2 decimal places



            accordion.Controls.Add(new LiteralControl("<li>"));
            Label slopeLabel = new Label();
            slopeLabel.ID   = "lblSlope";
            slopeLabel.Text = "Slope: ";
            accordion.Controls.Add(slopeLabel);

            TextBox slopeTextBox = new TextBox();
            slopeTextBox.ID       = "txtSlope";
            slopeTextBox.Text     = slope.ToString();
            slopeTextBox.CssClass = "txtField txtInput";
            slopeTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
            slopeTextBox.Attributes.Add("runat", "server");
            accordion.Controls.Add(slopeTextBox);

            Label overTwelve = new Label();
            overTwelve.ID   = "lblOverTwelve";
            overTwelve.Text = " / 12";
            accordion.Controls.Add(overTwelve);
            accordion.Controls.Add(new LiteralControl("</li>"));
            #endregion         //slope

            accordion.Controls.Add(new LiteralControl("</ul>"));
            #endregion     //wall height entry

            #region Wall Width Entry
            accordion.Controls.Add(new LiteralControl("<ul class=\"toggleOptions\">"));
            accordion.Controls.Add(new LiteralControl("<h2>Wall Widths</h2>"));

            for (int i = 0; i < aListOfWalls.Count; i++)
            {
                //accordion.Controls.Add(new LiteralControl("<li onclick=alert("+(i+1)+");>"));
                accordion.Controls.Add(new LiteralControl("<li onclick=drawWall(document.getElementById('MainContent_txtWidth" + (i + 1) + "').value,document.getElementById('MainContent_lblStartHeightDisplay" + (i + 1) + "').innerHTML,document.getElementById('MainContent_lblEndHeightDisplay" + (i + 1) + "').innerHTML," + (i + 1) + ");>"));
                Label accordionLabel = new Label();
                accordionLabel.ID   = "lblWall" + (i + 1) + "Label";
                accordionLabel.Text = aListOfWalls[i].Name;
                accordion.Controls.Add(accordionLabel);

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

                #region Wall Length
                accordion.Controls.Add(new LiteralControl("<li>"));
                Label width = new Label();
                width.ID   = "lblWidth" + (i + 1);
                width.Text = "Width: ";
                accordion.Controls.Add(width);

                TextBox widthTextBox = new TextBox();
                widthTextBox.ID       = "txtWidth" + (i + 1);
                widthTextBox.Text     = aListOfWalls[i].Length.ToString();
                widthTextBox.CssClass = "txtField txtInput";
                widthTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);");
                widthTextBox.Attributes.Add("runat", "server");
                accordion.Controls.Add(widthTextBox);

                DropDownList widthFractions = new DropDownList();
                widthFractions.ID = "ddlWall" + (i + 1) + "Fractions";

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

                widthFractions.Attributes.Add("runat", "server");
                accordion.Controls.Add(widthFractions);

                accordion.Controls.Add(new LiteralControl("</li>"));
                #endregion         //wall length

                #region Wall StartHeight
                accordion.Controls.Add(new LiteralControl("<li>"));
                Label startHeight = new Label();
                startHeight.ID   = "lblStartHeight" + (i + 1);
                startHeight.Text = "Start Height: ";
                accordion.Controls.Add(startHeight);

                Label startHeightDisplay = new Label();
                startHeightDisplay.ID   = "lblStartHeightDisplay" + (i + 1);
                startHeightDisplay.Text = aListOfWalls[i].StartHeight.ToString();
                startHeightDisplay.Attributes.Add("runat", "server");
                accordion.Controls.Add(startHeightDisplay);

                accordion.Controls.Add(new LiteralControl("</li>"));
                #endregion         //wall start height

                #region Wall EndHeight
                accordion.Controls.Add(new LiteralControl("<li>"));
                Label endHeight = new Label();
                endHeight.ID   = "lblEndHeight" + (i + 1);
                endHeight.Text = "End Height: ";
                accordion.Controls.Add(endHeight);

                Label endHeightDisplay = new Label();
                endHeightDisplay.ID   = "lblEndHeightDisplay" + (i + 1);
                endHeightDisplay.Text = aListOfWalls[i].EndHeight.ToString();
                endHeightDisplay.Attributes.Add("runat", "server");
                accordion.Controls.Add(endHeightDisplay);

                accordion.Controls.Add(new LiteralControl("</li>"));
                #endregion         //wall endheight

                accordion.Controls.Add(new LiteralControl("</ul></div></li>"));
            }

            accordion.Controls.Add(new LiteralControl("</ul>"));
            #endregion //wall width entry

            #endregion //dynamic accordion population
        }
Beispiel #6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //If any of the textboxes required for all users are empty stop immediately
            if (txtLogin.Text == "" ||
                txtPassword.Text == "" ||
                txtEmail.Text == "" ||
                txtFirstName.Text == "" ||
                txtLastName.Text == "")
            {
                lblError.Text = "Please enter data into all fields.";
            }
            else
            {
                #region Dealer Sales Rep
                //adding a dealer sales rep
                //Need to check hidden for usergroup as the ddl is built/cleared client side on change of ddlusertype
                if (ddlUserType.SelectedValue == "Dealer" && hidUserGroup.Value == "Sales Rep")
                {
                    DateTime aDate = DateTime.Now;
                    sdsUsers.InsertCommand = "INSERT INTO users (login, password, email_address, enrol_date, last_access, user_type, user_group, reference_id, first_name, last_name, status)"
                                             + "VALUES('"
                                             + GlobalFunctions.escapeSqlString(txtLogin.Text) + "', '"
                                             + GlobalFunctions.CalculateSHAHash(txtPassword.Text) + "', '"
                                             + GlobalFunctions.escapeSqlString(txtEmail.Text) + "', '"
                                             + aDate.ToString("yyyy/MM/dd") + "', '"
                                             + aDate.ToString("yyyy/MM/dd") + "', '"                    //default to same-day
                                             + "D" + "', '"                                             //Must be D-S because a dealer can only add users of his dealership
                                             + "S" + "', "
                                             + Convert.ToInt32(Session["dealer_id"].ToString()) + ", '" //reference ID is the dealer id in the dealer table they belong to
                                             + GlobalFunctions.escapeSqlString(txtFirstName.Text) + "', '"
                                             + GlobalFunctions.escapeSqlString(txtLastName.Text) + "', "
                                             + 1 + ")";
                    sdsUsers.Insert();
                    lblError.Text = "Successfully Added";
                }
                #endregion

                #region Dealer Admin
                //adding a head dealer
                else if (ddlUserType.SelectedValue == "Dealer" && hidUserGroup.Value == "Admin")
                {
                    //Requires additional checks if adding a dealer
                    if (txtDealershipName.Text == "" ||
                        txtMultiplier.Text == "")
                    {
                        lblError.Text = "Please enter data into all fields.";
                    }
                    else
                    {
                        //open SQL connection for use with transaction
                        using (SqlConnection aConnection = new SqlConnection(sdsUsers.ConnectionString))
                        {
                            //Open connection, then create a command and a transaction that are linked to it
                            aConnection.Open();
                            SqlCommand     aCommand = aConnection.CreateCommand();
                            SqlTransaction aTransaction;

                            // 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
                            {
                                //Add to dealer table
                                aCommand.CommandText = "INSERT INTO dealers (dealer_name, first_name, last_name, country, multiplier)"
                                                       + "VALUES('"
                                                       + GlobalFunctions.escapeSqlString(txtDealershipName.Text) + "', '"
                                                       + GlobalFunctions.escapeSqlString(txtFirstName.Text) + "', '"
                                                       + GlobalFunctions.escapeSqlString(txtLastName.Text) + "', '"
                                                       + ddlCountry.SelectedValue + "', "
                                                       + Convert.ToDecimal(txtMultiplier.Text) + ")"; //user enters %, so 80% will become 1.8 as a multiplier
                                aCommand.ExecuteNonQuery();                                           //Execute a command that does not return anything

                                aCommand.CommandText = "SELECT dealer_id FROM dealers WHERE dealer_name='" + txtDealershipName.Text + "'";
                                int newDealerId = Convert.ToInt32(aCommand.ExecuteScalar()); //ExecuteScalar returns the value in the first field of the first row of a query. Good for getting one piece of data immediately

                                //Now add user
                                DateTime aDate = DateTime.Now;
                                aCommand.CommandText = "INSERT INTO users (login, password, email_address, enrol_date, last_access, user_type, user_group, reference_id, first_name, last_name, status)"
                                                       + "VALUES('"
                                                       + txtLogin.Text + "', '"
                                                       + GlobalFunctions.CalculateSHAHash(txtPassword.Text) + "', '"
                                                       + GlobalFunctions.escapeSqlString(txtEmail.Text) + "', '"
                                                       + aDate.ToString("yyyy/MM/dd") + "', '"
                                                       + aDate.ToString("yyyy/MM/dd") + "', '" //default to same-day
                                                       + "D" + "', '"                          //Must be D-A within this block of logic
                                                       + "A" + "', "
                                                       + newDealerId + ", '"                   //reference ID is the dealer id in the dealer table they belong to
                                                       + GlobalFunctions.escapeSqlString(txtFirstName.Text) + "', '"
                                                       + GlobalFunctions.escapeSqlString(txtLastName.Text) + "', "
                                                       + 1 + ")";
                                aCommand.ExecuteNonQuery(); //Execute a command that does not return anything

                                //An entrance into the model preferences table, one entry for each model type
                                //These have hardcoded default values that any added dealer will have as their preferences.
                                //They can be edited here.

                                #region Model 100 preferences entry
                                aCommand.CommandText = "INSERT INTO model_preferences (dealer_id, model_type, default_filler, interior_panel_skin, exterior_panel_skin, frame_colour, door_type, door_style, door_swing, door_hinge, door_hardware, door_colour, door_glass_tint, door_vinyl_tint, door_screen_type, window_type, window_colour, window_glass_tint, window_vinyl_tint, window_screen_type, sunshade_valance_colour, sunshade_fabric_colour, sunshade_openness, roof_type, roof_interior_skin, roof_exterior_skin, roof_thickness, floor_thickness, floor_metal_barrier, kneewall_height, kneewall_type, kneewall_glass_tint, transom_height, transom_style, transom_glass_tint, transom_vinyl_tint, transom_screen_type, markup)"
                                                       + "VALUES("
                                                       + newDealerId + ", "
                                                       + "'M100',"
                                                       + "10,"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White',"
                                                       //door
                                                       + "'Cabana',"
                                                       + "'Full Screen',"
                                                       + "'Out',"
                                                       + "'R',"
                                                       + "'Satin Silver',"
                                                       + "'White',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       //window
                                                       + "'Fixed Vinyl',"
                                                       + "'White',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       //sunshade
                                                       + "'White',"
                                                       + "'Chalk',"
                                                       + "'3%',"
                                                       //roof
                                                       + "'Studio',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'3',"
                                                       //floor
                                                       + "'4.5',"
                                                       + "0,"
                                                       //kneewall
                                                       + 20d + ","
                                                       + "'Glass',"
                                                       + "'Clear',"
                                                       //transom
                                                       + 20d + ","
                                                       + "'Glass',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       + 0.25d
                                                       + ")";
                                aCommand.ExecuteNonQuery(); //Execute a command that does not return anything
                                #endregion

                                #region Model 200 preferences entry
                                aCommand.CommandText = "INSERT INTO model_preferences (dealer_id, model_type, default_filler, interior_panel_skin, exterior_panel_skin, frame_colour, door_type, door_style, door_swing, door_hinge, door_hardware, door_colour, door_glass_tint, door_vinyl_tint, door_screen_type, window_type, window_colour, window_glass_tint, window_vinyl_tint, window_screen_type, sunshade_valance_colour, sunshade_fabric_colour, sunshade_openness, roof_type, roof_interior_skin, roof_exterior_skin, roof_thickness, floor_thickness, floor_metal_barrier, kneewall_height, kneewall_type, kneewall_glass_tint, transom_height, transom_style, transom_glass_tint, transom_vinyl_tint, transom_screen_type, markup)"
                                                       + "VALUES("
                                                       + newDealerId + ", "
                                                       + "'M200',"
                                                       + "10,"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White',"
                                                       //door
                                                       + "'Cabana',"
                                                       + "'Full Screen',"
                                                       + "'Out',"
                                                       + "'R',"
                                                       + "'Satin Silver',"
                                                       + "'White',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       //window
                                                       + "'Vertical 4 Track',"
                                                       + "'White',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       //sunshade
                                                       + "'White',"
                                                       + "'Chalk',"
                                                       + "'3%',"
                                                       //roof
                                                       + "'Studio',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'3',"
                                                       //floor
                                                       + "'4.5',"
                                                       + "0,"
                                                       //kneewall
                                                       + 20d + ","
                                                       + "'Glass',"
                                                       + "'Clear',"
                                                       //transom
                                                       + 20d + ","
                                                       + "'Glass',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       + 0.25d
                                                       + ")";
                                aCommand.ExecuteNonQuery(); //Execute a command that does not return anything
                                #endregion

                                #region Model 300 preferences entry
                                aCommand.CommandText = "INSERT INTO model_preferences (dealer_id, model_type, default_filler, interior_panel_skin, exterior_panel_skin, frame_colour, door_type, door_style, door_swing, door_hinge, door_hardware, door_colour, door_glass_tint, door_vinyl_tint, door_screen_type, window_type, window_colour, window_glass_tint, window_vinyl_tint, window_screen_type, sunshade_valance_colour, sunshade_fabric_colour, sunshade_openness, roof_type, roof_interior_skin, roof_exterior_skin, roof_thickness, floor_thickness, floor_metal_barrier, kneewall_height, kneewall_type, kneewall_glass_tint, transom_height, transom_style, transom_glass_tint, transom_vinyl_tint, transom_screen_type, markup)"
                                                       + "VALUES("
                                                       + newDealerId + ", "
                                                       + "'M300',"
                                                       + "10,"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White',"
                                                       //door
                                                       + "'Cabana',"
                                                       + "'Full Screen',"
                                                       + "'Out',"
                                                       + "'R',"
                                                       + "'Satin Silver',"
                                                       + "'White',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       //window
                                                       + "'Horizontal Roller',"
                                                       + "'White',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       //sunshade
                                                       + "'White',"
                                                       + "'Chalk',"
                                                       + "'3%',"
                                                       //roof
                                                       + "'Studio',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'3',"
                                                       //floor
                                                       + "'4.5',"
                                                       + "0,"
                                                       //kneewall
                                                       + 20d + ","
                                                       + "'Glass',"
                                                       + "'Clear',"
                                                       //transom
                                                       + 20d + ","
                                                       + "'Glass',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       + 0.25d
                                                       + ")";
                                aCommand.ExecuteNonQuery(); //Execute a command that does not return anything
                                #endregion

                                #region Model 400 preferences entry
                                aCommand.CommandText = "INSERT INTO model_preferences (dealer_id, model_type, default_filler, interior_panel_skin, exterior_panel_skin, frame_colour, door_type, door_style, door_swing, door_hinge, door_hardware, door_colour, door_glass_tint, door_vinyl_tint, door_screen_type, window_type, window_colour, window_glass_tint, window_vinyl_tint, window_screen_type, sunshade_valance_colour, sunshade_fabric_colour, sunshade_openness, roof_type, roof_interior_skin, roof_exterior_skin, roof_thickness, floor_thickness, floor_metal_barrier, kneewall_height, kneewall_type, kneewall_glass_tint, transom_height, transom_style, transom_glass_tint, transom_vinyl_tint, transom_screen_type, markup)"
                                                       + "VALUES("
                                                       + newDealerId + ", "
                                                       + "'M400',"
                                                       + "10,"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White',"
                                                       //door
                                                       + "'Cabana',"
                                                       + "'Full Screen',"
                                                       + "'Out',"
                                                       + "'R',"
                                                       + "'Satin Silver',"
                                                       + "'White',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       //window
                                                       + "'Horizontal Roller',"
                                                       + "'White',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       //sunshade
                                                       + "'White',"
                                                       + "'Chalk',"
                                                       + "'3%',"
                                                       //roof
                                                       + "'Studio',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'White Aluminum Stucco',"
                                                       + "'3',"
                                                       //floor
                                                       + "'4.5',"
                                                       + "0,"
                                                       //kneewall
                                                       + 20d + ","
                                                       + "'Glass',"
                                                       + "'Clear',"
                                                       //transom
                                                       + 20d + ","
                                                       + "'Glass',"
                                                       + "'Clear',"
                                                       + "'Clear',"
                                                       + "'No Screen',"
                                                       + 0.25d
                                                       + ")";
                                aCommand.ExecuteNonQuery(); //Execute a command that does not return anything
                                #endregion

                                //Lastly, a preferences table entry, with defaults
                                aCommand.CommandText = "INSERT INTO preferences (dealer_id, installation_type, model_type, layout, cut_pitch)"
                                                       + "VALUES("
                                                       + newDealerId + ", "
                                                       + "'House',"
                                                       + "'M200',"
                                                       + "'preset 1',"
                                                       + "1"
                                                       + ")";
                                aCommand.ExecuteNonQuery(); //Execute a command that does not return anything

                                lblError.Text = "Successfully Added";

                                // Attempt to commit the transaction.
                                aTransaction.Commit();
                            }
                            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.
                                    Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType());
                                    Console.WriteLine("  Message: {0}", ex2.Message);
                                }
                            }
                        }
                    }
                }
                #endregion

                #region Sunspace CSR
                //Sunspace CSR
                else if (ddlUserType.SelectedValue == "Sunspace" && ddlUserGroup.SelectedValue == "Customer Service Rep")
                {
                    using (SqlConnection aConnection = new SqlConnection(sdsUsers.ConnectionString))
                    {
                        aConnection.Open();
                        SqlCommand     aCommand = aConnection.CreateCommand();
                        SqlTransaction aTransaction;

                        // 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
                        {
                            //Add to dealer table
                            aCommand.CommandText = "INSERT INTO sunspace (position, first_name, last_name)"
                                                   + "VALUES('"
                                                   + "CSR" + "', '"  //can only be CSR at this point, can be changed to a variable later
                                                   + GlobalFunctions.escapeSqlString(txtFirstName.Text) + "', '"
                                                   + GlobalFunctions.escapeSqlString(txtLastName.Text) + "'"
                                                   + ")";
                            aCommand.ExecuteNonQuery(); //Execute a command that does not return anything

                            aCommand.CommandText = "SELECT sunspace_id FROM sunspace WHERE position='" + "CSR" + "' AND first_name='" + GlobalFunctions.escapeSqlString(txtFirstName.Text) + "' AND last_name='" + GlobalFunctions.escapeSqlString(txtLastName.Text) + "'";
                            int newSunspaceId = Convert.ToInt32(aCommand.ExecuteScalar()); //ExecuteScalar returns the value in the first field of the first row of a query. Good for getting one piece of data immediately

                            //Now add user
                            DateTime aDate = DateTime.Now;
                            aCommand.CommandText = "INSERT INTO users (login, password, email_address, enrol_date, last_access, user_type, user_group, reference_id, first_name, last_name, status)"
                                                   + "VALUES('"
                                                   + GlobalFunctions.escapeSqlString(txtLogin.Text) + "', '"
                                                   + GlobalFunctions.CalculateSHAHash(txtPassword.Text) + "', '"
                                                   + GlobalFunctions.escapeSqlString(txtEmail.Text) + "', '"
                                                   + aDate.ToString("yyyy/MM/dd") + "', '"
                                                   + aDate.ToString("yyyy/MM/dd") + "', '" //default to same-day
                                                   + "S" + "', '"                          //Must be S-C within this block of logic
                                                   + "C" + "', "
                                                   + newSunspaceId + ", '"                 //reference ID is the dealer id in the dealer table they belong to
                                                   + GlobalFunctions.escapeSqlString(txtFirstName.Text) + "', '"
                                                   + GlobalFunctions.escapeSqlString(txtLastName.Text) + "', "
                                                   + 1 + ")";
                            aCommand.ExecuteNonQuery(); //Execute a command that does not return anything

                            lblError.Text = "Successfully Added";

                            // Attempt to commit the transaction.
                            aTransaction.Commit();
                        }
                        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.
                                Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType());
                                Console.WriteLine("  Message: {0}", ex2.Message);
                            }
                        }
                    }
                }
                #endregion

                #region Sunspace Admin
                //Sunspace Admin
                else
                {
                    //You currently may not add an admin in such a way.  Such a decision should come from high up and be done directly through a database query.
                }
                #endregion
            }
        }
Beispiel #7
0
        public void FillSpaceWithWindows(string windowType, string windowColour, string framingColour, int numberOfVents, float kneewallHeight, string kneewallType, string transomType,
                                         bool sunshade, string valance, string fabric, string openness, string chain, string screenType, double railing)
        {
            float currentLocation = 0f;

            //Loop through linear items using currentLocation to keep track
            for (int i = 0; i <= LinearItems.Count; i++)//
            {
                try
                {
                    //If an item starts at this location, we aren't in a workable area
                    if (LinearItems[i].FixedLocation == currentLocation)
                    {
                        //We set the location equal to the length of the linear item, which is the end of it
                        currentLocation += LinearItems[i].Length;
                    }
                    //Item must start after current
                    else if (LinearItems[i].FixedLocation > currentLocation)
                    {
                        //The space is equal to where the next item starts - current location
                        float space = LinearItems[i].FixedLocation - currentLocation;
                        float numOfWindowsInThisSpace = 1; //If the space is too large for one window mod, we need this many
                        float eachSpace = space;           //If the space is too large for one window mod, we'll have a # of mods of this size

                        float MAX_MOD_WIDTH = 0;
                        float MIN_MOD_WIDTH = 0;

                        switch (windowType)
                        {
                        case "Fixed Vinyl":
                            MIN_MOD_WIDTH = Constants.VINYL_TRAP_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.VINYL_TRAP_MAX_WIDTH_WARRANTY;
                            break;

                        case "Fixed Glass 2\"":
                            MIN_MOD_WIDTH = Constants.VINYL_TRAP_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.VINYL_TRAP_MAX_WIDTH_WARRANTY;
                            break;

                        case "Fixed Glass 3\"":
                            MIN_MOD_WIDTH = Constants.VINYL_TRAP_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.VINYL_TRAP_MAX_WIDTH_WARRANTY;
                            break;

                        case "Vertical 4 Track":
                            MIN_MOD_WIDTH = Constants.V4T_4V_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.V4T_4V_MAX_WIDTH_WARRANTY;
                            break;

                        case "Horizontal 2 Track":
                        case "Horizontal Roller":
                            MIN_MOD_WIDTH = Constants.HORIZONTAL_ROLLER_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.HORIZONTAL_ROLLER_MAX_WIDTH_WARRANTY;
                            break;

                        case "Single Slider":
                            MIN_MOD_WIDTH = Constants.SINGLE_SLIDER_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.SINGLE_SLIDER_MAX_WIDTH_WARRANTY;
                            break;

                        case "Double Slider":
                            MIN_MOD_WIDTH = Constants.DOUBLE_SLIDER_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.DOUBLE_SLIDER_MAX_WIDTH_WARRANTY;
                            break;

                        case "Open Wall":
                            MIN_MOD_WIDTH = Constants.V4T_4V_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.V4T_4V_MAX_WIDTH_WARRANTY;
                            break;

                        case "Solid Wall":
                            MIN_MOD_WIDTH = Constants.V4T_4V_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.V4T_4V_MAX_WIDTH_WARRANTY;
                            break;

                        case "Screen":
                            MIN_MOD_WIDTH = Constants.SCREEN_MIN_WIDTH_WARRANTY;     //We use the trap version because they can have both
                            MAX_MOD_WIDTH = Constants.SCREEN_MAX_WIDTH_WARRANTY;
                            break;
                        }

                        //Find optimal lengths of window mods given space
                        float[] windowSpecifics = FindOptimalLengthOfWindowModsGivenSpace(space, MIN_MOD_WIDTH, MAX_MOD_WIDTH);

                        float height;

                        //Loop mod creation for each window counted in this space
                        for (int windowCounter = 0; windowCounter < windowSpecifics[1]; windowCounter++)
                        {
                            //We have a space, so create a window mod to fill it
                            Mod aMod = new Mod();
                            aMod.FixedLocation = currentLocation;
                            aMod.StartHeight   = GetHeightAtLocation(currentLocation);
                            aMod.EndHeight     = GetHeightAtLocation(currentLocation + windowSpecifics[0]);
                            aMod.ItemType      = "Mod";
                            aMod.Length        = windowSpecifics[0];
                            if (windowCounter == 0)
                            {
                                aMod.Length += windowSpecifics[2];
                            }
                            aMod.ModType          = "Window";
                            aMod.Sunshade         = sunshade;
                            aMod.SunshadeValance  = valance;
                            aMod.SunshadeFabric   = fabric;
                            aMod.SunshadeOpenness = openness;
                            aMod.SunshadeChain    = chain;

                            height = Math.Max(aMod.StartHeight, aMod.EndHeight);

                            //Check for kneewall info
                            if (kneewallHeight > 0)
                            {
                                //Have one
                                Kneewall aKneewall = new Kneewall();
                                aKneewall.FEndHeight = aKneewall.FStartHeight = kneewallHeight;
                                aKneewall.EndHeight  = aKneewall.StartHeight = kneewallHeight - 2.125f;
                                height -= kneewallHeight; //Remove this from usable height, as the kneewall takes it up
                                aKneewall.KneewallType = kneewallType;
                                aKneewall.ItemType     = "Kneewall";
                                aKneewall.FLength      = aMod.Length - 2;
                                aMod.ModularItems.Add(aKneewall);
                            }

                            float highestPunch = 0f;
                            //Kneewall will have been added now, or not, either way we add the window
                            //find highest punch
                            for (int j = 0; j < LinearItems.Count; j++)
                            {
                                if (LinearItems[j].ItemType == "Mod")
                                {
                                    Mod tempMod = (Mod)LinearItems[j];

                                    if (tempMod.ModType == "Door")
                                    {
                                        //check 0 because door will always be first item in door mod
                                        if (((Door)tempMod.ModularItems[0]).Punch > highestPunch)
                                        {
                                            highestPunch = ((Door)tempMod.ModularItems[0]).Punch;
                                        }
                                    }
                                }
                            }

                            //If punch is 0 at this point there are no doors, in such a case, we will set the punch to be a set distance below the min height of the wall
                            //That way we arbitrarily set a location for the transom to start and maintain consistency.
                            if (highestPunch == 0)
                            {
                                highestPunch = GlobalFunctions.RoundDownToNearestEighthInch(Math.Min(StartHeight, EndHeight) - 4.125F - Constants.KNEEWALL_PUNCH); //changeme based on type
                            }
                            //Now we know where the ending height is, so we subtract kneewall to get the height of the window
                            //Punch takes up space too, so subtract it as well
                            float windowHeight = highestPunch - kneewallHeight - Constants.KNEEWALL_PUNCH;
                            //Create the window
                            Window aWindow = new Window();
                            aWindow.FEndHeight  = aWindow.FStartHeight = windowHeight; //CHANGEME hardcoded 2.125
                            aWindow.RightHeight = aWindow.LeftHeight = windowHeight - 2.125f;
                            aWindow.FLength     = aMod.Length - 2;
                            aWindow.Width       = aWindow.FLength - 2.125f; //CHANGEME hardcoded
                            aWindow.Colour      = windowColour;
                            aWindow.FrameColour = framingColour;
                            aWindow.ItemType    = "Window";
                            aWindow.NumVents    = numberOfVents;
                            aWindow.ScreenType  = screenType; //fixt
                            aWindow.WindowStyle = windowType;

                            //Check for spreader bar boolean
                            if (windowType == "Vertical 4 Track" && aWindow.FLength > Constants.V4T_SPREADER_BAR_NEEDED)
                            {
                                aWindow.SpreaderBar = (aWindow.FLength / 2) - (Constants.SPREADER_BAR_SIZE / 2); //Find center of window, then place center of spreader bar at that position (by subtracting half of it)
                            }
                            if (windowType == "Horizontal Roller" && aWindow.FLength > Constants.HORIZONTAL_ROLLER_SPREADER_BAR_NEEDED)
                            {
                                aWindow.SpreaderBar = (aWindow.FEndHeight / 2) - (Constants.SPREADER_BAR_SIZE / 2);
                                aWindow.WindowStyle = "Horizontal Roller XO";
                            }
                            if (windowType == "Vinyl")
                            {
                                if (aWindow.FLength > Constants.TRANSOM_SPREADER_BAR_REQUIRED || aWindow.FEndHeight > Constants.TRANSOM_SPREADER_BAR_REQUIRED || aWindow.FStartHeight > Constants.TRANSOM_SPREADER_BAR_REQUIRED)
                                {
                                    //If length is longer, vertical bar, else horizontal bar
                                    if (aWindow.Width >= aWindow.FEndHeight && aWindow.Width >= aWindow.FStartHeight)
                                    {
                                        aWindow.SpreaderBar = (aWindow.FLength / 2) - (Constants.SPREADER_BAR_SIZE / 2);
                                    }
                                    else
                                    {
                                        aWindow.SpreaderBar = (aWindow.FEndHeight / 2) - (Constants.SPREADER_BAR_SIZE / 2);
                                    }
                                    //If dimensions are equal?
                                }
                            }

                            aWindow.IntegratedRailing = railing;

                            aMod.ModularItems.Add(aWindow);

                            //Now we handle transom
                            float modStartWallHeight = GlobalFunctions.getHeightAtPosition(StartHeight, EndHeight, currentLocation, Length);
                            float modEndWallHeight   = GlobalFunctions.getHeightAtPosition(StartHeight, EndHeight, (currentLocation + aMod.Length), Length);
                            float spaceAbovePunch    = Math.Max(modStartWallHeight, modEndWallHeight) - highestPunch - .25f; //Punch physical space

                            float[] transomInfo = GlobalFunctions.findOptimalHeightsOfWindows(spaceAbovePunch, transomType);

                            if (StartHeight == EndHeight)
                            {
                                //rectangular window
                                for (int currentWindow = 0; currentWindow < transomInfo[0]; currentWindow++)
                                {
                                    //Set window properties
                                    Window aTransom = new Window();
                                    aTransom.FEndHeight  = aTransom.FStartHeight = transomInfo[1];        //Window with frame
                                    aTransom.RightHeight = aTransom.LeftHeight = transomInfo[1] - 2.125f; //Window itself
                                    aTransom.Colour      = windowColour;
                                    aTransom.ItemType    = "Window";
                                    aTransom.FLength     = aMod.Length - 2;
                                    aTransom.Width       = aTransom.FLength - 2.125f;
                                    aTransom.WindowStyle = transomType;
                                    if (currentWindow == 0)
                                    {
                                        aTransom.FEndHeight   += transomInfo[2];
                                        aTransom.FStartHeight += transomInfo[2];
                                        aTransom.RightHeight  += transomInfo[2];
                                        aTransom.LeftHeight   += transomInfo[2];
                                    }

                                    if (aTransom.FLength > Constants.TRANSOM_SPREADER_BAR_REQUIRED || aTransom.FEndHeight > Constants.TRANSOM_SPREADER_BAR_REQUIRED || aTransom.FStartHeight > Constants.TRANSOM_SPREADER_BAR_REQUIRED)
                                    {
                                        //If length is longer, vertical bar, else horizontal bar
                                        if (aTransom.Width > aTransom.FEndHeight && aTransom.Width > aTransom.FStartHeight)
                                        {
                                            aTransom.SpreaderBar = (aTransom.FLength / 2) - (Constants.SPREADER_BAR_SIZE / 2);
                                        }
                                        else
                                        {
                                            aTransom.SpreaderBar = (aTransom.FEndHeight / 2) - (Constants.SPREADER_BAR_SIZE / 2);
                                        }
                                        //If dimensions are equal?
                                    }
                                    aMod.ModularItems.Add(aTransom);
                                }
                            }
                            else
                            {
                                //trapezoid
                                float nextTransomHeight;

                                //If start wall is higher, lower end height
                                if (modStartWallHeight == Math.Max(modStartWallHeight, modEndWallHeight))
                                {
                                    nextTransomHeight = transomInfo[1];
                                }
                                else
                                {
                                    nextTransomHeight = transomInfo[1] - (Math.Max(modStartWallHeight, modEndWallHeight) - Math.Min(modStartWallHeight, modEndWallHeight));
                                }

                                for (int currentWindow = 0; currentWindow < transomInfo[0]; currentWindow++)
                                {
                                    //Set window properties
                                    Window aTransom = new Window();
                                    aTransom.Colour      = windowColour;
                                    aTransom.ItemType    = "Window";
                                    aTransom.FLength     = aMod.Length - 2;
                                    aTransom.Width       = aMod.Length - 2 - 2.125f;
                                    aTransom.WindowStyle = transomType;

                                    aTransom.FStartHeight = nextTransomHeight;
                                    aTransom.LeftHeight   = aTransom.FStartHeight - 2.125f;
                                    //If start wall is higher, lower end height
                                    if (modStartWallHeight == Math.Max(modStartWallHeight, modEndWallHeight))
                                    {
                                        aTransom.FEndHeight = aTransom.FStartHeight - (modStartWallHeight - modEndWallHeight);
                                    }
                                    else
                                    {
                                        aTransom.FEndHeight = aTransom.FStartHeight + (modEndWallHeight - modStartWallHeight);
                                    }

                                    aTransom.RightHeight = aTransom.FEndHeight - 2.125f;
                                    nextTransomHeight    = aTransom.FEndHeight;

                                    //Add remaining area to first window
                                    if (currentWindow == 0)
                                    {
                                        aTransom.FEndHeight   += transomInfo[2];
                                        aTransom.FStartHeight += transomInfo[2];
                                        aTransom.RightHeight  += transomInfo[2];
                                        aTransom.LeftHeight   += transomInfo[2];
                                    }

                                    aTransom.FStartHeight = GlobalFunctions.RoundDownToNearestEighthInch(aTransom.FStartHeight);
                                    aTransom.FEndHeight   = GlobalFunctions.RoundDownToNearestEighthInch(aTransom.FEndHeight);
                                    aTransom.LeftHeight   = GlobalFunctions.RoundDownToNearestEighthInch(aTransom.LeftHeight);
                                    aTransom.RightHeight  = GlobalFunctions.RoundDownToNearestEighthInch(aTransom.RightHeight);

                                    ////If last window, we need to change a height to make it sloped
                                    //if (currentWindow == transomInfo[0] - 1)
                                    //{
                                    //    //If start wall is higher, we lower end height
                                    //    if (modStartWallHeight == Math.Max(modStartWallHeight, modEndWallHeight))
                                    //    {
                                    //        aTransom.FEndHeight -= (modStartWallHeight - modEndWallHeight);
                                    //        aTransom.RightHeight -= (modStartWallHeight - modEndWallHeight);
                                    //    }
                                    //    //Otherwise we lower start height
                                    //    else
                                    //    {
                                    //        aTransom.FStartHeight -= (modEndWallHeight - modStartWallHeight);
                                    //        aTransom.LeftHeight -= (modEndWallHeight - modStartWallHeight);
                                    //    }
                                    //}
                                    aMod.ModularItems.Add(aTransom);
                                }
                            }

                            //float[] windowInfo = GlobalFunctions.findOptimalHeightsOfWindows
                            //Find where to place the mod, and place it
                            for (int j = 0; j < LinearItems.Count; j++)
                            {
                                if (LinearItems[j].FixedLocation > aMod.FixedLocation)
                                {
                                    //j is past, so we insert into j-1 and exit the loop
                                    LinearItems.Insert(j, aMod);
                                    break;
                                }
                            }
                            //Sets currentlocation to the ending location of current linear item
                            currentLocation = currentLocation + aMod.Length;
                        }
                    }
                }
                catch (Exception ex)
                {
                    //If caught, it's because we tried to touch the next linear item but it was past the last
                    //Check currentLocation to see if there is still space left
                }
            }
        }