private void BindLicensesList() { BLL.UserLicenses bll = new BLL.UserLicenses(); gridLicensesList.DataSource = bll.GetList("UserID = " + CurrUser.iUserID); gridLicensesList.DataBind(); }
protected void btnSave_Click(object sender, EventArgs e) { Model.Users userInfo = UsersManager.GetModel(CurrUser.iUserID); try { if (null == userInfo) { LPLog.LogMessage(LogType.Logerror, string.Format("User Personalization - Settings: User with id {0} does not exist.", CurrUser.iUserID)); ClientFun("unknowerrmsg2", "alert('User does not exists, unknow error.');"); return; } if (!GetUserInfo(ref userInfo)) { ClientFun("invalidinputmsg", "alert('Invalid input!');"); return; } if (this.FileUpload1.HasFile) { string strMsg = ""; bool bIsValid = PageCommon.ValidateUpload(this, this.FileUpload1, 1024 * 1024 * 15, out strMsg, ".jpg", ".bmp", ".png", ".gif"); if (!bIsValid) { ClientFun("userPicInvalid", string.Format("alert('{0}');", strMsg)); return; } } string phone = this.txbPhone.Text.Trim(); userInfo.Phone = phone; userInfo.Fax = this.txbFax.Text.Trim(); userInfo.Cell = this.txbCell.Text.Trim(); userInfo.LicenseNumber = this.txbLicense.Text.Trim(); userInfo.NMLS = this.txbNMLS.Text.Trim(); userInfo.ExchangePassword = this.txbExchangPwd.Text.Trim(); if (userInfo.ExchangePassword == "" && !string.IsNullOrEmpty(this.tbPWD.Text)) { userInfo.ExchangePassword = this.tbPWD.Text.Trim(); } UsersManager.Update(userInfo); #region Save as UserLicense gdc CR43 if (!string.IsNullOrEmpty(hidLicenseNumberList.Value.Trim())) { try { List <Model.UserLicenses> ulList = new List <Model.UserLicenses>(); foreach (var item in hidLicenseNumberList.Value.Split(',')) { if (string.IsNullOrEmpty(item)) { continue; } Model.UserLicenses model = new Model.UserLicenses(); model.LicenseNumber = item; model.UserId = CurrUser.iUserID; ulList.Add(model); } BLL.UserLicenses ulBll = new BLL.UserLicenses(); ulBll.UpdatebatchByUserID(ulList); BindLicensesList(); } catch (Exception ex) { LPLog.LogMessage(ex.Message); PageCommon.AlertMsg(this, "Failed to Save User Licenses:" + ex.Message); return; } } #endregion if (!string.IsNullOrEmpty(this.tbPWD.Text)) { try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { ReqHdr hdr; UpdateADUserRequest uReq = new UpdateADUserRequest(); hdr = new ReqHdr(); hdr.UserId = CurrUser.iUserID; uReq.hdr = hdr; uReq.Command = UserMgrCommandType.ChangePassword; uReq.AD_OU_Filter = this.hiPrefix.Value; uReq.AD_User = new LP_Service.User(); uReq.AD_User.Password = this.tbPWD.Text; uReq.AD_User.Username = this.hiUsername.Value; uReq.AD_User.Firstname = this.hiFirstName.Value; uReq.AD_User.Lastname = this.hiLastName.Value; uReq.AD_User.Email = this.lbEmail.Text; UpdateADUserResponse uResponse; uResponse = service.UpdateADUser(uReq); if (!uResponse.hdr.Successful) { PageCommon.AlertMsg(this, "Failed to update your password. Please make sure your new password meets the password policy requirements."); LPLog.LogMessage(LogType.Logerror, "Failed to change password in AD, username="******"Failed to change password in AD, reason: User Manager is not running."); return; } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to change password in AD, exception info: " + ex.Message); LPLog.LogMessage(LogType.Logerror, "Failed to change password in AD, username="******", Exception:" + ex.Message); return; } } ClientFun("sucsmsg", "alert('Saved!');"); } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to save user Personalization - Settings info, reason:" + ex.Message); LPLog.LogMessage(LogType.Logerror, "Failed to save user Personalization - Settings info: " + ex.Message); return; } }