asp.kn
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;
using System.Security.Cryptography;
namespace Bton
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string GetMD5(string chuoi)
{
string str_md5 = "";
byte[] mang = System.Text.Encoding.UTF8.GetBytes(chuoi);
MD5CryptoServiceProvider my_md5 = new MD5CryptoServiceProvider();
mang = my_md5.ComputeHash(mang);
foreach (byte b in mang)
{
str_md5 += b.ToString("X2");
}
return str_md5;
}
protected void btndangnhap_Click(object sender, EventArgs e)
{
SqlConnection cnn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\QLSV.mdf;Integrated Security=True;User Instance=True");
cnn.Open();
txtmahoa.Text = GetMD5(txtmatkhau.Text);
SqlDataAdapter da = new SqlDataAdapter("Select TENDN From NGUOIDUNG Where TENDN= '" + txtdangnhap.Text + "' and MATKHAU = '" + txtmahoa.Text + "'", cnn);
DataTable tb = new DataTable();
da.Fill(tb);
if (tb.Rows.Count > 0)
{
lblthongbao.Text = "Bạn đã đăng nhập thành công";
Response.Write("<script>alert('Dang nhap thanh cong')<script>");
Response.Redirect("hososv.aspx");
}
else
{
lblthongbao.Text = "Đăng nhập thất bại!";
}
}
}
}
Bạn đang đọc truyện trên: Truyen247.Pro