<%
dim subFunctionList, subFunctionAction, subFunctionRight
dim sright,name,pass1,pass2

subaction = Request("subaction")
if subaction = "add" then
	name = Request("name")
	pass1 = Request("pass1")
	pass2 = Request("pass2")
	if name <> "" then
		sql = "SELECT COUNT(*) FROM bg_adminUser WHERE name='"& name &"'"
		rs.Open sql,conn,1,1
		if not (rs.Eof and rs.Bof) then
			if rs(0) > 0 then
				errorMsg = "该操作员已经存在！"
			end if
		end if
		rs.Close

		if errorMsg = "" then
			if pass1 = pass2 then
				sright = replace(Request("right")," ","")
				if sright = "" then
					errorMsg = errorMsg & "请选择操作员权限！"
				else
					sql = "INSERT INTO bg_adminUser (name,pass,myright) VALUES ('"& name& "','"& MD5(pass1) &"','"& sright  &"')"
					conn.Execute(sql)
					errorMsg = errorMsg & "成功的添加了新操作员 "& name &"！"
				end if
			else
				errorMsg = errorMsg & "您输入的口令不正确！<br>"& vbCrLf &"请点击浏览器的“后退”按钮修改。"
			end if
		end if
	else
		errorMsg = errorMsg & "您没有输入帐号名称！<br>"& vbCrLf &"请点击浏览器的“后退”按钮修改。"
	end if
end if
if errorMsg <> "" then
	DisplayMessage errorMsg,True
end if
%>
<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF" align="center">
<form name="InfoEdit" action="functions.asp" method="post" onSubmit="return checkForm();">
<input type="hidden" name="action" value="<%=action%>">
<input type="hidden" name="subaction" value="add">
<input type="hidden" name="LOGINID" value="<%=LOGINID%>">
  <tr class="ListTableHeader">
    <td colspan="2" background="images/TableHeaderBg.gif" nowrap><b>添加新操作员：</b></td>
  </tr>
  <tr class="InputTableRow">
    <td align="right" width="14%">登录帐号：</td>
    <td width="86%"><input type="text" name="name" size="16" maxlength="10" class="ButtonEdit" value=""""> <font color="#FF0000">*</font></td>
  </tr>
  <tr class="InputTableRow">
    <td align="right">登录口令：</td>
    <td><input type="password" name="pass1" size="16" maxlength="16" class="ButtonEditPwd"></td>
  </tr>
  <tr class="InputTableRow">
    <td align="right">登录口令确认：</td>
    <td><input type="password" name="pass2" size="16" maxlength="16" class="ButtonEditPwd"></td>
  </tr>
  <tr class="InputTableRow">
    <td align="right" valign="top">操作权限：</td>
    <td>
      <table>
<%
for i = 0 to ubound(strMainFunction)
	response.write "        <tr><td bgcolor=""#C0C0C0"" colspan=""2""><b>"& strMainFunction(i) &"</b></td></tr>"& vbCrLf
    subFunctionList = split(strFunctionList(i),":")
    subFunctionAction = split(strFunctionAction(i),":")
	subFunctionRight = split(strFunctionRight(i),":")
	for j = 0 to Ubound(subFunctionList)
		response.write "        <tr><td bgcolor=""#EEEEEE""><input type=""checkbox"" name=""right"" value="""& subFunctionRight(j) &"""></td><td bgcolor=""#EEEEEE""><input style=""background-color:#cccc99; border-width:1;border-style:solid"" value="""& subFunctionList(j) &""" size=""12"" READONLY> </td></tr>"& vbCrLf
	next
next
%>
      </table>
    </td>
  </tr>
  <tr class="MainPageBar" height="26">
    <td align="center" colspan="2"><input type="submit" name="Submit" value=" 确 定 " class="ButtonReply"> &nbsp; <input type="reset" value=" 清 除 " class="ButtonReset"></td>
  </tr>
</form>
</table>
<script language="JavaScript">
<!--
  function checkForm()
  {
          if (document.InfoEdit.name.value.length == 0)
          {
                  alert("请输入管理员帐号！");
                  document.InfoEdit.name.focus();
                  return false;
          }
		  return true;
  }
//-->
</script>