From e6b286ed61ed09c1fe205dae068914420570eeac Mon Sep 17 00:00:00 2001 From: "liuchun_0206@163.com" Date: Thu, 10 Nov 2016 10:14:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=9C=89=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Bootstrap.Admin.csproj | 1 + Bootstrap.Admin/Content/html/RegResult.html | 37 +++++++++++++++++++ Bootstrap.Admin/Controllers/HomeController.cs | 13 +++++-- Bootstrap.Admin/Scripts/register.js | 11 ++++-- Bootstrap.Admin/Views/Home/Register.cshtml | 15 +++++++- Bootstrap.DataAccess/User.cs | 4 ++ Bootstrap.DataAccess/UserHelper.cs | 23 +++++++----- DatabaseScripts/Install.sql | 12 ++++++ 8 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 Bootstrap.Admin/Content/html/RegResult.html diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index 862e040e..381ca403 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -119,6 +119,7 @@ + diff --git a/Bootstrap.Admin/Content/html/RegResult.html b/Bootstrap.Admin/Content/html/RegResult.html new file mode 100644 index 00000000..05526623 --- /dev/null +++ b/Bootstrap.Admin/Content/html/RegResult.html @@ -0,0 +1,37 @@ + + + + + + + + + +
+ +
+ + + + + diff --git a/Bootstrap.Admin/Controllers/HomeController.cs b/Bootstrap.Admin/Controllers/HomeController.cs index 58379a99..d1ee31ea 100644 --- a/Bootstrap.Admin/Controllers/HomeController.cs +++ b/Bootstrap.Admin/Controllers/HomeController.cs @@ -72,11 +72,16 @@ namespace Bootstrap.Admin.Controllers /// /// [AllowAnonymous] - public ActionResult Register(string userName, string displayName, string password) + public ActionResult Register(string userName, string displayName, string password,string description) { - var result = UserHelper.RegisterUser(userName, displayName, password); - if (result) return RedirectToAction("Login"); - else return View(); + var result = UserHelper.RegisterUser(userName, displayName, password,description); + if (result) + { + return Redirect("/Content/html/RegResult.html"); + } + + else + return View(); } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Scripts/register.js b/Bootstrap.Admin/Scripts/register.js index 1685fe15..361afeb3 100644 --- a/Bootstrap.Admin/Scripts/register.js +++ b/Bootstrap.Admin/Scripts/register.js @@ -11,7 +11,11 @@ password: { required: true, maxlength: 50 - } + }, + description: { + required: true, + maxlength: 500 + } }); $('#btnAccount').click(function () { @@ -19,8 +23,9 @@ if (valid) { $('.setup-main').hide(); $('.steps li').toggleClass('current'); - $('.setup-confirm span:first').text($('#userName').val()); - $('.setup-confirm span:last').text($('#displayName').val()); + $('#loginID').text($('#userName').val()); + $('#loginName').text($('#displayName').val()); + $('#loginDesc').text($('#description').val()); $('.setup-confirm').show(); } }); diff --git a/Bootstrap.Admin/Views/Home/Register.cshtml b/Bootstrap.Admin/Views/Home/Register.cshtml index 126661c0..be4b006b 100644 --- a/Bootstrap.Admin/Views/Home/Register.cshtml +++ b/Bootstrap.Admin/Views/Home/Register.cshtml @@ -43,16 +43,24 @@ + +
+ + +

您注册的信息如下:

- +
- + +
+
+
@@ -63,10 +71,13 @@
  • Unlimited特性一
  • Unlimited特性二
  • +
  • Unlimited特性三
  • +
  • Unlimited特性四
  • 优点一
  • 优点二
  • 优点三
  • +
  • 优点四
diff --git a/Bootstrap.DataAccess/User.cs b/Bootstrap.DataAccess/User.cs index bdb6f6c2..8042b2bd 100644 --- a/Bootstrap.DataAccess/User.cs +++ b/Bootstrap.DataAccess/User.cs @@ -31,5 +31,9 @@ namespace Bootstrap.DataAccess /// 获得/设置 用户被批复时间 /// public DateTime ApprovedTime { get; set; } + /// + /// 获得/设置 用户的申请理由 + /// + public string Description { get; set; } } } diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs index b7772961..72fc1308 100644 --- a/Bootstrap.DataAccess/UserHelper.cs +++ b/Bootstrap.DataAccess/UserHelper.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Data.SqlClient; -using System.Globalization; using System.Linq; namespace Bootstrap.DataAccess @@ -128,13 +127,17 @@ namespace Bootstrap.DataAccess { if (p == null) throw new ArgumentNullException("p"); bool ret = false; - if (p.UserName.Length > 50) p.UserName.Substring(0, 50); + if (p.UserName.Length > 50) + p.UserName.Substring(0, 50); p.PassSalt = LgbCryptography.GenerateSalt(); p.Password = LgbCryptography.ComputeHash(p.Password, p.PassSalt); - if (p.DisplayName.Length > 50) p.DisplayName.Substring(0, 50); + if (string.IsNullOrEmpty(p.Description)) + p.Description=" "; + else if(p.Description.Length > 500) + p.Description.Substring(0, 500); string sql = p.ID == 0 ? - "Insert Into Users (UserName, Password, PassSalt, DisplayName, RegisterTime, ApprovedTime) Values (@UserName, @Password, @PassSalt, @DisplayName, GetDate(), @ApprovedTime)" : - "Update Users set UserName = @UserName, Password = @Password, PassSalt = @PassSalt, DisplayName = @DisplayName where ID = @ID"; + "Insert Into Users (UserName, Password, PassSalt, DisplayName, RegisterTime, ApprovedTime,Description) Values (@UserName, @Password, @PassSalt, @DisplayName, GetDate(), @ApprovedTime,@Description)" : + "Update Users set UserName = @UserName, Password = @Password, PassSalt = @PassSalt, DisplayName = @DisplayName,Description=@Description where ID = @ID"; try { using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) @@ -145,6 +148,7 @@ namespace Bootstrap.DataAccess cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@PassSalt", p.PassSalt, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@DisplayName", p.DisplayName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ApprovedTime", DBAccess.ToDBValue(p.ApprovedTime), ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", p.Description, ParameterDirection.Input)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); } CacheCleanUtility.ClearCache(userIds: p.ID == 0 ? "" : p.ID.ToString()); @@ -327,11 +331,12 @@ namespace Bootstrap.DataAccess /// /// /// - public static bool RegisterUser(string userName, string displayName, string password) + public static bool RegisterUser(string userName, string displayName, string password,string description) { - //TODO:判断注册用户是否合理,判断合法后插入数据库中返回真,并通知管理员组有新用户注册,需要批复。数据库Users表中增加一个字段标示用户是否被批复 - if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(displayName) || string.IsNullOrEmpty(password)) return false; - return SaveUser(new User() { UserName = userName, DisplayName = displayName, Password = password }); + //TODO:未完成并通知管理员组有新用户注册,需要批复。 + if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(displayName) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(description)) + return false; + return SaveUser(new User() { UserName = userName, DisplayName = displayName, Password = password,Description=description }); } } } \ No newline at end of file diff --git a/DatabaseScripts/Install.sql b/DatabaseScripts/Install.sql index e3bed185..933c66e9 100644 --- a/DatabaseScripts/Install.sql +++ b/DatabaseScripts/Install.sql @@ -15,6 +15,7 @@ SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO + CREATE TABLE [dbo].[Users]( [ID] [int] IDENTITY(1,1) NOT NULL, [UserName] [varchar](50) NOT NULL, @@ -23,28 +24,39 @@ CREATE TABLE [dbo].[Users]( [DisplayName] [nvarchar](50) NOT NULL, [RegisterTime] [datetime] NOT NULL, [ApprovedTime] [datetime] NULL, + [Description] [nvarchar](500) NULL, CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] + GO + SET ANSI_PADDING OFF GO + EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'ID' GO + EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserName' GO + EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'Password' GO + EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码盐' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'PassSalt' GO + EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'显示名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'DisplayName' GO + EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'注册时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'RegisterTime' GO + EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批复时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'ApprovedTime' GO + /****** Object: Table [dbo].[UserRole] Script Date: 11/07/2016 11:45:40 ******/ SET ANSI_NULLS ON GO