public string ChangeUserPassword(SystemUser user) { string ouput = ""; if (user.Passwd.Equals("")) { ouput = "Please Enter New Password"; } else if (user.Cpasswd.Equals("")) { ouput = "Please Confirm Password"; } else if (user.Passwd != user.Cpasswd) { ouput = "Passwords do not match"; } else if (!IsPasswordStrengthOk(user.Passwd)) { ouput = "Your Password Strength is not ok(Password should be alpha-numeric and length of 6)"; } else { string EncryptedPassword = bll.EncryptString(user.Passwd); datafile.UpdatePassword(user.Userid, EncryptedPassword); ouput = "System User Password has been Changed Successfully"; } return(ouput); }
private void Access(SystemUser user) { user.Passwd = bll.EncryptString(user.Passwd); dataTable = datafile.GetUserAccessibility(user); int UserID = int.Parse(dataTable.Rows[0]["UserID"].ToString()); string RoleCode = dataTable.Rows[0]["RoleCode"].ToString(); bool IsActiveRole = bool.Parse(dataTable.Rows[0]["IsRoleActive"].ToString()); bool IsActiveArea = bool.Parse(dataTable.Rows[0]["IsAreaActive"].ToString()); bool IsActiveBranch = bool.Parse(dataTable.Rows[0]["IsBranchActive"].ToString()); bool IsActiveUser = bool.Parse(dataTable.Rows[0]["Active"].ToString()); bool IsLoggedIn = bool.Parse(dataTable.Rows[0]["LoggedOn"].ToString()); bool reset = bool.Parse(dataTable.Rows[0]["Reset"].ToString()); if (IsActiveRole) { if (IsActiveArea) { if (IsActiveBranch) { if (IsActiveUser) { string Message = ""; if (reset) { Message = "Please you need to change your password to continue"; RequestToChangePassword(Message); Label1.Text = UserID.ToString(); Label2.Text = user.Uname; } else { DateTime DateOfChange = AssignSessions(dataTable); if (bll.PasswordExpired(DateOfChange)) { Message = "Your Password expired and needs to be changed"; RequestToChangePassword(Message); Label1.Text = UserID.ToString(); txtNewPassword.Focus(); ShowMessage(".", true); } else { double RemainingDays = bll.IsRemainingDays(DateOfChange); if (RemainingDays < 5) { //Message = "Your Password will expire in "+RemainingDays+" day(s), Do you want to change"; WarnAboutExpiry(RemainingDays); Label1.Text = UserID.ToString(); Label2.Text = user.Uname; txtNewPassword.Focus(); ShowMessage(".", true); } else { string StartPage = Session["Page"].ToString(); Redirection(StartPage); AssignUserCookie(); } } } //} } else { ShowMessage("Your Account is disabled, Please Contact System Administrators", true); } } else { ShowMessage("Your Company is disabled, Please Contact System Administrators", true); } } else { ShowMessage("Your Operating Region is disabled, Please Contact System Administrators", true); } } else { ShowMessage("Your System Role is disabled, Please Contact System Administrators", true); } }
protected void BtnSave_Click(object sender, EventArgs e) { try { string evariable = ""; string ValueCode = lblcode.Text.Trim(); string variable = txtvalue.Text.Trim(); string name = txtname.Text.Trim(); string Isnum = lblIsnum.Text.Trim(); int num; if (variable.Equals("")) { ShowMessage("Please Enter variable", true); txtvalue.Focus(); } else { if (Isnum.Equals("True")) { if ((Int32.TryParse(variable, out num))) { evariable = bll.EncryptString(variable); Process.UpdateSystemParameter(ValueCode, evariable); ShowMessage(name + " Parameter Updated Successfully", false); LoadParameters(); } else { ShowMessage("Numeric Varriable expected", true); txtvalue.Focus(); } } else { if (ValueCode.Equals("20")) { string checkstr = "PAN"; if (!checkstr.Contains(variable)) { ShowMessage("Variable must be A,N or P only", true); txtvalue.Focus(); } else { evariable = bll.EncryptString(variable); Process.UpdateSystemParameter(ValueCode, evariable); ShowMessage(name + " Parameter Updated Successfully", false); LoadParameters(); } } else { evariable = bll.EncryptString(variable); Process.UpdateSystemParameter(ValueCode, evariable); ShowMessage(name + " Parameter Updated Successfully", false); LoadParameters(); } } } } catch (Exception ex) { ShowMessage(ex.Message, true); } }