<!--#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()
%>
<script src="<%=CmsAdminMapPath%>js/check/manager.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain" onsubmit="return CheckForm();">
  <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(0, 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" onfocus="ChkEnNum(this)" />
              <label>*,添加后不可修改</label></td>
          </tr>
          <tr>
            <th> 登录密码： </th>
            <td class="td2"><input type="password" name="AdminPass" id="AdminPass" class="txtInput w300" maxlength="50" autocomplete="off" />
              <label>*</label></td>
          </tr>
          <tr>
            <th> 确认密码： </th>
            <td class="td2"><input type="password" name="AdminPass1" id="AdminPass1" class="txtInput w300" maxlength="50" autocomplete="off" />
              <label>*</label></td>
          </tr>
          <tr>
            <th> 帐号状态： </th>
            <td class="td2"><span id="rblIsLock">
              <input id="rblIsLock_0" type="radio" name="IsLock" value="0" checked="checked" />
              <label for="rblIsLock_0">启用 </label>
              <input id="rblIsLock_1" type="radio" name="IsLock" value="1" />
              <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", "add"
    '=====================================================================
    Dim RoleId, RoleType, AdminName, AdminPass, AdminPass1, IsLock, oRs
    RoleId = Easp.Post("RoleId:n:0")
    AdminName = Trim(Easp.Post("AdminName:s"))
    AdminPass = Trim(Easp.Post("AdminPass:s"))
    AdminPass1 = Trim(Easp.Post("AdminPass1:s"))
    IsLock = Easp.Post("IsLock:n:0")
    '=====================================================================
    If RoleId = 0 Then
        CmsAdmin.JscriptMsg "角色类型必须选择！", "back", "Error", "null"
    End If
    If Easp.IsN(AdminName) 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
    Set oRs = Easp.db.GR(TablePrefix & "Admin:Id:1", " AdminName = '"& AdminName &"' ", "")
    If Not Easp.IsN(oRs) Then
        CmsAdmin.JscriptMsg "已经存在用户名："& AdminName &"！", "back", "Error", "null"
    End If
    Easp.C oRs
    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
    List("AdminName") = AdminName
    List("AdminPass") = Easp.MD5(AdminPass)
    List("LoginTime") = Now()
    List("LoginIp") = Easp.GetIp()
    List("LoginNum") = 0
    List("IsLock") = IsLock
    List("AddTime") = Now()
    ResultVal = Easp.db.AR(TablePrefix & "Admin:id", List.Hash)
    '=====================================================================
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.JscriptMsg "添加管理员成功！", "Admin.Index.Asp", "Success", "null"
    End If
    '=====================================================================
End Sub
%>
