using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class dangnhap : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["IL"]=0;
}
protected void btndangnhap_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString =
ConfigurationManager.ConnectionStrings["BookStore"].ConnectionString;
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select count(*) from tuser where UserName=@User and
Pass=@Pass";
cmd.Parameters.AddWithValue("@User", txtuser.Text);
cmd.Parameters.AddWithValue("@Pass", txtpass.Text);
cmd.Connection = conn;
conn.Open();
int usercount = (int)cmd.ExecuteScalar();
conn.Close();
conn.Dispose();
if (usercount >= 1)
{
Session["IL"] = 1;
Response.Redirect("ThemSach.aspx");
}
else
{
lblmsg.Text=("Sai Tên đăng nhập hoặc mật khẩu");
cmd.ExecuteNonQuery();
nhaplai();
Label1.Text = "Them SAch thanh cong";
conn.Close();
conn.Dispose();
}
protected void btnnhaplai_Click(object sender, EventArgs e)
{
nhaplai();
}
void nhaplai()
{
txttensach.Text = "";
txtnoidung.Text = "";
dlcd.SelectedValue = "1";
FlHinh.Dispose();
}
}