public ActionResult Add(FriendLinkModel model) { if (ModelState.IsValid) { FriendLinkInfo friendLinkInfo = new FriendLinkInfo() { Name = model.FriendLinkName, Title = model.FriendLinkTitle == null ? "" : model.FriendLinkTitle, Logo = model.FriendLinkLogo == null ? "" : model.FriendLinkLogo, Url = model.FriendLinkUrl, Target = model.Target, DisplayOrder = model.DisplayOrder }; AdminFriendLinks.CreateFriendLink(friendLinkInfo); AddAdminOperateLog("添加友情链接", "添加友情链接,友情链接为:" + model.FriendLinkName); return PromptView("友情链接添加成功"); } Load(); return View(model); }
/// <summary> /// 获得友情链接列表 /// </summary> public static FriendLinkInfo[] GetFriendLinkList() { DataTable dt = BrnShop.Core.BSPData.RDBS.GetFriendLinkList(); FriendLinkInfo[] friendLinkList = new FriendLinkInfo[dt.Rows.Count]; int index = 0; foreach (DataRow row in dt.Rows) { FriendLinkInfo friendLinkInfo = new FriendLinkInfo(); friendLinkInfo.Id = TypeHelper.ObjectToInt(row["id"]); friendLinkInfo.Name = row["name"].ToString(); friendLinkInfo.Title = row["title"].ToString(); friendLinkInfo.Logo = row["logo"].ToString(); friendLinkInfo.Url = row["url"].ToString(); friendLinkInfo.Target = TypeHelper.ObjectToInt(row["target"]); friendLinkInfo.DisplayOrder = TypeHelper.ObjectToInt(row["displayorder"]); friendLinkList[index] = friendLinkInfo; index++; } return friendLinkList; }
/// <summary> /// 更新友情链接 /// </summary> public static void UpdateFriendLink(FriendLinkInfo friendLinkInfo) { BrnShop.Core.BSPData.RDBS.UpdateFriendLink(friendLinkInfo); }
/// <summary> /// 创建友情链接 /// </summary> public void CreateFriendLink(FriendLinkInfo friendLinkInfo) { DbParameter[] param = { GenerateInParam("@name",SqlDbType.NChar, 50, friendLinkInfo.Name), GenerateInParam("@title",SqlDbType.NChar, 100, friendLinkInfo.Title), GenerateInParam("@logo",SqlDbType.NChar, 250, friendLinkInfo.Logo), GenerateInParam("@url",SqlDbType.NChar, 250, friendLinkInfo.Url), GenerateInParam("@target",SqlDbType.Int, 4, friendLinkInfo.Target), GenerateInParam("@displayorder",SqlDbType.Int,4,friendLinkInfo.DisplayOrder) }; string commandText = String.Format("INSERT INTO [{0}friendlinks] ([name],[title],[logo],[url],[target],[displayorder]) VALUES(@name,@title,@logo,@url,@target,@displayorder)", RDBSHelper.RDBSTablePre); RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, param); }
/// <summary> /// 更新友情链接 /// </summary> public void UpdateFriendLink(FriendLinkInfo friendLinkInfo) { DbParameter[] param = { GenerateInParam("@name",SqlDbType.NChar, 50, friendLinkInfo.Name), GenerateInParam("@title",SqlDbType.NChar, 100, friendLinkInfo.Title), GenerateInParam("@logo",SqlDbType.NChar, 250, friendLinkInfo.Logo), GenerateInParam("@url",SqlDbType.NChar, 250, friendLinkInfo.Url), GenerateInParam("@target",SqlDbType.Int, 4, friendLinkInfo.Target), GenerateInParam("@displayorder",SqlDbType.Int,4,friendLinkInfo.DisplayOrder), GenerateInParam("@id",SqlDbType.Int, 4, friendLinkInfo.Id) }; string commandText = String.Format("UPDATE [{0}friendlinks] SET [name]=@name,[title]=@title,[logo]=@logo,[url]=@url,[target]=@target,[displayorder]=@displayorder WHERE [id]=@id", RDBSHelper.RDBSTablePre); RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, param); }
/// <summary> /// 更新友情链接 /// </summary> public static void UpdateFriendLink(FriendLinkInfo friendLinkInfo) { BrnShop.Data.FriendLinks.UpdateFriendLink(friendLinkInfo); BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_FRIENDLINK_LIST); }