用三层架构实现登录,并模拟后台审核功能,未审核成功不予登录(ASP.NET)
2012-12-21 02:24
651 查看
先建如下项目:
先写模型层
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Model
{
public class Student
{
private string stuId;
public string StuId
{
get { return stuId; }
set { stuId = value; }
}
private string stuPwd;
public string StuPwd
{
get { return stuPwd; }
set { stuPwd = value; }
}
private string stuName;
public string StuName
{
get { return stuName; }
set { stuName = value; }
}
private string stuAge;
public string StuAge
{
get { return stuAge; }
set { stuAge = value; }
}
private string stuSex;
public string StuSex
{
get { return stuSex; }
set { stuSex = value; }
}
private string stuTel;
public string StuTel
{
get { return stuTel; }
set { stuTel = value; }
}
private string stuAddr;
public string StuAddr
{
get { return stuAddr; }
set { stuAddr = value; }
}
private string stuAudit;
public string StuAudit
{
get { return stuAudit; }
set { stuAudit = value; }
}
}
}
然后写数据链路层:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Model;
namespace DAL
{
public class Student_DAL
{
/// <summary>
/// 验证用户登陆
/// </summary>
/// <param name="user"></param>
/// <param name="right"></param>
/// <returns></returns>
public object CheckStuLogin(Student student,string right)
{
string sqlText;
sqlText = "select stuPwd from stuInfo where stuId=@userId";
SqlParameter[] paras = new SqlParameter[1]
{
new SqlParameter("userId",student.StuId)
};
object obj = SqlLink.GetScaler(sqlText, paras);
return obj;
}
}
}
然后写业务层
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using Model;
using System.Data;
namespace BLL
{
public class Student_BLL
{
Student_DAL studal = new Student_DAL();
public int CheckStuLogin(Student student, string right)
{
object obj = studal.CheckStuLogin(student, right);
int result = -1;
if (obj == null)
{
result = 0; //用户不存在
}
else if (obj.ToString().Trim() == student.StuPwd)
{
result = 1;//正确
}
else if (obj.ToString().Trim() != student.StuPwd)
{
result = 2;//密码错误
}
else
{
result = 3; //系统错误
}
return result;
}
}
}
然后写表示层
以上都只是部分的代码及截图。需要详细代码,以及数据库脚本的可以留言,或发邮件。191660130@qq.com
整个项目效果图如下:
通过审核的效果如下
未通过审核的效果如下:
后台审核:
本文出自 “Love-JS” 博客,请务必保留此出处http://leileiaijishu.blog.51cto.com/6286126/1095712
先写模型层
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Model
{
public class Student
{
private string stuId;
public string StuId
{
get { return stuId; }
set { stuId = value; }
}
private string stuPwd;
public string StuPwd
{
get { return stuPwd; }
set { stuPwd = value; }
}
private string stuName;
public string StuName
{
get { return stuName; }
set { stuName = value; }
}
private string stuAge;
public string StuAge
{
get { return stuAge; }
set { stuAge = value; }
}
private string stuSex;
public string StuSex
{
get { return stuSex; }
set { stuSex = value; }
}
private string stuTel;
public string StuTel
{
get { return stuTel; }
set { stuTel = value; }
}
private string stuAddr;
public string StuAddr
{
get { return stuAddr; }
set { stuAddr = value; }
}
private string stuAudit;
public string StuAudit
{
get { return stuAudit; }
set { stuAudit = value; }
}
}
}
然后写数据链路层:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Model;
namespace DAL
{
public class Student_DAL
{
/// <summary>
/// 验证用户登陆
/// </summary>
/// <param name="user"></param>
/// <param name="right"></param>
/// <returns></returns>
public object CheckStuLogin(Student student,string right)
{
string sqlText;
sqlText = "select stuPwd from stuInfo where stuId=@userId";
SqlParameter[] paras = new SqlParameter[1]
{
new SqlParameter("userId",student.StuId)
};
object obj = SqlLink.GetScaler(sqlText, paras);
return obj;
}
}
}
然后写业务层
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using Model;
using System.Data;
namespace BLL
{
public class Student_BLL
{
Student_DAL studal = new Student_DAL();
public int CheckStuLogin(Student student, string right)
{
object obj = studal.CheckStuLogin(student, right);
int result = -1;
if (obj == null)
{
result = 0; //用户不存在
}
else if (obj.ToString().Trim() == student.StuPwd)
{
result = 1;//正确
}
else if (obj.ToString().Trim() != student.StuPwd)
{
result = 2;//密码错误
}
else
{
result = 3; //系统错误
}
return result;
}
}
}
然后写表示层
以上都只是部分的代码及截图。需要详细代码,以及数据库脚本的可以留言,或发邮件。191660130@qq.com
整个项目效果图如下:
通过审核的效果如下
未通过审核的效果如下:
后台审核:
本文出自 “Love-JS” 博客,请务必保留此出处http://leileiaijishu.blog.51cto.com/6286126/1095712
相关文章推荐
- Ajax调用asp.net后台方法功能实现
- 菜鸟蔡之Ajax复习第一篇(后台asp.net)(传统的JavaScript方法实现Ajax功能)
- 【无私分享:从入门到精通ASP.NET MVC】从0开始,一起搭框架、做项目(5.5) 登录功能的实现,完善登录功能
- ASP.NET jQuery 食谱11 (通过使用jQuery validation插件简单实现用户登录页面验证功能)
- Asp.Net Core 2.0 项目实战(10) 基于cookie登录授权认证并实现前台会员、后台管理员同时登录
- 整合公司3个网站后台管理子系统的经验总结 - 实现多系统的单点登录(ASP.NET + ASP) 推荐
- 简单的asp.net模拟邮箱系统基础实现(一 总体功能版块的设计,与简单数据库的设计)
- 简单的asp.net模拟邮箱系统基础实现(二 (1)具体版块功能的实现及关键代码之注册页面)
- 简单的asp.net模拟邮箱系统基础实现(二 (2)具体版块功能的实现及关键代码之登陆页面)
- ASP.NET MVC4 WEB API入门 第二篇:ASP.NET MVC入门基础(2)—— 简单登录功能的实现
- sql server 关于表中只增标识问题 C# 实现自动化打开和关闭可执行文件(或 关闭停止与系统交互的可执行文件) ajaxfileupload插件上传图片功能,用MVC和aspx做后台各写了一个案例 将小写阿拉伯数字转换成大写的汉字, C# WinForm 中英文实现, 国际化实现的简单方法 ASP.NET Core 2 学习笔记(六)ASP.NET Core 2 学习笔记(三)
- 模拟实现ASP.NET框架的基本功能(一)
- 模拟实现ASP.NET框架基本功能(三)
- asp.net jQuery Ajax用户登录功能的实现
- asp.net连接sql server2005实现简单的登录功能
- 简单的asp.net模拟邮箱系统基础实现(二 (4)具体版块功能的实现及关键代码之收件和写信)
- ASP.NET MVC使用中转站方式获取code实现微信登录,分享功能
- asp.net jQuery Ajax用户登录功能的实现
- 演练:ASP.NET控件实现 创建具有成员资格和用户登录功能的网站