You are on page 1of 2

Project: HROR

HR User Module

Change Password

• Add Web form and save with “frmChangePassword.aspx “ under “HRUser.Master”, design as per
requirements

Change Password Requirements

• Create stored procedure “sp_Change_Password”

• Design Change Password page

• Display User Name in Page_Load() and cannot be update (Enable=false)

• Check null for the following

 New Password & Conform Password

• Check Password format (Password must be between 4 and 8 characters. It should contain upper-case
letters, lower-case letters and digits only)

• Compare Confirm Password

• Define business function Change_Password() in BAL_Login class

• Send frontend data to the above business function from btnUpdate_Click()

Create the following stored procedure which will receive Employee ID and New Password to update the
password

CREATE PROCEDURE sp_Change_Password(


@EId int,
@PWD varchar(10))
AS
BEGIN

Faculty: Suresh Naidu Thota Page 1


Project: HROR

UPDATE tblLoginDetails
SET Password = @PWD
WHERE
EmpId = @EId

END

1. Define the following business method in BAL_Login.cs


public void Change_Password(int EId, string Pwd, out string Status)
{
Status = "";

SqlParameter[] Params = new SqlParameter[2];

Params[0] = new SqlParameter("@EId", SqlDbType.Int);


Params[0].Value = EId;
Params[1] = new SqlParameter("@PWD", SqlDbType.VarChar);
Params[1].Value = Pwd;

try
{
int i = SqlHelper.ExecuteNonQuery(clsConnection.GetConString(),
CommandType.StoredProcedure, "sp_Change_Password", Params);

if (i > 0)
{
Status = "Password Changed Successfully";
}
else
{
Status = "Password Change Failed";
}
}
catch (Exception ex)
{
Status = ex.Message;
}
} //End of Change_Password()

2. Check validations as per requirements

3. Write the following code in the frmChangePassword.aspx.cs

protected void Page_Load(object sender, EventArgs e)


{
txtUserName.Text = Session["UserName"].ToString();
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
int EId = Convert.ToInt32(Session["EmpId"]);
string Status;
BAL_Login obj = new BAL_Login();
obj.Change_Password(EId, txtPassword.Text, out Status);
lblErrMsg.Text = Status;
}

Faculty: Suresh Naidu Thota Page 2

You might also like