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."; // } //} }
//protected void Button1_Click(object sender, EventArgs e) //{ // Label4.Text = Checker.GoodLikesInput(txtLikes.Text); //} protected void btnSubmit_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(2000); objDBhelper = new FaceBookHelper.DataBaseRequest(); if ((txtFirstName.Text == "") || (txtLastName.Text == "") || (txtPhoneNumber.Text == "") || (txtAddress.Text == "") || (txtEmail.Text == "") || (txtUserName.Text == "") || (txtPassWord.Text == "") || (txtLikes.Text == "") || (txtCity.Text == "") || (txtState.Text == "")) { lblSubmitInfo.Visible = true; lblSubmitInfo.Text = "*All Fields Have To Be Filled Out*"; } else { lblSubmitInfo.Visible = false; String firstName = txtFirstName.Text; String lastName = txtLastName.Text; String phoneNumber = txtPhoneNumber.Text; String address = txtAddress.Text; String email = txtEmail.Text; String userName = txtUserName.Text; String passWord = txtPassWord.Text; String security1 = txtQuestion1.Text; String security2 = txtQuestion2.Text; String security3 = txtQuestion3.Text; String likes = txtLikes.Text; String city = txtCity.Text; String state = txtState.Text; 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; } Boolean passwordsMatch = false; if ((txtPassWord.Text != txtConfirmPassword.Text)) { lblConfirmPassWord.Visible = true; lblConfirmPassWord.Text = "*Your Passwords don't match*"; passwordsMatch = false; } else { lblConfirmPassWord.Visible = false; passwordsMatch = true; } //code here to check the txtLikes feild... the list of things the user likes to do has to be seperated by a comma //likes = objDBhelper.GoodLikesInput(likes); String modifedLikesInput = Checker.GoodLikesInput(likes); //code here to check the txtLikes feild... the list of things the user likes to do has to be seperated by a comma if ((Checker.AllAlphabetChars(firstName)) && (Checker.AllAlphabetChars(lastName)) && (Checker.ValidPhoneNumber(phoneNumber)) && (Checker.GoodEmailAddress(email)) && (passwordsMatch) && (Checker.AllAlphabetChars(city)) && (Checker.AllAlphabetChars(state))) { 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; } lblSubmitInfo.Visible = false; int goodUsernamePassword = objDBhelper.CreateUser(firstName, lastName, phoneNumber, address, email, userName, passWord, security1, security2, security3, DropDownListQuestionSet1.SelectedValue, DropDownListQuestionSet2.SelectedValue, DropDownListQuestionSet3.SelectedValue, loginPreferences, modifedLikesInput, city, state); //if the username/password combo is not already taken than a user is created and added to the table //the return from the "CreateUser" method will be an int //0 = means the username/password combo is not in the system yet // andything other than 0 means the username/password combo exists and the UserID of that user with this username/password combo is returned if (goodUsernamePassword == 0) { lblSubmitInfo.Visible = true; lblSubmitInfo.Text = "*Account Created*"; //code here to update the SettingsObject record in the database table for this user// DataSet dsUserRecord = objDBhelper.GetUserRecordWithUsernamePassword(userName, passWord); //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 { int userID = int.Parse(dsUserRecord.Tables[0].Rows[i]["UserID"].ToString()); SerializeAndDeserializing.SerializingUserSettingsOBJ(userID, loginPreferences, "background-color:#dfe3ee"); if (Request.Cookies["CIS3342_CookieCustom"] != null) { Response.Cookies["CIS3342_CookieCustom"].Expires = DateTime.Now.AddDays(-1); } HttpCookie myCookie = new HttpCookie("CIS3342_Cookie"); myCookie.Values["userID"] = dsUserRecord.Tables[0].Rows[i]["UserID"].ToString(); 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["City"] = dsUserRecord.Tables[0].Rows[i]["City"].ToString(); myCookie.Values["State"] = dsUserRecord.Tables[0].Rows[i]["State"].ToString(); myCookie.Values["PhotoPath"] = dsUserRecord.Tables[0].Rows[i]["PhotoPath"].ToString(); myCookie.Values["Likes"] = dsUserRecord.Tables[0].Rows[i]["Likes"].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());//encrypts password! 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["WallPost"] = dsUserRecord.Tables[0].Rows[i]["WallPost"].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); } //code here to update the SettingsObject record in the database table for this user// int adjustSettingsNowValue = Convert.ToInt32(radAdjustSettingsNow.SelectedValue); switch (adjustSettingsNowValue) { case 1: // user selects no, they do not want to change these setting now Response.Redirect("Home.aspx"); break; case 2: //user selects yes, they do not want to change these setting now Response.Redirect("GeneralAccountSettings.aspx"); break; default: break; } } else //goodUsernamePassword is not 0 { lblSubmitInfo.Visible = true; lblSubmitInfo.Text = "*Username/Password combination is already taken**"; } } else { lblSubmitInfo.Visible = true; lblSubmitInfo.Text = "*One Or More Fields Are Invalid*"; } } }