<% userPageRights="{mail}" %>
<!--#include file="check.asp"-->
<!--#include file="../Include/Char.asp" -->
<!--#include file="../MailList/MailListConst.asp" -->
<%
'Define Variable 
dim i
dim rs
dim mGrade,mSql,mFlag,mBgColor

'initialization 
mFlag=true'add

'Display
if request("action")="edit" then 
  mSql="Select * From MailList_User Where F_ID="&Request.QueryString("ModifyID")
  Set rs=Conn.Execute(mSql)
  If not rs.Eof then
    mUserName = rs("F_UserName")
    mEmail = rs("F_Email")
	mUserGroupID = rs("F_UserGroupID")
	mIsTake = rs("F_IsTake")
	mTakeContent = rs("F_TakeContent")
	mMemo = rs("F_Memo")
    rs.Close
  End if
  mFlag=false
end if

if Request.ServerVariables("REQUEST_METHOD")="POST" then
  mUserName = checkStr(Trim(Request.Form("txtUserName")))
  mEmail = checkStr(Trim(LCase(Request.Form("txtEmail"))))
  mUserGroupID = Request.Form("selUserGroupID")
  if Request.Form("chkIsTake")="1" then mIsTake = 1 else mIsTake =0
  mTakeContent = checkStr(Trim(Request.Form("txtTakeContent")))
  mMemo = checkStr(Trim(Request.Form("txtMemo")))
  if Request("action")="Insert" then
    mSql = "Insert Into MailList_User(F_UserName,F_Email,F_UserGroupID,F_IsTake,F_TakeContent,F_Memo,F_IPInfo,F_Addtime)"
	mSql = mSql + "Values('"&mUserName&"','"&mEmail&"',"&mUserGroupID&","&mIsTake&",'"&mTakeContent&"','"&mMemo&"','"&Request.ServerVariables("REMOTE_ADDR")&"','"&now()&"')"
    conn.Execute(mSql)
    response.redirect "Admin_MailUser.asp?action=IsInsert"
  else
    mSql = "Update MailList_User Set F_UserName='"&mUserName&"',F_Email='"&mEmail&"',F_UserGroupID="&mUserGroupID&",F_IsTake="&mIsTake&",F_TakeContent='"&mTakeContent&"',F_Memo='"&mMemo&"'"
	mSql = mSql+" Where F_ID="&Request("ModifyID")
    conn.Execute(mSql)
    response.redirect "Admin_MailUser.asp?action=IsModify&pageno="&Request("pageno")
  end if
End if

'Delect Records
if request("action")="Delete" then
  mSql = "DELETE FROM MailList_User WHERE F_ID=" &Request.QueryString("DeleteID")
  conn.execute mSql
  Response.write "<script>location.replace('Admin_MailUser.asp?action=IsDelete&pageno="&Request.Querystring("pageno")&"')</script>"
end if
%>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Images/Style.css" rel="stylesheet" type="text/css">
<SCRIPT language="JavaScript">
function jDelete(url)
{
  if((confirm(" 警告:请确定是否删除,删除后不能恢复! "))==true) 
	self.location=url+'&action=Delete';
}
</SCRIPT>
<script language="javascript">
function CheckData(){
  if (document.form1.txtUserName.value=="")
   {
    alert("对不起,用户名不能为空，请输入！");
	document.form1.txtUserName.focus();
	return false;
   }
  if (document.form1.txtEmail.value=="")
   {
    alert("对不起,Email不能为空，请输入！");
	document.form1.txtEmail.focus();
	return false;
   }

}
</script>
</head>
<body text="#000000" >

<br>
<table class=tableBorder width="95%" border=0 align="center" cellpadding=5 cellspacing=1>
  <tbody>
    <tr> 
      <th height=21 colspan="2" sytle="line-height:150%">分类显示</th>
    </tr>
    <tr> 
      <td colspan="2"  class=forumRow><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
          <tr> 
            <td > 
              <%
			   Response.write "分类显示： "
               mSql="Select F_ID,F_Value from MailList_UserGroup"
               Set rs=conn.Execute(mSql)
			   Do While Not rs.Eof
			     Response.write "<a href='Admin_MailUser.asp?UserGroupID="&rs(0)&"'>"
			     Response.write rs(1)
				 Response.write "</a>"
				 Response.Write " | "
				 rs.MoveNext
			   Loop
		       Response.write "<a href='Admin_MailUser.asp'>全部</a>"
			   rs.close
			   %>
            </td>
          </tr>
        </table> </td>
    </tr>
  </tbody>
</table>
<br>
<table class=tableBorder width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
    <tr> 
          <th height=21 colspan="7" sytle="line-height:150%">邮件用户</th>
    </tr>
	    <tr style="cursor:hand" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#EBEEF6'"  bgcolor="#dde1ec" align="center"> 
          <td width="5%" height="11" class=forumHeaderBackgroundAlternate><b>ID</b></td>
          <td class=forumHeaderBackgroundAlternate width="12%"><b>用户名</b></td>
          <td class=forumHeaderBackgroundAlternate><b>邮件地址</b></td>
          <td class=forumHeaderBackgroundAlternate width="22%"><b>订(退)阅时间</b></td>
          <td class=forumHeaderBackgroundAlternate width="12%"><b>IP址址</b></td>
          <td class=forumHeaderBackgroundAlternate width="12%"><b>列表组别</b></td>
          <td class=forumHeaderBackgroundAlternate width="14%"><b>管理</b><a title="添加记录" href='Admin_MailUser.asp'><font color="#FFFFFF">[添加]</font></a></td>
        </tr>
      </table>
      <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#ebeef6">
        <%  
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request.querystring("pageno")
    pmcount=16  
	UserGroupID = Request.Querystring("UserGroupID")
    IF UserGroupID="" then
	  mSql="select * from MailList_User order by F_ID desc"
	Else
  	  mSql="select * from MailList_User Where F_UserGroupID="&UserGroupID&" order by F_ID desc"
    End if
	rs.open mSql,conn,1,1

	if rs.eof then
	   'response.write "<br><p  align='center'><font color=red><B> 对不起，数据已清空！</B></font></p>"
    else
    rs.pagesize=pmcount
    mpage=rs.pagecount
    if pageno="" then pageno=1
    if  cint(pageno)<1 or cint(pageno)>mpage then  pageno=1
    rs.absolutepage=pageno

 Dim rc,re
 rc=rs.pagesize
 re=1
 do while not rs.eof and rc>0
 mBgColor=Request.Querystring("BgColor")
 if Trim(rs("F_ID"))=Trim(mBgColor) then mColor= "D6DFFF" else mColor= "ffffff"
%>
        <tr bgcolor="<%=mColor%>"   onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#EBEEF6'" > 
          <td  width="5%" align="center"><%=rs("F_ID")%></td>
          <td width="12%" align="center" ><%=rs("F_UserName")%> </td>
          <td align="center" ><a href='MailSendManage.asp?Email=<%=rs("F_Email")%>'><%=rs("F_Email")%></a></td>
          <td width="22%" align="center" > 
            <%
			if rs("F_IsTake") then
			  response.write rs("F_Addtime")
			else
			  Response.write "<font color=red>"&rs("F_Addtime2")&"</font>"
			End if
			%>
          </td>
          <td width="12%" align="center" > 
            <%
			if rs("F_IsTake") then
			  Response.write rs("F_IPInfo")
			else
			  Response.write "<font color=red>"&rs("F_IPInfo2")&"</font>"
			end if
			%>
          </td>
          <td width="12%" align="center" > 
            <%
	        mSql = "Select F_Value From MailList_UserGroup Where F_ID=" & rs("F_UserGroupID")
      	    Set rst = conn.Execute(mSql) 
			if Not rst.Eof then Response.write rst(0)
			rst.Close
			%>
          </td>
          <td width="14%" align="center" ><a title="修改记录" href='Admin_MailUser.asp?action=edit&ModifyID=<%=rs("F_ID")%>&BgColor=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>'><font color="#666666">[修改]</font></a><a title="请确定是否删除,删除后不能恢复!" href="javascript:jDelete('Admin_MailUser.asp?DeleteID=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>')"><font color="#666666">[删除]</font></a> 
          </td>
        </tr>
        <%
 rs.movenext
 re=re+1
 rc=rc-1
 loop
 end if
%>
      </table>
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="FFFFFF">
        <tr> 
          <td width="38%" height="22"> &nbsp;共 <font color=red><strong>
            <% = rs.recordcount%>
            </strong></font> 条记录 当前第 <font color=red><strong>
            <% = Trim(pageno)%>
            </strong></font>页/共 <font color=red><strong>
            <% = Trim(mpage)%>
            </strong></font>页 </td>
          <td width="62%" align="right"> 
            <%
if pageno>1 then
   response.write "<a href='Admin_MailUser.asp?UserGroupID="&Request("UserGroupID")&"'> <img alt='首页' src='Images/boqb02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='首页' src='Images/boqb02.gif' border=0 width='15' height='14'>"
end if

if pageno>1 then
   response.write "<a href='Admin_MailUser.asp?UserGroupID="&Request("UserGroupID")&"&pageno="&pageno-1&"'><img alt='上一页' src='Images/bob02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='上一页' src='Images/bob02.gif' border=0 width='15' height='14'>"
end if

add=5'数字分页个数+1
if pageno-int(add/2)<=1 then m=1 else m=pageno-int(add/2)
if m+add>mpage then 
   n=mpage
   if mpage-add<=1 then m=1 else m=mpage-add
else
   n=m+add
end if

for pno=m to n
 if pno=cint(pageno) then
   response.write "&nbsp;<font color=red>"&pno&"</font>"
 else
   response.write "<b>&nbsp;<a href='Admin_MailUser.asp?UserGroupID="&Request("UserGroupID")&"&pageno="&pno&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='Admin_MailUser.asp?UserGroupID="&Request("UserGroupID")&"&pageno="&pageno+1&"'><img alt='下一页' src='Images/fbob02.gif' border=0 width='15' height='14'></a>"
else 
  response.write "<img alt='下一页' src='Images/fbob02.gif' border=0 width='15' height='14'>"
end if

if int(pageno) < int(rs.pagecount) then
   response.write "<a href='Admin_MailUser.asp?UserGroupID="&Request("UserGroupID")&"&pageno="&mpage&"'><img alt='末页' src='Images/fboqb02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='末页' src='Images/fboqb02.gif' border=0 width='15' height='14'>"
end if
Response.write "&nbsp;&nbsp;"
%>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<%if mFlag=true then'add%>
<br>
<table class=tableBorder  width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
          <tr> 
            <form name="form1" method="post" action="Admin_MailUser.asp?action=Insert" onSubmit="return CheckData()">
              <td valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
        
                  <tr> 
                    <td valign="top" bgcolor="fcfcfc">
					
					<table width="100%" border="0" cellspacing="1" cellpadding="2">
                     <tr> 
                    
                  <th height="22" colspan="7" align="center" sytle="line-height:150%">功能：新增记录</th>
                    </tr> 
					    <tr> 
                          <td class=forumRow width="12%" height="19">用 户 名：</td>
                          <td class=forumRowHighlight width="88%"><input name="txtUserName" type="text"  class="input"  value="" size="21" maxlength="20"></td>
                        </tr>
                        <tr> 
                          <td class=forumRow>邮件地址：</td>
                          <td class=forumRowHighlight><input name="txtEmail" type="text"  class="input" value="" size="21" maxlength="40"></td>
                        </tr>
                        <tr> 
                          <td class=forumRow>用 户 组： </td>
                          <td class=forumRowHighlight> 
						  <select name="selUserGroupID">
                          <%
						   mSql = "Select F_ID,F_Value From MailList_UserGroup"
						   Set rst = conn.Execute(mSql)
						   Do While Not rst.Eof
						     if Trim(UserGroupID) = Trim(rst("F_ID")) then
     				            response.write "<option value=" + cstr(rst("F_ID"))
                    			response.write " Selected"
                				response.write ">" + rst("F_Value")
                             else
                                response.write "<option value='" & rst("F_ID") &"'>"& rst("F_Value") &"</option>"
                             end if
						     rst.MoveNext
						   Loop
						   rst.Close
						   %>
                            </select> </td>
                        </tr>
                        <tr> 
                          <td class=forumRow>邮件订阅： </td>
                          <td class=forumRowHighlight><input type="checkbox" name="chkIsTake" value="1">
                            订阅的话，请打勾</td>
                        </tr>
                        <tr>
                          <td class=forumRow>订阅内容： </td>
                          <td class=forumRowHighlight><input name="txtTakeContent" type="text"  class="INPUT" value="" size="70"></td>
                        </tr>
                        <tr> 
                          <td class=forumRow>备　　注：</td>
                          <td class=forumRowHighlight><input name="txtMemo" type="text"  class="INPUT" value="" size="70"></td>
                        </tr>
                        <tr> 
                          <td class=forumRow height="37" colspan="2"><input type="submit" name="Submit3" value="提交" class="button"> 
                    <input type="reSet" name="Submit22" value="重置" class="button"></td>
                        </tr>
                      </table>
                      
                    </td>
                  </tr>
                </table></td>
            </form>
          </tr>
        </table>
        
<br>
<%else%>
<br>
<br>

            <form name="form1" method="post" action="Admin_MailUser.asp?pageno=<%=request("pageno")%>&ModifyID=<%=request("ModifyID")%>" onSubmit="return CheckData()">
                 <table class=tableBorder width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
                     <tr> 
                    
      <th height="22" colspan="7" align="center" sytle="line-height:150%">功能：修改记录</th>
                    </tr>    
			            <tr> 
                          <td class=forumRow width="12%" height="19">用 户 名：</td>
                          <td class=forumRow width="88%"><input name="txtUserName" type="text"  class="INPUT" value="<%=mUserName%>" size="21" maxlength="20"></td>
                        </tr>
                        <tr> 
                          <td class=forumRow>邮件地址：</td>
                          <td class=forumRow><input name="txtEmail" type="text"  class="INPUT" value="<%=mEmail%>" size="21" maxlength="40"></td>
                        </tr>
                        <tr> 
                          <td class=forumRow>用 户 组： </td>
                          <td class=forumRow> 
						  <select name="selUserGroupID">
                          <%
						   mSql = "Select F_ID,F_Value From MailList_UserGroup"
						   Set rst = conn.Execute(mSql)
						   Do While Not rst.Eof
						     if Trim(mUserGroupID) = Trim(rst("F_ID")) then
     				            response.write "<option value=" + cstr(rst("F_ID"))
                    			response.write " Selected"
                				response.write ">" + rst("F_Value")
                             else
                                response.write "<option value='" & rst("F_ID") &"'>"& rst("F_Value") &"</option>"
                             end if
						     rst.MoveNext
						   Loop
						   rst.Close
						   %>
                            </select> </td>
                        </tr>
                        <tr> 
                          <td class=forumRow>邮件订阅： </td>
                          <td class=forumRow><input name="chkIsTake" type="checkbox" value="1" <%if mIsTake=true then Response.write "checked"%>>
                            订阅的话，请打勾</td>
                        </tr>
                        <tr>
                          <td class=forumRow>订阅内容： </td>
                          <td class=forumRow><input name="txtTakeContent" type="text"  class="INPUT" value="<%=mTakeContent%>" size="70"></td>
                        </tr>
                        <tr> 
                          <td class=forumRow>备　　注：</td>
                          <td class=forumRow><input name="txtMemo" type="text"  class="INPUT" value="<%=mMemo%>" size="70"></td>
                        </tr>
                        <tr> 
                          <td class=forumRow height="37" colspan="2"><input type="submit" name="Submit" value="提交" class="button"> 
        <input type="reSet" name="Submit2" value="重置" class="button"></td>
                        </tr>
                      </table>
            
  <br>
</form>

        <%end if%>

</body>
</html>
<%
 rs.close
 CloseDatabase
%>