Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Button3.Enabled = false;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\sachin\Documents\Visual Studio 2012\WebSites\WebSite9\App_Data\Database.mdf;Integrated Security=True ");
- con.Open();
- SqlCommand cmd = new SqlCommand("Select * from admin where username='" + TextBox1.Text + "'",con);
- SqlDataReader rdr = cmd.ExecuteReader();
- if (rdr.Read())
- {
- TextBox2.Text = rdr[1].ToString();
- TextBox3.Text = rdr[2].ToString();
- TextBox4.Text = rdr[3].ToString();
- // TextBox1.Enabled = false;
- TextBox2.Enabled = false;
- TextBox3.Enabled = false;
- TextBox4.Enabled = false;
- }
- else
- {
- Response.Write("<script>alert('invalid username');</script>");
- }
- con.Close();
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\sachin\Documents\Visual Studio 2012\WebSites\WebSite9\App_Data\Database.mdf;Integrated Security=True ");
- con.Open();
- SqlCommand cmd = new SqlCommand("update admin
- set password='"+TextBox2.Text+"',email='"+TextBox3.Text+"',city='"+TextBox4.Text+"'
- where username='"+TextBox1.Text+"'",con);
- cmd.ExecuteNonQuery();
- con.Close();
- }
- protected void Button4_Click(object sender, EventArgs e)
- {
- Button3.Enabled = true;
- TextBox2.Enabled = false;
- TextBox3.Enabled = false;
- TextBox4.Enabled = false;
- }
- protected void Button3_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\sachin\Documents\Visual Studio 2012\WebSites\WebSite9\App_Data\Database.mdf;Integrated Security=True ");
- con.Open();
- SqlCommand cmd = new SqlCommand("delete admin where username='" + TextBox1.Text + "'", con);
- cmd.ExecuteNonQuery();
- con.Close();
- }
- protected void Button5_Click(object sender, EventArgs e)
- {
- TextBox2.Enabled = true;
- TextBox3.Enabled = true;
- TextBox4.Enabled = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement