<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../conn/conn.asp"-->
<!--#include file="../inc/Commoncode.asp"-->
<!--#include file="../inc/CommonFunction.asp"-->
<%link="person_letters.asp"%>
<!--#include file="checkpmember.asp" -->
<!--#include file="flagandexpend.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>求职信-个人求职管理中心-<%=SiteTitle%></title>
<link href="../member/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/input.js"></script>
<script language="JavaScript">
<!--
//功能：去掉字符串前后空格
//返回值：去掉空格后的字符串
function fnRemoveBrank(strSource)
{
 return strSource.replace(/^\s*/,'').replace(/\s*$/,'');
}
function String.prototype.lenB()
{
return this.replace(/[^\x00-\xff]/g,"**").length;
}
function Juge(theForm)
{
  if (fnRemoveBrank(theForm.title.value) == "")
  {
    alert("请输入求职信标题!");
    theForm.title.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.content.value) == "")
  {
    alert("请输入求职信内容!");
    theForm.content.focus();
    return (false);
  }
  if ((theForm.content.value).lenB()>=2000)
  {
	 alert("求职信内容太长了，要求不多于2000个字符!");
	 theForm.content.focus();
	 return (false);
  } 
 }
-->
</script>
</head>
<body>
<div class="memmenul">
<%step=trim(request("step"))
Select Case step
	Case "Add"
		Call ShowData()
	Case "Modify"
		Call ShowData()
	Case "SaveData"
		Call SaveData()
	Case "Del"
		Call Del()
	Case Else
		Call main()
End Select%>
</div>
<%
conn.close:set conn=nothing%>
<%Sub main()%>
<div class="leftmenutit"><span>求职信</span></div>
<table width="98%" border="0" cellspacing="0" cellpadding="0" class="mtable" align="center">
  <tr>
    <td>你可以在这里保存求职信，附在简历上发给招聘单位。你可以保存<%=Group_Plimits(7)%>份不同内容的求职信，以适应不同职位的需求,目前你已经添加并保存过<%=Pletternums%>份。</td>
  </tr>
<%
set rs=server.createobject("ADODB.Recordset")
sql="select letter_id,letter_title from job_p_letter where letter_pmember='"&pmember_login&"' order by letter_announcedate desc"
rs.open sql,conn,1,1
if not rs.eof then
%>  
  <tr>
    <td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="mtable" style="border:1px #ABCEE2 solid;">
  <tr>
    <td align="center"><strong>ID</strong></td>
    <td align="center"><strong>求职信标题</strong></td>
    <td align="center"><strong>预览/打印</strong></td>
    <td align="center"><strong>修改</strong></td>
    <td align="center"><strong>删除</strong></td>
  </tr>
<%for i=1 to rs.recordcount%>
  <tr>
    <td align="center"><%=rs("letter_id")%></td>
    <td align="center"><%=rs("letter_title")%></td>
    <td align="center"><a href="letter_preview.asp?id=<%=rs("letter_id")%>" target="_blank"><img src="../images/sign_04.gif" border="0"></a></td>
    <td align="center"><A href="person_letters.asp?step=Modify&id=<%=rs("letter_id")%>"><IMG height=17 alt=修改求职信 src='../images/sign_05.gif' width=16 border=0></A></td>
    <td align="center"><input type="image" onClick="if (confirm('确定删除该求职信吗？')) window.location='person_letters.asp?step=Del&id=<%=rs("letter_id")%>'" src="../images/sign_07.gif" style="border-width:0px;"></td>
  </tr>
<%rs.movenext
next
end if
rs.close
set rs=nothing
%>
</table>
</td>
  </tr>
  <tr>
    <td><input name="btnAdd" type="button" class="inputs" onClick="javascript:window.location.href='person_letters.asp?step=Add'" value="新增求职信"></td>
  </tr>
</table>
<%End Sub%>
<%Sub ShowData()
if request("id")<>"" and step="Modify" then
letter_id=clng(trim(request("id")))
set rs=server.createobject("ADODB.Recordset")
sql="select letter_title,letter_content from job_p_letter where letter_id="&letter_id&""
rs.open sql,conn,1,1
letter_title=rs("letter_title")
letter_content=rs("letter_content")
rs.close
set rs=nothing
else
'判断求职信是否达到上限
If CheckPFlag("Plimits",7)=False then
response.write "<script language=javascript>alert('您填写的求职信数量已达到上限，请联系网站客服进行升级！');location.href='person_letters.asp';</script>"
response.end()
end if
end if %>
<div class="leftmenutit"><span><%if step="Modify" then%>修改<%else%>新增<%end if%>求职信</span></div>
<table width="98%" border="0" cellspacing="0" cellpadding="0" class="mtable" align="center">
<form name="lettermodi" action="person_letters.asp?step=SaveData&id=<%=letter_id%>" method="post" onSubmit="return Juge(this)">
  <tr>
    <td align="right">求职信标题：</td>
    <td><input name="title" type="text" id="title" size="40" maxlength="50" value="<%=letter_title%>"></td>
  </tr>
  <tr>
    <td align="right">求职信内容：</td>
    <td><textarea name="content" id="content" rows="8" cols="60"><%=ChangeStrbox(letter_content)%></textarea>（限2000字符）</td>
  </tr>
  <tr>
    <td colspan="2"> &nbsp;
      &nbsp;
      <input name="btnSave" type="submit" class="inputs" value="保　存">　
  &nbsp;    <input  name=Exit type=button class="inputs" onClick="javascript:window.location.href='person_letters.asp'" value="返　回"></li></td>
    </tr>
</form>
</table>
<%End Sub%>










<%Sub SaveData()
 letter_title=CheckStr(trim(request("title")))
 if letter_title="" then
  Response.Write ("<script language=JavaScript>{alert('错误：求职信标题不能为空!');location.href = 'javascript:history.go(-1)';}</script>")
  Response.End
 end if
 letter_content=CheckStrbox(request("content"))
 If letter_content="" Then
  Response.Write ("<script language=JavaScript>{alert('错误：求职信内容不能为空!');location.href = 'javascript:history.go(-1)';}</script>")
  Response.End
 Else
	 If lenmix(letter_content)>=2000 Then 
	  response.write "<script language=javascript>alert('错误：求职信内容太长了，要求不多于2000个字符!！');location.href='javascript:history.back()';</script>"
	  response.end 
	 End If
 End If

 '把信息存入求职信表letter 
set rs=server.CreateObject("adodb.recordset")
if request("id")<>"" then
letter_id=clng(trim(request("id")))
sql="select * from job_p_letter where letter_id="&letter_id
rs.open sql,conn,1,3
	if not rs.eof then
	rs("letter_title")=letter_title
	rs("letter_content")=letter_content
	rs("letter_announcedate")=Now()
	rs.update
	end if
else
sql="select * from job_p_letter"
rs.open sql,conn,1,3
rs.addnew
rs("letter_pmember")=pmember_login
rs("letter_title")=letter_title
rs("letter_content")=letter_content
rs("letter_announcedate")=Now()
rs.update
'更新求职信数量
conn.Execute("Update JOB_member set Member_letternums=Member_letternums+1 where Member_login = '"&pmember_login&"' and Member_typeid=1")
end if
rs.close
set rs=nothing
response.redirect "person_letters.asp"
response.end
End Sub%>
<%Sub Del()
if step="Del" and request("id")<>"" then '删除求职信
letter_id=clng(trim(request("id")))
conn.execute "delete from job_p_letter where letter_id="&letter_id&" and letter_pmember='"&pmember_login&"'"
response.redirect "person_letters.asp"
response.end
end if
End Sub%>