<!--#include file="../inc/Secure.htm"-->
<%dim ThisKey
ThisKey = "c"
%>
<!--#include file="../inc/permission.htm"-->
<!--#include file="../inc/conn.htm"-->
<!--#include file="../inc/dbtools.htm"-->
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../CSS/main.css">
</HEAD>
<script src="../Document/Popup.js"></script>
<BODY BGCOLOR="#FFFFFF" leftmargin=20>

<BR>
<div align=center>
<table width="88%" border="0" cellspacing="0" cellpadding="0">
  <tr align="center"> 
	<td width="25%"><a href="index.htm"><img src="../images/zxgg.gif" width="110" height="20" border=0></a></td>
	<td width="25%"><a href="read_index.htm"><img src="../images/lsgg.gif" width="110" height="20" border=0></a></td>
	<td width="25%"><img src="../images/wyqfgg-2.gif" width="110" height="20" border=0></td>
	<td width="25%"><a href="myBulletin.htm"><img src="../images/wfbdgg.gif" width="110" height="20" border=0></a></td>
  </tr>
</table>
</div>
<BR>

<%
LoginID=trim(session("LoginID"))
if LoginID="" then LoginID=0
UserName=GetTableValue ("tblUser","Name","ID",LoginID)

toName=replace(trim(request("toName")),"'","''")
ToID=replace(trim(request("toID")),"'","''")
ToAll=trim(request("ToAll"))
if ToAll="" then ToAll=0
ToDepartment=trim(request("ToDepartment"))
ClassID=trim(request("ClassID"))
Title=replace(trim(request("Title")),"'","''")
KeyWords=replace(trim(request("KeyWords")),"'","''")
Body=replace(rtrim(request("Body")),"'","''")
FromID=LoginID
FromName=UserName


if request("cmdUp")<>"" then
	AddBulletin()
	oConn.close
	response.write "<h2>公告已经成功发出，谢谢！</h2><BR><BR>"
	response.write "<a href=index.htm><img src=""../images/return.gif"" alt=返回 border=0></a>"
	response.end
end if

%>

<form name="UserForm" method="post" action="">
<div align=center>
<table border=1 cellpadding=3 cellspacing=1 width="92%" bgcolor=#EEEEEE bordercolordark="#FFFFFF" bordercolorlight="#999999">
<tr width="100%" bgcolor=#53A9FF>
	<td colspan=4 align=center>填写新的公告！
	</td>	
</tr>

<tr width="100%">
	<td align=right width="14%">标题</td>
	<td><input type="text" name="Title" size=40 maxlength=100 class="input"></td>
	<td align=right width="15%" nowrap>主题词</td>
	<td><input type="text" name="KeyWords" size=20 maxlength=30 class="input"></td>
</tr>

<tr>
	<td align=right>分类</td>
	<td><%options "ClassID","tblBulletinClass","Name",0%></td>
	<td align=right colspan=2>&nbsp;</td>
</tr>
<tr>
	<td align=right>内容</td>
	<td colspan=3><textarea name="body" rows=15 cols=60><%=body%></textarea></td>
</tr>

<tr>
	<td align=right>发布人</td>
	<td colspan=3 valign=top><input type="text" name="FromName" value="<%=UserName%>" class="input" size=20 readonly></td>
</tr>

<tr>
<td align=right>公告对象：</td>
<td colspan=3>
<input type="text" name="ToName" value="" readonly class="input" size=50>
</td>
</tr>
<tr>
<td align=right>&nbsp;</td>
<td colspan=3>
<INPUT TYPE="button" name="cmdAttach" value="指定对象" onclick="OpenWindow('ReadUsers.htm','UserWindow')">
<input type="checkbox" name="ToAll" value="1">全部员工
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
或选择单个部门：<%options "ToDepartment","tblDepartment","Name",0%>
</td>
</tr>
<tr>
<td align=right>&nbsp;</td>
<td colspan=3 align=center>
<INPUT TYPE="submit" name="cmdUp" value="确  定" onclick="return CheckData();">&nbsp;&nbsp;
<INPUT TYPE="button" name="backto" value="返  回" onclick="javascript:window.location.href='index.htm'">
</td>
</tr>
</table>
</div>
<INPUT TYPE="hidden" name="ToID" value="">
<INPUT TYPE="hidden" name="FromID" value="<%=LoginID%>">

</form>
<BR><BR>
</BODY>
</HTML>
<!--#include file="../inc/conn_close.htm"-->
<script language=javascript>

function OpenWindow(url,windowname)
{
window.open(url,windowname,'left=100,top=50,height=350,width=650,toolbar=no,menubar=no,scrollbars=yes')
}

function CheckData()
{
	if (jtrim(document.UserForm.Title.value)=="")
	{
		alert("标题不能为空！");
		return false;
	}

	if ((jtrim(document.UserForm.ToName.value)=="") && (document.UserForm.ToAll.checked==false) && (jtrim(document.UserForm.ToDepartment.value)=="0"))
	{
		alert ("请指定传阅人！");
		return false;
	}
	return true;
}
</script>
<script language="javascript" src="../inc/jtrim.js"></script>
<%
sub DeleteOneDir (PathName)
	PathName=Server.Mappath(PathName)
	dim fsfl
	Set fsfl = server.CreateObject("Scripting.FileSystemObject")
	if trim(PathName)<>"" and fsfl.FolderExists(PathName) then 
		fsfl.DeleteFolder PathName
	end if
	set fsfl=nothing	
end sub
Function GetTableValue(TableName,Field,ValueField,Value)
	if TableName<>"" and Value<>"" then
		Set RsTmp = Server.Createobject("Adodb.recordset")
		strSql = "Select "& Field &" from "& TableName &" where "& ValueField &"='"& Value &"'"
		Rstmp.open strSql,oConn,1,1
		If not Rstmp.eof then
			GetTableValue=trim(Rstmp(Field))
		else
			GetTableValue=""
		end if
		Rstmp.close
		'set RsTmp = Nothing
	else
		GetTableValue=""
	end if
End Function

Sub AddBulletin()
	sql="INSERT INTO tblBulletin(FromID, ClassID, Toall, Todepartment, Title, KeyWords, FromName,Body,toName,ToID) VALUES(" & FromID & _
		","& ClassID & _
		","& ToAll & _
		","& ToDepartment & _
		",'" & Title & _
		"','"& KeyWords & _
		"','"& FromName & _
		"','"& body & _
		"','"& ToName & _
		"','"& ToID & _
		"');"		
		'response.write sql
		oConn.execute (sql)
end sub
%>