<script LANGUAGE="JavaScript">
function check()
{
  if (document.Form1.username.value=="")
     {
      alert("请输入用户名！")
      document.Form1.username.focus()
      document.Form1.username.select()
      return
     }
  if (document.Form1.password.value=="")
     {
      alert("请输入密码！")
      document.Form1.password.focus()
      document.Form1.password.select()		
      return
     }
     document.Form1.submit()
}
</SCRIPT>
<!--#include file="top_m.asp" -->
<!--#include file="include/menu.asp"-->
<!--#include file="checkuserflag.asp"-->
<%call CheckUserFlag("31")

Set ObjAB = Server.CreateObject("dc_data100_v1_0.admin_user_power")
Set ObjDCW = Server.CreateObject("dc_data100_v1_0.C_A_Config")
main DataPathFile

function main(DataPathFile2)
%>
<center>
          <%
           if request("action")="editsave" then 
              ObjDCW.editsave_admin_user DataPathFile2
           elseif request("action")="add" then 
              call add()
           elseif request("action")="addsave" then 
              ObjDCW.addsave_admin_user DataPathFile2
           else
              call manager()
           end if
           %>
           <p><%=body%></p>
<%
end function

sub manager()
dim sql
dim rs
dim id
id=request("id")

ObjDCW.read_record D_data_Dep,DataPathFile,"A_Manage_Users","A_M_D_ID,A_M_U_User,A_M_U_Password,A_M_U_Power"," where A_M_U_ID=" & cstr(id)
rs=split(D_data_Dep(0),",")
%>
<script language="JavaScript">
<!--
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked; 
   }
  }
//-->
</script>
<table border=0 cellPadding=0 cellSpacing=0 width="96%">
  <tr>
    <td align="center">
      <form action="admin_user_ok.asp?action=editsave&id=<%=id%>" method="post" name="Form1">
      <table cellPadding=0 cellSpacing=0 width=100%>
      <tr> 
         <td align="left" height="28" colspan=2 bgcolor=#99ccff>&nbsp;&nbsp;管理员信息修改--</td>
      </tr>
      <tr> 
         <td width="29%" height="28" align="right">用&nbsp;户&nbsp;名：</td>
         <td width="71%"><font color="#FFFFFF">&nbsp;&nbsp;<input type=text name=username size="30" class="smallInput" value=<%=rs(1)%>>
         </font>
         </td>
      </tr>
      <tr>
         <td align="right" height="28">密&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
         <td>&nbsp;&nbsp;<input type=password name=password size="30" class="smallInput" value="<%=rs(2)%>">
         不修改密码，不用填写！</td>
      </tr>
      <tr>
        <td align="right" height="28">部　　门：</td>
        <td>&nbsp;            <select name="bumen" id="bumen">
<%user_depart_id=rs(0)
sql_str=" where A_M_D_company_id=" & Session("DC_Manage_CompanyID")
if Session("DC_Manage_DepartmentID")<>0 then
	sql_str=sql_str & " and A_M_D_ID=" & Session("DC_Manage_DepartmentID")
end if 
sql_str=sql_str & " order by A_M_D_ID asc"
ObjDCW.read_record D_data_Dep,DataPathFile,"A_Manage_Department","A_M_D_ID,A_M_D_Name",sql_str
MaxRecord=ubound(D_data_Dep)-1
for i=0 to MaxRecord step 1
	rs_d=split(D_data_Dep(i),",")
	response.write "<option value=""" & rs_d(0) & """"
	if rs_d(0)=user_depart_id then response.write "selected"
	response.write ">" & rs_d(1) & "</option>"
next
%>
                </select>
          <input name="oldpassword" type="hidden" id="oldpassword" value="<%=rs(2)%>">        </td>
      </tr>
      <tr> 
         <td align="left" height="28" colspan=2 bgcolor=#e8f4ff>　管理权限</td>
      </tr>
      <tr>
         <td colspan=2>
         <table width="97%" align="center">
           <tr><td>
<%ObjAB.admin_user_power_edit menu,rs(3)%>
         </td></tr></table>
         </td>
       </tr>
       <tr>
         <td colspan=2 height="28" align="center" bgcolor=#e8f4ff> 
         <input type="button" value="修  改"  class="smallInput" onclick=check() <%if rs(0)=0 then response.write "disabled" end if%>>&nbsp;&nbsp;&nbsp;&nbsp;<input name=chkall type=checkbox value=on onclick=CheckAll(this.form)>选择所有权限
         </td>
       </tr>
     </table>
	 </form>
   </td>
  </tr>
</table>
<%
end sub

sub add()
%>
<script language="JavaScript">
<!--
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked; 
   }
  }
//-->
</script>
<table border=0 cellPadding=0 cellSpacing=0 width="96%">
  <tr>
    <td align="center">
      <form action="admin_user_ok.asp?action=addsave&id=<%=id%>" method="post" name="Form1">
      <table cellPadding=0 cellSpacing=0 width=100%>
      <tr> 
         <td align="left" height="28" colspan=2 bgcolor=#99ccff><b>　添加管理员--</b></td>
      </tr>
      <tr> 
         <td width="29%" height="28" align="right">用&nbsp;户&nbsp;名：</td>
         <td width="71%"><font color="#FFFFFF">&nbsp;&nbsp;<input type=text name=username size="30">
         </font>         </td>
      </tr>
      <tr>
         <td align="right" height="28">密&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
         <td>&nbsp;&nbsp;<input type=text name=password size="30"></td>
      </tr>
      <tr>
        <td align="right" height="28">部　　门：</td>
        <td><font color="#FFFFFF">&nbsp;
            <select name="bumen" id="bumen">
<%sql_str=" where A_M_D_company_id=" & Session("DC_Manage_CompanyID")
if Session("DC_Manage_DepartmentID")<>0 then
	sql_str=sql_str & " and A_M_D_ID=" & Session("DC_Manage_DepartmentID")
end if 
sql_str=sql_str & " order by A_M_D_ID asc"
departM=ObjDCW.read_record(D_data_Dep,DataPathFile,"A_Manage_Department","A_M_D_ID,A_M_D_Name",sql_str)
MaxRecord=ubound(D_data_Dep)-1
for i=0 to MaxRecord step 1
	rs=split(D_data_Dep(i),",")
	response.write "<option value=""" & rs(0) & """>" & rs(1) & "</option>"
next
set departM=nothing
%>
                                                            </select>
        </font></td>
      </tr>
      <tr> 
         <td align="left" height="28" colspan=2 bgcolor=#e8f4ff><b>　管理权限</b></td>
      </tr>
      <tr> 
         <td height="20" colspan=2></td>
      </tr>
      <tr>
         <td colspan=2>
         <table width="97%" align="center">
           <tr><td>
         <%ObjAB.admin_user_power_add menu%>
         </td></tr></table>
         </td>
       </tr>
       <tr>
         <td colspan=2 height="28" align="center" bgcolor=#e8f4ff> 
         <input type="button" value="添  加"  class="smallInput" onclick=check()>&nbsp;&nbsp;&nbsp;&nbsp;<input name=chkall type=checkbox value=on onclick=CheckAll(this.form)>选择所有权限         </td>
       </tr>
     </table>
	 </form>
   </td>
  </tr>
</table>
<%
end sub
%>
</center>