/// <summary> ///根据nodeid 和条件列表,获取所有新闻,includechild为0则不包括子节点的信息,不为0时则包括所有子节点信息(影响性能) /// </summary> /// <param name="NodeID"></param> /// <param name="FiledName"></param> /// <param name="FiledValue"></param> /// <param name="includechild"></param> /// <returns></returns> public int GetInfoNumByNode(int NodeID, ArrayList FiledName, ArrayList FiledValue, int includechild) { int recordcount = 0; string sbCondition = string.Empty; sbCondition = CommOperate.SelectCondition(FiledName, FiledValue); string cmdtxt = string.Empty; if (NodeID == 0) { cmdtxt = "Select count(*) from T_InfoList where 1=1 and IsDelete=0 " + sbCondition.ToString(); } else { if (includechild != 0) //包含子节点 { NodeOperate nop = new NodeOperate(); ArrayList childlist = nop.GetAllChildNode(NodeID); string childstring = string.Empty;//子节点列表 for (int i = 0; i < childlist.Count; i++) { childstring += childlist[i].ToString() + ","; } childstring = childstring.Substring(0, childstring.Length - 1);//截取最后一个"," ,组成类似1,2,3形式 cmdtxt = "Select count(*) from T_InfoList where IsDelete=0 and InfoCateID in(" + childstring.Trim() + ") " + sbCondition.ToString(); } else { cmdtxt = "Select count(*) from T_InfoList where IsDelete=0 and InfoCateID= " + NodeID + " " + sbCondition.ToString(); } } // System.Web.HttpContext.Current.Response.Write(cmdtxt); //System.Web.HttpContext.Current.Response.End(); dh.Open(); dh.BeginTrans(); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, cmdtxt, null)) { if (dr.HasRows) { dr.Read(); Int32.TryParse(dr[0].ToString(), out recordcount); } else { recordcount = 0; } } dh.CommitTrans(); dh.Close(); return(recordcount); }
/// <summary> ///获取管理员数量 /// </summary> /// <param name="FiledName"></param> /// <param name="FiledValue"></param> /// <returns></returns> public int GetAdminNumByCondition(ArrayList FiledName, ArrayList FiledValue) { int recordcount = 0; string sbCondition = string.Empty; sbCondition = CommOperate.SelectCondition(FiledName, FiledValue); string cmdtxt = "Select count(*) from T_Admin where 1=1 " + sbCondition.ToString(); dh.Open(); dh.BeginTrans(); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, cmdtxt, null)) { if (dr.HasRows) { dr.Read(); Int32.TryParse(dr[0].ToString(), out recordcount); } } dh.CommitTrans(); dh.Close(); return(recordcount); }
/// <summary> /// 修改nodepath和parentid /// </summary> /// <param name="toid">新的parentid</param> /// <param name="path">当前path,没有可为空</param> /// <param name="currentid">当前节点ID,没有则自动获取最新插入ID作为当前ID</param> /// <returns></returns> public int UpdateNodePath(int toid, string path, int?currentid) { int stat = 0; string CurrentId = string.Empty;; //当前节点ID dh.Open(); if (currentid.HasValue == false) { using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, "select IDENT_CURRENT('T_NodeList')", null)) { if (dr.HasRows) { dr.Read(); CurrentId = dr[0].ToString().Trim(); } else { CurrentId = "0"; } } } else { CurrentId = currentid.ToString(); } NameValueCollection nvc = new NameValueCollection(); string NewPath = string.Empty; if (toid == 0)//移动到一级栏目 { NewPath = "0," + CurrentId + ","; } else //如果不是一级栏目 { string pid = toid.ToString(); nvc.Add("@NodeID", pid); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, "Select NodePath from T_NodeList where NodeID=@NodeID", nvc)) { if (dr.HasRows) { dr.Read(); string ToPath = dr[0].ToString().Trim(); NewPath = ToPath + CurrentId + ","; if (path.Contains(ToPath + CurrentId) && toid != 0) { dh.Close(); CommonLibrary.RunJs.AlertAndBack("要移动的路径与当前路径相同!"); } if ((ToPath).Contains(path) && path.Trim() != "") { dh.Close(); CommonLibrary.RunJs.AlertAndBack("要移动的路径不能是当前类别的子节点"); } } else { dh.Close(); CommonLibrary.RunJs.AlertAndBack("不存在父节点,请检查"); } } } nvc.Clear(); nvc.Add("@NodePath", NewPath); nvc.Add("@ParentID", toid.ToString()); nvc.Add("@NodeID", CurrentId); string UpdateNode = "Update T_NodeList Set NodePath=@NodePath,ParentID=@ParentID where NodeID=@NodeID"; dh.BeginTrans(); dh.ExecuteNonQuery(CommandType.Text, UpdateNode, nvc); if (path.Trim() != "") { #region 更新子节点path,sql版 string UpdateChildNodes = "Update T_NodeList Set NodePath= Replace(NodePath,'" + path + "','" + NewPath + "') where CHARINDEX('" + path + "',NodePath)>0 "; #endregion dh.ExecuteNonQuery(CommandType.Text, UpdateChildNodes, null); } dh.CommitTrans(); dh.Close(); return(stat); }