📄 action.jsp
字号:
<%@page language="java" contentType="text/html;charset=GBK"%>
<%@page import="java.io.File,java.util.*,java.text.*,java.sql.*,oa.main.DealString,oa.main.ParentBean"%>
<jsp:useBean id="pb" class="oa.main.ParentBean" scope="page"/>
<%
try{
if (pb.getConn() == null){
%>
数据库无法响应,请<a href="javascript:window.history.back(-1);">返回</a>重试
<%out.close();
}
DealString ds = new DealString();
String uid = (String)session.getAttribute("zgbh");
if(uid==null)
{
response.sendRedirect("../../session_oa.htm");
return;
}
String cur = ds.toString((String)request.getParameter("cur"));
//增删改动作标志
String action1 = ds.toString((String)request.getParameter("action"));
//out.println("action1========"+action1);
//修改时的编号
String id = ds.toString(request.getParameter("id"));//通知id
String noticeMenId = ds.toString(request.getParameter("noticeMenId"));////通知接收人表的id
String receiverzgbh = ds.toString(request.getParameter("receiver"));
//登陆用户的编号
String zgbh = (String)session.getAttribute("zgbh");
//取得表单数据
String strJB = ds.toString(request.getParameter("sel_jb"));
String strReceiver = ds.toString(request.getParameter("txt_receiverZGBH"));
strReceiver = strReceiver.replaceAll(",",";");
String strTitle = ds.toGBK(ds.toString(request.getParameter("txt_title")));
String strKeyWord = ds.toGBK(ds.toString(request.getParameter("txt_kw")));
String strAddtime = ds.toString(request.getParameter("addtime"));
String strStarttime = ds.toString(request.getParameter("starttime"));
String strEndtime = ds.toString(request.getParameter("endtime"));
String strWordNo = ds.toGBK(ds.toString(request.getParameter("txt_wordno")));
//取得关于附件的参数
String strORGID = ds.toGBK((String)request.getParameter("ORGID"));//附件
String strOLDORGID = ds.toGBK((String)request.getParameter("OLDORGID"));;//附件原名
String strstrsize = ds.toString((String)request.getParameter("strsize"));//STRSIZE
String strcursize = ds.toString((String)request.getParameter("cursize"));//CURSIZE
//取得附件的位置
String wz = oa.main.ParentBean.FilesPath+"meet\\";
//新增数据.......
int strID = -1;
int errcode = -1;
int maxNo = -1;
String sql = "";
if(action1!=null && action1.equals("add"))
{
strAddtime=ds.getDateTime();
//out.println("正在新增数据.......");
strID = getMaxNo("HG2_MEET_NOTICE");
sql = "insert into HG2_MEET_NOTICE values('"+String.valueOf(strID)+"','"+strTitle+"','"+strKeyWord+"','"+strWordNo+"',"+strJB+",'"+strAddtime+"','"+strStarttime+"','"+strEndtime+"','"+zgbh+"',0,'"+strOLDORGID+"','"+strORGID+"','"+strcursize+"','"+strstrsize+"')";
errcode = pb.executeUpdate(sql);
String []strReceivers = strReceiver.split(";");
for(int tmp = 0;tmp<strReceivers.length;tmp++)
{
maxNo = getMaxNo("HG2_MEET_NOTICEMEN");
sql = "insert into HG2_MEET_NOTICEMEN values('"+String.valueOf(maxNo)+"','"+String.valueOf(strID)+"','"+strReceivers[tmp]+"','','','0','0')";
errcode = pb.executeUpdate(sql);
}
// //添加短消息操作
// Hashtable ht = new Hashtable();
// ht.put("receiver",strReceiver.replaceAll(";",","));
// ht.put("sender",zgbh);
// ht.put("title","您有会议通知,请查收!");
//修改:添加到查看会议的连接
// String location = "window.opener.parent.frames[2].location='../oa/meeting/notice/read.jsp?id="+strID+"'";
// String look = "<a href=\"# \" onclick=\""+location+"\">[查看会议]</a>" ;
// ht.put("content","会议:"+strTitle+",时间:"+strStarttime+">>"+look);
// errcode = smsbean.addSMS(ht);
response.sendRedirect("list.jsp?cur="+cur);
}
//修改数据.......
if(action1!=null && action1.equals("mod"))
{
//out.println("正在修改数据.......");
sql = "update HG2_MEET_NOTICE set TITLE='"+strTitle+"',KEYWORD='"+strKeyWord+"',LEVEL1="+strJB+",TIME='"+strAddtime+"',TIMESTART='"+strStarttime+"',TIMEEND='"+strEndtime+"',WORD='"+strWordNo+"',SENDER='"+zgbh+"',OLDORGID='"+strOLDORGID+"',ORGID='"+strORGID+"',CURSIZE='"+strcursize+"',STRSIZE='"+strstrsize+"' where ID='"+id+"'";
errcode = pb.executeUpdate(sql);
if(!receiverzgbh.equals(strReceiver))
{
sql = "delete from HG2_MEET_NOTICEMEN where NOTICEID='"+id+"'";
errcode = pb.deleteRecord(sql);
String []strReceivers = strReceiver.split(";");
for(int tmp = 0;tmp<strReceivers.length;tmp++)
{
maxNo = getMaxNo("HG2_MEET_NOTICEMEN");
sql = "insert into HG2_MEET_NOTICEMEN values('"+String.valueOf(maxNo)+"','"+id+"','"+strReceivers[tmp]+"','','','0','0')";
errcode = pb.executeUpdate(sql);
}
}
response.sendRedirect("list.jsp?cur="+cur);
}
//删除数据.......
if(action1!=null && action1.equals("del"))
{
out.println("正在删除数据.......");
Vector vect = new Vector();
String strSender = "";
sql = "select SENDER,ORGID from HG2_MEET_NOTICE where ID='"+id+"'"; //and ISDEL=0
vect = pb.getDataBySql(sql);
strSender = (String)((Hashtable)vect.get(0)).get("SENDER");
sql = "select RECEIVER from HG2_MEET_NOTICEMEN where NOTICEID='"+id+"' and RECEIVER='"+zgbh+"'";
Vector v_receiver = pb.getDataBySql(sql);
//取得附件名称
String strTempOrgid = (String)((Hashtable)vect.get(0)).get("ORGID");
String strTempOrgids[] = strTempOrgid.split(",");
if(zgbh.equals(strSender))//登陆人是通知的发布人
{
sql = "select ID from HG2_MEET_NOTICEMEN where NOTICEID='"+id+"' and ISDEL=0";
vect = pb.getDataBySql(sql);
//zc //增加
String sqlread = "";
sqlread = " select ID,RECEIVER,READTIME,ISREAD,REBACK "
+ " from HG2_MEET_NOTICEMEN "
+ " where ISREAD = 1 "
+ " and NOTICEID="+id;
Vector vectread = pb.getDataBySql(sqlread);
if(vect.size()!=0)//接收人没有删除该纪录 只能修改ISDEL=1
{
sql = "update HG2_MEET_NOTICE set ISDEL=1 where ID='"+id+"'";
errcode = pb.executeUpdate(sql);
}
else//接收人都删除了该纪录 从数据库中彻底删除
{
//删除附件物理文件
for(int tempi = 0;tempi<strTempOrgids.length;tempi++){
File file=new File(wz+strTempOrgids[tempi]);
if (file.exists()){
file.delete();
}
}
//删除会议
sql = "delete from HG2_MEET_NOTICE where ID='"+id+"'";
errcode = pb.deleteRecord(sql);
sql = "delete from HG2_MEET_NOTICEMEN where NOTICEID='"+id+"'";
errcode = pb.deleteRecord(sql);
}
if(vectread.size()==0)//接收人都没有阅读该纪录 从数据库中彻底删除
{
//删除附件物理文件
for(int tempi = 0;tempi<strTempOrgids.length;tempi++){
File file=new File(wz+strTempOrgids[tempi]);
if (file.exists()){
file.delete();
}
}
//删除会议
sql = "delete from HG2_MEET_NOTICE where ID='"+id+"'";
errcode = pb.deleteRecord(sql);
sql = "delete from HG2_MEET_NOTICEMEN where NOTICEID='"+id+"'";
errcode = pb.deleteRecord(sql);
// //zc/删除短消息
// String templocation = "window.opener.parent.frames[2].location='../oa/meeting/notice/read.jsp?id="+id+"'";
// templocation = templocation.replaceAll("'","''");
// sql = "delete from SMS where content like '%"+templocation+"%'";
// errcode = pb.deleteRecord(sql);
}
}
if(v_receiver.size()>0)//登陆人是通知的接收人
{
sql = "select ID from HG2_MEET_NOTICEMEN where NOTICEID='"+id+"' and ISDEL=0 and RECEIVER<>'"+zgbh+"'";
vect = pb.getDataBySql(sql);
if(vect.size()!=0)//该通知的接收人还有没有删除该纪录的 只能修改其ISDEL=1
{
sql = "update HG2_MEET_NOTICEMEN set ISDEL=1 where NOTICEID='"+id+"' and RECEIVER='"+zgbh+"'";
errcode = pb.executeUpdate(sql);
}
else//该通知的接收人都删除了该纪录 判断通知的发布人是否删除了该纪录
{
sql = "select ID from HG2_MEET_NOTICE where ID='"+id+"' and ISDEL=0";// and SENDER='"+zgbh+"'
vect = pb.getDataBySql(sql);
if(vect.size()!=0)//通知的发布人没有删除该纪录 只能修改其ISDEL=1
{
sql = "update HG2_MEET_NOTICEMEN set ISDEL=1 where NOTICEID='"+id+"' and RECEIVER='"+zgbh+"'";
errcode = pb.executeUpdate(sql);
}
else//通知的发布人删除了该纪录 从数据库中彻底删除
{
//删除附件物理文件
for(int tempi = 0;tempi<strTempOrgids.length;tempi++){
File file=new File(wz+strTempOrgids[tempi]);
if (file.exists()){
file.delete();
}
}
//删除会议
sql = "delete from HG2_MEET_NOTICE where ID='"+id+"'";
errcode = pb.deleteRecord(sql);
sql = "delete from HG2_MEET_NOTICEMEN where NOTICEID='"+id+"'";
errcode = pb.deleteRecord(sql);
}
}
}
response.sendRedirect("list.jsp?cur="+cur);
}
//填写反馈意见
if(action1!=null && action1.equals("opinion"))
{
String rebackyj = ds.toGBK(ds.toString(request.getParameter("txt_yj")));
//out.println("正在修改反馈意见数据.......");
sql = "update HG2_MEET_NOTICEMEN set REBACK='"+rebackyj+"' where ID='"+noticeMenId+"'";
errcode = pb.executeUpdate(sql);
response.sendRedirect("read.jsp?id="+id+"&cur="+cur);
}
//清空相关所有信息
if(action1!=null && action1.equals("alldel"))
{
out.println("正在清除数据.......");
Vector vect = new Vector();
sql = "select SENDER,ORGID from HG2_MEET_NOTICE where ID='"+id+"'";
vect = pb.getDataBySql(sql);
//取得附件名称
String strTempOrgid = (String)((Hashtable)vect.get(0)).get("ORGID");
String strTempOrgids[] = strTempOrgid.split(",");
//删除附件物理文件
for(int tempi = 0;tempi<strTempOrgids.length;tempi++){
File file=new File(wz+strTempOrgids[tempi]);
if (file.exists()){
file.delete();
}
}
//删除会议
sql = "delete from HG2_MEET_NOTICE where ID='"+id+"'";
errcode = pb.deleteRecord(sql);
//删除接受人信息
sql = "delete from HG2_MEET_NOTICEMEN where NOTICEID='"+id+"'";
errcode = pb.deleteRecord(sql);
// //zc/删除短消息
// String templocation = "window.opener.parent.frames[2].location='../oa/meeting/notice/read.jsp?id="+id+"'";
// templocation = templocation.replaceAll("'","''");
// sql = "delete from SMS where content like '%"+templocation+"%'";
// errcode = pb.deleteRecord(sql);
response.sendRedirect("list.jsp?cur="+cur);
}
%>
<%}finally{
if(pb!=null)
pb.closeConn();
}%>
<%!
public int getMaxNo(String tabname)
{
DealString ds = new DealString();
ParentBean pb = new ParentBean();
String maxNo = "0";
int imaxNo = -1;
String sql = "select ID from "+tabname;
ResultSet rs = pb.selectRecord(sql);
Statement stmt = null;
try{
while (rs.next()) { //取得本部门的级别序号的最大编号
maxNo = ds.toString(rs.getString("id"));
if(imaxNo<Integer.parseInt(maxNo))
imaxNo = Integer.parseInt(maxNo);
}
}catch(Exception e){System.out.println("取得HG2_MEET_NOTICE最大ID时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("取得HG2_MEET_NOTICE最大ID关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("取得HG2_MEET_NOTICE最大ID关闭声明时statement出错"+e);}
}
return imaxNo+1;
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -