<% 		Dim ID,action,LabelRS,LabelName,LabelFlag,LabelContent,SQLStr,Description,ShowErr
		action = Request.QueryString("action")
	  Set LabelRS = Server.CreateObject("Adodb.Recordset")
		If action = "EditLabel" or  action = "Edit" Then
			ID = skweboa.Return_to_numerical(Request.QueryString("ID"))
			Set LabelRS = Server.CreateObject("Adodb.Recordset")
			SQLStr = "SELECT * FROM Label_skweb Where ID=" & ID & ""
			LabelRS.Open SQLStr, Conn, 1, 1
			LabelName = Replace(Replace(LabelRS("LabelName"), "{skweb_", ""), "}", "")
			Description = LabelRS("Description")
			LabelFlag = Clng(LabelRS("LabelFlag"))
			LabelContent = Server.HTMLEncode(LabelRS("LabelContent"))
			LabelRS.Close

		Else
		  If LabelContent="" Then LabelContent="请输入您的html代码"
		End If
		
		
		
		Select Case Request.Form("action")
			
		 Case "AddNew"
			LabelName = Replace(Replace(Trim(Request.Form("LabelName")), """", ""), "'", "")
			Description = Replace(Trim(Request.Form("Description")), "'", "")
			LabelContent = Trim(Request.Form("Content"))
			LabelFlag = Trim(Request.Form("LabelFlag"))
			If LabelName = "" Then
		    Call skweboa.SK_window(ShowErr,"","1","3")
			  Response.End
			End If

			If LabelContent = "" Then Call skweboa.SK_window(ShowErr,"","1"): Response.End
 			LabelName = "{skweb_" & LabelName & "}"
			LabelRS.Open "Select LabelName From Label_skweb Where LabelName='" & LabelName & "'", Conn, 1, 1
			If Not LabelRS.EOF Then
			  Call skweboa.SK_window("标签名称已经存在","","1","3")
			  LabelRS.Close
			  Conn.Close
			  Set LabelRS = Nothing
			  Set Conn = Nothing
 			  Response.End
			Else
				LabelRS.Close
				LabelRS.Open "Select * From Label_skweb", Conn, 1, 3
				LabelRS.AddNew
				LabelRS("LabelName") = LabelName
				LabelRS("LabelContent") = LabelContent
				LabelRS("LabelFlag") = LabelFlag
				 LabelRS("Description") = Description
				 LabelRS("AddDate") = Now
				 LabelRS("LabelType") = 2
				 LabelRS.Update
				 Application.Contents.RemoveAll
  
  
  		 If request("qt")="t" Then  
	           Response.Write("<script language=JavaScript>var api = frameElement.api, W = api.opener;api.reload( api.get('elCMSlablemode'));api.get('indexeditlableediy',1).close();api.close(); </script>")
        else
			 Call skweboa.SK_window("添加标签成功",""&MyDbPath&"SKCMS/dialog.asp?action=closmain","","3")
		end if
		
		
				 				 
			End If
			
			
		Case "EditSubmit"
			ID = skweboa.Return_to_numerical(Trim(Request.Form("ID")))
			LabelName = Replace(Replace(Trim(Request.Form("LabelName")), """", ""), "'", "")
			Description = Replace(Trim(Request.Form("Description")), "'", "")
			LabelContent = Request.Form("Content")
					LabelFlag = Trim(Request.Form("LabelFlag"))
			If LabelName = "" Then
			   Call skweboa.SK_window(ShowErr,"","1")
			  Response.End
			End If
			If LabelContent = "" Then Call skweboa.SK_window(ShowErr,"","1"):Response.End
 			LabelName = "{skweb_" & LabelName & "}"
			LabelRS.Open "Select LabelName From Label_skweb Where ID <>" & ID & " AND LabelName='" & LabelName & "'", Conn, 1, 1
			If Not LabelRS.EOF Then
			  Call skweboa.SK_window("标签名称已经存在","","1","3")
			  Response.End
			Else
				LabelRS.Close
				LabelRS.Open "Select * From Label_skweb Where ID=" & ID & "", Conn, 1, 3
				 LabelRS("LabelName") = LabelName
				 LabelRS("LabelContent") = LabelContent
				 		 LabelRS("LabelFlag") = LabelFlag
				 LabelRS("Description") = Description
				 LabelRS("AddDate") = Now
				 LabelRS.Update
				 Application.Contents.RemoveAll
 
				 
		  If request("qt")="t" Then  
	           Response.Write("<script language=JavaScript>var api = frameElement.api, W = api.opener;api.reload( api.get('elCMSlablemode'));api.close(); </script>")
        else
		 			 				 Call skweboa.SK_window("标签修改成功",""&MyDbPath&"SKCMS/dialog.asp?action=closreload","","3")
		end if
		
		
			End If
		 
			End Select
 %>