Exemplo n.º 1
0
        protected void btnSubmitUpdate_Click(object sender, EventArgs e)
        {
            SerializeAndDeserializing = new FaceBookHelper.SerializeAndDeserializing();

            HttpCookie cookie = Request.Cookies["CIS3342_Cookie"];

            String oldUsername = cookie.Values["userName"];
            String oldPassword = cookie.Values["passWord"];

            String firstName         = txtFirstName.Text;
            String lastName          = txtLastName.Text;
            String phoneNumber       = txtPhoneNumber.Text;
            String address           = txtAddress.Text;
            String email             = txtEmail.Text;
            String newUserName       = txtUserName.Text;
            String newPassWord       = txtPassWord.Text;
            String newPassWordConfim = txtConfirmPassword.Text;
            String question1Response = txtQuestion1.Text;
            String question2Response = txtQuestion2.Text;
            String question3Response = txtQuestion3.Text;

            String city  = txtCity.Text;
            String state = txtState.Text;
            String likes = txtLikes.Text;

            if ((firstName == "") || (lastName == "") || (phoneNumber == "") || (address == "") || (email == "") || (newUserName == "") || (newPassWord == "") || (newPassWordConfim == "") || (question1Response == "") || (question2Response == "") || (question3Response == "") || (city == "") || (state == "") || (likes == ""))
            {
                lblSubmitUpdate.Visible = true;
                lblSubmitUpdate.Text    = "*All fields must be filled out*";
            }
            else
            {
                lblSubmitUpdate.Visible = false;
                Boolean passwordsMatch = false;
                if ((txtPassWord.Text) != (txtConfirmPassword.Text))
                {
                    lblPassWordConfim.Visible = true;
                    lblPassWordConfim.Text    = "*Your passwords do not match*";
                    passwordsMatch            = false;
                }
                else
                {
                    lblPassWordConfim.Visible = false;
                    passwordsMatch            = true;
                }



                ////////code to check all the feilds have the right inputs
                if (!Checker.AllAlphabetChars(city))
                {
                    lblCityInfo.Visible = true;
                    lblCityInfo.Text    = "*Only Alphabetical Characters Allowed*";
                }
                else
                {
                    lblCityInfo.Visible = false;
                }

                if (!Checker.AllAlphabetChars(state))
                {
                    lblStateInfo.Visible = true;
                    lblStateInfo.Text    = "*Only Alphabetical Characters Allowed*";
                }
                else
                {
                    lblStateInfo.Visible = false;
                }


                if (!Checker.AllAlphabetChars(firstName))
                {
                    lblFirstNameInfo.Visible = true;
                    lblFirstNameInfo.Text    = "*Only Alphabetical Characters Allowed*";
                }
                else
                {
                    lblFirstNameInfo.Visible = false;
                }

                if (!Checker.AllAlphabetChars(lastName))
                {
                    lblLastNameInfo.Visible = true;
                    lblLastNameInfo.Text    = "*Only Alphabetical Characters Allowed*";
                }
                else
                {
                    lblLastNameInfo.Visible = false;
                }

                if (!Checker.ValidPhoneNumber(phoneNumber))
                {
                    lblPhoneNumberInfo.Visible = true;
                    lblPhoneNumberInfo.Text    = "*Vailid Format* <br/> Correct Format: 123-123-4567 ";
                }
                else
                {
                    lblPhoneNumberInfo.Visible = false;
                }

                if (!Checker.GoodEmailAddress(email))
                {
                    lblEmailInfo.Visible = true;
                    lblEmailInfo.Text    = "*Invaild Email Format* <br/> Correct Format: <br/> [email protected] or [email protected] or [email protected]";
                }
                else
                {
                    lblEmailInfo.Visible = false;
                }
                ////////code to check all the feilds have the right inputs
                if ((Checker.AllAlphabetChars(firstName)) && (Checker.AllAlphabetChars(lastName)) && (Checker.ValidPhoneNumber(phoneNumber)) && (Checker.GoodEmailAddress(email)) && (passwordsMatch) && (Checker.AllAlphabetChars(city)) && (Checker.AllAlphabetChars(state)))
                {
                    objDBhelper = new FaceBookHelper.DataBaseRequest();

                    //alter this
                    int usernamePasswordComboUpdated = objDBhelper.UpdateUserInformation(txtFirstName.Text, txtLastName.Text, txtPhoneNumber.Text, txtAddress.Text, txtEmail.Text, oldUsername, oldPassword, txtUserName.Text, txtPassWord.Text, txtQuestion1.Text, txtQuestion2.Text, txtQuestion3.Text, txtCity.Text, txtState.Text, Checker.GoodLikesInput(txtLikes.Text));
                    //alter this



                    if (usernamePasswordComboUpdated != 0)
                    {
                        lblSubmitUpdate.Visible = false;

                        DataSet dsUserRecord = objDBhelper.GetUserRecordWithUsernamePassword(txtUserName.Text, txtPassWord.Text); //pulls User record linked to valid username/password combo

                        for (int i = 0; i < dsUserRecord.Tables.Count; i++)                                                       //loops through User record and creates a new cookie with all information linked to the User
                        {
                            HttpCookie myCookie = new HttpCookie("CIS3342_Cookie");                                               //new cookie!

                            myCookie.Values["firstName"]   = dsUserRecord.Tables[0].Rows[i]["FirstName"].ToString();
                            myCookie.Values["lastName"]    = dsUserRecord.Tables[0].Rows[i]["LastName"].ToString();
                            myCookie.Values["phoneNumber"] = dsUserRecord.Tables[0].Rows[i]["PhoneNumber"].ToString();
                            myCookie.Values["address"]     = dsUserRecord.Tables[0].Rows[i]["Address"].ToString();
                            myCookie.Values["email"]       = dsUserRecord.Tables[0].Rows[i]["Email"].ToString();

                            myCookie.Values["userName"] = dsUserRecord.Tables[0].Rows[i]["UserName"].ToString();
                            //myCookie.Values["passWord"] = dsUserRecord.Tables[0].Rows[i]["PassWord"].ToString();
                            myCookie.Values["passWord"] = crypto.PerformEncryption(dsUserRecord.Tables[0].Rows[i]["PassWord"].ToString());//encrypt data

                            myCookie.Values["security1"] = dsUserRecord.Tables[0].Rows[i]["Security1"].ToString();
                            myCookie.Values["security2"] = dsUserRecord.Tables[0].Rows[i]["Security2"].ToString();
                            myCookie.Values["security3"] = dsUserRecord.Tables[0].Rows[i]["Security3"].ToString();

                            myCookie.Values["Security1Question"] = dsUserRecord.Tables[0].Rows[i]["Security1Question"].ToString();
                            myCookie.Values["Security2Question"] = dsUserRecord.Tables[0].Rows[i]["Security2Question"].ToString();
                            myCookie.Values["Security3Question"] = dsUserRecord.Tables[0].Rows[i]["Security3Question"].ToString();

                            myCookie.Values["loginPreferences"] = dsUserRecord.Tables[0].Rows[i]["loginPreferences"].ToString();

                            myCookie.Values["LastVisited"] = DateTime.Now.ToString();
                            myCookie.Expires = new DateTime(2025, 1, 1);

                            Response.Cookies.Add(myCookie);
                        }

                        lblSubmitUpdate.Visible = true;
                        lblSubmitUpdate.Text    = "*Update Completed*";



                        ////code here to send an email confirmation after the friend request is sent out ////code here to send an email confirmation after the friend request is sent out //
                        //HttpCookie cookieEdit = Request.Cookies["CIS3342_Cookie"];
                        //String myID = crypto.PerformDecryption(cookieEdit.Values["passWord"]);//Decrypts password!

                        //String yourEmail = "";
                        //DataSet friendsRecord = objDBhelper.GetUserRecordByID(int.Parse(myID));
                        //for (int i = 0; i < friendsRecord.Tables[0].Rows.Count; i++)
                        //{
                        //    yourEmail = friendsRecord.Tables[0].Rows[i]["Email"].ToString();
                        //}

                        ////code here to send an email confirmation after the friend request is sent out //
                        //Email objEmail = new Email();
                        //String strTO = yourEmail;
                        //String strFROM = "FaceBookAutomatedEmail.com";
                        //String strSubject = "testing out the email feature bro!";
                        //String strMessage = "Thanks for updating you information on " + DateTime.Now.ToString(); ;
                        //objEmail.SendMail(strTO, strFROM, strSubject, strMessage);
                        ////code here to send an email confirmation after the friend request is sent////code here to send an email confirmation after the friend request is sent out //
                    }
                    else
                    {
                        lblSubmitUpdate.Visible = true;
                        lblSubmitUpdate.Text    = "*Your password and username combination is already taken*";
                    }
                }
                else
                {
                    lblSubmitUpdate.Visible = true;
                    lblSubmitUpdate.Text    = "*One or more of your fields are invalid in format*";
                }
            }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            objDBhelper = new FaceBookHelper.DataBaseRequest();
            SerializeAndDeserializing = new FaceBookHelper.SerializeAndDeserializing();

            String backgroundColors = "";
            String fontColors       = "";
            String fontTypes        = "";
            String theme            = "";

            ////backgroundColors
            int strDdlValue = Convert.ToInt32(ddlBackgroundColors.SelectedValue);

            switch (strDdlValue)
            {
            case 1:
                backgroundColors = "background-color:#000";
                break;

            case 2:
                backgroundColors = "background-color:#ff0000";
                break;

            case 3:
                backgroundColors = "background-color:#00ff00";
                break;

            case 4:
                backgroundColors = "background-color:#0000ff";
                break;

            case 5:
                backgroundColors = "background-color:#ffff00";
                break;

            case 6:
                backgroundColors = "background-color:#00ffff";
                break;

            case 7:
                backgroundColors = "background-color:#ffb6c1";
                break;

            case 8:
                backgroundColors = "background-color:#fff";
                break;

            case 9:
                backgroundColors = "background-color:#dfe3ee";
                break;

            default:
                break;
            }

            int strDdlValuefontColors = Convert.ToInt32(ddlFontColors.SelectedValue);

            switch (strDdlValuefontColors)
            {
            case 1:
                fontColors = "color:#000";
                break;

            case 2:
                fontColors = "color:#ff0000";
                break;

            case 3:
                fontColors = "color:#00ff00";
                break;

            case 4:
                fontColors = "color:#0000ff";
                break;

            case 5:
                fontColors = "color:#ffff00";
                break;

            case 6:
                fontColors = "color:#00ffff";
                break;

            case 7:
                fontColors = "color:#ffb6c1";
                break;

            case 8:
                fontColors = "color:#fff";
                break;

            default:
                break;
            }

            int strDdlValuefontTypes = Convert.ToInt32(ddlFontTypes.SelectedValue);

            switch (strDdlValuefontTypes)
            {
            case 1:
                fontTypes = "font-family:Serif";
                break;

            case 2:
                fontTypes = "font-family:Sans-Serif";
                break;

            case 3:
                fontTypes = "font-family:Monospace";
                break;

            case 4:
                fontTypes = "font-family:Fantasy";
                break;

            case 5:
                fontTypes = "font-family:Script";
                break;

            default:
                break;
            }

            int    test             = Convert.ToInt32(radLoginPreferences.SelectedValue);
            String loginPreferences = "";

            switch (test)
            {
            case 1:
                loginPreferences = "None";
                break;

            case 2:
                loginPreferences = "Fast";
                break;

            case 3:
                loginPreferences = "Auto";
                break;

            default:
                break;
            }

            HttpCookie myCookieTheme = new HttpCookie("CIS3342_CookieCustom");

            myCookieTheme.Values["backgroundColors"] = backgroundColors;
            myCookieTheme.Values["fontColors"]       = fontColors;
            myCookieTheme.Values["fontTypes"]        = fontTypes;
            myCookieTheme.Values["themes"]           = theme;
            myCookieTheme.Expires = new DateTime(2025, 1, 1);

            Response.Cookies.Add(myCookieTheme);

            HttpCookie cookie       = Request.Cookies["CIS3342_Cookie"];
            String     tempUsername = cookie.Values["userName"].ToString();
            String     tempPassword = cookie.Values["passWord"].ToString();

            objDBhelper.ChangeUserloginPreference(tempUsername, tempPassword, loginPreferences); //updates user's "Login Preferences" record in database table

            cookie.Values["loginPreferences"] = loginPreferences;                                //updates cookie "loginPreferences" value
            Response.Cookies.Add(cookie);


            lblSaveINFO.Visible = true;
            lblSaveINFO.Text    = "*User's Settings Saved*";

            //code here to serialize the user's loginPreferences and background color
            HttpCookie cookieUser = Request.Cookies["CIS3342_Cookie"];

            int    userIDCookie           = int.Parse(cookieUser.Values["userID"]);
            String loginPreferencesCookie = cookieUser.Values["loginPreferences"];

            SerializeAndDeserializing.SerializingUserSettingsOBJ(userIDCookie, loginPreferencesCookie, backgroundColors);
            //code here to serialize the user's loginPreferences and background color


            //HttpCookie myCookie = Request.Cookies["CIS3342_Cookie"];
            //String myEmail = myCookie.Values["Email"];
            ////code here to send an email confirmation after the friend request is sent out //
            //Email objEmail = new Email();
            //String strTO = myEmail;//insert the recipient's email address here
            //String strFROM = "Face Book Maintenance Team";
            //String strSubject = "Update Account";
            //String strMessage = "Thank For Updating Your Account!";
            //objEmail.SendMail(strTO, strFROM, strSubject, strMessage);
            ////code here to send an email confirmation after the friend request is sent//



            //string loginSettings, privacySettings, fontTypeSettings, fontColorSettings,
            //    backgroundColorSettings, themeSettings;

            //loginSettings = radLoginPreferences.Text;
            //privacySettings = radPrivacySettings.SelectedItem.Text;
            //fontTypeSettings = ddlFontTypes.SelectedItem.Text;
            //fontColorSettings = ddlFontColors.SelectedItem.Text;
            //backgroundColorSettings = ddlBackgroundColors.SelectedItem.Text;
            //themeSettings = ddlThemes.SelectedItem.Text;

            //if (themeSettings == null)
            //{
            //    UserSettings objUserSettings = new UserSettings();
            //    objUserSettings.LoginSettings = loginSettings;
            //    objUserSettings.PrivacySettings = privacySettings;
            //    objUserSettings.FontTypeSettings = fontTypeSettings;
            //    objUserSettings.FontColorSettings = fontColorSettings;
            //    objUserSettings.BackgroundColorSettings = backgroundColorSettings;

            //    BinaryFormatter serializer = new BinaryFormatter();
            //    MemoryStream memStream = new MemoryStream();
            //    Byte[] byteArray;
            //    serializer.Serialize(memStream, objUserSettings);
            //    byteArray = memStream.ToArray();

            //    objCommand.CommandType = CommandType.StoredProcedure;
            //    objCommand.CommandText = "StoreUserSettings";


            //    objCommand.Parameters.AddWithValue("@theUserSettings", byteArray);

            //    int retVal = objDB.DoUpdateUsingCmdObj(objCommand);

            //    if (retVal > 0)
            //    {
            //        lblSaveINFO.Text = "Your settings were successfully saved!";
            //    }
            //    else
            //    {
            //        lblSaveINFO.Text = "Oops, a problem occured while storing your settings.";
            //    }
            //}
            //else
            //{
            //    UserSettings objUserSettings = new UserSettings();
            //    objUserSettings.LoginSettings = loginSettings;
            //    objUserSettings.PrivacySettings = privacySettings;
            //    objUserSettings.ThemeSettings = themeSettings;

            //    BinaryFormatter serializer = new BinaryFormatter();
            //    MemoryStream memStream = new MemoryStream();
            //    Byte[] byteArray;
            //    serializer.Serialize(memStream, objUserSettings);
            //    byteArray = memStream.ToArray();

            //    objCommand.CommandType = CommandType.StoredProcedure;
            //    objCommand.CommandText = "StoreUserSettings";

            //    objCommand.Parameters.AddWithValue("@theUserSettings", byteArray);

            //    int retVal = objDB.DoUpdateUsingCmdObj(objCommand);

            //    if (retVal > 0)
            //    {
            //        lblSaveINFO.Text = "Your settings were successfully saved!";
            //    }
            //    else
            //    {
            //        lblSaveINFO.Text = "Oops, a problem occured while storing your settings.";
            //    }


            //}
        }