<!--#include file="../fy.Function.asp"-->
<!--#include file="fy.UM.ASP"-->
<!--#include file="../../Field.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>会员修改/添加 By Act</title>
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/content.css">
 <SCRIPT LANGUAGE='JavaScript'>
 var fyuser="<%=fycms.strToAsc(RSQL(Trim(Request.Cookies(fycmsN)("AdminName"))))%>";
var fypass="<%=fycms.strToAsc(RSQL(Trim(Request.Cookies(fycmsN)("AdminPassword"))))%>";
</SCRIPT>
<!--#include file="../../editor/index.asp"-->
<%=writejs("../../")%>
<script type="text/javascript" src="../../fy_inc/js/jquery.js"></script>
<script type='text/javascript' src='../../fy_inc/js/time/WdatePicker.js'></script>
<script type="text/javascript" src="../../fy_inc/js/swfobject.js"></script>
<script type='text/javascript' src='../../fy_inc/js/lhg/lhgdialog.min.js'></script>
<script type='text/javascript' src='../js/main.js'></script>
</head>
<body>
<%  If Not fycms.ChkAdmin() Then   Call fycms.Alert("对不起，你没有操作权限！","")
	dim sqlUser,rsUser,UserName,Province,city,locked,realName,Sex,Email,IF_NULL,i,rs,ChargeType
	dim Birthday,Mobile,HomeTel,QQ,MSN,address,postcode,myface,GroupID,Score,A,Password,RPassWord,BeginDate,EDays,Point,Money
	dim Action,UserID,UModeID,templetsid
	Action = Request("Action")
	UserID=ChkNumeric(Request("UserID"))
	UModeID=ChkNumeric(Request("UModeID"))
	if UModeID=0  Then UModeID=1
	Select Case Action
			Case "Edit","Add"
 				Call AddEdit()
			Case "AddSave"
				Call ESave
			Case "ESave"
				Call ESave
			Case "del"
				Call Del()
 			Case Else
				Call AddEdit()
	End Select
 
	sub ESave()
	
			UserID=ChkNumeric(request("UserID"))
			 
			Set rs=fycms.actexe("select UModeID from user_fy where userid="&userid)
			If Not rs.eof Then UModeID=rs("UModeID")
			Password  = Trim(request("Password"))
			RPassWord= Trim(request("RPassWord"))
  			Sex       = Trim(Request("Sex"))
			Email     = Trim(request("Email"))
 			QQ        = Trim(request("QQ"))
			MSN       = Trim(request("MSN"))
			GroupID   = ChkNumeric(request("GroupID"))
			locked    = Trim(request("locked"))
 			ChargeType=ChkNumeric(Trim(request("ChargeType")))
			Score=ChkNumeric(Trim(request("Score")))
			BeginDate=Trim(request("BeginDate"))
			EDays=ChkNumeric(Trim(request("EDays")))
			Point=ChkNumeric(Trim(request("Point")))
			Money=ChkNumeric(Trim(request("Money")))
			templetsid=ChkNumeric(Trim(request("templetsid")))
  			province= Request("prov")
			city=     Request("city")
			UserName=Trim(request("UserName"))
			RealName=Trim(request("RealName"))
			Address=Trim(request("Address"))
 			BirthDay=Trim(request("BirthDay"))
 			HomeTel=Trim(request("HomeTel"))
			Mobile=Trim(request("Mobile"))
			postcode=Trim(request("postcode"))

			
			IF_NULL=fycms.Act_MX_Arr(UModeID,2)
			If IsArray(IF_NULL) Then
			For I=0 To Ubound(IF_NULL,2)
			 If IF_NULL(2,I)=0 And Trim(fycms.S(IF_NULL(0,I)))="" Then  Call  fycms.ALERT(IF_NULL(1,I)&"不能为空","")
			Next
			End If
 			Set rsUser=Server.CreateObject("Adodb.RecordSet")
			sqlUser="select * from User_fy where UserID=" & UserID
			rsUser.Open sqlUser,Conn,1,3
			if   rsUser.eof Then
				if UserName="" then
 					Call fycms.Alert("姓名不能为空","")
				end if
  				rsUser.addnew
				rsUser("UModeID")=UModeID
				rsUser("UserName")=UserName
			end if
 
			if Password<>RPassWord then
 				Call fycms.Alert("密码和确认密码不一致","")
			end if
			if Sex="" then
 				Call fycms.Alert("性别不能为空","")
			end if
			if Email<>"" and  fycms.IsValidEmail(Email)=false then
					Call fycms.Alert("您的Email有错误","")
 			end if
			
		
			if GroupID="" then
 				Call fycms.Alert("请指定用户级别！","")
			else
				GroupID=CLng(GroupID)
			end if
			if locked<>0 then locked=1
 			
			if   IsDate(BeginDate)=false then
				BeginDate=now
			end if
 			
			if  IsDate(BirthDay)=false then
				BirthDay=now
			end if
 			rsUser("RealName")=RealName
			if Password<>"" then
				rsUser("Password")=md5(Password,64)
			end if
  			rsUser("BeginDate")=BeginDate
 			rsUser("EDays")=EDays
 			rsUser("Point")=Point
 			rsUser("Money")=Money
 			rsUser("Email")=Email
			rsUser("Sex")=Sex
			rsUser("GroupID")=GroupID
			rsUser("locked")=locked
 			rsUser("Birthday")=Birthday
			rsUser("province")=province
			rsUser("ChargeType")=ChargeType
			rsUser("Score")=Score
			rsUser("templetsid")=templetsid
			

			rsUser("Mobile")=Mobile
			rsUser("HomeTel")=HomeTel
			rsUser("QQ")=QQ
			rsUser("MSN")=MSN
			rsUser("Mobile")=address
			rsUser("address")=Mobile
			rsUser("postcode")=postcode
		 

			rsUser("City")=City
 			rsUser.update
			

			Set rs=fycms.actexe("Select top 1 UserID from User_fy  order by UserID desc")
			If Not rs.eof Then UserID = rs("UserID")


		  Set RS=Server.CreateObject("Adodb.RecordSet")
		  RS.Open "Select * From "&fycms.ACT_U(UModeID,2)&" Where UserID=" & UserID & "",Conn,1,3
		  If RS.eof Then 
			  fycms.ACTEXE("insert Into "&fycms.ACT_U(UModeID,2)&"(UserID) values("&UserID&")")
			  rs.Close
			  RS.Open "Select * From "&fycms.ACT_U(UModeID,2)&" Where UserID=" & UserID & "",Conn,1,3
 		  End If
 		  	rs("myface")=Trim(request("myface")) 
			rs("UserName")=UserName
			rs("RealName")=Trim(request("RealName"))
			rs("GroupID")=GroupID 
			 If IsArray(IF_NULL) Then
 				For I=0 To Ubound(IF_NULL,2)
 					If IF_NULL(3,I)="NumberType" Then 
						   If fycms.regexField(fycms.S(IF_NULL(0,I)),"^\d+$")=True Then 
							   rs("" & IF_NULL(0,I) & "" )= fycms.S(IF_NULL(0,I))
						   End If 
					ElseIf IF_NULL(3,I)="DateType" Then 
						If IsDate(fycms.S(IF_NULL(0,I)))=False Then 
							rs("" & IF_NULL(0,I) & "")= Now()
						Else 
							rs("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
						End If
					ElseIf IF_NULL(4,I)="1" Then 
 							 rs("" & IF_NULL(0,I) & "")= fycms.AField(IF_NULL(5,I))
					ElseIf IF_NULL(4,I)="2" Then 
							If fycms.regexField(fycms.S(IF_NULL(0,I)),IF_NULL(5,I))=True Then 
								rs("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
							Else 
								Call fycms.Alert(IF_NULL(6,I),"")
 							End If 
  					Else 
						rs("" & IF_NULL(0,I) & "")=fycms.S(IF_NULL(0,I))
					End If 


 
					actField=""
 				Next
			 End If			
		    rs.Update
			
			
			rsUser.Close
			set rsUser=Nothing
			Call fycms.InsertLog(UserName,3,"对模型ID "&UModeID&" 的会员ID "&UserID&" 进行修改操作",Request.ServerVariables("QUERY_STRING"))
			Call fycms.Alert("恭喜您，操作成功！请按确定返回！","index.asp?ModeID="&UModeID&"")
	
	end sub 



 	Sub AddEdit() 
	if Action="Edit" Then
		UserID=ChkNumeric(fycms.S("UserID"))
		if UserID=0 then call fycms.Alert("非法提交参数!","")
		Set rsUser=Server.CreateObject("Adodb.RecordSet")
		sqlUser="select * from User_fy where UserID=" & UserID
		rsUser.Open sqlUser,Conn,1,3
		UserName=rsuser("UserName")
		Province=rsUser("Province")
		city=rsUser("city")
		locked=rsUser("locked")
		realName=rsUser("realName")
		Sex=rsUser("Sex")
	    GroupID=rsUser("GroupID")
		Email=rsUser("Email")
 		Score=rsUser("Score")
		Birthday=rsUser("Birthday")
		Mobile=rsUser("Mobile")
		HomeTel=rsUser("HomeTel")
		QQ=rsUser("QQ")
		MSN=rsUser("MSN")
		address=rsUser("address")
		postcode=rsUser("postcode")
		myface=rsUser("myface")
		UModeID=rsUser("UModeID")
		BeginDate=rsUser("BeginDate")
		EDays=rsUser("EDays")
		Point=rsUser("Point")
		Money=rsUser("Money")
		ChargeType=rsUser("ChargeType")
		templetsid=rsUser("templetsid")
		A="ESave"
 	Else
		A="AddSave"
		UModeID=1:sex=1:GroupID=3:ChargeType=1:templetsid=1
	end if%>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 添加/修改</div>
    <div class="opers">
    <A href="?UModeID=1" class="btn">所有用户</A>
<A href="fy.e.asp?UModeID=1" class="btn btn_primary">添加用户</A>
<A href="index.asp?UserSearch=1" class="btn ">被锁住的用户</A>
<A href="index.asp?UserSearch=2" class="btn ">待审批会员</A>
<A href="index.asp?UserSearch=3" class="btn ">待邮件验证</A>
<A href="index.asp?UserSearch=4" class="btn ">24小时内登录</A>
<A href="index.asp?UserSearch=5" class="btn ">24小时内注册</A>
    </div>

 <form  name="fycmsfrom"   method="post" action="?Action=<%= A %>&UserID=<%= UserID %>&UModeID=<%=UModeID%>">
    <div class="divtable"> 
        <dl>
            <dt>用户名称：</dt>
            <dd>
               <input name="UserName" type="text"  class="Ainput"   value="<%= UserName %>" size="30" /> 
            </dd>
         </dl>
        
        <dl>
            <dt>用户状态：</dt>
            <dd>
               <input type="radio" name="locked" id="locked1" value="0" <%if locked=0 then echo "checked"%>>
        <label for="locked1"><font color="green">正常</font></label>&nbsp;&nbsp;
       <label for="locked2"><input type="radio" name="locked" id="locked2" value="1" <%if locked=1 then echo "checked"%>>
        <font color="red">锁定</font></label>
             </dd>
         </dl>
        <dl>
            <dt>计费方式：</dt>
            <dd>
               <label for="ChargeType1"><input type="radio" name="ChargeType" id="ChargeType1" value="1"  <%if ChargeType=1 then echo "checked"%>>
        <font color="green">扣点数（推荐）</font></label>
       <!-- <label for="ChargeType2"> <input type="radio" name="ChargeType" id="ChargeType2" value="2" <%if ChargeType=2 then echo "checked"%>>
        <font color="blue">有效期</font></label>      
 -->      <label for="ChargeType3"> <input type="radio" name="ChargeType" id="ChargeType3" value="3" <%if ChargeType=3 then echo "checked"%>>
        <font color="red">无限期</font></label>  
             </dd>
         </dl>
        <dl>
            <dt>用户<%=fycms.fycms_Sys(24)%>：</dt>
            <dd>
               <input name="Point" type="text"  class="Ainput"   value="<%= Point %>" size="30" />
      用户资金：<input name="Money" type="text"  class="Ainput"   value="<%= Money %>" size="30" />
             </dd>
         </dl>
        <dl>
            <dt>真实姓名：</dt>
            <dd>
               <input name="realName" type="text"  class="Ainput"   value="<%= realName %>" size="30" />
             </dd>
         </dl>
        <dl>
            <dt>用户密码：</dt>
            <dd>
               <input name="PassWord" type="text"  class="Ainput"  value="" size="30" />
    <font color="#FF6600">如果不想修改，请留空</font>
             </dd>
         </dl>
        <dl>
            <dt>重复密码：</dt>
            <dd>
               <input name="RPassWord" type="text"  class="Ainput"  value="" size="30" />
    <font color="#FF6600">如果不想修改，请留空</font>
             </dd>
         </dl>
        <dl>
            <dt>用户性别：</dt>
            <dd>
               <INPUT type=radio value="0" name=sex id="sex1"  <%if Sex="0" then echo "CHECKED"%>>
        男</label> &nbsp;&nbsp;
        <label for="sex2"><INPUT type=radio value="1" name=sex id="sex2" <%if Sex="1" then echo "CHECKED"%>>
        女</label>
             </dd>
         </dl>
        <dl>
            <dt>用户等级：</dt>
            <dd>
               <select name="GroupID" id="GroupID">
 	<%=fycms.GroupOption_select(GroupID,UModeID)%>
     </select> 
             </dd>
         </dl>
        <dl>
            <dt>用户邮箱：</dt>
            <dd>
               <input name="Email" type="text"  class="Ainput"  value="<%= Email %>" size="30" />
             </dd>
         </dl>
        <dl>
            <dt>所在省市：</dt>
            <dd>
               <select name="prov" onChange="selectcityarea('prov','city','fycmsfrom');" style="width:110">
        <%if Province<>"" then%>
        <option  value="<%=Province%>" selected="selected"><%=Province%></option>
        <%else%>
        <option  value="" selected="selected">==请选择省份==</option>
        <%end if%>
      </select>
          <select name="city" style="width:110">
            <%if  city<>"" then%>
            <option  value="<%=city%>" selected="selected"><%=city%></option>
            <%else%>
            <option  value="" selected="selected">==请选择城市==</option>
            <%end if%>
          </select>
          <script language="javascript" src="<%=fycms.ActSys%>fy_inc/Province.js"></script>
             </dd>
         </dl>
        <dl>
            <dt>出生日期：</dt>
            <dd>
                <input name="Birthday" type="text" class="Ainput"  id="Birthday" size="30"  onClick="WdatePicker()"  value="<%=Birthday%>">
             </dd>
         </dl>
        <dl>
            <dt>手机：</dt>
            <dd>
               <input name="Mobile"  class="Ainput" type="text" id="Mobile" size="30"  value="<%=Mobile%>">
             </dd>
         </dl>
        <dl>
            <dt>电话：</dt>
            <dd>
               <input name="HomeTel"  class="Ainput"  type="text" id="HomeTel" size="30"  value="<%=HomeTel%>">
             </dd>
         </dl>
        <dl>
            <dt>QQ：</dt>
            <dd>
               <input name="QQ" class="Ainput"  type="text" id="QQ" size="30"  value="<%=QQ%>">
             </dd>
         </dl>
        <dl>
            <dt>MSN：</dt>
            <dd>
               <input name="MSN" class="Ainput"  type="text" id="MSN" size="30"  value="<%=MSN%>">
             </dd>
         </dl>
        <dl>
            <dt>地址：</dt>
            <dd>
               <input name="address"  class="Ainput"  type="text" id="address" size="30"  value="<%=address%>">
             </dd>
         </dl>
        <dl>
            <dt>邮编：</dt>
            <dd>
               <input name="postcode" class="Ainput"  type="text" id="postcode" size="30"  value="<%=postcode%>"> 
             </dd>
         </dl>
        <dl>
            <dt>会员点数：</dt>
            <dd>
               <input name="Score" type="text"  class="Ainput"  value="<%= Score %>" size="30"    />
             </dd>
         </dl>

        <dl>
            <dt>模版空间：</dt>
            <dd>
 			   <select name="templetsid" id="templetsid">
				<%= fycms.userspace(templetsid) %>
			    </select>
             </dd>
         </dl>




       <dl class="merger" >
            <dt>扩展信息</dt> <dd></dd>
          </dl>


		   <%= U_M.ACT_MXEdit(UModeID,UserID) %>
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
                <a class="btn" href="javascript:void(0);" onclick="CheckForm()">重置</a>
            </dd>
         </dl>
        
    </div>
    </form>

<%end sub
%>
</div>

<SCRIPT language=javascript>
<!--
function CheckForm()
{ 

 
var form=document.fycmsfrom;
   if (form.UserName.value=='')
    { 
		alert("请输入用户名!");   
	  form.UserName.focus();    
	   return false;
    }
		  
	 if (form.PassWord.value!=form.RPassWord.value)   
	   {    
	     alert("两次输入的密码不一致!");   
		  form.PassWord.focus();   
		  return false;    
		  }
	   <%echo checkeditpost(UModeID,2)%>
	    form.submit();
        return true;
}

//-->
 
function insertHTMLToEditor(codeStr,I)
{
  	var oEditor = CKEDITOR.instances[I];
 	if ( oEditor.mode == 'wysiwyg' )
	{
 		oEditor.insertHtml( codeStr );
	}
	else
		alert( '未定义' );
}
	
 
 //-->

	</script>

</body>
</html>
