예제 #1
0
        public static bool InsertVIPAuthorizationExchangeCodeConfig(VIPAuthorizationExchangeCodeConfig model)
        {
            int RandKey = new Random().Next(100000, 999999);

            const string sql = @" DECLARE @i INT        
                                 DECLARE @code VARCHAR(1000)
                                 SET @i = 1

                                 WHILE ( @i <= @SumNum )
                                    BEGIN 
                                        SET @code = RIGHT(ABS(CAST(CHECKSUM(NEWID()) AS BIGINT)
                                                              * CHECKSUM(NEWID())), 12)
                                        IF NOT EXISTS ( SELECT  1
                                                        FROM    Configuration.dbo.SE_VIPAuthorizationExchangeCodeConfig
                                                        WHERE   ExchangeCode = @code )
                                            BEGIN
                                                INSERT  INTO Configuration.dbo.SE_VIPAuthorizationExchangeCodeConfig
                                                        ( ExchangeCode ,
                                                          CodeBatch ,
                                                          VIPAuthorizationRuleId ,
                                                          Status ,
                                                          CreateTime ,
                                                          EndTime
                                                        )
                                                VALUES  ( @code ,
                                                          @CodeBatch , -- CodeBatch - nvarchar(100)
                                                          @VIPAuthorizationRuleId , -- VIPAuthorizationRuleId - int
                                                          @Status , -- Status - smallint
                                                          GETDATE() , -- CreateTime - datetime
                                                          @EndTime  -- EndTime - datetime
                                                        )  
                                                SET @i = @i + 1    
                                            END 
                                    END   ";


            var sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@CodeBatch", RandKey),
                new SqlParameter("@VIPAuthorizationRuleId", model.VIPAuthorizationRuleId),
                new SqlParameter("@Status", model.Status),
                new SqlParameter("@EndTime", model.EndTime),
                new SqlParameter("@SumNum", model.SumNum)
            };

            const string sql1 = @"SELECT COUNT(1)
                                 FROM   Configuration.dbo.SE_VIPAuthorizationExchangeCodeConfig
                                 WHERE  CodeBatch = @CodeBatch";

            if ((int)SqlHelper.ExecuteScalar(conn, CommandType.Text, sql1, new SqlParameter("@CodeBatch", RandKey)) > 0)
            {
                return(false);
            }
            else
            {
                return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameter) > 0);
            }
        }
예제 #2
0
        public ActionResult Edit(VIPAuthorizationExchangeCodeConfig model)
        {
            string js = "<script>alert(\"保存失败 \");location='/VIPAuthorizationExchangeCodeConfig/Index';</script>";

            if (VIPAuthorizationExchangeCodeConfigManager.InsertVIPAuthorizationExchangeCodeConfig(model))
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(Content(js));
            }
        }
예제 #3
0
        public ActionResult Edit(int id = 0)
        {
            ViewBag.RuleList = VIPAuthorizationRuleConfigManager.GetVIPAuthorizationRuleAndId();


            if (id == 0)
            {
                VIPAuthorizationExchangeCodeConfig model = new VIPAuthorizationExchangeCodeConfig();
                model.SumNum  = 1;
                model.EndTime = DateTime.Now;
                return(View(model));
            }
            else
            {
                return(View(VIPAuthorizationExchangeCodeConfigManager.GetVIPAuthorizationExchangeCodeConfig(id)));
            }
        }
 public bool InsertVIPAuthorizationExchangeCodeConfig(VIPAuthorizationExchangeCodeConfig model)
 {
     try
     {
         return(DALVIPAuthorizationExchangeCodeConfig.InsertVIPAuthorizationExchangeCodeConfig(model));
     }
     catch (TuhuBizException)
     {
         throw;
     }
     catch (Exception ex)
     {
         var exception = new VIPAuthorizationExchangeCodeConfigException(1, "InsertVIPAuthorizationExchangeCodeConfig", ex);
         Logger.Log(Level.Error, exception, "InsertVIPAuthorizationExchangeCodeConfig");
         throw ex;
     }
 }
예제 #5
0
        public static bool UpdateVIPAuthorizationExchangeCodeConfig(VIPAuthorizationExchangeCodeConfig model)
        {
            const string sql          = @"UPDATE Configuration..SE_VIPAuthorizationExchangeCodeConfig SET 
                                       [VIPAuthorizationRuleId]=@VIPAuthorizationRuleId
                                      ,[Status]=@Status                               
                                      ,[EndTime]=@EndTime                
                                WHERE ExchangeCode=@ExchangeCode";
            var          sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@ExchangeCode", model.ExchangeCode ?? string.Empty),
                new SqlParameter("@CodeBatch", model.CodeBatch ?? string.Empty),
                new SqlParameter("@VIPAuthorizationRuleId", model.VIPAuthorizationRuleId),
                new SqlParameter("@Status", model.Status),
                new SqlParameter("@EndTime", model.EndTime)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameter) > 0);
        }