<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--#INCLUDE FILE="setup.asp" -->
<!--#INCLUDE FILE="checkuser.asp" -->
<!--#INCLUDE FILE="theme.asp" -->
<!--#INCLUDE FILE="include/char.asp" -->
<%
Dim Locate,Act
locat="个人资料修改"
Dim ErrMsg

if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=login.asp>登录</a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
Else
	Select Case Request("action")
	Case "update"
		Dim userpwd,question,answer
		Dim homepage,birthday
		%>
		<!--#INCLUDE FILE="include/chkmodinfo.asp"-->
		<%
		Call update()
		Call footer()
	Case "MakeWish"
		act="修改生日愿望"
		Call pagehead()
		Call modiform()
	Case "Modiwish"
		act="修改生日愿望"
		Call pagehead()
		Call modiwish()
	Case Else
		Call top(1,1)
		Call userinfo()
		Call footer()
	End Select
End if


Sub userinfo()

Dim Rs
Dim hp

Set Rs=Conn.Execute("Select * from student where userid='"&membername&"'")

hp=Rs("homepage")
if Rs("homepage")="" or isnull(Rs("homepage")) Then hp="http://"

%>
<script language=javascript>
function ShowPreview()
{
var selobj=document.userform.face;
var imgobj=document.images['face'];
if(selobj.selectedIndex==0)
	{imgobj.style.visibility="hidden";}
else
	{imgobj.style.visibility="visible";
	imgobj.src="face\/image"+selobj.options[selobj.selectedIndex].value+".gif";
	}
}
</SCRIPT>
<br><BR>
<FORM action="mymodify.asp" method=post name="userform" onsubmit="return submitonce(this);">
<input type=hidden name=action value=update>
<table cellpadding=0 cellspacing=0 border=0 width="100%" Class=TableBorder align=center>
        <tr>
            <td>
                <table cellpadding=4 cellspacing=1 border=0 width=100% Class=TableBorder>
  <TBODY>
  <TR align=middle >
    <Th colSpan=2 height=24>修改 <%=htmlencode(membername)%> 的个人资料</Th></TR>
  <TR>
    <TD colSpan=2 height=24 Class=DarkTableBody>&nbsp;<IMG SRC="IMAGES/2.gif" WIDTH="60" HEIGHT="9" BORDER=0 ALT="">::: 个人帐号信息 :::</TD></TR>  
  <TR Class=LightTableBody>
    <TD colspan=2><a href="../manage/User_ModifyPWD.asp"> 修改密码</a></TD>
</TR>
  <TR Class=LightTableBody>
    <TD width=150 height=32> &nbsp;密码提示</TD>
    <TD height=32 align=left><INPUT maxLength=50 size=27 readonly="only" name=question value="<%=Rs("question")%>" <%if sysadmin then response.write "disabled title=系统管理员不能使用此项功能"%>> 
      <font color=red>请到通行证处修改</font></TD></TR>
<TR Class=LightTableBody>
    <TD width=150 height=32> &nbsp;问题答案</TD>
    <TD height=32 align=left><INPUT maxLength=50 size=27 name=answer readonly="only" value="<%=Rs("answer")%>" <%if sysadmin then response.write "disabled title=系统管理员不能使用此项功能"%>><INPUT type=hidden name=oldanswer value="<%=Rs("answer")%>" > &nbsp;<font color=red>请到通行证处修改</font>取回密码答案采用了MD5加密，如要修改可直接填写。
      </TD></TR>

  <TR>
    <TD colSpan=2 height=24 Class=DarkTableBody>&nbsp;<IMG SRC="IMAGES/2.gif" WIDTH="60" HEIGHT="9" BORDER=0 ALT="">::: 个人基本信息 :::</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;真实姓名 **</TD>
    <TD align=left><INPUT type=text maxLength=4 size=27 name=realname value="<%=Rs("realname")%>"> 
    </TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;性&nbsp;&nbsp;&nbsp;&nbsp;别</TD>
    <TD align=left>			<input type="radio" name="sex" value=False <% if Rs("sex")=False Then Response.write "checked" %> >
			男孩 
			<input type="radio" name="sex" value=True <% if Rs("sex")=True Then Response.write "checked" %> >
			女孩
</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;生&nbsp;&nbsp;&nbsp;&nbsp;日 **</TD>
    <td nowrap height="26" align=left><input maxLength="4" name="year" size="4"  value=<%=year(Rs("birthday"))%>>&nbsp;年&nbsp;<input maxLength="2" name="month" size="2"  value=<%=month(Rs("birthday"))%>>&nbsp;月&nbsp;<input maxLength="2" name="day" size="2"  value=<%=day(Rs("birthday"))%>>&nbsp;日
    </TD></TR>

  <TR Class=LightTableBody>
    <TD width=150 height=32> &nbsp;形&nbsp;&nbsp;&nbsp;&nbsp;象</TD>
    <TD height=32 align=left>
               <Select name=face size=1 onChange="ShowPreview()" >
			   <option value=0>不使用</option>
<%for i=1 to 100
	response.write "<option value="&i
	if i=rs("imageid") Then response.write " selected"
	response.write ">Face"&i&"</option>"
next%>

      </Select>&nbsp;[<a href="javascript:openScript('Help.asp?About=portrait',500,500)">头像列表</a>]&nbsp;
	  <%
	  response.write "<img id=face "
	  if rs("imageid")<>0 then
	  response.write "src=""face/image"&rs("imageid")&".gif"""
	  else
	  response.write "style=""visibility:hidden"""
	  end if
	  response.write " alt=个人形象代表 width=24 height=24 align=absmiddle>"%>
	  </td>
  </TR>
  <TR>
    <TD colSpan=2 height=24 Class=DarkTableBody>&nbsp;<IMG SRC="IMAGES/2.gif" WIDTH="60" HEIGHT="9" BORDER=0 ALT="">::: 个人联系信息 :::</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150 height=32> &nbsp;电子邮件 **</TD>
    <TD height=32 align=left><INPUT maxLength=50 size=27 name=email readonly="only" value="<%=htmlencode(Rs("email"))%>">&nbsp;<input type="checkbox" name="isemailshow" value="1" <%if Rs("isemailshow")=False Then Response.write "checked"%>>保密
      <font color=red>请到通行证处修改</font></TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;QQ号码</TD>
    <TD align=left><INPUT maxLength=20 size=27 name=oicq value="<%=Rs("oicq")%>">&nbsp;<input type="checkbox" name="isoicqshow" value="1" <%if Rs("isoicqshow")=False Then Response.write "checked"%>>保密 </TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;MSN</TD>
    <TD align=left><input type="text" name="msn" size="27"  value="<%=Rs("msn")%>">&nbsp;<input type="checkbox" name="ismsnshow" value="1" <%if Rs("ismsnshow")=False Then Response.write "checked"%>>保密</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;主页地址</TD>
    <TD align=left><input name="homepage" size="55" value="<%=hp%>" value="<%=Rs("homepage")%>">&nbsp;<input type="checkbox" name="ishomepageshow" value="1" <%if Rs("ishomepageshow")=False Then Response.write "checked"%>>保密</td>
    </TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;联系电话</TD>
    <TD align=left><INPUT maxLength=20 size=27 name=telephone value="<%=Rs("telephone")%>"> 只能用数字和"-"</TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;移动电话</TD>
    <TD align=left><INPUT maxLength=11 size=27 name=mobilephone value="<%=Rs("mobilephone")%>"> </TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;工作单位</TD>
    <TD align=left><INPUT maxLength=20 size=55 name=workshop value="<%=Rs("workshop")%>"> </TD></TR>

	<TR Class=LightTableBody>
    <TD width=150> &nbsp;邮政编码</TD>
    <TD align=left><INPUT maxLength=6 size=27 name=zipcode value="<%=Rs("zipcode")%>"> </TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;通信地址</TD>
    <TD align=left><INPUT maxLength=20 size=55 name=address value="<%=Rs("address")%>"> </TD></TR>
  <TR>
    <TD colSpan=2 height=24 Class=DarkTableBody>&nbsp;<IMG SRC="IMAGES/2.gif" WIDTH="60" HEIGHT="9" BORDER=0 ALT="">::: 其它个人选项 :::</TD></TR>  

  <TR Class=LightTableBody>
    <TD width=150> &nbsp;人生格言<BR><BR>不能超过5行，<br>支持<font color=brown>UBB</font>标签，<br>
不能多于200个字符。 </TD>
    <TD><TEXTAREA name=maxim rows=5 wrap=PHYSICAL cols=55 value=""><%=Rs("maxim")%></TEXTAREA> 
    </TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;邮件通知</TD>
    <TD><%
	response.write "<input type=checkbox name=NewMemberFlag value=1"
	if Rs("NewMemberFlag")=True Then response.write " checked"
	if IntVar(5)="0" then Response.write " disabled"
	response.write ">"
	if IntVar(5)="0" then 
		response.write "<a disabled>新同学加入提醒</a>"
	else
		response.write "新同学加入提醒"
	end if
	response.write "&nbsp;&nbsp;<input type=checkbox name=NewAnnounceFlag value=1"
	if Rs("NewAnnounceFlag")=True Then Response.write "checked"
	if IntVar(5)="0" then Response.write " disabled"
	response.write ">"
	if IntVar(5)="0" then 
		response.write "<a disabled>新班级留言提醒</a>"
	else
		response.write "新班级留言提醒"
	end if
	response.write "&nbsp;&nbsp;<input type=checkbox name=NewFotoFlag value=1"
	if Rs("NewFotoFlag")=True Then Response.write "checked"
	if IntVar(5)="0" then Response.write " disabled"
	response.write ">"
	if IntVar(5)="0" then 
		response.write "<a disabled>新班级相片提醒</a>"
	else
		response.write "新班级相片提醒"
	end if

	%>

</TD></TR>

  <TR align=middle Class=DarkTableBody>
    <TD colSpan=2><DIV align=center><INPUT value="更新(U)" name=Submit type=submit accesskey="u" class=button>&nbsp;&nbsp;&nbsp;&nbsp; <INPUT type=reset value="重写(R)" name=Submit2 accesskey="r" class=button> 
</DIV></TD></TR>


</TBODY></TABLE></td></tr></table>
</FORM>
<%
End Sub



Sub update()
	
	Dim Rs,sql
	Dim ErrMsg
	if chkinput=False Then	
		Exit Sub
	End if

	Set Rs = Server.CreateObject("ADODB.Recordset")

	sql = "Select * from student where userid='"&membername&"'"
	Rs.open sql,Conn,1,3

	if Rs.eof and Rs.bof Then
		ErrMsg=ErrMsg+"<br>"+"<li>该用户名不存在！"
		Call top(1,1)
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if

	Rs("birthday")=birthday
	if userpwd<>"" Then Rs("userpwd")=userpwd
	if not sysadmin then 
		Rs("question")=question
		Rs("answer")=answer
	end if
	Rs("homepage")=homepage
	Rs("ishomepageshow")=Not Cbool(request("ishomepageshow"))
	Rs("realname")=trim(request.Form("realname"))
	Rs("imageid")=cint(request.form("face"))
	Rs("email")=trim(request.Form("email"))
	Rs("isemailshow")=Not Cbool(request("isemailshow"))
	Rs("oicq")=trim(request.Form("oicq")) 
	Rs("isoicqshow")=Not Cbool(request("isoicqshow"))
	Rs("msn")=trim(request.Form("msn"))
	Rs("ismsnshow")=Not Cbool(request("ismsnshow"))
	Rs("telephone")=trim(request.Form("telephone"))
	Rs("mobilephone")=trim(request.form("mobilephone"))
	Rs("workshop")=trim(Request.form("workshop"))
	Rs("zipcode")=trim(request.Form("zipcode"))
	Rs("maxim")=request.Form("maxim")
	Rs("address")=trim(request.Form("address"))
	if IntVar(5)<>"0" then
	Rs("NewMemberFlag")=Cbool(request("NewMemberFlag"))
	Rs("NewAnnounceFlag")=Cbool(request("NewAnnounceFlag"))
	Rs("NewFotoFlag")=Cbool(request("NewFotoFlag"))
	end if
	Rs("sex")=cbool(Request.form("sex"))
	Rs("point")=Rs("point")+PointSet(14)
	Rs.Update

	Rs.close
	Set Rs=Nothing
	if userpwd<>"" Then Response.cookies("fytxl")("fypasswd")=userpwd
	Call top(1,1)
	success "修改资料","您已经成功的修改了您的个人信息和个人选项。"

End Sub


Sub modiform()

	Dim BirRs
	Set BirRs=Conn.Execute("Select birthday,wish from student where userid='"&membername&"'")
	%>
	<table width=100% height=100% bgcolor=<%=BodyColor%>><tr><td valign=top>
	<FORM action="mymodify.asp" method=post name="wishform">
	<input type=hidden name=action value=Modiwish>
	<TABLE border=0 Class=TableBorder cellspacing=1 cellpadding=5>
	<TR bgcolor=<%=tabletitlecolor%>>
		<TD colspan=2><IMG SRC="IMAGES/wish.gif" WIDTH="27" HEIGHT="30" BORDER=0 Align=absmiddle>我的生日愿望</TD>
	</TR>
	  <TR Class=DarkTableBody>
		<TD align=left colspan=2>嗨！你可以修改你的生日和生日愿望，让大家知道你的Birthday Wish,让大家一起来分享你的快乐！</TD>
	</TR>
	  <TR Class=LightTableBody>
		<TD align=center>生日：</td><td><input maxLength="4" name="year" size="4" value=<%=year(BirRs(0))%>>&nbsp;年&nbsp;<input maxLength="2" name="month" size="2"  value=<%=month(BirRs(0))%>>&nbsp;月&nbsp;<input maxLength="2" name="day" size="2"  value=<%=day(BirRs(0))%>>&nbsp;日</TD>
	</TR>
	  <TR Class=LightTableBody>
		<TD align=center>愿望：</td><td><TEXTAREA name=wish rows=5 cols=35><%=BirRs(1)%></TEXTAREA> </TD>
	</TR>
	  <TR Class=DarkTableBody>
		<TD align=center colspan=2><INPUT type=submit value=修改 name=Submit class=button>&nbsp;&nbsp;&nbsp;&nbsp;<INPUT onclick=javascript:window.close(); type=reset value=取消 name=Submit2 class=button> </TD>
	</TR>
	</TABLE></form>
	<%
	Set BirRs=Nothing

End Sub


Sub modiwish()


	biryear=request.Form("year")
	If len(biryear)<>4 or not isInteger(biryear) then
		ErrMsg=ErrMsg+"<br>"+"<li>生日年份应为四位数字!"
		FoundErr=true
	Else
		biryear=cint(biryear)
		If biryear>cint(year(date)) or biryear<(cint(year(date))-60) then
			ErrMsg=ErrMsg+"<br>"+"<li>请输入正确的用户出生年份！"
			FoundErr=true
		End If
	End If

	birmonth=request.form("month")
	birday=request.form("day")
	birthday=biryear&"-"&birmonth&"-"&birday
	if not isdate(birthday) then
		errmsg=errmsg+"<br>"+"<li>生日输入有误！"
		founderr=true
	else
		birthday=cdate(birthday)
	end if


	wish=trim(checkstr(Request.form("wish")))
	if strlength(wish)>250 Then
		ErrMsg=ErrMsg+"<br>"+"<li>生日愿望不能超过250个字符!"
		founderr=True
	End if

	if founderr=True Then
		Call Error("Information",ErrMsg)
		Exit Sub
	End if

	Conn.Execute("update student Set birthday=#"&birthday&"#,wish='"&wish&"' where userid='"&membername&"'")
	response.write "<table width=100% height=100% bgcolor="&BodyColor&"><tr><td valign=top>"

	success "修改资料","成功修改生日愿望！"

End Sub
%>

