如果变成打字高手:步步为营 .NET三层架构解析 七、UI的设计(登陆页面、注册页页和添加部门页面)-程序开...
来源:百度文库 编辑:中财网 时间:2024/04/27 06:14:49
步步为营 .NET三层架构解析 七、UI的设计(登陆页面、注册页页和添加部门页面)
文章录入:7747.Net 责任编辑:7747.Net 10
【字体:小 大】
在我们设计好了三层架构的SQLHelper、Model、DAL和BLL后,我们要开始来调用它设计好的功能了。首先我们来设计Login.aspx,先看界面的设计:view sourceprint?
再来看Login.aspx.cs的设计:记得加上这个:view sourceprint?using BLL; using Model; 而后才是:view sourceprint?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加密后保存到数据库的
view sourceprint? 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(""); } } else { Response.Write(""); } } private void SetSession(department Department,string DepartID) { if (Department == null || string.IsNullOrEmpty(DepartID)) { Response.Write(""); return; } Session["Ename"] = txtUserName.Text.Trim().ToString(); Session["Departid"] = DepartID; Session["Operater"] = ""; if (Department.departname == "控制中心") { Response.Write(""); } else { Response.Write(""); } } 接下来我们要在App_Code文件下新建PageBase.cs
view sourceprint?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的设计:view sourceprint?
ADDdepart.aspx.cs的设计:view sourceprint?//继承PageBase类
view sourceprint?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(), "", ""); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "", ""); } } } 再来看下注册页面Register.aspx的设计:view sourceprint?
下面是Register.aspx.cs的设计:view sourceprint?protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BinData(); } } public void BinData() { List Departmentlist = new List(); 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(), "", ""); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "", ""); } } 以上只是UI简单的调用BLL的功能,下次再讲解下GridView调用BLL和GridView的分页,可能我设计的只是较简单,欢迎大家提出你们宝贵的意见.来共同提高.欢迎拍砖. 摘自红色黑客联盟(www.7747.net) 原文:http://www.7747.net/kf/201103/86550.html
文章录入:7747.Net 责任编辑:7747.Net 10
【字体:小 大】
在我们设计好了三层架构的SQLHelper、Model、DAL和BLL后,我们要开始来调用它设计好的功能了。首先我们来设计Login.aspx,先看界面的设计:view sourceprint?
帐户名: | |
密码: | |
|
view sourceprint? 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(""); } } else { Response.Write(""); } } private void SetSession(department Department,string DepartID) { if (Department == null || string.IsNullOrEmpty(DepartID)) { Response.Write(""); return; } Session["Ename"] = txtUserName.Text.Trim().ToString(); Session["Departid"] = DepartID; Session["Operater"] = ""; if (Department.departname == "控制中心") { Response.Write(""); } else { Response.Write(""); } } 接下来我们要在App_Code文件下新建PageBase.cs
view sourceprint?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的设计:view sourceprint?
部门名称: | |
描述: | |
|
view sourceprint?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(), "", ""); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "", ""); } } } 再来看下注册页面Register.aspx的设计:view sourceprint?
帐户名: | | |
姓名: | | |
年龄: | | |
密码: | | |
重复密码: | | |
部门: | | |
|
.net 三层架构是什么东东
ASP.NET三层架构(中文版)下载
asp.net三层架构调用方法问题
哪里有Asp.net三层架构视频教学啊
.net三层架构在开发程序中的具体设计
web 三层架构
有没有asp.net(C#)的书介绍,是做管理系统的.最好有三层架构
关于.net三层开发
什么是基于Midas三层架构技术
三层架构先设计哪一层?
Intel CPU微架构解析
.net平台架构
Net架构对?
asp.net三层结构问题~~~!!!
在软件编程中,什么叫做三层架构?
讲述三层架构程式和服务器的结构运原理
能不能提供一个三层架构的电子商务系统(C#)
两层体系架构与三层体系架构的异同点。
请问软件三层架构是如何架构的,用什么工具开发?
两层架构与三层架构的区别,从优缺点角度说明?
两层架构与三层架构的区别,从优缺点角度说明?
.net架构到底是个什么样的架构
ASP.Net(c#)、三层结构开发
有关asp.net架构的问题