public ActionResult Edit(string data)
        {
            RecommendGetGiftConfig model = JsonConvert.DeserializeObject <RecommendGetGiftConfig>(data);

            if (model.Id != 0)
            {
                model.UpdateName = User.Identity.Name;
                if (RecommendGetGiftConfigManager.UpdateRecommendGetGiftConfig(model))
                {
                    AddOprLog(model, "修改");
                    return(Json(true));
                }
                else
                {
                    return(Json(false));
                }
            }
            else
            {
                int newid = 0;
                model.CreateName = User.Identity.Name;
                if (RecommendGetGiftConfigManager.InsertRecommendGetGiftConfig(model, ref newid))
                {
                    model.Id = newid;
                    AddOprLog(model, "添加");
                    return(Json(true));
                }
                else
                {
                    return(Json(false));
                }
            }
        }
示例#2
0
 public bool InsertRecommendGetGiftConfig(RecommendGetGiftConfig model, ref int id)
 {
     try
     {
         return(DALRecommendGetGiftConfig.InsertRecommendGetGiftConfig(model, ref id));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "InsertRecommendGetGiftConfig");
         throw ex;
     }
 }
示例#3
0
 public List <RecommendGetGiftConfig> GetRecommendGetGiftConfigList(RecommendGetGiftConfig model, int pageSize, int pageIndex, out int recordCount)
 {
     try
     {
         return(DALRecommendGetGiftConfig.GetRecommendGetGiftConfig(model, pageSize, pageIndex, out recordCount));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "GetRecommendGetGiftConfigList");
         throw ex;
     }
 }
        public void AddOprLog(RecommendGetGiftConfig model, string opr)
        {
            OprLog oprModel = new OprLog();

            oprModel.Author         = User.Identity.Name;
            oprModel.ChangeDatetime = DateTime.Now;
            oprModel.HostName       = Request.UserHostName;
            oprModel.ObjectID       = model.Id;
            oprModel.ObjectType     = "SERGG";
            oprModel.Operation      = opr;
            OprLogManager.AddOprLog(oprModel);
        }
 public ActionResult Share(int id = 0)
 {
     if (id == 0)
     {
         return(View(new RecommendGetGiftConfig()));
     }
     else
     {
         RecommendGetGiftConfig model = RecommendGetGiftConfigManager.GetRecommendGetGiftConfigById(id);
         model.Channel = JsonConvert.DeserializeObject <List <ShareChannel> >(model.ShareChannel);
         return(View(model));
     }
 }
        public ActionResult Edit(int id = 0)
        {
            if (id == 0)
            {
                return(View(new RecommendGetGiftConfig()));
            }
            else
            {
                RecommendGetGiftConfig model = RecommendGetGiftConfigManager.GetRecommendGetGiftConfigById(id);

                return(View(model));
            }
        }
        public ActionResult Index(RecommendGetGiftConfig model, int pageIndex = 1, int pageSize = 20)
        {
            int    count  = 0;
            string strSql = string.Empty;
            var    lists  = RecommendGetGiftConfigManager.GetRecommendGetGiftConfigList(model, pageSize, pageIndex, out count);

            var list  = new OutData <List <RecommendGetGiftConfig>, int>(lists, count);
            var pager = new PagerModel(pageIndex, pageSize)
            {
                TotalItem = count
            };

            return(View(new ListModel <RecommendGetGiftConfig>(list.ReturnValue, pager)));
        }
        public JsonResult Delete(int id)
        {
            bool result = false;
            RecommendGetGiftConfig model = new RecommendGetGiftConfig();

            model.Id = id;

            if (RecommendGetGiftConfigManager.DeleteRecommendGetGiftConfig(id))
            {
                AddOprLog(model, "删除");
                result = true;
            }
            return(Json(result));
        }
示例#9
0
        public static bool UpdateRecommendGetGiftConfig(RecommendGetGiftConfig model)
        {
            const string sql          = @"UPDATE Configuration..SE_RecommendGetGiftConfig SET  
                                         Name=@Name
                                        ,Banner=@Banner
                                        ,AwardLimit=@AwardLimit
                                        ,AwardType=@AwardType
                                        ,AwardValue=@AwardValue
                                        ,RegisteredText=@RegisteredText
                                        ,AwardedText=@AwardedText
                                        ,ShareButtonValue=@ShareButtonValue
                                        ,ShareChannel=@ShareChannel
                                        ,Rules=@Rules 
                                        ,TimeLimitCollectRules=@TimeLimitCollectRules 
                                        ,UpdateName=@UpdateName
                                        ,UpdateTime=GETDATE() 
                                        ,GetRuleGUID=@GetRuleGUID 
                                        ,TabName=@TabName 
                                        ,IsSendCode=ISNULL(@IsSendCode,IsSendCode)
                                        ,UserGroupId=ISNULL(@UserGroupId,UserGroupId)
                                        ,StartTime=ISNULL(@StartTime,StartTime)
                                        ,EndTime=ISNULL(@EndTime,EndTime)
                                 WHERE Id=@Id";
            var          sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@AwardedText", model.AwardedText ?? string.Empty),
                new SqlParameter("@AwardLimit", model.AwardLimit),
                new SqlParameter("@AwardType", model.AwardType ?? string.Empty),
                new SqlParameter("@AwardValue", model.AwardValue),
                new SqlParameter("@Banner", model.Banner),
                new SqlParameter("@CreateName", model.CreateName ?? string.Empty),
                new SqlParameter("@Name", model.Name ?? string.Empty),
                new SqlParameter("@RegisteredText", model.RegisteredText ?? string.Empty),
                new SqlParameter("@Rules", model.Rules ?? string.Empty),
                new SqlParameter("@TimeLimitCollectRules", model.TimeLimitCollectRules ?? string.Empty),
                new SqlParameter("@ShareButtonValue", model.ShareButtonValue ?? string.Empty),
                new SqlParameter("@ShareChannel", model.ShareChannel ?? string.Empty),
                new SqlParameter("@UpdateName", model.UpdateName ?? string.Empty),
                new SqlParameter("@Id", model.Id),
                new SqlParameter("@GetRuleGUID", model.GetRuleGUID ?? string.Empty),
                new SqlParameter("@TabName", model.TabName ?? string.Empty),
                new SqlParameter("@IsSendCode", model.IsSendCode),
                new SqlParameter("@UserGroupId", model.UserGroupId),
                new SqlParameter("@StartTime", model.StartTime),
                new SqlParameter("@EndTime", model.EndTime)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameter) > 0);
        }
示例#10
0
        public static List <RecommendGetGiftConfig> GetRecommendGetGiftConfig(RecommendGetGiftConfig model, int pageSize, int pageIndex, out int recordCount)
        {
            string sql      = @"SELECT  [Id]
                                  ,[Number]
                                  ,[Name]
                                  ,[Banner]
                                  ,[AwardLimit]
                                  ,[AwardType]
                                  ,[AwardValue]
                                  ,[GetRuleGUID]
                                  ,[RegisteredText]
                                  ,[AwardedText]
                                  ,[ShareButtonValue]
                                  ,[ShareChannel]
                                  ,[Rules]
                                  ,[TimeLimitCollectRules]
                                  ,[CreateName]
                                  ,[CreateTime]
                                  ,[UpdateName]
                                  ,[UpdateTime]
                                  ,TabName
                                  ,IsSendCode
                                  ,UserGroupId
                                  ,StartTime
                                  ,EndTime
                            FROM    [Configuration].[dbo].[SE_RecommendGetGiftConfig] AS A WITH (NOLOCK)                                 
                                    ORDER BY  A.[UpdateTime] DESC 
                                    OFFSET ( @PageIndex - 1 ) * @PageSize ROWS  FETCH NEXT @PageSize ROWS  ONLY 
                                ";
            string sqlCount = @"SELECT Count(0)
                                FROM    [Configuration].[dbo].[SE_RecommendGetGiftConfig] AS A WITH (NOLOCK)";

            var sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@PageSize", pageSize),
                new SqlParameter("@PageIndex", pageIndex)
            };

            recordCount = (int)SqlHelper.ExecuteScalar(connOnRead, CommandType.Text, sqlCount);
            return(SqlHelper.ExecuteDataTable(connOnRead, CommandType.Text, sql, sqlParameters).ConvertTo <RecommendGetGiftConfig>().ToList());
        }
示例#11
0
 public bool UpdateRecommendGetGiftConfig(RecommendGetGiftConfig model)
 {
     try
     {
         var temp = GetRecommendGetGiftConfigById(model.Id);
         if (temp != null)
         {
             if (temp.StartTime < DateTime.Now || (temp.StartTime == null && temp.EndTime == null))//已经开始了
             {
                 model.IsSendCode  = null;
                 model.UserGroupId = null;
                 model.StartTime   = null;
                 model.EndTime     = temp.EndTime == null ? null : model.EndTime;
             }
         }
         return(DALRecommendGetGiftConfig.UpdateRecommendGetGiftConfig(model));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "UpdateRecommendGetGiftConfig");
         throw ex;
     }
 }
示例#12
0
        public static bool InsertRecommendGetGiftConfig(RecommendGetGiftConfig model, ref int id)
        {
            const string sql = @"  INSERT INTO Configuration..[SE_RecommendGetGiftConfig]
                                              (  
                                               [Number]
                                              ,[Name]
                                              ,[Banner]
                                              ,[AwardLimit]
                                              ,[AwardType]
                                              ,[AwardValue]
                                              ,[GetRuleGUID]
                                              ,[RegisteredText]
                                              ,[AwardedText]
                                              ,[ShareButtonValue]
                                              ,[ShareChannel]
                                              ,[Rules]
                                              ,[TimeLimitCollectRules]
                                              ,[CreateName]
                                              ,[CreateTime]
                                              ,[UpdateName]
                                              ,[UpdateTime]
                                              ,TabName
                                              ,IsSendCode
                                              ,UserGroupId
                                              ,StartTime
                                              ,EndTime
                                              )
                                      VALUES  ( 
                                               NEWID()
                                              ,@Name
                                              ,@Banner
                                              ,@AwardLimit
                                              ,@AwardType
                                              ,@AwardValue
                                              ,@GetRuleGUID
                                              ,@RegisteredText
                                              ,@AwardedText
                                              ,@ShareButtonValue
                                              ,@ShareChannel
                                              ,@Rules
                                              ,@TimeLimitCollectRules
                                              ,@CreateName
                                              ,GETDATE()
                                              ,@UpdateName
                                              ,GETDATE()
                                              ,@TabName
                                              ,@IsSendCode
                                              ,@UserGroupId
                                              ,@StartTime
                                              ,@EndTime
                                              )SELECT @@IDENTITY";

            var sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@AwardedText", model.AwardedText ?? string.Empty),
                new SqlParameter("@AwardLimit", model.AwardLimit),
                new SqlParameter("@AwardType", model.AwardType ?? string.Empty),
                new SqlParameter("@AwardValue", model.AwardValue),
                new SqlParameter("@Banner", model.Banner),
                new SqlParameter("@CreateName", model.CreateName ?? string.Empty),
                new SqlParameter("@Name", model.Name ?? string.Empty),
                new SqlParameter("@RegisteredText", model.RegisteredText ?? string.Empty),
                new SqlParameter("@Rules", model.Rules ?? string.Empty),
                new SqlParameter("@TimeLimitCollectRules", model.TimeLimitCollectRules ?? string.Empty),
                new SqlParameter("@ShareButtonValue", model.ShareButtonValue ?? string.Empty),
                new SqlParameter("@ShareChannel", model.ShareChannel ?? string.Empty),
                new SqlParameter("@UpdateName", model.UpdateName ?? string.Empty),
                new SqlParameter("@GetRuleGUID", model.GetRuleGUID ?? string.Empty),
                new SqlParameter("@TabName", model.TabName ?? string.Empty),
                new SqlParameter("@IsSendCode", model.IsSendCode),
                new SqlParameter("@UserGroupId", model.UserGroupId),
                new SqlParameter("@StartTime", model.StartTime),
                new SqlParameter("@EndTime", model.EndTime)
            };

            id = Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, sqlParameter));
            return(id > 0);
        }