首页 > 其他 > 详细

三层架构之UI层

时间:2019-06-30 20:56:26      阅读:145      评论:0      收藏:0      [点我收藏+]

之前已经发表了BLL,DAL,MODEL,三个层的源码

继续UI层:

先简单实现用户的登录及注册

高级操作可按照上一篇文章进行源码完善

技术分享图片

如图所示↑ UI层目录文件

 

Reg.aspx 进行注册操作  <数据库的写入和执行>

后台源码如下:

  1 using System;
  2 using System.Collections.Generic;
  3 using System.Linq;
  4 using System.Web;
  5 using System.Web.UI;
  6 using System.Web.UI.WebControls;
  7 using Model;
  8 using BLL;
  9 using DAL;
 10 using System.Windows.Forms;
 11 
 12 namespace WebApp
 13 {
 14     public partial class Reg : System.Web.UI.Page
 15     {
 16         User_Table user_Table;
 17         LoginManger lm = new LoginManger(); //实例化登录验证类
 18         AEScook aScook = new AEScook();  //实例化AES加密类
 19         protected void Page_Load(object sender, EventArgs e)
 20         {
 21         //自动执行
 22         }
 23         protected void btn_Reg_Click(object sender, EventArgs e)
 24         {
 25             if (txt_Password.Text.Trim() == "" && txt_Password2.Text.Trim() == "")
 26             {
 27                 try
 28                 {
 29                     throw new Exception("注册失败");
 30                 }
 31                 catch
 32                 {
 33                     Response.Write("<script>alert(‘注册密码不能为空!请重新输入。‘)</script>");
 34                 }
 35             }
 36             else
 37             {
 38                 if (txt_Password.Text.Trim() != txt_Password2.Text.Trim())
 39                 {
 40                     try
 41                     {
 42                         throw new Exception("注册失败");
 43                     }
 44                     catch
 45                     {
 46                         Response.Write("<script>alert(‘两次输入的密码不一致,请重新输入!‘)</script>");
 47                     }
 48                 }
 49                 else
 50                 {
 51                     if (txt_Date_Of_Birth.Text.Trim() == "")
 52                     {
 53                         try
 54                         {
 55                             throw new Exception("注册失败");
 56                         }
 57                         catch
 58                         {
 59                             Response.Write("<script>alert(‘请填写出生日期!‘)</script>");
 60                         }
 61                     }
 62                     else
 63                     {
 64                         if (txt_NickName.Text.Trim() == "")
 65                         {
 66                             try
 67                             {
 68                                 throw new Exception("注册失败");
 69                             }
 70                             catch
 71                             {
 72                                 Response.Write("<script>alert(‘请输入您的登录账号!‘)</script>");
 73                             }
 74                         }
 75                         else
 76                         {
 77                             if (txt_UserName.Text.Trim() == "")
 78                             {
 79                                 try
 80                                 {
 81                                     throw new Exception("注册失败");
 82                                 }
 83                                 catch
 84                                 {
 85                                     Response.Write("<script>alert(‘请输入您的姓名!‘)</script>");
 86                                 }
 87                             }
 88                             else
 89                             {
 90 
 91                                 hd_CreateDate.Value = System.DateTime.Now.ToString();  //获取当前服务器时间
 92                                 User_Table user_Table = new User_Table()
 93                                 {
 94                                     UserName = txt_UserName.Text.Trim(),
 95                                     NickName = txt_NickName.Text.Trim(),
 96                                     Password = txt_Password.Text.Trim(),
 97                                     PwdDeed = aES(txt_Password2.Text.Trim()),
 98                                     Sex = ddl_Sex.Text.Trim(),
 99                                     Date_Of_Birth = Convert.ToDateTime(txt_Date_Of_Birth.Text.Trim()),
100                                     IDCard = txt_IDCard.Text.Trim(),
101                                     CreateDate = Convert.ToDateTime(hd_CreateDate.Value.Trim().ToString())
102                                 };
103 
104                                 string messageStr = "";
105                                 if (lm.Add(user_Table, out messageStr))
106                                 {
107                                     Response.Write("<script>alert(‘注册成功‘)</script>");
108                                     Response.Redirect("Sign.aspx", false);
109                                 }
110                                 else
111                                 {
112                                     MessageBox.Show(messageStr);
113                                     txt_UserName.Focus();
114                                 }
115                             }
116                         }
117                     }
118                 }
119             }
120         }
121 
122         public string aES(string pwdeed) //密钥加密
123         {
124             pwdeed = txt_Password2.Text.Trim(); //调用ASE加密密码并传值给pwdeed
125             aScook.AESEncrypt("AAES", pwdeed, "60"); 
126             return pwdeed;
127         }
128     }
129 }

 

三层架构之UI层

原文:https://www.cnblogs.com/MineLSG/p/11111102.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!