/// <summary> /// 获取所有子类id序列,例如 1,3,4,5,6 /// </summary> /// <param name="id">要查询频道的id</param> /// <returns></returns> public static string GetChildID(int id) { ModeChannel value = new ModeChannel(); value.ID = 0; ModeChannel conditon = new ModeChannel(); conditon.Path = "%~" + id + "~%"; conditon.AddAttach("Path", "like"); if (AdminMethod.ExhibitionID != 0) { conditon.ExhibitionID = AdminMethod.ExhibitionID; } List <ModeChannel> childChannelList = TableOperate <ModeChannel> .Select(value, conditon); string idStr = ""; for (int i = 0; i < childChannelList.Count; i++) { idStr += childChannelList[i].ID + ","; } idStr = idStr.Trim(','); return(idStr); }
/// <summary> /// 添加栏目 /// </summary> public static int Insert(ModeChannel channel) { if (channel.ParentID == 0) { channel.Depth = 0; channel.ParentID = 0; channel.Path = "0~"; channel.NamePath = "所有栏目~"; channel.AddInsert("RootID", "IDENT_CURRENT('ModeChannel')"); } else { ModeChannel condition = new ModeChannel(); condition.ID = channel.ParentID; ModeChannel pArentChannel = TableOperate <ModeChannel> .GetRowData(condition); string path = Convert.ToString(pArentChannel.Path) + channel.ParentID + "~"; string namePath = Convert.ToString(pArentChannel.NamePath) + Convert.ToString(pArentChannel.Name) + "~"; channel.Depth = pArentChannel.Depth + 1; channel.Path = path; channel.RootID = pArentChannel.RootID; channel.NamePath = namePath; } return(TableOperate <ModeChannel> .InsertReturnID(channel)); }
public static List <ModeChannel> MySelectByParentID(int ParentID) { List <ModeChannel> channelData = new List <ModeChannel>(); List <int> idList = new List <int>(); //查询数据 ModeChannel value = new ModeChannel(); ModeChannel conditon = new ModeChannel(); if (ParentID > 0) { conditon.Path = "%~" + ParentID + "~%"; conditon.AddAttach("Path", "like"); } List <ModeChannel> oldTypeData = TableOperate <ModeChannel> .Select(value, conditon, 0, " order by ParentID, Depth, OrderID DESC, ID DESC "); for (int i = 0; i < oldTypeData.Count; i++) { ModeChannel typeObj = oldTypeData[i]; if (typeObj.Depth == 0) //深度为0,直接添加 { channelData.Insert(0, typeObj); idList.Insert(0, typeObj.ID); } else { int pArentIndex = idList.IndexOf(typeObj.ParentID); //查找上及目录所在位置! channelData.Insert(pArentIndex + 1, typeObj); idList.Insert(pArentIndex + 1, typeObj.ID); //将数据插入上级目录之后 } } return(channelData); }
public static List <ModeChannel> GetMyID(int id) { ModeChannel value = new ModeChannel(); ModeChannel conditon = new ModeChannel(); conditon.ID = id; List <ModeChannel> oldTypeData = TableOperate <ModeChannel> .Select(value, conditon, 0, " order by ParentID, Depth, OrderID ASC, ID DESC "); return(oldTypeData); }
public static ModeChannel GetChannelByID(int id) { ModeChannel conditon = new ModeChannel(); conditon.ID = id; if (AdminMethod.ExhibitionID != 0) { conditon.ExhibitionID = AdminMethod.ExhibitionID; } return(TableOperate <ModeChannel> .GetRowData(conditon)); }
public static string GetHtmlUrl(int id) { ModeChannel condition = new ModeChannel(); condition.ID = id; if (AdminMethod.ExhibitionID != 0) { condition.ExhibitionID = AdminMethod.ExhibitionID; } ModeChannel newChannel = TableOperate <ModeChannel> .GetRowData(condition); //string tFile = StaticPage.GetUrlRule(newChannel.TemplateFile, id); //string relustFile = StaticPage.GetUrlRule(newChannel.LanMuRule, newChannel.RootID, id, 0); return(""); }
/// <summary> /// 修改栏目 /// </summary> public static int Update(ModeChannel channel) { //修改信息 ModeChannel condition = new ModeChannel(); condition.ID = channel.ID; ModeChannel oldChannel = TableOperate <ModeChannel> .GetRowData(condition); if (channel.ParentID != oldChannel.ParentID) { if (channel.ParentID == 0) { channel.Depth = 0; channel.ParentID = 0; channel.Path = "0~"; channel.NamePath = "所有栏目~"; channel.AddInsert("RootID", "IDENT_CURRENT('Channel')"); } else { condition = new ModeChannel(); condition.ID = channel.ParentID; ModeChannel pArentChannel = TableOperate <ModeChannel> .GetRowData(condition); string path = Convert.ToString(pArentChannel.Path) + channel.ParentID + "~"; string namePath = Convert.ToString(pArentChannel.NamePath) + Convert.ToString(pArentChannel.Name) + "~"; channel.Depth = pArentChannel.Depth + 1; channel.Path = path; channel.RootID = pArentChannel.RootID; channel.NamePath = namePath; } } else { channel.Depth = oldChannel.Depth; channel.Path = oldChannel.Path; channel.NamePath = oldChannel.NamePath; channel.RootID = oldChannel.RootID; } //修改下面是有的子项的Depth, Path, RootID, NamePath UpdateChild(channel, oldChannel); return(TableOperate <ModeChannel> .Update(channel)); }
private static int UpdateChild(ModeChannel channel, ModeChannel oldChannel) { //int depthSpan = channel.Depth - oldChannel.Depth; ModeChannel value = new ModeChannel(); ModeChannel condition = new ModeChannel(); condition.Path = "%~" + channel.ID + "~%"; condition.AddAttach("Path", "like"); value.RootID = channel.RootID; value.Depth = channel.Depth - oldChannel.Depth; value.AddParameter("OldPath", oldChannel.Path + "" + channel.ID + "~"); value.AddParameter("OldNamePath", oldChannel.NamePath + "" + oldChannel.Name + "~"); value.Path = channel.Path + "" + channel.ID + "~"; value.NamePath = channel.NamePath + "" + channel.Name + "~"; value.SetUpdate(" RootID=@RootID, Depth = Depth + @Depth, [Path]=REPLACE([Path], @OldPath, @Path) , [NamePath]=REPLACE([NamePath], @OldNamePath, @NamePath)"); return(TableOperate <ModeChannel> .Update(value, condition)); }
public static List <ModeChannel> SelectByRootID(int rootID) { List <ModeChannel> channelData = new List <ModeChannel>(); List <int> idList = new List <int>(); //查询数据 ModeChannel value = new ModeChannel(); ModeChannel conditon = new ModeChannel(); if (AdminMethod.ExhibitionID != 0) { conditon.ExhibitionID = AdminMethod.ExhibitionID; } if (rootID > 0) { conditon.RootID = rootID; } List <ModeChannel> oldTypeData = TableOperate <ModeChannel> .Select(value, conditon, 0, " order by Depth, ParentID, OrderID DESC, ID DESC "); for (int i = 0; i < oldTypeData.Count; i++) { ModeChannel typeObj = oldTypeData[i]; if (typeObj.Depth == 0) //深度为0,直接添加 { channelData.Insert(0, typeObj); idList.Insert(0, typeObj.ID); } else { int pArentIndex = idList.IndexOf(typeObj.ParentID); //查找上及目录所在位置! channelData.Insert(pArentIndex + 1, typeObj); idList.Insert(pArentIndex + 1, typeObj.ID); //将数据插入上级目录之后 } } return(channelData); }
protected void Page_Load(object sender, EventArgs e) { Result result = new Result(); JavaScriptSerializer js = new JavaScriptSerializer(); try { if (!string.IsNullOrEmpty(this.Request["iD"])) { int iD = Convert.ToInt32(this.Request["iD"]); if (TableOperate <ModeChannel> .Delete(iD) > 0) { List <ModeChannel> channelList = ModeChannelProvider.SelectAll(); foreach (var item in channelList) { if (item.Path.IndexOf(this.Request["iD"]) > -1) { TableOperate <ModeChannel> .Delete(item.ID); } } result.isOk = true; } else { result.msg = "删除失败"; } } else if (!string.IsNullOrEmpty(this.Request["checkshop"])) { string checkshop = Convert.ToString(this.Request["checkshop"]); checkshop = RequestString.NoHTML(checkshop); int id = TableOperate <ModeChannel> .MultiDelete(checkshop); if (id > 0) { result.isOk = true; } else { result.msg = "删除失败"; } } else if (!string.IsNullOrEmpty(this.Request["all"])) { ModeChannel condition = new ModeChannel(); condition.ExhibitionID = AdminMethod.ExhibitionID; int id = TableOperate <ModeChannel> .Delete(condition); if (id > 0) { result.isOk = true; } else { result.msg = "删除失败"; } } } catch (Exception ex) { result.isOk = false; result.msg = ex.ToString(); } Response.ContentType = "text/json"; Response.Write(js.Serialize(result)); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { m_ExhibitionList = ModeChannelProvider.SelectAll(); string action = GetstringKey("action"); pid = GetIntKey("pid"); if (action != "save") { if (!string.IsNullOrEmpty(this.Request["iD"])) { int _iD = Convert.ToInt32(this.Request["iD"]); ModeChannel condition = new ModeChannel(); condition.ID = _iD; news = TableOperate <ModeChannel> .GetRowData(condition); m_nowChild = Convert.ToString(news.Child).ToLower(); iD.Value = Convert.ToString(news.ID); } DataBind(); } else { Result result = new Result(); string logbrief = ""; ModeChannel newChannelNews = new ModeChannel(); newChannelNews.ID = 0; newChannelNews.AutoForm(this.Page); string Title = newChannelNews.Name; int _iD; if (!string.IsNullOrEmpty(this.Request["iD"])) { _iD = Convert.ToInt32(this.Request["iD"]); ModeChannelProvider.Update(newChannelNews); result.msg = "编辑成功,等待返回列表"; logbrief = "管理员:【" + AdminMethod.AdminFullName + "】在" + DateTime.Now.GetDateTimeFormats('f')[0].ToString() + "编辑了为【" + Title + "】的场景模式"; } else { newChannelNews.AddTime = DateTime.Now; newChannelNews.AddID = AdminMethod.AdminID; newChannelNews.ExhibitionID = AdminMethod.ExhibitionID; _iD = ModeChannelProvider.Insert(newChannelNews); result.msg = "添加成功,等待返回列表"; logbrief = "管理员:【" + AdminMethod.AdminFullName + "】在" + DateTime.Now.GetDateTimeFormats('f')[0].ToString() + "添加了为【" + Title + "】的场景模式"; } if (_iD > 0) { result.isOk = true; Lognet.AddLogin(logbrief); } else { result.msg = "操作失败"; } Response.ContentType = "text/json"; Response.Write(new JavaScriptSerializer().Serialize(result)); Response.End(); } DataBind(); }