步步为营 .NET三层架构解析 七、UI的设计(登陆页面、注册页页和添加部门页面)...
在我们设计好了三层架构的SQLHelper、Model、DAL和BLL后,我们要开始来调用它设计好的功能了。
首先我们来设计Login.aspx,先看界面的设计:
<table><tr><td style="width: 100px; text-align: right">帐户名:</td><td style="width: 100px"><asp:TextBox ID="txtUserName" runat="server"></asp:TextBox></td></tr><tr><td style="width: 100px; text-align: right">密码:</td><td style="width: 100px"><asp:TextBox ID="txtPassWord" runat="server" TextMode="Password"></asp:TextBox></td></tr><tr><td style="width: 100px"></td><td style="width: 100px"><asp:Button ID="btnLogin" runat="server" OnClick="btnLogin_Click1" Text="登陆" /></td></tr></table>
再来看Login.aspx.cs的设计:
记得加上这个:
using BLL;
using Model;
而后才是:
protected void Page_Load(object sender, EventArgs e){}protected void btnLogin_Click1(object sender, EventArgs e){custom Custom = new custom();customSystem CustomSystem = new customSystem();Custom = CustomSystem.GetSinglename(txtUserName.Text.Trim().ToString());if (Custom.ename == txtUserName.Text.Trim().ToString()){// 密码是经过MD5加密后保存到数据库的
if (Custom.password == FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassWord.Text.Trim().ToString(), "MD5")){department Department = new department();departmentSystem DepartmentSystem = new departmentSystem();Department = DepartmentSystem.Getsingledepartment(Custom.departID);SetSession(Department,Custom.departID.ToString());}else{Response.Write("<script>alert('密码错误');location.href='Login.aspx';</script>");}}else{Response.Write("<script>alert('帐户名不存在');location.href='Login.aspx';</script>");}}private void SetSession(department Department,string DepartID){if (Department == null || string.IsNullOrEmpty(DepartID)){Response.Write("<script>alert('网站运行错误或你没设置部门信息,请联系管理员.');location.href='Login.aspx';</script>");return;}Session["Ename"] = txtUserName.Text.Trim().ToString();Session["Departid"] = DepartID;Session["Operater"] = "";if (Department.departname == "控制中心"){Response.Write("<script>alert('登录成功');location.href='Default.aspx';</script>");}else{Response.Write("<script>alert('登录成功');location.href='Default2.aspx';</script>");}}
接下来我们要在App_Code文件下新建PageBase.cs
public bool IsAdmin(){if (Session["Departid"] != null){department Department = new department();departmentSystem DepartmentSystem = new departmentSystem();Department = DepartmentSystem.Getsingledepartment(int.Parse(Session["Departid"].ToString()));if (Department.departname != "控制中心"){Response.Redirect("/Web/Login.aspx");Response.End();return false;}}else{Response.Redirect("/Web/Login.aspx");Response.End();return false;}return true;}
加入下面之个方法:
再来看下ADDdepart.aspx的设计:
<table><tr><td style="width: 100px">部门名称:</td><td style="width: 100px"><asp:TextBox ID="txtDepartmentName" runat="server"></asp:TextBox></td></tr><tr><td style="width: 100px">描述:</td><td style="width: 100px"><asp:TextBox ID="txtDescription" runat="server"></asp:TextBox></td></tr><tr><td style="width: 100px"></td><td style="width: 100px"><asp:Button ID="btnAdd" runat="server" OnClick="btnAdd_Click" Text="增加" /></td></tr></table>
ADDdepart.aspx.cs的设计:
//继承PageBase类
public partial class ADDdepart : PageBase
{protected void Page_Load(object sender, EventArgs e){if (!Page.IsPostBack){IsAdmin();}}protected void btnAdd_Click(object sender, EventArgs e){department Department = new department();department Departmenter = new department();departmentSystem DepartmentSystem = new departmentSystem();Department.departname = txtDepartmentName.Text.Trim();Department.description = txtDescription.Text.Trim();Departmenter = DepartmentSystem.Getdepartmenter(txtDepartmentName.Text.Trim());if (Departmenter.id <= 0){if (DepartmentSystem.Adddepartment(Department) >= 1){ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('恭喜您,部门添加成功!');</script>");}}else{ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('您填的部门己存在,请更改!');</script>");}}
}
再来看下注册页面Register.aspx的设计:
<table><tr><td style="width: 100px; text-align: right">帐户名:</td><td style="width: 100px"><asp:TextBox ID="txtUserName" runat="server"></asp:TextBox></td><td style="width: 100px"></td></tr><tr><td style="width: 100px; text-align: right;">姓名:</td><td style="width: 100px"><asp:TextBox ID="txtName" runat="server"></asp:TextBox></td><td style="width: 100px"></td></tr><tr><td style="width: 100px; text-align: right;">年龄:</td><td style="width: 100px"><asp:TextBox ID="txtAge" runat="server"></asp:TextBox></td><td style="width: 100px"></td></tr><tr><td style="width: 100px; text-align: right;">密码:</td><td style="width: 100px"><asp:TextBox ID="txtPassWord" runat="server" TextMode="Password"></asp:TextBox></td><td style="width: 100px"><asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox4"ControlToValidate="TextBox5" ErrorMessage="密码不一样"></asp:CompareValidator></td></tr><tr><td style="width: 100px; text-align: right;">重复密码:</td><td style="width: 100px"><asp:TextBox ID="txtConfirmPassWord" runat="server" TextMode="Password"></asp:TextBox></td><td style="width: 100px"></td></tr><tr><td style="width: 100px; text-align: right;">部门:</td><td style="width: 100px"><asp:DropDownList ID="ddlDepartment" runat="server"></asp:DropDownList></td><td style="width: 100px"></td></tr><tr><td style="width: 100px"></td><td style="width: 100px"><asp:Button ID="btnLogin" runat="server" OnClick="btnLogin_Click" Text="注册" /></td><td style="width: 100px"></td></tr></table>
下面是Register.aspx.cs的设计:
protected void Page_Load(object sender, EventArgs e){if (!IsPostBack){ BinData();}}public void BinData(){List<department> Departmentlist = new List<department>();departmentSystem DepartmentSystem = new departmentSystem();Departmentlist = DepartmentSystem.GetDepartment();ddlDepartment.DataSource = Departmentlist;ddlDepartment.DataTextField = "departname";ddlDepartment.DataValueField = "id";ddlDepartment.DataBind();}protected void btnLogin_Click(object sender, EventArgs e){custom Custom = new custom();customSystem CustomSystem = new customSystem();custom Customn = new custom();Customn = CustomSystem.GetSinglename(txtUserName.Text.Trim());if (Customn.id <= 0){Custom.ename = txtUserName.Text.Trim();Custom.cname = txtName.Text.Trim();Custom.age = Convert.ToInt32(txtAge.Text.Trim());Custom.password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassWord.Text.Trim(), "MD5");Custom.departID = int.Parse(ddlDepartment.SelectedValue);if (CustomSystem.customADD(Custom) >= 1){ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('恭喜您,帐号添加成功!');</script>");}}else{ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('你输入的帐户名己存在,请更改!');</script>");}}
以上只是UI简单的调用BLL的功能,下次再讲解下GridView调用BLL和GridView的分页,可能我设计的只是较简单,欢迎大家提出你们宝贵的意见.来共同提高.欢迎拍砖.
转载于:https://www.cnblogs.com/springyangwc/archive/2011/03/27/1997314.html
步步为营 .NET三层架构解析 七、UI的设计(登陆页面、注册页页和添加部门页面)...相关推荐
- 步步为营 .NET三层架构解析 四、Model设计(四种设计方式)
说到Model设计,我们先谈谈它的作用: Model又叫实体类,model层里面的一个类对应数据库里面的一张表, 类里面的每一个属性对应表里面的一个字段,每个属性都有自己的 GET 和 SET 方法, ...
- 步步为营 .NET三层架构解析系列总结
这个系列我一共写了八篇,从什么是三层架构到一个简单的三层架构从数据库设计.SQLHelper设计.Modle设计.DAL设计.BLL设计到UI的设计作了简单的说明,在这其中有很多读者提出了很好的意见, ...
- ASP.NET的三层架构(DAL,BLL,UI)
BLL 是业务逻辑层 Business Logic Layer DAL 是数据访问层 Data Access Layer ASP.NET的三层架构(DAL,BLL,UI ...
- 镇江php开发,myweb 我的家乡镇江,web技术开发的网站,三层架构,5大模块设计 WEB(ASP,PHP,...) 238万源代码下载- www.pudn.com...
文件名称: myweb下载 收藏√ [ 5 4 3 2 1 ] 开发工具: HTML 文件大小: 8226 KB 上传时间: 2015-04-11 下载次数: 0 提 供 者: min 详细 ...
- C# 三层架构与七层架构
前言 学习三层的时候对于这三层有了大致的了解,但是还是说不出个一二,今天试着总结一下,将自己的知识重新梳理一遍. 三层架构 概念 三层架构通常意义上讲的就是将整个业务应用划分为:表现层(UI).业务逻 ...
- 根据UI图设计的大小换算REM单位以及大屏页面全屏展示
需求:UI图设计的1366px,产品希望往大了适配,字体和div宽度都需要适配实际页面宽: 设置rem节点适配 例如设计的UI图尺寸是1366宽的,则正常页面往下滚动的是情况下,输入UI图设计的尺寸, ...
- 从web三层架构解析软件错误
B/S架构的系统,都会使用如下的基础软件架构: 数据访问层:实现对数据的访问功能,如增加.删除.修改.查询数据. 业务逻辑层:实现业务的具体逻辑功能,如学生入学.退学.成绩管理等. 页面显示层:将业务 ...
- 关于MVC与三层架构、个人总结网上杂七杂八得出的最终成果、asp.net (core) MVC、JavaWeb的MVC
阅读本文必须明白的事情 首先需要明白的是不同语言实现的MVC与三层架构对应的层是不一样的!!! 拿.net来说,.net实现MVC与其他语言的MVC具体实现是不同的,asp.net MVC与 MVC ...
- 什么是三层架构?简单的介绍三层架构!
三层架构(3-tierarchitecture) 通常意义上的三层架构就是将整个业务应用划分为:表现层(Presentation layer).业务逻辑层(Business Logic Layer). ...
最新文章
- 从零开发一个 Java Web 项目要点
- Smartforms常见的问题
- springboot拦截请求路径_SpringBoot整合Ant Design Pro进行部署
- 第一章 简单工厂模式
- 并发工具类【线程安全相关的类】
- 怎么用代码制作WordPress的归档页面
- WindowsApi 解压缩文件
- Lowest Common Multiple Plus
- 《Java核心技术36讲》读后
- 【第三课】Arcgis软件详细介绍
- 苹果怎么用测试软件,苹果测试员如何使用TestFlight进行测试
- docker 在win7电脑上的部署
- dubbo服务暴露与注册
- 人工智能:嵌入式技术的机遇与挑战
- Ubuntu14.04 安装Firefox flash插件
- 这猪蹄是人类能吃完的?
- mybatis 关于出现Parameter array not found. Available parameters are [collection, list]问题的解决方案
- VMware Workstation 与 Device/Credential Guard 不兼容解决方案
- 通过excel文件在arcgis中点转面
- ChatGPT会对未来5年的NLP算法从业者带来怎样的冲击?
热门文章
- [Python]网络爬虫(12):爬虫框架Scrapy的第一个爬虫示例入门教程
- 栈溢出笔记1.4 黑掉example_2
- C++11 并发指南九(综合运用: C++11 多线程下生产者消费者模型详解)
- linux 获取本机的所有IP地址
- 企业安全建设之自动化代码扫描(代码审计)
- Wireshark条件过滤后的数据包保存
- windows拷贝内容到ubuntu中
- webkit事件处理
- Service Unavailable解决方法
- 推荐算法为啥这么“灵”,又为啥会“失灵”?