示例#1
0
        protected void btnQuestion3_OrderOnly_Click(object sender, EventArgs e)
        {
            //if existing is blank, it must be a new customer
            if (hidExisting.Value == "")
            {
                insertNewCustomer();
            }

            if (hidProjectType.Value == "Windows")
            {
                Response.Redirect("WizardWindowsOnly.aspx");
            }
            else if (hidProjectType.Value == "Door")
            {
                Response.Redirect("WizardDoorOnly.aspx");
            }
            else if (hidProjectType.Value == "Flooring")
            {
                Response.Redirect("WizardFloorOnlyOrder.aspx");
            }
            else if (hidProjectType.Value == "Roof")
            {
                Response.Redirect("WizardRoofOnly.aspx");
            }
            else if (hidProjectType.Value == "Walls")
            {
                Session.Add("model", GlobalFunctions.escapeSqlString(hidModelNumber.Value.ToString()));
                Session.Add("wallsOnlyNumber", GlobalFunctions.escapeSqlString(hidWallNumber.Value.ToString()));
                Response.Redirect("WizardWallsOnly.aspx");
            }
        }
示例#2
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();
        }
示例#3
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");
                }
            }
        }
示例#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");
            }
        }
示例#5
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
            }
        }