用三层架构实现登录,并模拟后台审核功能,未审核成功不予登录(ASP.NET)
先建如下项目:
创新互联致力于互联网品牌建设与网络营销,包括成都网站设计、网站制作、SEO优化、网络推广、整站优化营销策划推广、电子商务、移动互联网营销等。创新互联为不同类型的客户提供良好的互联网应用定制及解决方案,创新互联核心团队10多年专注互联网开发,积累了丰富的网站经验,为广大企业客户提供一站式企业网站建设服务,在网站建设行业内树立了良好口碑。
先写模型层
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
{
///
/// 验证用户登陆
///
///
///
///
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
整个项目效果图如下:
通过审核的效果如下
未通过审核的效果如下:
后台审核:
本文题目:用三层架构实现登录,并模拟后台审核功能,未审核成功不予登录(ASP.NET)
分享地址:http://myzitong.com/article/gjsgoj.html