|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Windows.Forms;
public partial class first : System.Web.UI.Page
{
public static string objcon = ConfigurationManager.AppSettings["con"].ToString();
SqlConnection con = new SqlConnection(objcon);
SqlCommand cmd;
SqlDataReader rd;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string a = Convert.ToString(TextBox1.Text);
string b = Convert.ToString(TextBox2.Text);
if (a == "admin" && b == "admin")
{
Session["user"] = "admin";
Response.Redirect("adminentrypge.aspx");
}
else
{
con.Open();
cmd = new SqlCommand("select uname,pwd from staff where uname='" + a + "' and pwd='" + b + "'", con);
rd = cmd.ExecuteReader();
if (rd.HasRows)
{
while (rd.Read())
{
Session["staff"] = Convert.ToString(rd.GetValue(0));
Response.Redirect("staffhme.aspx");
}
}
else
Label1.Text = "Check Your uid and pwd";
con.Close();
}
}
protected void Button5_Click(object sender, EventArgs e)
{
Label4.Visible = true;
Label5.Visible = true;
Label6.Visible=true;
TextBox3.Visible = true;
TextBox4.Visible = true;
TextBox5.Visible=true;
Button3.Visible = true;
Button4.Visible = true;
}
protected void Button3_Click(object sender, EventArgs e)
{
string a = Convert.ToString(TextBox3.Text);
string b = Convert.ToString(TextBox4.Text);
string c = Convert.ToString(TextBox5.Text);
con.Open();
cmd = new SqlCommand("update staff set pwd='" + b + "'where uname='" + c + "'", con);
cmd.ExecuteNonQuery();
Response.Write("<script>alert('Your password was changed')</script>");
con.Close();
}
protected void Button4_Click(object sender, EventArgs e)
{
Label4.Visible = false;
Label5.Visible = false;
Label6.Visible = false;
TextBox3.Visible = false;
TextBox4.Visible = false;
TextBox5.Visible = false;
Button3.Visible = false;
Button4.Visible = false;
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
}
}
|