protected void btnLoad_Click(object sender, EventArgs e) { //Load Approved Data SecurityPolicyDAL oSpDAL = new SecurityPolicyDAL(); Result oResult = new Result(); oResult = oSpDAL.LoadApprovedData(); SecurityPolicy oSp = null; if (oResult.Status) { oSp = (SecurityPolicy)oResult.Return; if (oSp != null) { DDListUtil.Assign(ddlRequiredToChangePw, oSp.IsChangePassFirst); txtOldPwprohibited.Text = oSp.OldPassProhibited.ToString(); txtMinimumPwLg.Text = oSp.MinPassLength.ToString(); DDListUtil.Assign(ddlAlphaNumPw, oSp.IsForceAlphaNumericPass); txtPwExpDays.Text = oSp.PassExpiresAfterDays.ToString(); txtDayEarly.Text = oSp.DaysEarlierPass.ToString(); txtWrongLoginTrial.Text = oSp.MaxWrongTtrial.ToString(); ucUserDet.UserDetail = oSp.UserDetails; hdSecurityPolicyID.Value = oSp.SecurityPolicyID.ToString(); } else { ucMessage.OpenMessage(Constants.MSG_ERROR_NOT_FOUND, Constants.MSG_TYPE_INFO); ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(string), Constants.POPUP_WINDOW, Util.OpenPopup("info"), true); } } else { ucMessage.OpenMessage(Constants.MSG_ERROR_NOT_FOUND, Constants.MSG_TYPE_ERROR); } }
protected void btnSave_Click(object sender, EventArgs e) { // need to check first //This block is used for checking the Security Policy UserDAL oUserDAL = new UserDAL(); bool status = true; string sErrorMessage = string.Empty; Result oResult = null; if (string.IsNullOrEmpty(hdUserID.Value)) { oResult = oUserDAL.CheckUserIDAvailability(txtLoginUserID.Text.Trim()); if (oResult.Status) { if (Convert.ToInt32((Object)oResult.Return) > 0) { sErrorMessage = "This User Login ID exists. Please try with another one"; txtLoginUserID.Text = string.Empty; status = false; } } } else { SecurityPolicyDAL oSpDAL = new SecurityPolicyDAL(); Result oPOResult = oSpDAL.LoadApprovedData(); SecurityPolicy oSp = null; if (oPOResult.Status) { oSp = (SecurityPolicy)oPOResult.Return; if (oSp != null) { int iMinLength = oSp.MinPassLength; bool bAlpNu = oSp.IsForceAlphaNumericPass; if (txtNewPassword.Text.Length < iMinLength) { sErrorMessage += "<LI>Password is too short.</LI>"; status = false; } if (bAlpNu) { if (IsIsDigitValidPassword(txtNewPassword.Text) == false) { sErrorMessage += "<LI>Password must be alpha numeric.</LI>"; status = false; } } } } } //This block is used for checking the Security Policy if (status) { User oUser = new User(); oUser.UserID = Util.GetIntNumber(hdUserID.Value == "" ? "0" : hdUserID.Value); oUser.UserName = Request[txtLoginUserID.UniqueID].Trim(); oUser.Group.GroupID = Util.GetIntNumber(ddlUserClass.SelectedItem.Value); oUser.FirstName = txtUserFirstName.Text; oUser.LastName = txtUserLastName.Text; oUser.Password = txtNewPassword.Text; oUser.Designation.DesignationID = Util.GetIntNumber(ddlDesignation.SelectedItem.Value); oUser.Status = chkStatus.Checked; oUser.DivisionID = ddlDivision.SelectedValue; oUser.UserDetails = ucUserDet.UserDetail;; oResult = (Result)oUserDAL.Save(oUser); if (oResult.Status) { ClearTextValue(); LoadList(); ucMessage.OpenMessage(Constants.MSG_SUCCESS_SAVE, Constants.MSG_TYPE_SUCCESS); } else { ucMessage.OpenMessage(Constants.MSG_ERROR_SAVE, Constants.MSG_TYPE_ERROR); } } else { ucMessage.OpenMessage("<UI>" + sErrorMessage + "</UI>", Constants.MSG_TYPE_ERROR); } }
protected void btnSave_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtNewPassword.Text) && !string.IsNullOrEmpty(txtOldPassword.Text) && !string.IsNullOrEmpty(txtConfirmPassword.Text)) { string sErrorMessage = string.Empty; Config oConfig = (Config)Session[Constants.SES_USER_CONFIG]; if (oConfig != null) { // need to check first //This block is used for checking the Security Policy SecurityPolicyDAL oSpDAL = new SecurityPolicyDAL(); Result oPOResult = new Result(); oPOResult = oSpDAL.LoadApprovedData(); SecurityPolicy oSp = null; bool status = true; if (oPOResult.Status) { oSp = (SecurityPolicy)oPOResult.Return; if (oSp != null) { int iMinLength = oSp.MinPassLength; bool bAlpNu = oSp.IsForceAlphaNumericPass; if (txtNewPassword.Text.Length < iMinLength) { sErrorMessage += "<LI>Password is too short.</LI>"; status = false; } if (bAlpNu) { if (IsIsDigitValidPassword(txtNewPassword.Text) == false) { sErrorMessage += "<LI>Password must be alpha numeric.</LI>"; status = false; } } } } //This block is used for checking the Security Policy if (status == true) { User oUesr = new User(txtLoginUserID.Text); oUesr.Password = txtNewPassword.Text; UserDAL oUserDAL = new UserDAL(); Result oResult = (Result)oUserDAL.ChangePassword(oConfig.UserID, oConfig.UserName, txtOldPassword.Text, txtNewPassword.Text); if (oResult.Status) { ucMessage.OpenMessage(oResult.Message, Constants.MSG_TYPE_SUCCESS); } else { ucMessage.OpenMessage(oResult.Message, Constants.MSG_TYPE_ERROR); } } else { ucMessage.OpenMessage("<UI>" + sErrorMessage + "</UI>", Constants.MSG_TYPE_ERROR); } } } }