Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            try 
            {
                DataSet ds = new DataSet();
                //objLogin.Mode = 2;
                objLogin.LoginId = Convert.ToInt32(Session["LoginId"].ToString());
                ds = objLogin.GetLoginDataSet();
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    if (txtOldPassword.Text == ds.Tables[0].Rows[0]["Password"].ToString())
                    {
                        string ABC = txtNewPassword.Text;
                        if (txtConfirmPwd.Text == ABC)
                        {
                            objLogin.Password = txtNewPassword.Text;
                            objLogin.ConfirmPassword = txtConfirmPwd.Text;
                            objLogin.LoginId = Convert.ToInt32(Session["LoginId"].ToString());
                            objLogin.IsActive = 1;
                            objLogin.IsDeleted = 0;
                            objLogin.UpdatedBy = Convert.ToInt32(Session["LoginId"].ToString());
                            objLogin.UpdatedDate = Convert.ToDateTime(System.DateTime.Today.ToString()).ToString("yyyy/MM/dd");
                            int result = objLogin.InsertPwdData();
                            if (result > 0)
                            {
                                txtNewPassword.Text = string.Empty;
                                txtConfirmPwd.Text = string.Empty;
                                txtOldPassword.Text = string.Empty;
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert('Password Changed Sucessfully');", true);
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert('Data not Saved');", true);
                            }
                        }
                        else 
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert('Password Doesn't Match');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert('Current Password is Incorrect');", true);
                    }                   
                }
            }
            catch { }
        }       
public DataSet GetLoginDataSet()
        {
            try
            {
                SqlParameter[] P = new SqlParameter[3];
                P[0] = new SqlParameter("@LoginId", LoginId);
                P[1] = new SqlParameter("@LoginName", LoginName);
                P[2] = new SqlParameter("@Password", Password);
                //return sqlHelper.ExecuteDataset(ClsConnection.ConnectionString, "Select Password from LoginMaster where LoginId='" + LoginId + "'", P);
                return sqlHelper.ExecuteDataset(ClsConnection.ConnectionString, CommandType.StoredProcedure, "SP_LoginMaster", P);    
            }
            catch
            {
                return null;
            }
        }
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900