You are on page 1of 2

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.

Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; public partial class admin_ChangePassword : System.Web.UI.Page { string s; protected void Page_Load(object sender, EventArgs e) { if (Session["admin"] == null) { Response.Redirect("~/admin/AdminLogin.aspx"); } if (Session["admin"] != null) { Label3.Text = (string)Session["admin"]; } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { try { SqlCommand cmd = new SqlCommand("select password from AdminLogin whe re username='" + Label3.Text.ToString() + "'", DBConnection.connect()); cmd.Connection.Open(); SqlDataReader dr; dr = cmd.ExecuteReader(); int i; for (i = 0; i < 1; i++) { if (dr.Read()) { s = dr[0].ToString(); } } cmd.Connection.Close(); if (s == TextBox2.Text.ToString()) { SqlCommand cmd1 = new SqlCommand("update AdminLogin set password ='" + TextBox3.Text.ToString() + "' where username='" + Label3.Text.ToString() + "' ", DBConnection.connect()); cmd1.Connection.Open(); cmd1.ExecuteNonQuery(); cmd1.Connection.Close(); TextBox2.Text = ""; TextBox3.Text = "";

TextBox4.Text = ""; // Response.Write(@"<script language='javascript'>alert('P ');</s cript>"); Label4.Text = "Password is Change Successfully"; Response.Redirect("~/admin/AdminControl.aspx"); } } catch { Label4.Text = "Error"; } } protected void LinkButton1_Click(object sender, EventArgs e) { Session["admin"] = null; Response.Redirect("~/admin/AdminLogin.aspx"); } }