<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_Manager.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    Dim oRs, Id, RoleId, RoleType, AdminName, AdminPass, IsLock
    Id = Easp.Get("id:n:0")
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    Set oRs = Easp.db.GR(TablePrefix & "Admin:Id,RoleId,RoleType,AdminName,AdminPass,IsLock:1", " Id = "& Id &" ", "")
    If Easp.IsN(oRs) Then
        CmsAdmin.JscriptMsg "不存在的数据！", "back", "Error", "null"
    Else
        RoleId = oRs("RoleId")
        AdminName = oRs("AdminName")
        AdminPass = oRs("AdminPass")
        IsLock = oRs("IsLock")
    End If
    Easp.C oRs
%>
<script src="<%=CmsAdminMapPath%>js/check/manager.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain" onsubmit="return CheckForm();">
  <input type="hidden" name="id" value="<%=Id%>" />
  <input type="hidden" name="ToUrl" value="<%=CmsFun.LoadToUrl()%>" />
  <div class="navigation"> <a href="Admin.Index.Asp" class="back">管理员管理</a>控制面板 &gt; 管理员管理 &gt; 编辑管理员 </div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">编辑管理员</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
        <col>
        <tbody>
          <tr>
            <th> 管理角色： </th>
            <td class="td2"><%=GetRoleList(RoleId, Easp.Cookie("ZjjCmsCms>RoleType"))%></td>
          </tr>
          <tr>
            <th> 用 户 名： </th>
            <td class="td2"><input type="text" name="AdminName" id="AdminName" class="txtInput w300"  maxlength="50" autocomplete="off" readonly="readonly" value="<%=AdminName%>" />
              <label>*,无法修改</label></td>
          </tr>
          <tr>
            <th> 登录密码： </th>
            <td class="td2"><input type="password" name="AdminPass" id="AdminPass" class="txtInput w300"  maxlength="50" autocomplete="off" value="0|0|0|0" />
              <label>*</label></td>
          </tr>
          <tr>
            <th> 确认密码： </th>
            <td class="td2"><input type="password" name="AdminPass1" id="AdminPass1" class="txtInput w300"  maxlength="50" autocomplete="off" value="0|0|0|0" />
              <label>*</label></td>
          </tr>
          <tr>
            <th> 帐号状态： </th>
            <td class="td2"><span id="rblIsLock">
              <input id="rblIsLock_0" type="radio" name="IsLock" value="0"<%=Easp.IIF(IsLock = 0," checked=""checked""","")%> />
              <label for="rblIsLock_0">启用 </label>
              <input id="rblIsLock_1" type="radio" name="IsLock" value="1"<%=Easp.IIF(IsLock = 1," checked=""checked""","")%> />
              <label for="rblIsLock_1">禁用 </label>
              </span></td>
          </tr>
          <tr>
            <th> </th>
            <td><input type="submit" value="提交保存" class="btnSubmit" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_manager", "edit"
    '=====================================================================
    Dim Id, RoleId, RoleType, AdminPass, AdminPass1
    Dim IsLock, oRs, ToUrl
    Id = Easp.Post("id:n:0")
    RoleId = Easp.Post("RoleId:n:0")
    AdminPass = Trim(Easp.Post("AdminPass:s"))
    AdminPass1 = Trim(Easp.Post("AdminPass1:s"))
    IsLock = Easp.Post("IsLock:n:0")
    ToUrl = Trim(Easp.Post("ToUrl:s"))
    '=====================================================================
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    If RoleId = 0 Then
        CmsAdmin.JscriptMsg "角色类型必须选择！", "back", "Error", "null"
    End If
    If Easp.IsN(AdminPass) Then
        CmsAdmin.JscriptMsg "登录密码必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(AdminPass1) Then
        CmsAdmin.JscriptMsg "确认密码必须填写！", "back", "Error", "null"
    End If
    If AdminPass <> AdminPass1 Then
        CmsAdmin.JscriptMsg "登录密码与确认密码不一致！", "back", "Error", "null"
    End If
    RoleType = Easp.db.RT(TablePrefix & "Admin_Role", " Id = "& RoleId &" ", "RoleType")
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("RoleId") = RoleId
    List("RoleType") = RoleType
    If AdminPass <> "0|0|0|0" Then
        List("AdminPass") = Easp.MD5(AdminPass)
    End If
    List("IsLock") = IsLock
    ResultVal = Easp.db.UR(TablePrefix & "Admin", " Id = "& Id &" ", List.Hash)
    '=====================================================================
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.JscriptMsg "编辑管理员成功！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Index.Asp", ToUrl), "Success", "null"
    End If
    '=====================================================================
End Sub
%>
