public ActionResult Edit(CouponActivityConfig model) { string js = "<script>alert(\"保存失败 \");location='/CouponActivityConfig/Index';</script>"; if (model.Id != 0) { if (CouponActivityConfigManager.UpdateCouponActivityConfig(model)) { return(RedirectToAction("Index", "CouponActivityConfig", new { type = model.Type })); } else { return(Content(js)); } } else { if (CouponActivityConfigManager.InsertCouponActivityConfig(model)) { return(RedirectToAction("Index", "CouponActivityConfig", new { type = model.Type })); } else { return(Content(js)); } } }
public static bool UpdateCouponActivityConfig(CouponActivityConfig model) { const string sql = @"UPDATE [Configuration].[dbo].[SE_CouponActivityConfig] SET ActivityName = @ActivityName , ActivityStatus = @ActivityStatus , CheckStatus = @CheckStatus , Type=@Type, LayerImage = @LayerImage , CouponId = @CouponId , ButtonChar = @ButtonChar , ActivityImage = @ActivityImage, UpdateTime = GETDATE(), GetRuleGUID=@GetRuleGUID WHERE Id = @Id"; var sqlParameters = new SqlParameter[] { new SqlParameter("@ActivityName", model.ActivityName), new SqlParameter("@ActivityNum", model.ActivityNum), new SqlParameter("@ActivityStatus", model.ActivityStatus), new SqlParameter("@ButtonChar", model.ButtonChar), new SqlParameter("@CheckStatus", model.CheckStatus), new SqlParameter("@CouponId", model.CouponId), new SqlParameter("@LayerImage", model.LayerImage), new SqlParameter("@Id", model.Id), new SqlParameter("@ActivityImage", model.ActivityImage), new SqlParameter("@GetRuleGUID", model.GetRuleGUID ?? string.Empty), new SqlParameter("@Type", model.Type) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameters) > 0); }
public ActionResult Edit(int type, int id = 0) { if (id == 0) { CouponActivityConfig model = new CouponActivityConfig(); model.Type = type; return(View(model)); } else { return(View(CouponActivityConfigManager.GetCouponActivityConfig(id))); } }
public static bool InsertCouponActivityConfig(CouponActivityConfig model) { const string sql = @"INSERT INTO [Configuration].[dbo].[SE_CouponActivityConfig] ( [ActivityNum] ,[ActivityName] ,[ActivityStatus] ,[CheckStatus] ,Type ,[LayerImage] ,[CouponId] ,[ButtonChar] ,[CreateTime] ,[UpdateTime] ,ActivityImage ,GetRuleGUID ) VALUES ( @ActivityNum ,@ActivityName ,@ActivityStatus ,@CheckStatus ,@Type ,@LayerImage ,@CouponId ,@ButtonChar ,GETDATE() ,GETDATE() ,@ActivityImage ,@GetRuleGUID )SELECT @@IDENTITY "; string activityNum = Guid.NewGuid().ToString(); var sqlParameters = new SqlParameter[] { new SqlParameter("@ActivityName", model.ActivityName), new SqlParameter("@ActivityNum", activityNum), new SqlParameter("@ActivityStatus", model.ActivityStatus), new SqlParameter("@ButtonChar", model.ButtonChar), new SqlParameter("@CheckStatus", model.CheckStatus), new SqlParameter("@CouponId", model.CouponId), new SqlParameter("@LayerImage", model.LayerImage), new SqlParameter("@ActivityImage", model.ActivityImage), new SqlParameter("@GetRuleGUID", model.GetRuleGUID), new SqlParameter("@Type", model.Type) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameters) > 0); }
public bool InsertCouponActivityConfig(CouponActivityConfig model) { try { return(DalCouponActivityConfig.InsertCouponActivityConfig(model)); } catch (TuhuBizException) { throw; } catch (Exception ex) { var exception = new CouponActivityConfigException(1, "InsertCouponActivityConfig", ex); Logger.Log(Level.Error, exception, "InsertCouponActivityConfig"); throw ex; } }
/// <summary> /// 添加蓄电池/加油卡浮动配置 /// </summary> /// <param name="conn"></param> /// <param name="model"></param> /// <returns></returns> public static int InsertCouponActivityConfig(SqlConnection conn, CouponActivityConfig model) { const string sql = @"INSERT INTO [Configuration].[dbo].[SE_CouponActivityConfig] ( [ActivityNum] ,[ActivityName] ,[ActivityStatus] ,[CheckStatus] ,Type ,[LayerImage] ,[CouponId] ,[CreateTime] ,[UpdateTime] ,ActivityImage ,Channel ) VALUES ( @ActivityNum ,@ActivityName ,@ActivityStatus ,@CheckStatus ,@Type ,@LayerImage ,@ButtonChar ,GETDATE() ,GETDATE() ,@ActivityImage ,@Channel )SELECT @@IDENTITY "; var sqlParameters = new SqlParameter[] { new SqlParameter("@ActivityName", model.ActivityName), new SqlParameter("@ActivityNum", model.ActivityNum), new SqlParameter("@ActivityStatus", model.ActivityStatus), new SqlParameter("@ButtonChar", model.ButtonChar), new SqlParameter("@CheckStatus", model.CheckStatus), new SqlParameter("@CouponId", model.CouponId), new SqlParameter("@LayerImage", model.LayerImage), new SqlParameter("@ActivityImage", model.ActivityImage), new SqlParameter("@Type", model.Type), new SqlParameter("@Channel", model.Channel), }; return(Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, sqlParameters))); }