UI layer of the three-tier architecture

Previously published BLL, DAL, MODEL, the source of three layers

Continue UI layer:

Briefly implement user login and registration

Advanced operating in accordance with the previous article , source-perfect

↑ UI file directory layer shown in FIG.

 

Reg.aspx registration operation <write and execute the database>

Backstage source as follows:

  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 new LoginManger (); // instantiate login verification class
 18 is          AEScook aScook = new new AEScook (); // instantiate classes AES encryption
 . 19          protected  void the Page_Load ( Object SENDER, EventArgs E)
 20 is          {
 21          // automate
 22 is          }
 23 is          protected  void btn_Reg_Click ( Object SENDER, EventArgs E)
 24          {
 25              IF (txt_Password.Text.Trim () == ""Txt_Password2.Text.Trim && () == "" )
 26 is              {
 27                  the try 
28                  {
 29                      the throw  new new Exception ( " registration failed " );
 30                  }
 31 is                  the catch 
32                  {
 33 is                      Response.Write ( " <Script> Alert ( 'registration password ! Please enter can not be empty ') </ Script>. " );
 34 is                  }
 35              }
 36              the else 
37 [              {
 38 is                  IF(txt_Password.Text.Trim () =! txt_Password2.Text.Trim ())
 39                  {
 40                      the try 
41 is                      {
 42 is                          the throw  new new Exception ( " registration failed " );
 43 is                      }
 44 is                      the catch 
45                      {
 46 is                          Response.Write ( " <Script> alert ( 'entered two passwords do not match, please re-enter!') </ Script> " );
 47                      }
 48                  }
 49                  the else 
50                  {
 51 is                     IF (txt_Date_Of_Birth.Text.Trim () == "" )
 52 is                      {
 53 is                          the try 
54 is                          {
 55                              the throw  new new Exception ( " registration failed " );
 56 is                          }
 57 is                          the catch 
58                          {
 59                              Response.Write ( " <Script> Alert ( 'please ! your date of birth ') </ Script> " );
 60                          }
 61 is                      }
 62 is                      the else 
63 is                     {
 64                          IF (txt_NickName.Text.Trim () == "" )
 65                          {
 66                              the try 
67                              {
 68                                  the throw  new new Exception ( " registration failed " );
 69                              }
 70                              the catch 
71 is                              {
 72                                  Response.Write ( " <Script> Alert ( 'Please enter your login account!') </ Script> " );
 73 is                              }
 74                          }
75                          the else 
76                          {
 77                              IF (txt_UserName.Text.Trim () == "" )
 78                              {
 79                                  the try 
80                                  {
 81                                      the throw  new new Exception ( " registration failed " );
 82                                  }
 83                                  the catch 
84                                  {
 85                                      Response.Write ( " <Script > alert ( '! Please enter your name') </ 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                              }
 1 16                          }
 117                      }
 1 18                  }
 119              }
 120          }
 121  
122          public  String AES ( String pwdeed) // encryption key 
123          {
 124              pwdeed txt_Password2.Text.Trim = (); // call ASE value to the encrypted password and pass pwdeed 
125              aScook.AESEncrypt ( " AAES ", pwdeed, "60"); 
126             return pwdeed;
127         }
128     }
129 }

 

Guess you like

Origin www.cnblogs.com/MineLSG/p/11111102.html