📄 pdocaddfile.aspx
字号:
<%@ Page Language="VB" ContentType="text/html" debug="true" %>
<%@ Import Namespace="system.data" %>
<%@ Import Namespace="system.data.oledb" %>
<!--#include file="webmaster/ckqx.aspx" -->
<html>
<head>
<title>公文发送拟稿</title>
<link href="CSS.CSS" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#CCCCCC">
<form runat="server" enctype="multipart/form-data">
<!--第一步,信件内容输入-->
<asp:panel runat="server" ID="zpa1">
<table width="549" height="22" border="0" cellpadding="0" cellspacing="0" background="pic/002.png">
<tr>
<td width="222"><font color="#FFFFFF"><strong> 公文发送拟稿</strong></font></td>
<td width="11"> </td>
<td width="359"> </td>
</tr>
</table>
<table width="549" height="400" border="1" cellpadditng="0" cellspacing="0" bordercolorlight="#008080" bordercolordark="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td width="574" height="252" valign="top" bgcolor="#FFFFFF">
<div align="center">
<center>
<table border="0" width="544" height="234" bgcolor="#FFFFFF" cellspacing="1">
<tr>
<td height="17" align="center" bgcolor="#FFFFFF"> </td>
<td width="254" height="17" bgcolor="#FFFFFF"></td>
<td width="206" bgcolor="#FFFFFF"> </td>
<td width="5" rowspan="5" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="8" align="center" bgcolor="#FFFFFF"><font color="#000000">主 题:</font></td>
<td height="8" colspan="2" bgcolor="#FFFFFF"> <p>
<asp:textbox BorderStyle="solid" BorderWidth="1" Columns="55" Font-Size="10" ID="ztitle" MaxLength="25" runat="server" TextMode="SingleLine" /><asp:requiredfieldvalidator ControlToValidate="ztitle" Display="Dynamic" ErrorMessage="公文标题不能少" ID="rztitle" runat="server" Text="*" />
限25字<br>
</p></td>
</tr>
<tr>
<td height="8" align="center" bgcolor="#FFFFFF"><font color="#000000">类 型:</font></td>
<td height="8" colspan="2" bgcolor="#FFFFFF">
<asp:dropdownlist ID="ztype" runat="server">
<asp:listitem selected="true">普通公文</asp:listitem>
<asp:listitem>私人信件</asp:listitem>
<asp:listitem>通知</asp:listitem>
<asp:listitem>内部资料</asp:listitem>
<asp:listitem>工作报表</asp:listitem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td width="66" height="148" align="center" bgcolor="#FFFFFF"><font color="#000000">内 容:
</font></td>
<td height="148" colspan="2" bgcolor="#FFFFFF"> <asp:textbox BorderStyle="solid" BorderWidth="1" Columns="55" Font-Size="10" ID="zcontent" Rows="14" runat="server" TextMode="MultiLine" /><asp:requiredfieldvalidator ControlToValidate="zcontent" Display="Dynamic" ErrorMessage="公文内容不能少" ID="rzcontent" runat="server" Text="*" /><asp:validationsummary DisplayMode="List" HeaderText="您的输入有下列错误:" ID="rerror" runat="server" ShowMessageBox="true" ShowSummary="false" /></td>
</tr>
<tr>
<td width="66" height="29" align="center" bgcolor="#FFFFFF"><font color="#000000">文档地址:</font></td>
<td height="29" bgcolor="#FFFFFF"> <input type="file" class="smallInput" id="myfile" size="30" runat="server"></td>
<td height="29" bgcolor="#FFFFFF"><font color="#000000"><img src="pic/images/Ico.gif" width="10" height="10"> 上传文件最大不能超过5M!!<br>
<img src="pic/images/Ico.gif" width="10" height="10"> 禁止上传EXE等文件,请先压缩!!</font></td>
</tr>
</table>
<br>
<asp:button Font-Size="10" ID="zsave" runat="server" Text="保存" OnClick="zaction2" />
<br>
</center>
</div>
</td>
</tr>
</table>
<p> </p>
<!--第一步信件内容输入完毕-->
</asp:panel>
<asp:panel runat="server" ID="zpa2" visible="false">
<!--第二部,选取收件人-->
<table width="549" height="22" border="0" cellpadding="0" cellspacing="0" background="pic/002.png">
<tr>
<td width="8"> </td>
<td width="274"><font color="#FFFFFF"><strong> 群发(收件人安所属部门排列)</strong></font></td>
<td width="37"> </td>
<td width="230"> </td>
</tr>
</table>
<table width="549" border="1" cellpadding="0" cellspacing="0" height="400" bordercolorlight="#008080" bordercolordark="#FFFFFF">
<tr>
<td width="1450" height="53" valign="top" bgcolor="#FFFFFF">
<asp:datagrid runat="server" ID="mygrid"
AutoGenerateColumns="false"
BorderColor="#CCCCCC"
HorizontalAlign="Center"
Width="98%"
>
<headerstyle Font-Bold="true" HorizontalAlign="center" />
<itemstyle HorizontalAlign="center" />
<columns>
<asp:boundcolumn DataField="id" HeaderText="ID" />
<asp:boundcolumn DataField="orealname" HeaderText="收件人" />
<asp:boundcolumn DataField="oworkroom" HeaderText="所属部门" />
<asp:templatecolumn HeaderText="选择收件人">
<itemtemplate>
<input type="checkbox" name="zscsjr" value=<%# container.dataitem("id") %>>
<!--如果用服务器端控件,由于在客户端会自动以DataGrid的行与列号生成自己的ID
所不,不能一次性得到所有复选框的值,而采用<input>这种类型的复选框,由于
在客户端仍然能使name属性为同一组,所以,能一次收集到所有选择的用户,不
用重新回到DataGrid控件一行数据一行数据的检测,省去了很多麻烦-->
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>
<div align="center">
<br>
<asp:button runat="server" Text="发送" CommandName="zsend" oncommand="zscsend" CommandArgument="more" />
<asp:button runat="server" Text="发送给所有用户" CommandName="zsend" oncommand="zscsend" CommandArgument="all" />
</div>
</td>
</tr>
</table>
<!--第二步选择收件人完-->
</asp:panel>
<asp:label runat="server" ID="showhidebox" Visible="false">
<script language="JavaScript" type="text/javascript">
alert("公文群发成功完成!")
window.location="pdocaddfile.aspx"
</script>
</asp:label>
</form>
</body>
</html>
<script language="VB" runat="server">
sub page_load(s as object,e as eventargs)
if not (checkqx("c")) then response.redirect("webmaster/error.aspx")
end sub
sub zaction2(s as object,e as eventargs)
'第一步中的“保存”按钮相对应的过程,保存第一步,进入第二步
session("myfile")=myfile
'通过会话变量来保存当前页中的文件字段,因为file控件不是server控件,必须采用这种
'方式来得到用户的输入
zpa1.visible=false
zpa2.visible=true
bindlist()
end sub
sub bindlist()
dim conn as new oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & server.MapPath("office.mdb"))
conn.open()
dim objada as new oledbdataadapter("select * from userinfo order by oworkroom",conn)
dim ds as new dataset()
objada.fill(ds,"oworkroom")
mygrid.datasource=ds.tables("oworkroom")
mygrid.databind()
conn.close()
end sub
sub zscsend(s as object,e as CommandEventArgs)
'根据用户选择的收件人发信
dim conn as new oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & server.MapPath("office.mdb"))
conn.open()
dim objcmd as new oledbcommand()
objcmd.connection=conn
objcmd.commandtext="insert into userdata (yourid,orealname,oworkroom,outid,otitle,ocontent,ofilename,odate,sizez,readz,typez) " & _
" values(?,?,?,?,?,?,?,?,?,?,?)"
dim uinfo()=session("lguinfo")
objcmd.parameters.add("@yourid",oledbtype.integer).value=uinfo(0)
'寄信人的ID号
objcmd.parameters.add("@orealname",oledbtype.char).value=uinfo(2)
objcmd.parameters.add("@oworkroom",oledbtype.char).value=uinfo(3)
'外寄给谁?即收件人的ID号
if e.CommandArgument="more" then
'如果选择发信给指定的人
if request.form("zscsjr")=nothing then
'如果用户没做选择
objcmd.parameters.add("@outid",oledbtype.varchar).value="all"
'默认也发给所有人
else
objcmd.parameters.add("@outid",oledbtype.varchar).value=request.form("zscsjr") & "Str"
'这里在收件人的后面加上一个S是为了让整个收件成成为一个字串
'因为如果只是包含,号的字串,仍然可能是一个可以转换成数字的表达式。如12,34表示1234
'为了避免这种错误,在收件人列表后加上一个Str,这样整个字串就不可能再转换成有效的数字
'了,这样做是为了在datauser表中区分哪些记录是邮件,而哪些邮件是公文
'上面把公文发送给所有的用户时,由于整个outid是赋值的all,它是不可能转换成有效数字的。
end if
else
'如果选择发信给所有的人
objcmd.parameters.add("@outid",oledbtype.varchar).value="all"
end if
objcmd.parameters.add("@otitle",oledbtype.char).value=ztitle.text
objcmd.parameters.add("@ocontent",oledbtype.varchar).value=zcontent.text
dim myfile as HtmlInputFile=session("myfile")
if myfile.postedfile.contentlength<>0 then
'如果上传的文件不为空
dim lsfile as object
lsfile=myfile.postedfile
dim lsname() as string=split(lsfile.filename,".")
dim lsnm as string=lsname(lsname.length-1)
dim lstime=now()
dim lsyear,lsmonth,lsday,lshour,lsminute,lssecond,lsfilename as string
lsyear=year(lstime)
lsmonth=right("0" & month(lstime),2)
lsday=right("0" & day(lstime),2)
lshour=right("0" & hour(lstime),2)
lsminute=right("0" & minute(lstime),2)
lssecond=right("0" & second(lstime),2)
dim lsrd as string
randomize
lsrd=cstr(int(100*rnd())+1)
lsfilename=lsyear & lsmonth & lsday & lshour & lsminute & lssecond & "-" & lsrd & "." & lsnm
'得到以当前日期及时间为前缀的新文件名,只保留原文档的护展名(防止文件出现重名现象、防止中文文件名)
dim lspath as string
lspath=session("docuppath") & lsfilename
lsfile.saveas(lspath)
'得到文件对象
objcmd.parameters.add("@ofilename",oledbtype.char).value=lsfilename
else
objcmd.parameters.add("@ofilename",oledbtype.char).value="N/A"
end if
objcmd.parameters.add("@odate",oledbtype.DBdate).value=formatdatetime(now(),dateformat.longdate)
if myfile.postedfile.contentlength<>0 then
'如果上传的文件不为空
if myfile.postedfile.contentlength>1024 then
objcmd.parameters.add("@sizez",oledbtype.char).value=int(myfile.postedfile.contentlength/1024) & "KB"
else
objcmd.parameters.add("@sizez",oledbtype.char).value=myfile.postedfile.contentlength & "Byte"
end if
else
objcmd.parameters.add("@sizez",oledbtype.char).value="N/S"
end if
objcmd.parameters.add("@readz",oledbtype.char).value="2"
objcmd.parameters.add("@typez",oledbtype.char).value=ztype.selecteditem.text
objcmd.executenonquery()
conn.close()
zpa2.visible=false
'隐藏主窗口
showhidebox.visible=true
'显示发送成功的对话框,在客户端显示
end sub
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -