<!--#include file="../ACT.Function.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>模型管理</title>
<link href="../Images/css1/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<% 	Dim Action,ModeID,Rs
	ModeID = ACTCMS.ChkNumeric(Request("ModeID"))
	If Not ACTCMS.ChkAdmin() Then   Call Actcms.Alert("对不起，你没有操作权限！","")
	Action = Request.QueryString("A")
	 if ModeID=0 or ModeID="" Then ModeID=1
	Select Case Action
		   Case "AddSave","ESave"
		   		Call AddSave()
			Case "Add","E"
				Call AddEdit()
			Case Else
				Call Main()
	End Select
	
	
	IF Action = "Del" Then
		IF ModeID  > 1 Then
			ACTCMS.ACTEXE("Delete From ModeUser_Act Where ModeID=" & ModeID)		
			Call Actcms.ActErr("删除模型成功&nbsp;&nbsp;<a href=User/Reg.MX.asp>点击这里返回管理首页</a>","2")
		Else
			Call Actcms.ActErr("系统定义的模型不允许删除","1")
		End IF
	End IF
	
	
	Sub AddSave()
		 Dim ModeName,ModeTable,sql,ChannelRS,ChannelRSSql,ModeNote,Template,RegCode
		 Dim UpfilesDir,RecyleIF
		 ModeName = ACTCMS.S("ModeName")
		 ModeTable = ACTCMS.S("ModeTable")&"_User_ACT"
		 ModeNote = ACTCMS.S("ModeNote")
		 Template = ACTCMS.S("Template")
		 RegCode = ACTCMS.S("RegCode")
		 IF ACTCMS.S("ModeName") = "" Then
		 	Call ACTCMS.Alert("模型名称为空!",""):Exit Sub
		 End if

		 if Action="AddSave" Then
			 IF ACTCMS.S("ModeTable") = "" Then
				Call ACTCMS.Alert("数据表为空!",""):Exit Sub
			 End if
			 If Not ACTCMS.ACTEXE("SELECT ModeName FROM ModeUser_Act Where ModeName='" & ModeName & "' order by ModeID desc").eof Then
				Call ACTCMS.Alert("系统已存在该模型名称!",""):Exit Sub
			 End if	
			 If Not ACTCMS.ACTEXE("SELECT ModeTable FROM ModeUser_Act Where ModeTable='" & ModeTable & "' order by ModeID desc").eof Then
				Call ACTCMS.Alert("系统已存在该数据表!",""):Exit Sub
			 End if	
			 Set ChannelRS = Server.CreateObject("adodb.recordset")
			  ChannelRSSql = "select * from ModeUser_Act"
			  ChannelRS.Open ChannelRSSql, Conn, 1, 3
			  ChannelRS.AddNew
		 	  ChannelRS("ModeTable") = ModeTable
			  ChannelRS("ModeName") = ModeName
			  ChannelRS("ModeNote") = ModeNote
			  ChannelRS("Template") = Template
			  ChannelRS("RegCode") = RegCode
			  ChannelRS.Update
			  ChannelRS.Close:Set ChannelRS = Nothing			
				 Sql="CREATE TABLE "&ModeTable&" ([UserID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"&_
				"GroupID SmallInt Default 0,"&_
				"[UserName] varchar(100),"&_
				"[password] varchar(100),"&_
				"LoginNumber int Default 0,"&_
				"ArticleNum int Default 0,"&_
				"ChargeType tinyint Default 0,"&_
				"Score int Default 0,"&_
				"Point int Default 0,"&_
				"Locked tinyint Default 0,"&_
				"Loginip varchar(50),"&_
				"RegDate datetime,"&_
				"LoginTime datetime,"&_
				"startdate datetime,"&_
				"EDays int Default 0,"&_
				"Email varchar(50),"&_
				"CheckNum varchar(16),"&_
				"Moneys Money,"&_
				"RealName varchar(50),"&_
				"sex tinyint Default 0,"&_
				"Province varchar(100),"&_
				"City varchar(50),"&_
				"Question varchar(50),"&_
				"Answer varchar(50),"&_
				"Birthday varchar(50),"&_
				"[note] varchar(250),"&_
				"Privacy tinyint Default 0"&_
				")"
			'SmallInt 整型,varchar(200)'文本,tinyint 字节, int Default 0 长整型
			ACTCMS.ACTEXE(sql)
			Call Actcms.ActErr("添加成功&nbsp;&nbsp;<a href=User/Reg.MX.asp>点击这里返回管理首页</a>","2")
		 
		 Else
		 	If Not ACTCMS.ACTEXE("SELECT ModeName FROM ModeUser_Act Where ModeID <>" & ModeID & " AND  ModeName='" & ModeName & "' order by ModeID desc").eof Then
				Call ACTCMS.Alert("系统已存在该模型名称-!",""):Exit Sub
			 End if	
			 Set ChannelRS = Server.CreateObject("adodb.recordset")
			  ChannelRSSql = "select * from ModeUser_Act Where ModeID=" &ModeID
			  ChannelRS.Open ChannelRSSql, Conn, 1, 3
			  if ChannelRS.eof then Call ACTCMS.Alert("错误!",""):Exit Sub
		 End if 
		  ChannelRS("ModeName") = ModeName
		  ChannelRS("ModeNote") = ModeNote
		  ChannelRS("Template") = Template
		  ChannelRS("RegCode") = RegCode
		  ChannelRS.Update
		  ChannelRS.Close:Set ChannelRS = Nothing	
		  Call Actcms.ActErr("修改成功&nbsp;&nbsp;<a href=User/Reg.MX.asp>点击这里返回管理首页</a>","")
	End Sub
	Sub Main()
	%>	
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
  <tr>
    <td class="bg_tr">您现在的位置：用户注册模型管理 &gt;&gt; 浏览</td>
  </tr>
  <tr>
    <td>当前模型： <a href="?A=Add">添加模型</a> | 导出内容模型 | 导入内容模型</td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
  <tr>
    <td align="center" class="bg_tr">用户组名称</td>
    <td align="center" class="bg_tr">表名</td>
    <td align="center" class="bg_tr">类型</td>
    <td align="center" class="bg_tr">描述</td>
	<td align="center" class="bg_tr">注册默认用户组</td>
    <td  align="center" class="bg_tr" nowrap>操作</td>
  </tr>
<% 
	  Set Rs =ACTCMS.ACTEXE("SELECT ModeID, ModeName,ModeTable, ModeNote  FROM ModeUser_Act order by ModeID asc")
	 If Rs.EOF  Then
	 	Response.Write	"<tr><td colspan=""6"" align=""center"">没有记录</td></tr>"
	 Else
		Do While Not Rs.EOF	
			 %>

  <tr  onMouseOver=overColor(this) onMouseOut=outColor(this)>
    <td align="center"><%= Rs("ModeName") %></td>
    <td align="center"><%= Rs("ModeTable") %></td>
    <td align="center"><% if Rs("ModeID")<2 Then Response.Write "<font color=red>系统</font>" Else  Response.Write "<font color=blue>自定义</font>"  %></td>
    <td align="center"><%= Rs("ModeNote") %></td>
    <td align="center">
	<%Dim rss		
		Set Rss = ACTCMS.ACTEXE("SELECT GroupSetting FROM Group_Act Where DefaultGroup=1 and  ModeID=" & Rs("ModeID") & " order by ModeID desc")
			 If rss.eof Then 
				response.write "<a href=""Group_Admin.asp""><font color=red>还未设置默认用户组</font></a>"
			 Else
				response.write Split(rss(0),"^@$@^")(0)
			 End if	
%>
	
	
	</td>
	<td align="center"><a href="Reg.M.ASP?A=L&ModeID=<%=Rs("ModeID")  %>">字段列表</a> ┆ <a href="?A=E&ModeID=<%=Rs("ModeID")  %>" >修改</a> ┆ <a href="?A=Del&ModeID=<%=Rs("ModeID")  %>"  onClick="{if(confirm('确定删除该模型吗?')){return true;}return false;}">删除</a></td>
  </tr>
  <% 
		
		Rs.movenext
		Loop
	End if	 %>
</table>	
	
	
<% 	
 
	End Sub
	Sub AddEdit()


	Dim FileFolder,ModeTable,ModeName,RegCode,ModeNote,A,Template
	if Action="Add" Then
	A="AddSave"
	Else
	Set Rs=server.CreateObject("adodb.recordset") 
	Rs.OPen "Select * from ModeUser_Act Where ModeID = "&ModeID&" order by ModeID desc",Conn,1,1
	ModeTable = Rs("ModeTable")
	ModeName = Rs("ModeName")
	ModeNote=Rs("ModeNote")
	RegCode=Rs("RegCode")
	Template=Rs("Template")
	A="ESave"
	end if
  %>
<form id="form1" name="form1" method="post" action="?A=<%= A %>&ModeID=<%= Request.QueryString("ModeID") %>">

  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
      <td colspan="2" class="bg_tr">您现在的位置：<a href="?">模型管理</a> &gt;&gt; 添加/修改 </td>
    </tr>
    <tr>
      <td height="25" align="right" class="td_bg">模型名称：&nbsp;&nbsp;</td>
      <td height="25" class="td_bg"><input name="ModeName" type="text" id="ModeName" value="<%=ModeName %>" /></td>
    </tr>
    <tr>
      <td height="25" align="right" class="td_bg">数据表名称：&nbsp;&nbsp;</td>
      <td height="25" class="td_bg"><input <% if A="ESave" then response.Write "disabled" %> name="ModeTable" type="text" id="ModeTable" value="<%= ModeTable %>" />
        <% if A<>"ESave" then response.Write "_User_ACT" %></td>
    </tr>

	<tr>
      <td height="25" align="right" class="td_bg">模型描述：&nbsp;&nbsp;</td>
      <td height="25" class="td_bg"><input name="ModeNote" type="text" id="ModeNote" value="<%= ModeNote %>" size="50" maxlength="250" />
        简单的描述.不能超过250个字符</td>
    </tr>

    <tr>
      <td height="25" align="right" class="td_bg">注册验证码：&nbsp;&nbsp;</td>
      <td height="25" class="td_bg">
	  <input  <% IF RegCode = 0 Then Response.Write "Checked" %> id="RegCode1" type="radio" name="RegCode" value="0">
        <label for="RegCode1">显示</label>
      <input  <% IF RegCode = 1 Then Response.Write "Checked" %> id="RegCode2"  type="radio" name="RegCode" value="1"> 
     <label for="RegCode2">不显示</label></td>
    </tr>
  

   	<tr>
      <td height="25" align="right" class="td_bg">用户空间：&nbsp;&nbsp;</td>
      <td height="25" class="td_bg">
	  <select name="Template" id="Template">
	<option <% IF Template = 0 Then Response.Write "selected=selected" %> value="0">个人用户空间</option>
	<option  <% IF Template = 1 Then Response.Write "selected=selected" %> value="1">企业用户空间</option>
</select>
	  
	  
        </td>
    </tr>

 <tr>
      <td align="right" class="td_bg">&nbsp;</td>
      <td class="td_bg"><input type=button onclick=CheckForm() class="ACT_btn"  name=Submit1 value="  保存  " />
      <input type="reset" name="Submit2" class="ACT_btn" value="  重置  " /></td>
    </tr>
  </table>
</form><br>

<% end sub  %>
<script language="JavaScript" type="text/javascript">

function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg1"
		Obj.bgColor="";
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg";
		Obj.bgColor="";
	}
}
function CheckForm()
{ var form=document.form1;
	
	 if (form.ModeName.value=='')
		{ alert("请输入模型名称!");   
		  form.ModeName.focus();    
		   return false;
		} 
	 if (form.ModeTable.value=='')
		{ alert("请输入数据表名称!");   
		  form.ModeTable.focus();    
		   return false;
		} 	    form.Submit1.value="正在提交数据,请稍等...";
		form.Submit1.disabled=true;
		form.Submit2.disabled=true;		
	    form.submit();
        return true;
	}
</script>

</body>
</html>
