示例#1
0
        public JsonResult SelectBatch(string batchId)
        {
            ThirdPartyCodeBatch result = new ThirdPartyCodeBatch();

            if (!string.IsNullOrWhiteSpace(batchId))
            {
                result = ThirdPartyMallConfigManage.SelectBatch(new Guid(batchId));
            }
            return(Json(result));
        }
示例#2
0
        /// <summary>
        /// 增加兑换码批次
        /// </summary>
        /// <param name="codeBatch"></param>
        /// <returns></returns>
        public static int InserBatches(ThirdPartyCodeBatch codeBatch)
        {
            const string sql = @"INSERT INTO Configuration.dbo.ThirdPartyCodeBatchConfig
                                      ( BatchGuid ,
                                        BatchName ,
                                        BatchQty ,
                                        StockQty ,
                                        LimitQty ,
                                        Instructions ,
                                        StartDateTime ,
                                        EndDateTime ,
                                        CreateDateTime ,
                                        Creator ,
                                        UpdateDateTime ,
                                        Modifier
                                      )
                              VALUES  ( @BatchGuid , -- BatchGuid - uniqueidentifier
                                        @BatchName , -- BatchName - nvarchar(100)
                                        @BatchQty , -- BatchQty - int
                                        @StockQty , -- StockQty - int
                                        @LimitQty , -- LimitQty - int
                                        @Instructions , -- Instructions - nvarchar(1000)
                                        @StartDateTime , -- StartDateTime - datetime
                                        @EndDateTime , -- EndDateTime - datetime
                                        GETDATE() , -- CreateDateTime - datetime
                                        @Creator , -- Creator - nvarchar(100)
                                        GETDATE() , -- UpdateDateTime - datetime
                                        @Modifier  -- Modifier - nvarchar(100)
                                      )
                                    SELECT @@IDENTITY
                                            ";

            var sqlParameter = new[]
            {
                new SqlParameter("@BatchGuid", codeBatch.BatchGuid),
                new SqlParameter("@BatchName", codeBatch.BatchName),
                new SqlParameter("@BatchQty", codeBatch.BatchQty),
                new SqlParameter("@StockQty", codeBatch.StockQty),
                new SqlParameter("@LimitQty", codeBatch.LimitQty),
                new SqlParameter("@Instructions", codeBatch.Instructions),
                new SqlParameter("@StartDateTime", codeBatch.StartDateTime),
                new SqlParameter("@EndDateTime", codeBatch.EndDateTime),
                new SqlParameter("@Creator", codeBatch.Creator),
                new SqlParameter("@Modifier", codeBatch.Modifier)
            };

            var result = SqlHelper.ExecuteScalar(Connfig, CommandType.Text, sql, sqlParameter);

            return(Convert.ToInt32(result));
        }
示例#3
0
 /// <summary>
 /// 编辑兑换码批次记录
 /// </summary>
 /// <param name="codeBatch"></param>
 /// <returns></returns>
 public static int UpdateBatches(ThirdPartyCodeBatch codeBatch)
 {
     try
     {
         return(DalThirdPartyExchangeCode.UpdateBatches(codeBatch));
     }
     catch (TuhuBizException)
     {
         throw;
     }
     catch (Exception ex)
     {
         var exception = new ThirdPartyExchangerCodeException(1, "UpdateBatches", ex);
         Logger.Log(Level.Error, exception, "UpdateBatches");
         throw ex;
     }
 }
示例#4
0
        /// <summary>
        /// 编辑兑换码批次记录
        /// </summary>
        /// <param name="codeBatch"></param>
        /// <returns></returns>
        public static int UpdateBatches(ThirdPartyCodeBatch codeBatch)
        {
            const string sql    = @"UPDATE  Configuration.dbo.ThirdPartyCodeBatchConfig
                                 SET     BatchName = @BatchName ,
                                         LimitQty = @LimitQty ,
                                         StartDateTime = @StartDateTime ,
                                         EndDateTime = @EndDateTime ,
                                         Instructions = @Instructions ,
                                         UpdateDateTime = @UpdateDateTime ,
                                         Modifier = @Modifier
                                         WHERE BatchGuid=@BatchGuid
                                    ;";
            int          result = -1;

            using (var dbhelper = new SqlDbHelper(ConnectionStringConfig))
            {
                try
                {
                    dbhelper.BeginTransaction();
                    var cmd = new SqlCommand(sql);
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@BatchGuid", codeBatch.BatchGuid);
                    cmd.Parameters.AddWithValue("@BatchName", codeBatch.BatchName);
                    cmd.Parameters.AddWithValue("@LimitQty", codeBatch.LimitQty);
                    cmd.Parameters.AddWithValue("@Instructions", codeBatch.Instructions);
                    cmd.Parameters.AddWithValue("@StartDateTime", codeBatch.StartDateTime);
                    cmd.Parameters.AddWithValue("@EndDateTime", codeBatch.EndDateTime);
                    cmd.Parameters.AddWithValue("@Modifier", codeBatch.Modifier);
                    cmd.Parameters.AddWithValue("@UpdateDateTime", codeBatch.UpdateDateTime);
                    var i = dbhelper.ExecuteNonQuery(cmd);
                    if (i > 0)
                    {
                        DalThirdPartyExchangeCode.UpdateExchangeCodeTime(codeBatch.StartDateTime, codeBatch.EndDateTime, codeBatch.BatchGuid);
                    }
                    dbhelper.Commit();
                    result = 1;
                }
                catch (Exception ex)
                {
                    dbhelper.Rollback();
                    return(-1);
                }
            }

            return(result);
        }
示例#5
0
        public JsonResult BranchOperate(string type, string branchId, string branchName, int limitQty, int batchQty, int stockQty, DateTime startDateTime, DateTime endDateTime, string instructions, int pkid)
        {
            int result = -1;

            if (ControllerContext.HttpContext.User == null)
            {
                return(Json(new { result = "请重新登录!" }));
            }
            ThirdPartyCodeBatch codeBranch = new ThirdPartyCodeBatch()
            {
                PKID           = pkid,
                BatchName      = branchName,
                BatchQty       = batchQty,
                StockQty       = stockQty,
                LimitQty       = limitQty,
                Instructions   = instructions,
                StartDateTime  = startDateTime,
                EndDateTime    = endDateTime,
                CreateDateTime = DateTime.Now,
                Creator        = ControllerContext.HttpContext.User.Identity.Name,
                UpdateDateTime = DateTime.Now,
                Modifier       = ControllerContext.HttpContext.User.Identity.Name,
            };

            switch (type)
            {
            case "insert":
                codeBranch.BatchGuid = Guid.NewGuid();
                Session["BatchId"]   = codeBranch.BatchGuid;
                result = ThirdPartyExchangeCodeManage.InserBatches(codeBranch);
                if (result > 0)
                {
                    new OprLogManager().AddOprLog(new OprLog()
                    {
                        Author         = HttpContext.User.Identity.Name,
                        AfterValue     = JsonConvert.SerializeObject(codeBranch),
                        ChangeDatetime = DateTime.Now,
                        ObjectID       = result,
                        ObjectType     = "ExchangeCodeBatch",
                        Operation      = "新增兑换码批次记录",
                        HostName       = Request.UserHostName
                    });
                }
                break;

            case "update":
                codeBranch.BatchGuid = new Guid(branchId);
                result = ThirdPartyExchangeCodeManage.UpdateBatches(codeBranch);
                if (result > 0)
                {
                    new OprLogManager().AddOprLog(new OprLog()
                    {
                        Author         = HttpContext.User.Identity.Name,
                        AfterValue     = JsonConvert.SerializeObject(codeBranch),
                        ChangeDatetime = DateTime.Now,
                        ObjectID       = codeBranch.PKID,
                        ObjectType     = "ExchangeCodeBatch",
                        Operation      = "编辑兑换码批次记录",
                        HostName       = Request.UserHostName
                    });
                }
                break;
            }
            return(Json(new { msg = result }));
        }