<!--#Include file="include/access.asp"-->
<!--#Include file="include/conn.asp"-->
<%'------获取操作项目标识
act=Request("act")
getConn()
'------修改类别
If act="modify" Then
  classId_form=Request.Form("classId")
  className_form=Trim(Request.Form("className"))
  Set classRs=conn.execute("select * from Class where UserName='" &session("userName")&"' and className= '"&className_form&"' and id<>"&classId_form&"")
  If Not classRs.Eof Then
    errmsg="类别已存在，请更换名称！"
    returnURL="JavaScript:History.Back()"
  Else
    conn.Execute("update Class set className= '"&className_form&"' where id="&classId_form&"")
	errmsg="类别修改成功！"
	returnURL="editClass.asp"
  End If
  Set classNameRs=Nothing
'------删除类别
ElseIf act="delete" Then
  classId_string=Request.QueryString("classId")
  '删除该类别的所有联系人
  conn.execute ("delete from MessageBook where UserName='" &session("userName")&"' and ClassId="&classId_string&"")
  '删除类别
  conn.execute ("delete from Class where id=" &classId_string&"")
  errmsg="类别删除成功！"
  returnURL="editClass.asp"
'------添加类别
ElseIf act="new" Then
  className_form=Trim(Request.Form("className"))
  Set classRs=conn.execute ("select * from Class where UserName='" &session("userName")&"' and className='" &className_form&"'")
  If Not classRs.Eof Then
    errmsg="类别已存在，请更换名称！"
	returnURL="javascript:history.back();"
  Else
    conn.execute("insert into Class(UserName,ClassName) values('"&session("userName")&"','"&className_form&"')")
	errmsg="类别添加成功！"
	returnURL="editClass.asp"
  End If
  Set classRs=Nothing
End If
Set conn=Nothing
%>
<HTMl>
<HEAD>
<META http-equiv="Refresh" content='1;URL=<%=returnURL%>'>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
<P align="center"><%=errmsg%>
</BODY>
</HTMl>
