diff --git a/Bootstrap.DataAccess/User.cs b/Bootstrap.DataAccess/User.cs
index a8ca3be0..e54dce61 100644
--- a/Bootstrap.DataAccess/User.cs
+++ b/Bootstrap.DataAccess/User.cs
@@ -49,18 +49,6 @@ namespace Bootstrap.DataAccess
///
public string Period { get; set; }
///
- /// 获得/设置 拒绝人
- ///
- public string RejectedBy { get; set; }
- ///
- /// 获得/设置 拒绝原因
- ///
- public string RejectedReason { get; set; }
- ///
- /// 获得/设置 拒绝时刻
- ///
- public string RejectedTime { get; set; }
- ///
/// 获得/设置 新密码
///
public string NewPassword { get; set; }
diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs
index c39c7b2d..bedf5cf2 100644
--- a/Bootstrap.DataAccess/UserHelper.cs
+++ b/Bootstrap.DataAccess/UserHelper.cs
@@ -60,7 +60,7 @@ namespace Bootstrap.DataAccess
{
return CacheManager.GetOrAdd(RetrieveNewUsersDataKey, key =>
{
- string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null and RejectedTime is null order by RegisterTime desc";
+ string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null order by RegisterTime desc";
List users = new List();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
@@ -153,13 +153,12 @@ namespace Bootstrap.DataAccess
public static bool RejectUser(int id, string rejectBy)
{
var ret = false;
- var sql = "update Users set RejectedTime = GETDATE(), RejectedBy = @rejectedBy, RejectedReason = @rejectedReason where ID = @id";
- using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
+ using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_RejectUsers"))
{
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", id));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedBy", rejectBy));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedReason", "未填写"));
- ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == 1;
+ ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == -1;
}
CacheCleanUtility.ClearCache(userIds: id.ToString());
return ret;
diff --git a/DatabaseScripts/Install.sql b/DatabaseScripts/Install.sql
index 12aa427d..b3127305 100644
--- a/DatabaseScripts/Install.sql
+++ b/DatabaseScripts/Install.sql
@@ -407,3 +407,41 @@ EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'完成进度'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分配时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Tasks', @level2type=N'COLUMN',@level2name=N'AssignTime'
GO
+
+/****** Object: Table [dbo].[RejectUsers] Script Date: 09/08/2018 15:34:25 ******/
+SET ANSI_NULLS ON
+GO
+
+SET QUOTED_IDENTIFIER ON
+GO
+
+SET ANSI_PADDING ON
+GO
+
+CREATE TABLE [dbo].[RejectUsers](
+ [ID] [int] IDENTITY(1,1) NOT NULL,
+ [UserName] [varchar](50) NOT NULL,
+ [DisplayName] [nvarchar](50) NOT NULL,
+ [RegisterTime] [datetime] NOT NULL,
+ [RejectedBy] [varchar](50) NULL,
+ [RejectedTime] [datetime] NULL,
+ [RejectedReason] [nvarchar](50) NULL,
+ CONSTRAINT [PK_RejectUsers] 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'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RejectUsers', @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'RejectUsers', @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'RejectUsers', @level2type=N'COLUMN',@level2name=N'RegisterTime'
+GO
\ No newline at end of file
diff --git a/DatabaseScripts/Procedures.sql b/DatabaseScripts/Procedures.sql
index 008c3f47..8f340f47 100644
--- a/DatabaseScripts/Procedures.sql
+++ b/DatabaseScripts/Procedures.sql
@@ -198,3 +198,40 @@ BEGIN
end
END
GO
+
+Drop PROCEDURE Proc_RejectUsers
+GO
+-- =============================================
+-- Author: Argo
+-- Create date: 2018-09-07
+-- Description:
+-- =============================================
+CREATE PROCEDURE [dbo].[Proc_RejectUsers]
+ -- Add the parameters for the stored procedure here
+ @id int,
+ @rejectedBy varchar(50),
+ @rejectedReason nvarchar(50)
+ WITH ENCRYPTION
+AS
+BEGIN
+ -- SET NOCOUNT ON added to prevent extra result sets from
+ -- interfering with SELECT statements.
+ SET NOCOUNT ON;
+ SET XACT_ABORT ON;
+ -- Insert statements for procedure here
+ begin
+ declare @registerTime datetime
+ declare @userName varchar(50)
+ declare @displayName nvarchar(50)
+ select @registerTime = Registertime, @userName = UserName, @displayName = DisplayName from Users where ID = @id
+
+ if @userName is not null
+ begin
+ begin tran
+ insert into RejectUsers (UserName, DisplayName, RegisterTime, RejectedBy, RejectedTime, RejectedReason) values (@userName, @displayName, @registerTime, @rejectedBy, GETDATE(), @rejectedReason)
+ delete from users where ID = @id
+ commit tran
+ end
+ end
+END
+GO