?? 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 + -