/// <summary> /// 插入数据 /// </summary> /// <param name="config">数据实体对象</param> /// <returns></returns> public int Insert(Advertise_Config config) { return this.advertiseConfigDA.Insert(config); }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(Advertise_Config model) { var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "@ID", SqlDbType.Int, model.ID, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Name", SqlDbType.VarChar, model.Name, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Source", SqlDbType.NVarChar, model.Source, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@URL", SqlDbType.VarChar, model.URL, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@ImagePath", SqlDbType.NVarChar, model.ImagePath, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Description", SqlDbType.VarChar, model.Description, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@IndexID", SqlDbType.Int, model.IndexID, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Width", SqlDbType.Int, model.Width, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Height", SqlDbType.Int, model.Height, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@ThumbnailImagePath", SqlDbType.VarChar, model.ThumbnailImagePath, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@ImageID", SqlDbType.Int, model.ImageID, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@BackgroundColor", SqlDbType.VarChar, model.BackgroundColor, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@isParent", SqlDbType.Bit, model.isParent, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@filter", SqlDbType.Int, model.filter, ParameterDirection.Input ) }; string sqlString = "Update Advertise_Config Set [Name]=@Name,[Source]=@Source,[URL]=@URL,[ImagePath]=@ImagePath,[Description]=@Description,[IndexID] = @IndexID,[Width] = @Width,[Height] = @Height,[ThumbnailImagePath] = @ThumbnailImagePath,[ImageID] = @ImageID ,[BackgroundColor] = @BackgroundColor,[isParent]=@isParent,[filter]=@filter Where ID=@ID"; return this.SqlServer.ExecuteNonQuery(CommandType.Text, sqlString, parameters, null); }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(Advertise_Config model) { return this.advertiseConfigDA.Update(model); }
/// <summary> /// 插入数据 /// </summary> /// <param name="config"></param> /// <returns></returns> public int Insert(Advertise_Config config) { var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "@PID", SqlDbType.Int, config.PID, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Name", SqlDbType.VarChar, config.Name, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Source", SqlDbType.NVarChar, config.Source, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@URL", SqlDbType.VarChar, config.URL, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@ImagePath", SqlDbType.NVarChar, config.ImagePath, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Description", SqlDbType.VarChar, config.Description, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@CreateTime", SqlDbType.DateTime, config.CreateTime, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@IndexID", SqlDbType.Int, config.IndexID, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Width", SqlDbType.Int, config.Width, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@Height", SqlDbType.Int, config.Height, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@ThumbnailImagePath", SqlDbType.VarChar, config.ThumbnailImagePath, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@ImageID", SqlDbType.Int, config.ImageID, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@BackgroundColor", SqlDbType.VarChar, config.BackgroundColor, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@isParent", SqlDbType.Bit, config.isParent, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@filter", SqlDbType.Int, config.filter, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "@ReferenceID", SqlDbType.Int, null, ParameterDirection.Output) }; var SQLStr = new StringBuilder(); SQLStr.Append( "Insert Into Advertise_Config([PID],[Name] ,[Source],[URL],[ImagePath],[Description],[CreateTime],[IndexID],[Width],[Height],[ThumbnailImagePath],[ImageID],[BackgroundColor],[isParent],[filter] ) Values "); SQLStr.Append( "(@PID,@Name,@Source,@URL,@ImagePath,@Description,@CreateTime,@IndexID,@Width,@Height,@ThumbnailImagePath,@ImageID,@BackgroundColor,@isParent,@filter) "); SQLStr.Append("Select @ReferenceID = @@IDENTITY "); SQLStr.Append(" update Advertise_Config set IsOrder=@ReferenceID,Code=@ReferenceID where ID=@ReferenceID"); this.SqlServer.ExecuteNonQuery(CommandType.Text, SQLStr.ToString(), parameters, null); return (int)parameters.Find(parameter => parameter.ParameterName == "@ReferenceID").Value; }
public string GetAdvertiseHtmlByTemplete(string htmlTemplete, Advertise_Config adv, string imgsize) { var obj = new object(); adv.ImagePath = Utils.GetAdvertiseImage(adv.ImagePath); switch (adv.Source) { case "1": // 产品 if (adv.IndexID > 0) { var cart = new OrderBillServices().QueryCartProduct(adv.IndexID); if (cart == null) { obj = adv; } else { adv.ImagePath = string.IsNullOrEmpty(adv.ImagePath) ? Utils.GetProductImage(cart.Path, imgsize) : adv.ImagePath; htmlTemplete = htmlTemplete.Replace("$Name$", Utils.ToString(cart.ProductName)); htmlTemplete = htmlTemplete.Replace("$Sold$", Utils.ToString(cart.SoldOfReality + cart.SoldOfVirtual)); htmlTemplete = htmlTemplete.Replace("$GoujiuPrice$", Utils.ToString(cart.PromotePrice)); obj = cart; } } else { obj = adv; } break; case "2": // LP if (adv.IndexID > 0) { Promote_LandingPage lp = new PromoteLandingPageService().Query(adv.IndexID); if (lp == null) { obj = adv; } else { lp.Name = adv.Name; obj = lp; } } else { obj = adv; } break; case "3": // 其他 obj = adv; break; default: // 默认 obj = adv; break; } if (htmlTemplete.Contains("$Description$")) { htmlTemplete = htmlTemplete.Replace("$Description$", Utils.ToString(adv.Description)); } if (htmlTemplete.Contains("$ImagePath$")) { htmlTemplete = htmlTemplete.Replace("$ImagePath$", Utils.ToString(adv.ImagePath)); } if (htmlTemplete.Contains("$BackgroundColor$")) { htmlTemplete = htmlTemplete.Replace("$BackgroundColor$", Utils.ToString(adv.BackgroundColor)); } if (htmlTemplete.Contains("$URL$")) { htmlTemplete = htmlTemplete.Replace("$URL$", Utils.ToString(adv.URL)); } if (htmlTemplete.Contains("$IndexID$")) { htmlTemplete = htmlTemplete.Replace("$IndexID$", Utils.ToString(adv.IndexID)); } var properties = TypeDescriptor.GetProperties(obj); foreach (PropertyDescriptor propertyDescriptror in properties) { htmlTemplete = htmlTemplete.Replace("$" + propertyDescriptror.Name + "$", Utils.ToString(propertyDescriptror.GetValue(obj))); } return htmlTemplete; }
public string GetAdvertiseHtmlByTemplete(string htmlTemplete, Advertise_Config adv ) { return this.GetAdvertiseHtmlByTemplete(htmlTemplete, adv, "1"); }
/// <summary> /// 修改操作 /// </summary> /// <param name="id">主键标识</param> /// <param name="name">标题</param> /// <param name="url">URL</param> /// <param name="description">描述</param> /// <param name="imgpath">图片路径</param> /// <param name="imagePath"></param> /// <param name="source">来源</param> /// <param name="height"></param> /// <param name="thumbnailImagePath"></param> /// <param name="indexId"></param> /// <param name="width"></param> /// <param name="imageId"></param> /// <param name="backgroundColor"></param> public ActionResult UpdateConfig(int id, string name, string url, string description, string imagePath, string source, string indexId, int width, int height, string thumbnailImagePath, string imageId, string backgroundColor, bool isParent, int filter) { var model = new Advertise_Config() { ID = id, Name = name, URL = url, Description = V5.Library.Utils.UnEscape(description), ImagePath = imagePath, Source = source, IndexID = string.IsNullOrEmpty(indexId) ? -1 : Convert.ToInt32(indexId), Width = width, Height = height, ThumbnailImagePath = thumbnailImagePath, ImageID = string.IsNullOrEmpty(imageId) ? -1 : Convert.ToInt32(imageId), BackgroundColor = backgroundColor, filter = filter, isParent = isParent }; this.advertiseConfigService = new AdvertiseConfigService(); if (this.advertiseConfigService.Update(model) > 0) { return Json(new AjaxResponse { Data = 1, Message = "修改成功" }); } return Json(new AjaxResponse { Data = 0, Message = "修改失败" }); }
/// <summary> /// 执添加操作 /// </summary> /// <param name="pid">父节点标识</param> /// <param name="name">标识</param> /// <param name="url">url</param> /// <param name="description">描述</param> /// <param name="imgpath">图片路径</param> /// <param name="imagePath"></param> /// <param name="source">来源</param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="thumbnailImagePath"></param> /// <param name="indexId"></param> /// <param name="imageId"></param> /// <param name="backgroundColor"></param> /// <returns></returns> public ActionResult InsertAdvertiseConfig(string pid, string name, string url, string description, string imagePath, string source, string indexId, int width, int height, string thumbnailImagePath, string imageId, string backgroundColor, bool isParent, int filter) { var advertiseConfig = new Advertise_Config(); if (!string.IsNullOrEmpty(pid)) { int result; int.TryParse(pid, out result); advertiseConfig.PID = result; } advertiseConfig.Name = name; advertiseConfig.URL = url; advertiseConfig.Description = V5.Library.Utils.UnEscape(description); advertiseConfig.ImagePath = imagePath; advertiseConfig.Source = source; advertiseConfig.CreateTime = DateTime.Now; advertiseConfig.IndexID = string.IsNullOrEmpty(indexId) ? -1 : Convert.ToInt32(indexId); advertiseConfig.Width = width; advertiseConfig.Height = height; advertiseConfig.ThumbnailImagePath = thumbnailImagePath; advertiseConfig.ImageID = string.IsNullOrEmpty(imageId) ? -1 : Convert.ToInt32(imageId); advertiseConfig.BackgroundColor = backgroundColor; advertiseConfig.filter = filter; advertiseConfig.isParent = isParent; this.advertiseConfigService = new AdvertiseConfigService(); this.advertiseConfigService.Insert(advertiseConfig); return Json(new AjaxResponse { Data = 1, Message = "添加成功" }); }