<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../../fy_inc/cls_pageview.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>自定义表单管理</title>
<link rel="stylesheet" type="text/css" href="../../css/base.css">
<link rel="stylesheet" type="text/css" href="../../css/content.css">
</head>
<body>   <% 	Dim ModeID,TableName,ModeName,Action,Rs,id
	 ModeID = ChkNumeric(Request("ModeID"))
	 ID = ChkNumeric(Request("ID"))
	 if ModeID=0 or ModeID="" Then ModeID=1
	 if id=0 or id="" Then id=1
	 If Not fycms.fycms_QXYZ(0,"form_fy","") Then   Call fycms.Alert("没有权限","") 
 	set rs=fycms.actexe("select * from ModeForm_fy where ModeID="&ModeID)
	if  rs.eof then  echo "错误":response.end
	TableName=rs("ModeTable")
	ModeName=rs("ModeName")
	

 %>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> <a href="index.asp">自定义表单</a> >> <a href="list.Form.asp?A=L&ModeID=<%= ModeID %>">字段列表</a> >> [<%= ModeName%>]模型  查看反馈</div>
    <div class="opers">
    	<a href="index.asp?A=Add" class="btn">添加自定义表单</a>
    </div>
 <%
 	Action = Request("A")
	Select Case Action
			Case "D"
				Call Del()
			case "List"
				call list()
			case "alldel"
				call alldel()
			Case Else
				Call Main()
	End Select
	Sub alldel()
 		fycms.ACTEXE("Delete From  "&TableName&" Where ID in("&rsql(fycms.s("ID"))&")")
		Call fycms.ActErr("删除表单成功","Sys_fy/Form/list.asp?ModeID="&ModeID&"","")		
 	End Sub 

	Sub del()
		fycms.ACTEXE("Delete From  "&TableName&" Where ID=" & ChkNumeric(Request("ID")))
		Call fycms.ActErr("删除表单成功","Sys_fy/Form/list.asp?ModeID="&ModeID&"","")		
 	End Sub 

	sub list()
 	dim rs,MX_Arr,i,k,rs1,rs2,mx
	set rs2=fycms.actexe("SELECT * FROM Table_fy Where fycms=3 and  ModeID=" & ModeID & " order by OrderID desc,ID asc ")
    If  rs2.eof Then echo "没有找到这条记录,请返回":response.end
	do while not rs2.eof
		mx=mx&rs2("FieldName")&","
 	rs2.movenext
	loop
	 mx=Left(mx, Len(mx) - 1)
  	set rs=fycms.actexe("select "&mx&" ,* from "&TableName&" where id="&id&" order by id desc")
     If  rs.eof Then echo "没有找到这条记录,请返回":response.end
 
 
 	 %>









    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead><tr>
    <th>标题</th>
    <th>提交内容</th>
  </tr> </thead>
  
  
  <tr>
    <td>用户：</td>
    <td>

<%   
    echo fycms.UserM(rs("UserID"))
 	  %>

</td>
  </tr>
   <tr>
    <td>提交时间：</td>
    <td>

<%=rs("addtime") %>

</td>
  </tr> 
      <tr>
    <td >用户IP：</td>
    <td>

<%=rs("UserIP") %>

</td>
  </tr> 
  
  
  <% =ACT_MXEdit(ModeID,ID) 
    %>
</table>
<% 


	 end sub  
	 
	 
	
	Public Function ACT_MXEdit(ModeID,ID)'表现方式.输出模型
	 Dim RS
	  Set RS=fycms.ACTEXE("Select * from Table_fy  Where ModeID=" & ModeID & "  and fycms=3 order by OrderID desc,ID asc")
	  	Do While Not RS.Eof
			ACT_MXEdit=ACT_MXEdit &"<tr>"&vbCrLf&"<td>"&RS("Title")&"：</td>"&vbCrLf&"<td>"&EditField(RS,ModeID,ID)&"</td>"&vbCrLf&"</tr>"&vbCrLf
			
		RS.MoveNext
		Loop
	  RS.Close:Set RS=Nothing
	 ACT_MXEdit=vbCrLf&ACT_MXEdit& vbCrLf 
	End function


	Function EditField(RSObj,ModeID,id)
		Dim i,IsNotNull,TitleTypeArr,checked,rs1,FieldName
		Dim arrtitle,arrvalue,titles
	  Set RS1=fycms.ACTEXE("Select * from "&TableName&"  Where id="&id&"")
	  FieldName= RSObj("FieldName")
	
		If rsobj("IsNotNull")="0" Then 
			IsNotNull="  <font color=red title=""必填"">*</font>  "&rsobj("Description")
		Else
			IsNotNull="  "&rsobj("Description")
		End If 
		 
	    EditField= RS1(FieldName)& vbCrLf 
	  RS1.Close:Set RS1=Nothing
	End Function 




	Sub Main()

	Dim strLocalUrl
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	Dim intPageNow
	intPageNow = request.QueryString("page")
	Dim intPageSize, strPageInfo
	intPageSize = 30
	Dim arrinfo, i
	Dim sql, sqlCount,pages
	 pages = "ModeID="&ModeID&"&page"
	sql = "SELECT [ModeID], [UserID], [addtime], [UserIP],[ID]" & _
		" FROM ["&TableName&"] where ModeID="&ModeID&" " & _
		"ORDER BY [id] desc"
	sqlCount = "SELECT Count([ModeID])" & _
			" FROM ["&TableName&"]  where ModeID="&ModeID&" "

		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
			clsRecordInfo.strSql = sql
			clsRecordInfo.intPageSize = intPageSize
			clsRecordInfo.intPageNow = intPageNow
			clsRecordInfo.strPageUrl = strLocalUrl
			clsRecordInfo.strPageVar = pages
		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
			
	
  %>
	<form name="Article" method="post" action="?A=alldel&ModeID=<%=ModeID%>">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>ID号</th>
	  <th>提交者</th>
	  <th>查看</th>
	  <th>时间</th>
	  <th>IP</th>
	  <th>管理操作</th>
	  </tr>
    </thead>
       <%  
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
  %>
  <tr  >
    <td align="center" >
	 <input name="ID" type="checkbox"  class="Ainput" size="4" maxlength="3" id="ID" value="<%=arrinfo(4,i)%>">	
	
	</td>
    <td align="center"><%
	 					  
 		  echo fycms.UserM(arrinfo(1,i))
							 
 %></td>
    <td align="center"><a href="?A=List&ModeID=<%= ModeID %>&ID=<%= arrinfo(4,i) %>">查看</a></td>
    <td align="center"><%= arrinfo(2,i) %></td>
    <td align="center"><%= arrinfo(3,i) %></td>
    <td align="center" ><a href="?A=D&ModeID=<%= ModeID %>&ID=<%= arrinfo(4,i) %>"  onClick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a></td>
  </tr><% 
		Next
	End If %>
	    <tr >
      <td height="25" colspan="7" align="center" class="td_bg"><%= strPageInfo%></td>
    </tr>
	   <tr>
      <td class="tl" colspan="7" >
 <label for="ChkAlls"><input name="ChkAll" type="checkbox" id="ChkAlls" onClick="CheckAll(this.form)" value="checkbox">选中本页显示的所有内容</label> 
 <input type="submit" class="btn btn_primary" name="Submit" value=" 批量删除 ">
    </td>
    </tr>
    </table>
   
</form>




 
<%
		 

	End Sub 
%>

<script language="JavaScript" type="text/javascript">
 
function CheckAll(form)
		  {  
		 for (var i=0;i<form.elements.length;i++)  
			{  
			   var e = Article.elements[i];  
			   if (e.name != 'ChkAll'&&e.type=="checkbox")  
			   e.checked = Article.ChkAll.checked;  
		   }  
	  }
</script>
  
</div>
</body>
</html>
