Admin –ChangePassword.aspx

 

Write this code in the button change event.The only thing one needs is the customerid  which is got through the Request.Params[“identity”] which is the identity of the admin .Just write the update query.

 

The source code for this files is

 

private void cmdChange_Click(object sender, System.EventArgs e)

              {

                     // Event fired when one clicks on Change button

                     id =Request.Params["identity"];

                     //Captures the identity of admin since only admin can change his password.

                     objcon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);

                    

                     if(txtPassword.Text != txtConfirm.Text) // Check if the passwords are not same

                     {

                          

                           RegisterStartupScript("messg","<script>ShowMessg();</script>");// Call the client side script.

                     }

                     else

                     {

 

                           s = prjstart.Components.encryptpass.protectpassword(txtPassword.Text); // Encrypt the password.

                           string sql = "update employees set password ='" + s + "' where customerid ='" + id + "'" ;

                           SqlCommand objcom = new SqlCommand(sql,objcon);

                           objcon.Open();

                           try

                           {

                                  objcom.ExecuteNonQuery();

                                  Session["result"]="Password Changed";

                                  Response.Redirect("adminpage.aspx");

                           }

                           catch(Exception ex)

                           {

                                  Console.WriteLine(ex.Message);

                           }

                     }

}

 

 

Back  to Main Page