/// <summary> /// 更新提示条配置 /// </summary> /// <param name="conn"></param> /// <param name="model"></param> /// <returns></returns> public static bool UpdateTipBannerDetailConfig(SqlConnection conn, TipBannerConfigDetailModel model) { var sql = @"UPDATE Configuration..TipBannerDetailConfig SET IsEnabled = @IsEnabled , Icon = @Icon , Content = @Content , Url = @Url , BackgroundColor = @BackgroundColor , BgTransparent = @BgTransparent , ContentColor = @ContentColor , Title = @Title , LastUpdateDateTime = GETDATE() WHERE PKID = @PKID;"; var parameters = new[] { new SqlParameter("@IsEnabled", model.IsEnabled), new SqlParameter("@Icon", model.Icon), new SqlParameter("@Content", model.Content), new SqlParameter("@Url", model.Url), new SqlParameter("@BackgroundColor", model.BackgroundColor), new SqlParameter("@BgTransparent", model.BgTransparent), new SqlParameter("@ContentColor", model.ContentColor), new SqlParameter("@Title", model.Title), new SqlParameter("@PKID", model.PKID) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters) > 0); }
public ActionResult UpdateTipBannerDetailConfig(TipBannerConfigDetailModel model) { if (model.PKID < 1) { return(Json(new { Status = false, Msg = "未知的更新对象" }, JsonRequestBehavior.AllowGet)); } var requiredPars = new List <string> { model.BackgroundColor, model.Content, model.ContentColor }; if (requiredPars.Any(str => string.IsNullOrWhiteSpace(str)) || (model.TypeId < 1) || (model.BgTransparent < 0 || model.BgTransparent > 1)) { return(Json(new { Status = false, Msg = "请检查必填项" }, JsonRequestBehavior.AllowGet)); } TipBannerConfigManager manager = new TipBannerConfigManager(); var isRepeat = manager.IsRepeatTipBannerDetailConfig(model); if (isRepeat) { return(Json(new { Status = false, Msg = "存在重复数据,同类型只允许开启一个配置" }, JsonRequestBehavior.AllowGet)); } var result = manager.UpdateTipBannerDetailConfig(model, User.Identity.Name); if (result) { return(Json(new { Status = true, Msg = "更新成功" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Status = false, Msg = "更新失败" }, JsonRequestBehavior.AllowGet)); } }
public bool AddTipBannerDetailConfig(TipBannerConfigDetailModel model, string user) { var result = false; try { var pkid = dbScopeManagerConfig.Execute(conn => DalTipBannerConfig.AddTipBannerDetailConfig(conn, model)); if (pkid > 0) { result = true; model.PKID = pkid; model.CreateDateTime = DateTime.Now; model.LastUpdateDateTime = DateTime.Now; var log = new BaoYangOprLog { LogType = "TipBannerDetailConfig", IdentityID = model.TypeName, OldValue = null, NewValue = JsonConvert.SerializeObject(model), Remarks = "Add", OperateUser = user, }; LoggerManager.InsertLog("BYOprLog", log); } } catch (Exception ex) { Logger.Error("AddTipBannerDetailConfig", ex); } return(result); }
public bool UpdateTipBannerDetailConfig(TipBannerConfigDetailModel model, string user) { var result = false; try { var oldValue = dbScopeManagerConfigRead.Execute(conn => DalTipBannerConfig.GetTipBannerDetailConfigByPKID(conn, model.PKID)); if (oldValue != null) { result = dbScopeManagerConfig.Execute(conn => DalTipBannerConfig.UpdateTipBannerDetailConfig(conn, model)); if (result) { model.LastUpdateDateTime = DateTime.Now; var log = new BaoYangOprLog { LogType = "TipBannerDetailConfig", IdentityID = oldValue.TypeName, OldValue = JsonConvert.SerializeObject(oldValue), NewValue = JsonConvert.SerializeObject(model), Remarks = "Update", OperateUser = user, }; LoggerManager.InsertLog("BYOprLog", log); } } } catch (Exception ex) { Logger.Error("UpdateTipBannerDetailConfig", ex); } return(result); }
public bool IsRepeatTipBannerDetailConfig(TipBannerConfigDetailModel model) { var isRepeat = false; try { isRepeat = dbScopeManagerConfigRead.Execute(conn => DalTipBannerConfig.IsRepeatTipBannerDetailConfig(conn, model)); } catch (Exception ex) { Logger.Error("IsRepeatTipBannerDetailConfig", ex); } return(isRepeat); }
public static bool IsRepeatTipBannerDetailConfig(SqlConnection conn, TipBannerConfigDetailModel model) { var sql = @"SELECT COUNT(1) FROM Configuration..TipBannerDetailConfig AS d WITH ( NOLOCK ) WHERE d.BannerTypeId = @BannerTypeId AND ( d.IsEnabled = 1 AND @IsEnabled = 1 ) AND d.PKID <> @PKID;"; var parameters = new[] { new SqlParameter("@BannerTypeId", model.TypeId), new SqlParameter("@IsEnabled", model.IsEnabled), new SqlParameter("@PKID", model.PKID) }; return(Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, parameters)) > 0); }
/// <summary> /// 添加提示条配置 /// </summary> /// <param name="conn"></param> /// <param name="model"></param> /// <returns></returns> public static int AddTipBannerDetailConfig(SqlConnection conn, TipBannerConfigDetailModel model) { #region SQL var sql = @"INSERT INTO Configuration..TipBannerDetailConfig ( BannerTypeId , IsEnabled , Icon , Content , Url , BackgroundColor , BgTransparent , ContentColor , Title ) VALUES ( @BannerTypeId , @IsEnabled , @Icon , @Content , @Url , @BackgroundColor , @BgTransparent , @ContentColor , @Title ); SELECT SCOPE_IDENTITY();"; #endregion var parameters = new[] { new SqlParameter("@BannerTypeId", model.TypeId), new SqlParameter("@IsEnabled", model.IsEnabled), new SqlParameter("@Icon", model.Icon), new SqlParameter("@Content", model.Content), new SqlParameter("@Url", model.Url), new SqlParameter("@BackgroundColor", model.BackgroundColor), new SqlParameter("@BgTransparent", model.BgTransparent), new SqlParameter("@ContentColor", model.ContentColor), new SqlParameter("@Title", model.Title) }; return(Convert.ToInt32(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters))); }