<% CLASS vogue PRIVATE xmlDom '-------------------------------------------------------------------------- 'vogueType PUBLIC typeCaption PUBLIC typeID PUBLIC parentTypeCaption PUBLIC parentTypeID PUBLIC PRI PUBLIC explain '-------------------------------------------------------------------------- 'vogue PUBLIC title '标题 PUBLIC vogueID 'MMST061.ID PUBLIC vogueTypeID 'mmst061.typeID PUBLIC vogueExplain '说明 PUBLIC picPath '图片 PUBLIC brandID '品牌 public see_flag PUBLIC sub saveVogueTypeToXMLFile(pFileName) set xmlDom =server.CreateObject("Microsoft.XMLDOM") xmlDom.async =false xmlDom.preserveWhiteSpace =false set pi = xmlDom.createProcessingInstruction("xml", "version=""1.0""") xmlDom.insertBefore pi, xmlDom.childNodes.item(0) dim elemRoot,attCaption,attIcon,attExplain set elemRoot =xmlDom.createElement("vogue") set attCaption =xmlDom.createAttribute("caption") attCaption.text="时尚精品分类" set attIcon =xmlDom.createAttribute("icon") attIcon.text="img/icon.vogue.gif" set attExplain =xmlDom.createAttribute("explain") attExplain.text="时尚精品分类" elemRoot.attributes.setNamedItem(attCaption) elemRoot.attributes.setNamedItem(attIcon) elemRoot.attributes.setNamedItem(attExplain) xmlDom.appendChild(elemRoot) switchTree -1,elemRoot,-1'第一个参数:parentTypeID,第二个参数:xmlDom的节点。最后一个参数:层次 xmlDom.save(server.MapPath(pFileName)) END SUB PRIVATE SUB switchTree(pParentTypeID,pParentNode,pLevel)'第一个参数:parentTypeID,第二个参数:xmlDom的节点。 dim sql,rst,elemNode,attID,attParentTypeID,attCaption,attPRI,attExplain ' sql="select *, from mmst060 where parentTypeID=" & pParentTypeID & " order by PRI" ' response.write sql ' response.End() sql=" SELECT a.*, ISNULL(b.totalNum, 0) AS totalNum " &_ " FROM mmst060 a LEFT OUTER JOIN " &_ " (SELECT COUNT(typeID) AS totalNum, typeID " &_ " FROM mmst061 " &_ " GROUP BY typeID) b ON a.ID = b.typeID " &_ " where parentTypeID="&pParentTypeID&" order by PRI" set rst=conn.execute(sql) while not rst.eof set elemNode =xmlDom.createElement("level" & (pLevel+1)) set attID =xmlDom.createAttribute("id") attID.text =rst("id") SET attParentTypeID =xmlDom.createAttribute("parentTypeID") attParentTypeID.text=rst("parentTypeID") set attCaption =xmlDom.createAttribute("caption") attCaption.text =rst("typeCaption")&"("&rst("totalNum")&")" set attExplain =xmlDom.createAttribute("explain") if not isNull(rst("explain")) then attExplain.text =rst("explain") else attExplain.text ="" end if set attPRI =xmlDom.createAttribute("PRI") if not isNull(rst("PRI")) then attPRI.text =rst("PRI") else attPRI.text ="99" end if elemNode.attributes.setNamedItem(attID) elemNode.attributes.setNamedItem(attParentTypeID) elemNode.attributes.setNamedItem(attCaption) elemNode.attributes.setNamedItem(attPRI) elemNode.attributes.setNamedItem(attExplain) switchTree rst("id"),elemNode,pLevel+1 pParentNode.appendChild(elemNode) rst.movenext wend end sub PUBLIC function addType dim rst,sql,returnArray(1) sql="select * from mmst060 where parentTypeID=" & parentTypeID & " and typeCaption=N'" & typeCaption & "'" set rst=conn.execute(sql) if not rst.eof then returnArray(0)=false returnArray(1)="在当前类别下以存在分类:" & typeCaption else sql=" insert into mmst060 (typeCaption,parentTypeID,PRI,explain) values " &_ " (N'"&typeCaption&"',"&parentTypeID&",'"&PRI&"',N'"&explain&"')" conn.execute sql returnArray(0)=true end if addType=returnArray end function PUBLIC FUNCTION editType dim sql,rst,returnArray(1) sql="select * from mmst060 where typeCaption=N'"&typeCaption&"' and parentTypeID=" & parentTypeID set rst=conn.execute(sql) if not rst.eof then returnArray(0)=false returnArray(1)="当前类别下以存在分类:" & typeCaption & ",请换一个名字在修改!" else sql="update mmst060 set typeCaption=N'"&typeCaption&"',PRI='"&PRI&"',explain=N'"&explain&"' where id=" & typeID conn.execute sql returnArray(0)=true end if editType=returnArray END FUNCTION PUBLIC FUNCTION deleteType dim sql,rst,returnArray(1),isOk isOk=true sql="select * from mmst060 where parentTypeID=" & typeID set rst=conn.execute(sql) if not rst.eof then isOk=false returnArray(0)=false returnArray(1)="当前类别下存在分类,请先删除分类!" end if if isOk then sql="select * from mmst061 where typeID=" & typeID set rst=conn.execute(sql) if not rst.eof then isOk=false returnArray(0)=false returnArray(1)="当前类别下有内容,请先删除此类别下的内容!" end if end if if isOk then sql="delete from mmst060 where id=" & typeID conn.execute sql returnArray(0)=true end if deleteType=returnArray END FUNCTION PUBLIC SUB editVogue DIM SQL,RST sql=" update mmst061 set title=N'"&title&"',explain=N'"&vogueExplain&"',picPath=N'"&picPath&"',PRI=" & PRI & "," &_ " brandID=N'"&brandID&"', see_flag='"&see_flag&"' where id=" & vogueID conn.execute sql END SUB PUBLIC SUB addVogue DIM SQL,RST sql=" insert into mmst061 (typeID,title,explain,picPath,brandID,updDate,updName,PRI,see_flag) " &_ " values (N'"&vogueTypeID&"',N'"&title&"',N'"&vogueExplain&"',N'"&picPath&"',N'"&brandID&"','"&date() & " " & time()&"',N'"&session("adminLogonaName")&"',"&PRI&",'"&see_flag&"')" conn.execute sql END SUB PUBLIC SUB saveVogueToXMLFile(pFileName) set xmlDom =server.CreateObject("Microsoft.XMLDOM") xmlDom.async =false xmlDom.preserveWhiteSpace =false set pi = xmlDom.createProcessingInstruction("xml", "version=""1.0""") xmlDom.insertBefore pi, xmlDom.childNodes.item(0) dim elemRoot,attCaption,attIcon,attExplain set elemRoot =xmlDom.createElement("vogue") dim sql,rst ' sql=" SELECT TOP 24 a.id,ISNULL(a.title, '') AS title, ISNULL(a.explain, '') AS explain, ISNULL(a.brand, " &_ ' " '') AS brand, ISNULL(a.manufacturer, '') AS manufacturer, ISNULL(a.contactMethod, '') " &_ ' " AS contactMethod, ISNULL(b.typeCaption, '') AS typeCaption, ISNULL(a.picPath, '') " &_ ' " AS picPath " &_ ' " FROM mmst061 a LEFT OUTER JOIN " &_ ' " MMST060 b ON a.typeID = b.ID " &_ ' " ORDER BY a.updDate DESC " sql=" SELECT TOP 24 a.id, ISNULL(a.title, '') AS title, ISNULL(a.explain, '') AS explain, " &_ " ISNULL(c.brandName, '') AS brandName,isNull(a.brandID,'') as brandID, ISNULL(b.typeCaption, '') AS typeCaption, " &_ " ISNULL(a.picPath, '') AS picPath,a.PRI " &_ " FROM mmst061 a LEFT OUTER JOIN " &_ " mmst060 b ON a.typeID = b.ID LEFT OUTER JOIN " &_ " mmst062 c ON a.brandID = c.id " &_ " ORDER BY a.PRI,a.updDate DESC " set rst=conn.execute(sql) while not rst.eof set elemNode =xmlDom.createElement("item") set attCaption =xmlDom.createAttribute("caption") attCaption.text =rst("title") set attExplain =xmlDom.createAttribute("explain") attExplain.text =rst("explain") set attBrandName =xmlDom.createAttribute("brandName") attBrandName.text =rst("brandName") set attBrandID =xmlDom.createAttribute("brandID") attBrandID.text =rst("brandID") set attTypeCaption =xmlDom.createAttribute("typeCaption") attTypeCaption.text =rst("typeCaption") set attPicPath =xmlDom.createAttribute("pic") attPicPath.text =rst("picPath") set attURL =xmlDom.createAttribute("URL") attURL.text ="vogueReader.asp?id=" & rst("id") set attPRI =xmlDom.createAttribute("PRI") attPRI =rst("PRI") elemNode.attributes.setNamedItem(attCaption) elemNode.attributes.setNamedItem(attExplain) elemNode.attributes.setNamedItem(attBrandName) elemNode.attributes.setNamedItem(attBrandID) elemNode.attributes.setNamedItem(attTypeCaption) elemNode.attributes.setNamedItem(attPicPath) elemNode.attributes.setNamedItem(attURL) elemRoot.appendChild(elemNode) rst.movenext wend xmlDom.appendChild(elemRoot) xmlDom.save(server.MapPath(pFileName)) END SUB END CLASS %>