<!--#include file="Config.asp" -->
<!--#include file="../inc/md5.asp"-->
<div class='menu'>&nbsp;编辑 &gt; 用户</div>
<%
eims = "User"
eTable = Prefix&eims
ListUrl = eims&"List.asp?eims="&eims
EditUrl = eims&"Edit.asp?eims="&eims
Mgt("p88") 'Cookies : Permission

UserName = Trim(Request.Form("UserName"))
PassWord = Trim(Request.Form("PassWord"))
'------------------------------------------------
Select Case action
Case "SaveAdd" '保存添加

If UserName = "" Then WtMsg("请填写用户")
Set Rs = Conn.Execute("Select * From ["&eTable&"] where UserName='"&UserName&"'")
If Not Rs.Eof Then WtMsg("已有相同用户")
'------------------------------------------------

If Len(UserName)<2 Or Len(UserName)>10 Then WtMsg("请正确输入用户，字符数2~10")
If Trim(Request.Form("eType")) = "" Then WtMsg("请选择用户类型")

If PassWord = "" Then WtMsg("请填写密码")
If Len(PassWord)<5 Or Len(PassWord)>20 Then WtMsg("请正确输入密码，字符数5~20")
	If PassWord <> "" or Trim(Request.Form("fPassWord")) <> "" Then
	If PassWord <> Trim(Request.Form("fPassWord")) Then WtMsg("两次输入的密码不一致")
End If
'------------------------------------------------
Set Rs=Server.CreateObject("Adodb.RecordSet")
Rs.Open "Select * From ["&eTable&"]",Conn,1,3
Rs.AddNew
Rs("UserName")=UserName
Rs("PassWord")=Md5(PassWord)
Rs("RelName")=Trim(Request.Form("RelName"))
Rs("Tel")=Trim(Request.Form("Tel"))
Rs("QQ")=Trim(Request.Form("QQ"))
Rs("Mail")=Trim(Request.Form("Mail"))
Rs("eType")=Trim(Request.Form("eType"))
Rs("ItemNote")=Trim(Request.Form("ItemNote"))
Rs("Permission")=Trim(Request.Form("fPermission"))
Rs("ItemRec")=Trim(Request.Form("ItemRec"))
Rs("AddDate")=Now()
Rs.Update
Response.Redirect "Redirect.asp?eims="&eims&"&eType="&Int(Request("eType"))&"&SortID="&SortID&"&ItemID="&Rs("ItemID")
Rs.Close:Set Rs=Nothing
Response.End
Case "SaveMod" '保存修改
'------------------------------------------------
If UserName = "" Then WtMsg("请填写用户")
Set Rs = Conn.Execute("Select Count(ItemID) From ["&eTable&"] where UserName='"&UserName&"' and ItemID<>"&ItemID)
If Rs(0)>0 Then WtMsg("已有相同用户")

If Len(UserName)<2 Or Len(UserName)>10 Then WtMsg("请正确输入用户，字符数2~10")
If Trim(Request.Form("eType")) = "" Then WtMsg("请选择用户类型")

If PassWord <> "" Then
	If Len(PassWord)<5 Or Len(PassWord)>20 Then WtMsg("请正确输入密码，字符数5~20")
End If
If PassWord <> "" or Trim(Request.Form("fPassWord")) <> "" Then
	If PassWord <> Trim(Request.Form("fPassWord")) Then WtMsg("两次输入的密码不一致")
End If
'------------------------------------------------
Set Rs=Server.CreateObject("Adodb.RecordSet")
Rs.Open "Select * From ["&eTable&"] Where ItemID="&ItemID,Conn,1,3
Rs("UserName")=UserName
If PassWord<>"" Then Rs("PassWord")=Md5(PassWord)
Rs("RelName")=Trim(Request.Form("RelName"))
Rs("Tel")=Trim(Request.Form("Tel"))
Rs("QQ")=Trim(Request.Form("QQ"))
Rs("Mail")=Trim(Request.Form("Mail"))
Rs("eType")=Trim(Request.Form("eType"))
Rs("ItemNote")=Trim(Request.Form("ItemNote"))
Rs("Permission")=Trim(Request.Form("fPermission"))
Rs("ItemRec")=Trim(Request.Form("ItemRec"))
Rs("EditDate")=Now()
Rs.Update
Rs.Close:Set Rs=Nothing
Response.Redirect "Redirect.asp?eims="&eims&"&eType="&Int(Request("eType"))&"&SortID="&SortID&"&ItemID="&ItemID
Response.End
Case "Edit" '显示数据
SaveStr="SaveMod"
Set Rs=Server.CreateObject("Adodb.RecordSet")
Rs.Open "Select * From ["&eTable&"] Where ItemID="&ItemID,Conn,1,1
If Not Rs.Eof Then
UserName=Trim(Rs("UserName"))
RelName=Trim(Rs("RelName"))
Tel=Trim(Rs("Tel"))
QQ=Trim(Rs("QQ"))
Mail=Trim(Rs("Mail")) 
eType=Trim(Rs("eType"))
ItemNote=Trim(Rs("ItemNote"))
fPermission=Trim(Rs("Permission"))
End If
Rs.Close:Set Rs=Nothing
End Select
'------------------------------------------------
if SaveStr="" then SaveStr="SaveAdd"

%>
<div class="content">
<Form name='eForm' method='post' action='?action=<%=SaveStr%>&ItemID=<%=ItemID%>'>
  <table width="100%" border="0" cellspacing="1" cellpAdding="1" align="center">
      <tr>
        <td align="center" width="12%">用户</td>
        <td><input name="UserName" type="text" value="<%=UserName%>"></td>
      </tr>
      <tr>
        <td align="center">用户类型</td>
        <td><select name='eType'>
            <option value=''>=请选择=</option>
            <option value='3' <%If eType="3" Then Response.Write "selected"%>>前台注册</option>
			<option value='2' <%If eType="2" Then Response.Write "selected"%>>特别用户</option>
            <option value='1' <%If eType="1" Then Response.Write "selected"%>>后台管理</option>
          </select></td>
      </tr>
      <tr>
        <td align="center">密码</td>
        <td><input name="PassWord" type="password">
          <%If action="Edit" Then Response.Write "<font color='red'>不填写则不修改</font>"%></td>
      </tr>
      <tr>
        <td align="center">确认密码</td>
        <td><input name="fPassWord" type="password">
          <%If action="Edit" Then Response.Write "<font color='red'>不填写则不修改</font>"%></td>
      </tr>
      <tr>
        <td align="center">真实姓名</td>
        <td><input name="RelName" type="text" value="<%=RelName%>"></td>
      </tr>
      <tr>
        <td align="center">联系电话</td>
        <td><input name="Tel" type="text" value="<%=Tel%>"></td>
      </tr>
      <tr>
        <td align="center">Q Q</td>
        <td><input name="QQ" type="text" value="<%=QQ%>"></td>
      </tr>
      <tr>
        <td align="center">电子邮箱</td>
        <td><input name="Mail" type="text" value="<%=Mail%>"></td>
      </tr>
      <tr>
        <td align="center">用户权限</td>
        <td>
		<p style=" margin:8px 0; background:#f0f0f0; padding:3px;"><strong>权限等级：</strong>
		<input type="checkbox" name="fPermission" value="a" <%if instr(fPermission,"a")>0 then response.write "checked"%> onClick="display('pid')">超级管理员 
		<font color="red">* 超级管理员有所有权限，下列权限分配只有添加和修改权限。</font></p>
		<div id="pid"  <%if instr(fPermission,"a")>0 then response.write "style='display:none'"%>>
		系统相关：<input type="checkbox" name="fPermission" value="p01" <%if instr(fPermission,"p01")>0 then response.write "checked"%>>
		文章管理：<input type="checkbox" name="fPermission" value="p10" <%if instr(fPermission,"p10")>0 then response.write "checked"%>>
		产品管理：<input type="checkbox" name="fPermission" value="p11" <%if instr(fPermission,"p11")>0 then response.write "checked"%>>
		下载管理：<input type="checkbox" name="fPermission" value="p12" <%if instr(fPermission,"p12")>0 then response.write "checked"%>>
		案例管理：<input type="checkbox" name="fPermission" value="p13" <%if instr(fPermission,"p13")>0 then response.write "checked"%>><br>
		招聘管理：<input type="checkbox" name="fPermission" value="p14" <%if instr(fPermission,"p14")>0 then response.write "checked"%>>
		链接管理：<input type="checkbox" name="fPermission" value="p15" <%if instr(fPermission,"p15")>0 then response.write "checked"%>>
		广告管理：<input type="checkbox" name="fPermission" value="p16" <%if instr(fPermission,"p16")>0 then response.write "checked"%>>
		用户管理：<input type="checkbox" name="fPermission" value="p88" <%if instr(fPermission,"p88")>0 then response.write "checked"%>>
		数据相关：<input type="checkbox" name="fPermission" value="p99" <%if instr(fPermission,"p99")>0 then response.write "checked"%>>
		</div>
		</td>
      </tr>
      <tr>
        <td align="center">备注</td>
        <td><textarea name="ItemNote" style="width:680px;height:200px;visibility:hidden;"><%=ItemNote%></textarea></td>
      </tr>
      <tr bgcolor="#FFFFFF">
        <td></td>
        <td align="left"><input type="submit" name="Submit" value="保 存">
          &nbsp;&nbsp;
          <input type="button" value="返 回" onClick="history.go(-1);"></td>
      </tr>    
  </table>
</Form>
  <br>
</div>
<br>
</body></html>
<%Call CloseConn()%>
