/// <summary> /// Save changes in main settings. /// </summary> /// <param name="sender">Object sender : fvMain.</param> /// <param name="e">FormViewUpdateEventArgs e.</param> protected void OnMainItemUpdating(Object sender, FormViewUpdateEventArgs e) { #region Inner controls TextBox tbxNickName = fvMain.FindControl("tbxNickName") as TextBox; TextBox tbxFirstName = fvMain.FindControl("tbxFirstName") as TextBox; TextBox tbxLastName = fvMain.FindControl("tbxLastName") as TextBox; TextBox tbxMiddleName = fvMain.FindControl("tbxMiddleName") as TextBox; TextBox tbxPhone = fvMain.FindControl("tbxPhone") as TextBox; TextBox tbxBirthday = fvMain.FindControl("tbxBirthday") as TextBox; TextBox tbxDescription = fvMain.FindControl("tbxDescription") as TextBox; DropDownList ddlSex = fvMain.FindControl("ddlSex") as DropDownList; #endregion DateTime birthday; DateTime?vBirthday = null; // Convert date to default date format. if (DateTime.TryParseExact( tbxBirthday.Text, Constants._dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out birthday)) { vBirthday = birthday; } Sex sex = new Sex(); Sex? vSex = null; Int32 ddlSexSelectedValue; if (Int32.TryParse(ddlSex.SelectedValue, out ddlSexSelectedValue)) { if (Enum.TryParse( Enum.GetName( typeof(Sex), Convert.ToInt32(ddlSex.SelectedValue)), out sex)) { vSex = sex; } } PersonalInfoRepository.ModifyPersonalInfo( null, true, false, this._userID, tbxNickName.Text.Trim(), tbxFirstName.Text.Trim(), tbxLastName.Text.Trim(), tbxMiddleName.Text.Trim(), vSex, tbxPhone.Text.Trim(), vBirthday, null, tbxDescription.Text.Trim()); }
public void ModifyMainUserInfo( String nickName, String firstName, String lastName, String middleName, String sex, String phone, String birthday, String description) { HttpContext.Current.Session["_userID"] = "e80cd2ac-8517-4e95-8321-3f4593d2106a"; Guid userID = Guid.Empty; if (Guid.TryParse((String)Session["_userID"], out userID)) { if (userID != Guid.Empty) { DateTime?vBirthday = new DateTime?(); try { vBirthday = Convert.ToDateTime(birthday); } catch (Exception ex) { vBirthday = null; } Sex vGender = new Sex(); Sex?vSex = new Sex?(); if (Enum.TryParse(Enum.GetName(typeof(Sex), Convert.ToInt32(sex)), out vGender)) { vSex = vGender; } else { vSex = null; } PersonalInfoRepository.ModifyPersonalInfo( null, true, false, userID, nickName, firstName, lastName, middleName, vSex, phone, vBirthday, null, description); } } }