protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=.;pwd=sa;uid=sa;database=PetShopping");
con.Open();
SqlCommand cmd = new SqlCommand("select Count(*) from users where usersName='"+this.TextBox1.Text.ToString()+"'and usersPassword='"+this.TextBox2.Text.ToString()+"'", con);
int count = Convert .ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
Session["usersName"] = this.TextBox1.Text.ToString();
Response.Redirect("Default1.aspx");
}
else
{
Response.Write("<script>alert('用户名或密码错误')</script>");
this.Response.Redirect("login.aspx") ;
}
con.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=.;pwd=sa;uid=sa;database=PetShopping");
con.Open();
SqlCommand cmd = new SqlCommand("select Count(*) from manager where managerName='" + this.TextBox3.Text.ToString() + "'and managerPassword='" + this.TextBox4.Text.ToString() + "'", con);
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
Session["usersName"] = this.TextBox3.Text.ToString();
Response.Redirect("houtaiguanli/Default.aspx"); }
else
{
Response.Write("<script>alert('用户名或密码错误')</script>");
this.Response.Redirect("login.aspx");
}
con.Close();
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{ }
{ }
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=.;pwd=sa;uid=sa;database=PetShopping");
con.Open();
SqlCommand cmd = new SqlCommand("select Count(*) from users where usersName='"+this.TextBox1.Text.ToString()+"'and usersPassword='"+this.TextBox2.Text.ToString()+"'", con);
int count = Convert .ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
Session["usersName"] = this.TextBox1.Text.ToString();
Response.Redirect("Default1.aspx");
}
else
{
Response.Write("<script>alert('用户名或密码错误')</script>");
this.Response.Redirect("login.aspx") ;
}
con.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=.;pwd=sa;uid=sa;database=PetShopping");
con.Open();
SqlCommand cmd = new SqlCommand("select Count(*) from manager where managerName='" + this.TextBox3.Text.ToString() + "'and managerPassword='" + this.TextBox4.Text.ToString() + "'", con);
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
Session["usersName"] = this.TextBox3.Text.ToString();
Response.Redirect("houtaiguanli/Default.aspx"); }
else
{
Response.Write("<script>alert('用户名或密码错误')</script>");
this.Response.Redirect("login.aspx");
}
con.Close();
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{ }
up 也可以在属性栏中更改属性,建议LZ把控件的相关属性了解下,一般都有注释的。
TextMode=“Password”
默认是 SingleLine<asp:TextBox ID="txt密码" runat="server" TextMode="Password"></asp:TextBox>
本人同求解.