简单三层实现登陆
2014-05-16 05:39
232 查看
Model层
[Serializable]
public partial class tb_admin
{ public tb_admin()
{}
#region Model private string _id;
private string _name; private string _pwd;
/// <summary>
///
/// </summary>
public string id { set{ _id=value;} get{return _id;} }
/// <summary>
///
/// </summary>
public string name { set{ _name=value;} get{return _name;} }
/// <summary>
///
/// </summary>
public string pwd { set{ _pwd=value;} get{return _pwd;} }
#endregion Model
}
DAL层
public class AdminServer {
public List<tb_admin> Tabletb_Admin( string name,string pwd) {
List<tb_admin> list = new List<tb_admin>();
string str = "select* from tb_admin where name='" + name + "'and pwd='" + pwd + "'";
DataTable table= DBHelper.GetDataTable(str);
if (table.Rows.Count>0)
{
foreach (DataRow item in table.Rows)
{
list.Add(DataRowToModel(item));
}
}
return list; }
/// <summary>
/// 得到一个对象实体
/// </summary>
public tb_admin DataRowToModel(DataRow row)
{
tb_admin model = new tb_admin();
if (row != null)
{
if (row["id"] != null)
{
model.id = row["id"].ToString();
}
if (row["name"] != null)
{
model.name = row["name"].ToString();
}
if (row["pwd"] != null)
{
model.pwd = row["pwd"].ToString();
}
}
return model;
}
BLL层
public static class AdminBLL
{
static AdminServer Admin=new AdminServer();
public static List<tb_admin> Tabletb_Admin( string name, string pwd)
{
return Admin.Tabletb_Admin(name,pwd);
}
}
UI层
protected void Button1_Click(object sender, EventArgs e)
{
string name = TextBox1.Text;
string pwd = TextBox2.Text;
string str=Convert.ToString(Session["code"]);
if (name=="")
{
Label2.Visible = true;
Label2.Text="用户名为空";
}
else if (pwd =="")
{
Label2.Visible = true;
Label2.Text = "密码名为空";
}
else
{
List<tb_admin> damin = AdminBLL.Tabletb_Admin(name, pwd);
if (damin.Count > 0)
{
if (TextBox3.Text == str)
{
Response.Redirect("TushuXinxiGuanl.aspx");
}
else
{
Label1.Visible = true;
Label1.Text = "验证码错误!";
}
}
}
}
[Serializable]
public partial class tb_admin
{ public tb_admin()
{}
#region Model private string _id;
private string _name; private string _pwd;
/// <summary>
///
/// </summary>
public string id { set{ _id=value;} get{return _id;} }
/// <summary>
///
/// </summary>
public string name { set{ _name=value;} get{return _name;} }
/// <summary>
///
/// </summary>
public string pwd { set{ _pwd=value;} get{return _pwd;} }
#endregion Model
}
DAL层
public class AdminServer {
public List<tb_admin> Tabletb_Admin( string name,string pwd) {
List<tb_admin> list = new List<tb_admin>();
string str = "select* from tb_admin where name='" + name + "'and pwd='" + pwd + "'";
DataTable table= DBHelper.GetDataTable(str);
if (table.Rows.Count>0)
{
foreach (DataRow item in table.Rows)
{
list.Add(DataRowToModel(item));
}
}
return list; }
/// <summary>
/// 得到一个对象实体
/// </summary>
public tb_admin DataRowToModel(DataRow row)
{
tb_admin model = new tb_admin();
if (row != null)
{
if (row["id"] != null)
{
model.id = row["id"].ToString();
}
if (row["name"] != null)
{
model.name = row["name"].ToString();
}
if (row["pwd"] != null)
{
model.pwd = row["pwd"].ToString();
}
}
return model;
}
BLL层
public static class AdminBLL
{
static AdminServer Admin=new AdminServer();
public static List<tb_admin> Tabletb_Admin( string name, string pwd)
{
return Admin.Tabletb_Admin(name,pwd);
}
}
UI层
protected void Button1_Click(object sender, EventArgs e)
{
string name = TextBox1.Text;
string pwd = TextBox2.Text;
string str=Convert.ToString(Session["code"]);
if (name=="")
{
Label2.Visible = true;
Label2.Text="用户名为空";
}
else if (pwd =="")
{
Label2.Visible = true;
Label2.Text = "密码名为空";
}
else
{
List<tb_admin> damin = AdminBLL.Tabletb_Admin(name, pwd);
if (damin.Count > 0)
{
if (TextBox3.Text == str)
{
Response.Redirect("TushuXinxiGuanl.aspx");
}
else
{
Label1.Visible = true;
Label1.Text = "验证码错误!";
}
}
}
}
相关文章推荐
- 转载---ajax简单三层实现登陆
- 三层架构(MVC)实现简单登陆注册验证(含验证码)
- 用Cache简单的实现单点登陆
- 一个简单的登陆页面实现
- 菜鸟上路-JSP用户登陆简单程序的实现
- 一个简单的三层实现
- extJs+json实现的一个登陆验证的简单例子
- 用户登陆与验证的简单实现
- 简单js实现弹出登陆框div层,背景变暗不可操作
- jsp+Mysql实现简单用户登陆
- Java中接口的实现与简单登陆界面的设计
- 单点登陆.NET的简单实现 (转)
- jsp实现客户登陆的简单验证
- ASP.NET中简单实现单点登陆
- 简单的三层结构(C#实现)
- ASP.NET使用Cookie简单实现记住登陆状态功能
- asp.net 2.0 三层架构的实现(最最原始,简单,一般, 但不平凡)用通俗的语言说出难以理解的。。。
- 原:使用objectdatasource进行简单三层架构的开发 , 并实现Repeater现删改查
- 简单三层+AJAX Control Toolkit实现dropdownlist无刷新联动
- 单点登陆.NET的简单实现 (转)