修改了注册页面,增加了描述字段,数据库有更新

This commit is contained in:
liuchun_0206@163.com 2016-11-10 10:14:27 +08:00
parent 546ff6a506
commit e6b286ed61
8 changed files with 98 additions and 18 deletions

View File

@ -119,6 +119,7 @@
<Content Include="Content\css\login.css" />
<Content Include="Content\css\register.css" />
<Content Include="Content\css\tasks.css" />
<Content Include="Content\html\RegResult.html" />
<Content Include="Content\images\bg.jpg" />
<Content Include="Content\images\lock-bg.jpg" />
<Content Include="Content\js\bootstrap-select.js" />

View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<link href="/Content/css/bootstrap.css" rel="stylesheet">
<link href="/Content/css/bootstrap-theme.css" rel="stylesheet">
</head>
<body>
<div class="container" align="center">
<form id="login" class="form-signin" method="post">
<h2 class="form-signin-heading">注册成功!</h2>
<div class="login-wrap">
<div class="input-group">
<span >你需要等待管理员的审核</span>
</div>
<div class="input-group">
<span>才能开启账号,请耐心等待!</span>
</div>
<input id="btnClose" type="button" value="关闭本页" onclick="custom_close()" />
</div>
</form>
</div>
</body>
</html>
<script language="javascript">
function custom_close() {
if(confirm("您确定要关闭本页吗?")) {
window.opener = null;
window.open('', '_self');
window.close();
}
else { }
}
</script>

View File

@ -72,11 +72,16 @@ namespace Bootstrap.Admin.Controllers
/// </summary>
/// <returns></returns>
[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();
}
}
}

View File

@ -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();
}
});

View File

@ -43,16 +43,24 @@
<span class="glyphicon glyphicon-lock input-group-addon"></span>
<input type="password" id="password" name="password" class="form-control" value="" placeholder="密码" />
</div>
<label for="description">申请理由:</label>
<div class="input-group">
<span class="glyphicon glyphicon-lock input-group-addon"></span>
<input type="text" id="description" name="description" class="form-control" value="" placeholder="申请理由" />
</div>
<button id="btnAccount" class="btn btn-primary" type="button">继续</button>
</div> <!-- /.setup-form-container -->
</div>
<div class="setup-confirm">
<h4>您注册的信息如下:</h4>
<div>
<label>登陆账号:</label><span></span>
<label>登陆账号:</label><span id="loginID"></span>
</div>
<div>
<label>显示名称:</label><span></span>
<label>显示名称:</label><span id="loginName"></span>
</div>
<div>
<label>申请理由:</label><span id="loginDesc"></span>
</div>
<button id="btnSubmit" class="btn btn-primary" type="submit">确认并提交</button>
</div>
@ -63,10 +71,13 @@
<ul class="features-list">
<li><strong>Unlimited</strong>特性一</li>
<li><strong>Unlimited</strong>特性二</li>
<li><strong>Unlimited</strong>特性三</li>
<li><strong>Unlimited</strong>特性四</li>
<li class="list-divider"></li>
<li><i class="glyphicon glyphicon-ok"></i>优点一</li>
<li><i class="glyphicon glyphicon-ok"></i>优点二</li>
<li><i class="glyphicon glyphicon-ok"></i>优点三</li>
<li><i class="glyphicon glyphicon-ok"></i>优点四</li>
</ul>
</div>
</div>

View File

@ -31,5 +31,9 @@ namespace Bootstrap.DataAccess
/// 获得/设置 用户被批复时间
/// </summary>
public DateTime ApprovedTime { get; set; }
/// <summary>
/// 获得/设置 用户的申请理由
/// </summary>
public string Description { get; set; }
}
}

View File

@ -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
///
/// </summary>
/// <returns></returns>
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 });
}
}
}

View File

@ -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