<%  dim Rs,FieldSql,action,FieldName,FieldType,ColumnType,TableName,Title,Text_Default,TitleSize,fun
Dim IsNotNull,MultipleTextType_Width,MultipleTextType_Height,ID,Type_Default,FieldRS,Description,Type_Type,check
Dim NType_Default,RadioType_Content,ListBoxType_Content,Content,RadioType_Type,ListBoxType_Type,ISType,YHtml
Dim SupportHtmlType_Width,SupportHtmlType_Heigh,OrderID,RadioPic_Type,regex,regError,SearchIF,ValueOnly,savepic,skupload
Dim IsEditor,sktype
 sktype = skweboa.Return_to_numerical(Request("sktype"))
 if ModeID=0 or ModeID="" Then ModeID=1	
if 	sktype=1 then
 TableName=skweboa.SK_Mroot(ModeID,2)
elseif  sktype=2 then
 TableName=skweboa.SK_MidUser(ModeID,2)
 elseif  sktype=3 then
 TableName=skweboa.SK_axe("select ModeTable from ModeForm_skweb Where ModeID=" & ModeID & " ")(0) 
end if 
 
 ID=skweboa.Return_to_numerical(Request("ID"))
	action = Request.QueryString("A") 
	Select Case action
		   Case "AddSave"
		   		Call AddSave()
			Case "ESave"
				Call Esave()
			Case "A","E"
				Call AddEdit()
			Case "px"
				Call px()
			Case Else
				Call Main()
	End Select



	IF action = "Del" Then
		Dim FieldN
		FieldN=skweboa.SK_axe("Select FieldName From Table_skweb Where skweboa="&sktype&" and  ID=" & ID)(0)
		skweboa.SK_axe("Delete from Table_skweb  Where skweboa="&sktype&" and  ID=" & ID & "")
		skweboa.SK_axe("Alter Table "& TableName &" Drop column "& FieldN &"")
		Call skweboa.SK_CaheDEL(SkcmsCookies & "_"&ModeID&"SK_Custom_folderCache")
		Call skweboa.SK_window("删除字段成功","" & Request.ServerVariables("HTTP_REFERER") & "","","3")
 	End IF
	

	
	
	Sub px()
			Dim i
			ID = Split(skweboa.s("ID"),","):OrderID = Split(skweboa.s("OrderID"),",")
			 For I = LBound(ID) To UBound(ID)
					Conn.execute("Update Table_skweb set OrderID="&OrderID(I)&" where skweboa="&sktype&" and  ID = "&ID(I)&"")
			Next 
			set conn=Nothing
		 Response.Redirect "?A=L&ModeID="&ModeID&"&sktype="&sktype&"&atype="&Request.QueryString("atype")
	End sub

	Sub AddSave()
		FieldType=skweboa.S("FieldType")
		Title=skweboa.S("Title")
		IsNotNull=skweboa.Return_to_numerical(skweboa.S("IsNotNull"))
		ISType=skweboa.Return_to_numerical(skweboa.S("ISType"))
		OrderID=skweboa.Return_to_numerical(skweboa.S("OrderID"))
		Type_Default=skweboa.S("Type_Default")
		Description=skweboa.S("Description")
		savepic=skweboa.Return_to_numerical(skweboa.S("savepic"))
		skupload=skweboa.Return_to_numerical(skweboa.S("skupload"))
		YHtml=skweboa.Return_to_numerical(skweboa.S("YHtml"))
		IF skweboa.SK_Check_the_English_name(Request.Form("FieldName")) = False  Then
			Call skweboa.SK_window("英文名称只能为英文、数字及下划线","","","3")
 		Else
			FieldName=skweboa.S("FieldName")&"_skweb"
		End if
		Dim skwebMode_Width,skwebMode_Height
		'长度.宽度.
		Select Case FieldType
			Case "TextType"'单行文本
				skwebMode_Width =  skweboa.Return_to_numerical(skweboa.S("TitleSize"))'文本框长度
				ColumnType="varchar(255)"
			Case "MultipleTextType"'多行文本(不支持Html
				skwebMode_Width =  skweboa.Return_to_numerical(skweboa.S("MultipleTextType_Width"))
				skwebMode_Height =  skweboa.Return_to_numerical(skweboa.S("MultipleTextType_Height"))
				Type_Type=YHtml
				 ColumnType="text"
			Case "MultipleHtmlType"'多行文本(支持Html)
				Content = skweboa.S("IsEditor")'编辑器属性放入Content字段
				skwebMode_Width =  skweboa.Return_to_numerical(skweboa.S("SupportHtmlType_Width"))
				skwebMode_Height =  skweboa.Return_to_numerical(skweboa.S("SupportHtmlType_Heigh"))
				Type_Type=savepic
				skupload=skupload
				ColumnType="text"
			Case "RadioType"'单选项
			    Content = skweboa.S("RadioType_Content")
				Type_Type =  skweboa.Return_to_numerical(skweboa.S("RadioType_Type"))'显示方式
				ColumnType="varchar(255)"
			Case "ListBoxType"'多选项
			    Content = skweboa.S("ListBoxType_Content")
				Type_Type =  skweboa.Return_to_numerical(skweboa.S("ListBoxType_Type"))
				ColumnType="text"
			Case "NumberType"'数字
			    skwebMode_Width =  skweboa.Return_to_numerical(skweboa.S("NumberType_TitleSize"))'数字的宽度放入总宽度字段名称中
				ColumnType="int"'
		   Case "DateType"
				 ColumnType="datetime"'Response.write "日期时间"
		   Case "NumberType"
				ColumnType="int"'Response.write "数字"
				
			Case "RadomType"'随机数
				Type_Type=skweboa.Return_to_numerical(skweboa.S("sjslang"))
 	          ColumnType="varchar(255)"'
				
		  case "PicType"
				 Type_Type =skweboa.Return_to_numerical(skweboa.S("RadioPic_Type"))
				 				ColumnType="text"

		   Case else
		     ColumnType="varchar(255)"
		End Select 
	

		 Set FieldRS = Server.CreateObject("ADODB.RECORDSET")
		 FieldSql = "Select * From [Table_skweb] Where   FieldName='" & FieldName & "' And ModeID=" & ModeID&" And skweboa="&sktype
		 FieldRS.Open FieldSql, conn, 3, 3
		 If FieldRS.EOF And FieldRS.BOF Then
			FieldRS.AddNew
			FieldRS("FieldName") = FieldName
			FieldRS("FieldType") = FieldType
			FieldRS("ModeID") = ModeID
			FieldRS("Title") = Title
			FieldRS("IsNotNull") = IsNotNull
			FieldRS("Width") = skwebMode_Width
			FieldRS("Height") = skwebMode_Height
			FieldRS("Type_Default") = Type_Default
			FieldRS("Description") = Description
			FieldRS("Type_Type") = Type_Type
			FieldRS("Content") = Content
			FieldRS("ISType") = ISType
			FieldRS("OrderID") = OrderID
			FieldRS("skweboa") = sktype
 			FieldRS("check") = skweboa.Return_to_numerical(skweboa.S("check"))		
			if skweboa.Return_to_numerical(skweboa.S("check"))	="1" then 
			FieldRS("regex") = skweboa.S("fun")
			else 
			FieldRS("regex") = skweboa.S("regex")
			FieldRS("regError") = skweboa.S("regError")
			end if 
			FieldRS("qtsNull") = 1
 			FieldRS("SearchIF") = skweboa.Return_to_numerical(skweboa.S("SearchIF"))		
		    FieldRS("ValueOnly") = skweboa.Return_to_numerical(skweboa.S("ValueOnly"))		
		    FieldRS.Update
			Conn.Execute("Alter Table "&TableName&" Add "&FieldName&" "&ColumnType&"")
			Call skweboa.SK_CaheDEL(SkcmsCookies & "_"&ModeID&"SK_Custom_folderCache")
			Call skweboa.SK_CaheDEL(SkcmsCookies & "_"&ModeID&"SK_Custom_folderListCache")
			
								Response.Write "<script language=""JavaScript"">var api = frameElement.api, W = api.opener;W.SK_close('load1');api.reload();W.SK_success('字段添加成功');api.close();</script>" 
										
		 Else
		 		Response.Write "<script language=""JavaScript"">var api = frameElement.api, W = api.opener;W.SK_close('load1');alert('字段重复了!',3);history.back();</script>" 
		   		 
		   Exit Sub
		 End If
	End  Sub 


	Sub Esave()
 
		Title=skweboa.S("Title")
		IsNotNull=skweboa.S("IsNotNull")
		Type_Default=skweboa.S("Type_Default")
		Description=skweboa.S("Description")
		OrderID=skweboa.Return_to_numerical(skweboa.S("OrderID"))
		savepic=skweboa.Return_to_numerical(skweboa.S("savepic"))
		skupload=skweboa.Return_to_numerical(skweboa.S("skupload"))
		YHtml=skweboa.Return_to_numerical(skweboa.S("YHtml"))
		 If TitleSize=0 Then TitleSize=40
		 Set FieldRS = Server.CreateObject("ADODB.RECORDSET")
		 FieldSql = "Select * From [Table_skweb] Where ID=" & ID
		 FieldRS.Open FieldSql, conn,1, 3
			FieldRS("ModeID") = ModeID
			FieldRS("Title") = Title
			FieldRS("IsNotNull") = IsNotNull
			Select Case FieldRS("FieldType")
				Case "TextType"'单行文本
					FieldRS("Width") =  skweboa.Return_to_numerical(skweboa.S("TitleSize"))'文本框长度
				Case "MultipleTextType"'多行文本(不支持Html
					FieldRS("Width") =  skweboa.Return_to_numerical(skweboa.S("MultipleTextType_Width"))
					FieldRS("Height") =  skweboa.Return_to_numerical(skweboa.S("MultipleTextType_Height"))
					FieldRS("Type_Type") =YHtml
				Case "MultipleHtmlType"'多行文本(支持Html)
					FieldRS("Content") = skweboa.S("IsEditor")'编辑器属性放入Content字段
					FieldRS("Width") =  skweboa.Return_to_numerical(skweboa.S("SupportHtmlType_Width"))
					FieldRS("Height") =  skweboa.Return_to_numerical(skweboa.S("SupportHtmlType_Heigh"))
					FieldRS("Type_Type") =savepic
					FieldRS("skupload") =skupload
				Case "RadioType"'单选项
					FieldRS("Content") = skweboa.S("RadioType_Content")
					FieldRS("Type_Type") =  skweboa.Return_to_numerical(skweboa.S("RadioType_Type"))'显示方式
				Case "ListBoxType"'多选项
					FieldRS("Content") = skweboa.S("ListBoxType_Content")
					FieldRS("Type_Type") =  skweboa.Return_to_numerical(skweboa.S("ListBoxType_Type"))		
				Case "NumberType"'数字
					FieldRS("Width") =  skweboa.Return_to_numerical(skweboa.S("NumberType_TitleSize"))'数字的宽度放入总宽度字段名称中	
			  Case "RadomType"'随机数
				FieldRS("Type_Type") =skweboa.Return_to_numerical(skweboa.S("sjslang"))
				case "PicType"
					 FieldRS("Type_Type") = skweboa.Return_to_numerical(skweboa.S("RadioPic_Type"))
 			End Select 
			FieldRS("Description") = Description
			FieldRS("Type_Default") = Type_Default
			FieldRS("ISType")= skweboa.Return_to_numerical(skweboa.S("ISType"))
			FieldRS("OrderID") = OrderID
 			FieldRS("check") = skweboa.Return_to_numerical(skweboa.S("check"))		
			If  skweboa.Return_to_numerical(skweboa.S("check"))	="1" then 
				FieldRS("regex") = skweboa.S("fun")
			Else  
				FieldRS("regex") = skweboa.S("regex")
				FieldRS("regError") = skweboa.S("regError")
			End  If  
			FieldRS("skweboa") = sktype
			FieldRS("SearchIF") = skweboa.Return_to_numerical(skweboa.S("SearchIF"))		
 		    FieldRS("ValueOnly") = skweboa.Return_to_numerical(skweboa.S("ValueOnly"))		
 			FieldRS.Update
		 
					Response.Write "<script language=""JavaScript"">var api = frameElement.api, W = api.opener;W.SK_close('load1');api.reload();W.SK_success('修改成功');api.close();</script>" 
					
 	End  Sub 

 Sub Main() %>